summaryrefslogtreecommitdiff
path: root/src/openttd.cpp
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2007-03-13 21:31:09 +0000
committerpeter1138 <peter1138@openttd.org>2007-03-13 21:31:09 +0000
commit4177215b4111dedba3f4c7ce354a0b19d7edbf28 (patch)
treefe4d9d074e74884136ae01d5711b69fe05d33a72 /src/openttd.cpp
parentc7bcdb69b185b239852ef6fa57aeeda5e86ceb3e (diff)
downloadopenttd-4177215b4111dedba3f4c7ce354a0b19d7edbf28.tar.xz
(svn r9147) -Fix (r1770, r8161): when loadin games, enroute_from and enroute_from_xy were updated in the wrong place, causing issues with TTD savegames/scenarios.
Diffstat (limited to 'src/openttd.cpp')
-rw-r--r--src/openttd.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/openttd.cpp b/src/openttd.cpp
index 0452d6ab8..5a9c7499c 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -1792,6 +1792,25 @@ bool AfterLoadGame()
FOR_ALL_VEHICLES(v) {
v->cargo_source_xy = IsValidStationID(v->cargo_source) ? GetStation(v->cargo_source)->xy : v->tile;
}
+
+ /* Store position of the station where the goods come from, so there
+ * are no very high payments when stations get removed. However, if the
+ * station where the goods came from is already removed, the source
+ * information is lost. In that case we set it to the position of this
+ * station */
+ Station *st;
+ FOR_ALL_STATIONS(st) {
+ for (CargoID c = 0; c < NUM_CARGO; c++) {
+ GoodsEntry *ge = &st->goods[c];
+
+ /* In old versions, enroute_from used 0xFF as INVALID_STATION */
+ if (CheckSavegameVersion(7) && ge->enroute_from == 0xFF) {
+ ge->enroute_from = INVALID_STATION;
+ }
+
+ ge->enroute_from_xy = IsValidStationID(ge->enroute_from) ? GetStation(ge->enroute_from)->xy : st->xy;
+ }
+ }
}
if (CheckSavegameVersion(45)) {