summaryrefslogtreecommitdiff
path: root/src/saveload
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/saveload
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/saveload')
-rw-r--r--src/saveload/afterload.cpp49
-rw-r--r--src/saveload/oldloader_sl.cpp4
-rw-r--r--src/saveload/subsidy_sl.cpp8
3 files changed, 34 insertions, 27 deletions
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);
diff --git a/src/saveload/oldloader_sl.cpp b/src/saveload/oldloader_sl.cpp
index ed7fe2551..f8fc0b777 100644
--- a/src/saveload/oldloader_sl.cpp
+++ b/src/saveload/oldloader_sl.cpp
@@ -1469,8 +1469,8 @@ static bool LoadOldEngineName(LoadgameState *ls, int num)
static const OldChunks subsidy_chunk[] = {
OCL_SVAR( OC_UINT8, Subsidy, cargo_type ),
OCL_SVAR( OC_UINT8, Subsidy, age ),
- OCL_SVAR( OC_FILE_U8 | OC_VAR_U16, Subsidy, from ),
- OCL_SVAR( OC_FILE_U8 | OC_VAR_U16, Subsidy, to ),
+ OCL_SVAR( OC_FILE_U8 | OC_VAR_U16, Subsidy, src ),
+ OCL_SVAR( OC_FILE_U8 | OC_VAR_U16, Subsidy, dst ),
OCL_END()
};
diff --git a/src/saveload/subsidy_sl.cpp b/src/saveload/subsidy_sl.cpp
index f7b6a8f12..b1e889e8f 100644
--- a/src/saveload/subsidy_sl.cpp
+++ b/src/saveload/subsidy_sl.cpp
@@ -10,10 +10,10 @@
static const SaveLoad _subsidies_desc[] = {
SLE_VAR(Subsidy, cargo_type, SLE_UINT8),
SLE_VAR(Subsidy, age, SLE_UINT8),
- SLE_CONDVAR(Subsidy, from, SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
- SLE_CONDVAR(Subsidy, from, SLE_UINT16, 5, SL_MAX_VERSION),
- SLE_CONDVAR(Subsidy, to, SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
- SLE_CONDVAR(Subsidy, to, SLE_UINT16, 5, SL_MAX_VERSION),
+ SLE_CONDVAR(Subsidy, src, SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
+ SLE_CONDVAR(Subsidy, src, SLE_UINT16, 5, SL_MAX_VERSION),
+ SLE_CONDVAR(Subsidy, dst, SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
+ SLE_CONDVAR(Subsidy, dst, SLE_UINT16, 5, SL_MAX_VERSION),
SLE_END()
};