summaryrefslogtreecommitdiff
path: root/src/subsidy_gui.cpp
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-08-07 22:23:34 +0000
committersmatz <smatz@openttd.org>2009-08-07 22:23:34 +0000
commit74d3382b946d71445fbce5699d1541946e928450 (patch)
tree03fe2b58ca63a3e1629c08eefbdf061154cc977c /src/subsidy_gui.cpp
parent39e145e586385861b4e3ded70f7df0a29b56fa00 (diff)
downloadopenttd-74d3382b946d71445fbce5699d1541946e928450.tar.xz
(svn r17107) -Codechange: store type of subsidy source and destination in the Subsidy struct instead of determining it every time it's needed
Diffstat (limited to 'src/subsidy_gui.cpp')
-rw-r--r--src/subsidy_gui.cpp33
1 files changed, 14 insertions, 19 deletions
diff --git a/src/subsidy_gui.cpp b/src/subsidy_gui.cpp
index 2c4baf5e2..de7d71c57 100644
--- a/src/subsidy_gui.cpp
+++ b/src/subsidy_gui.cpp
@@ -78,32 +78,27 @@ struct SubsidyListWindow : Window {
void HandleClick(const Subsidy *s)
{
- TownEffect te = CargoSpec::Get(s->cargo_type)->town_effect;
+ /* determine src coordinate for subsidy and try to scroll to it */
TileIndex xy;
-
- /* determine from coordinate for subsidy and try to scroll to it */
- uint offs = s->from;
- if (s->IsAwarded()) {
- xy = Station::Get(offs)->xy;
- } else if (te == TE_PASSENGERS || te == TE_MAIL) {
- xy = Town::Get(offs)->xy;
- } else {
- xy = Industry::Get(offs)->xy;
+ switch (s->src_type) {
+ case ST_INDUSTRY: xy = Industry::Get(s->src)->xy; break;
+ case ST_TOWN: xy = Town::Get(s->src)->xy; break;
+ case ST_STATION: xy = Station::Get(s->src)->xy; break;
+ default: NOT_REACHED();
}
if (_ctrl_pressed || !ScrollMainWindowToTile(xy)) {
if (_ctrl_pressed) ShowExtraViewPortWindow(xy);
- /* otherwise determine to coordinate for subsidy and scroll to it */
- offs = s->to;
- if (s->IsAwarded()) {
- xy = Station::Get(offs)->xy;
- } else if (te == TE_PASSENGERS || te == TE_MAIL || te == TE_GOODS || te == TE_FOOD) {
- xy = Town::Get(offs)->xy;
- } else {
- xy = Industry::Get(offs)->xy;
+ /* otherwise determine dst coordinate for subsidy and scroll to it */
+ switch (s->dst_type) {
+ case ST_INDUSTRY: xy = Industry::Get(s->dst)->xy; break;
+ case ST_TOWN: xy = Town::Get(s->dst)->xy; break;
+ case ST_STATION: xy = Station::Get(s->dst)->xy; break;
+ default: NOT_REACHED();
}
+
if (_ctrl_pressed) {
ShowExtraViewPortWindow(xy);
} else {
@@ -155,7 +150,7 @@ struct SubsidyListWindow : Window {
FOR_ALL_SUBSIDIES(s) {
if (s->IsAwarded()) {
SetupSubsidyDecodeParam(s, 1);
- SetDParam(3, Station::Get(s->to)->owner);
+ SetDParam(3, Station::Get(s->dst)->owner);
SetDParam(4, _date - ymd.day + 768 - s->age * 32);
/* Displays the two connected stations */