summaryrefslogtreecommitdiff
path: root/src/openttd.cpp
diff options
context:
space:
mode:
authorcelestar <celestar@openttd.org>2007-01-15 14:42:24 +0000
committercelestar <celestar@openttd.org>2007-01-15 14:42:24 +0000
commit05b783e551102127f1e48aa579a58b9a1ec8fabb (patch)
treecad841bb152e6112359e6b75928562e7161a7c26 /src/openttd.cpp
parent3b22cfe70d743cde8c268d415f311a0de4e630ea (diff)
downloadopenttd-05b783e551102127f1e48aa579a58b9a1ec8fabb.tar.xz
(svn r8144) -Fix: [FS#163] When a station is removed, vehicles do not get excessive payment any longer, as the origin TILE is now stored as long as the origin STATION for the transported cargos. Basically this is only a temporary fix until cargopackets are implemented, but it fixes one of the oldest known bugs (Special Thanks to Darkvater for lots of testing)
Diffstat (limited to 'src/openttd.cpp')
-rw-r--r--src/openttd.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/openttd.cpp b/src/openttd.cpp
index e0d0d1f27..cb030b4fa 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -1689,6 +1689,19 @@ bool AfterLoadGame(void)
} END_TILE_LOOP(tile_cur, MapSizeX(), MapSizeY(), 0)
}
+ if (CheckSavegameVersion(44)) {
+ Vehicle *v;
+ /* If we remove a station while cargo from it is still enroute, payment calculation will assume
+ * 0, 0 to be the origin of the cargo, resulting in very high payments usually. v->cargo_source_xy
+ * stores the coordinates, preserving them even if the station is removed. However, if a game is loaded
+ * where this situation exists, the cargo-source information is lost. in this case, we set the origin
+ * to the current tile of the vehicle to prevent excessive profits
+ */
+ FOR_ALL_VEHICLES(v) {
+ v->cargo_source_xy = IsValidStationID(v->cargo_source) ? GetStation(v->cargo_source)->xy : v->tile;
+ }
+ }
+
return true;
}