From 74d3382b946d71445fbce5699d1541946e928450 Mon Sep 17 00:00:00 2001 From: smatz Date: Fri, 7 Aug 2009 22:23:34 +0000 Subject: (svn r17107) -Codechange: store type of subsidy source and destination in the Subsidy struct instead of determining it every time it's needed --- src/saveload/afterload.cpp | 49 ++++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 21 deletions(-) (limited to 'src/saveload/afterload.cpp') diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index bf067409d..fa772cac1 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -1850,14 +1850,33 @@ bool AfterLoadGame() i++; } } + } + + if (CheckSavegameVersion(124)) { + /* The train station tile area was added */ + Waypoint *wp; + FOR_ALL_WAYPOINTS(wp) { + if (wp->facilities & FACIL_TRAIN) { + wp->train_station.tile = wp->xy; + wp->train_station.w = 1; + wp->train_station.h = 1; + } else {; + wp->train_station.tile = INVALID_TILE; + wp->train_station.w = 0; + wp->train_station.h = 0; + } + } + } + { /* Delete invalid subsidies possibly present in old versions (but converted to new savegame) */ Subsidy *s; FOR_ALL_SUBSIDIES(s) { if (s->IsAwarded()) { /* Station -> Station */ - const Station *from = Station::GetIfValid(s->from); - const Station *to = Station::GetIfValid(s->to); + const Station *from = Station::GetIfValid(s->src); + const Station *to = Station::GetIfValid(s->dst); + s->src_type = s->dst_type = ST_STATION; if (from != NULL && to != NULL && from->owner == to->owner && Company::IsValidID(from->owner)) continue; } else { const CargoSpec *cs = CargoSpec::Get(s->cargo_type); @@ -1865,16 +1884,20 @@ bool AfterLoadGame() case TE_PASSENGERS: case TE_MAIL: /* Town -> Town */ - if (Town::IsValidID(s->from) && Town::IsValidID(s->to)) continue; + s->src_type = s->dst_type = ST_TOWN; + if (Town::IsValidID(s->src) && Town::IsValidID(s->dst)) continue; break; case TE_GOODS: case TE_FOOD: /* Industry -> Town */ - if (Industry::IsValidID(s->from) && Town::IsValidID(s->to)) continue; + s->src_type = ST_INDUSTRY; + s->dst_type = ST_TOWN; + if (Industry::IsValidID(s->src) && Town::IsValidID(s->dst)) continue; break; default: /* Industry -> Industry */ - if (Industry::IsValidID(s->from) && Industry::IsValidID(s->to)) continue; + s->src_type = s->dst_type = ST_INDUSTRY; + if (Industry::IsValidID(s->src) && Industry::IsValidID(s->dst)) continue; break; } } @@ -1882,22 +1905,6 @@ bool AfterLoadGame() } } - if (CheckSavegameVersion(124)) { - /* The train station tile area was added */ - Waypoint *wp; - FOR_ALL_WAYPOINTS(wp) { - if (wp->facilities & FACIL_TRAIN) { - wp->train_station.tile = wp->xy; - wp->train_station.w = 1; - wp->train_station.h = 1; - } else {; - wp->train_station.tile = INVALID_TILE; - wp->train_station.w = 0; - wp->train_station.h = 0; - } - } - } - AfterLoadLabelMaps(); GamelogPrintDebug(1); -- cgit v1.2.3-54-g00ecf