summaryrefslogtreecommitdiff
path: root/src/openttd.cpp
diff options
context:
space:
mode:
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;
}