summaryrefslogtreecommitdiff
path: root/src/saveload/town_sl.cpp
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-10-30 11:13:12 +0100
committerErich Eckner <git@eckner.net>2018-10-30 15:28:03 +0100
commita34d095259409cf1454d9777deabbc00bcdb9407 (patch)
tree9e7c37ed33f5bd6b3c2f41cf248dcb656b2a4afa /src/saveload/town_sl.cpp
parent6647cb917963c4e0d6d633b7a92af78167050893 (diff)
downloadopenttd-underground-plus-others-original.tar.xz
underground patch appliedunderground-plus-others-original
Diffstat (limited to 'src/saveload/town_sl.cpp')
-rw-r--r--src/saveload/town_sl.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/saveload/town_sl.cpp b/src/saveload/town_sl.cpp
index de52604f5..6041bd98e 100644
--- a/src/saveload/town_sl.cpp
+++ b/src/saveload/town_sl.cpp
@@ -249,6 +249,8 @@ static void RealSave_Town(Town *t)
SlObject(&t->received[i], _town_received_desc);
}
+ t->SaveCargoSourceSink();
+
if (IsSavegameVersionBefore(166)) return;
SlObject(&t->cargo_accepted, GetTileMatrixDesc());
@@ -287,6 +289,8 @@ static void Load_TOWN()
SlErrorCorrupt("Invalid town name generator");
}
+ t->LoadCargoSourceSink();
+
if (IsSavegameVersionBefore(166)) continue;
SlObject(&t->cargo_accepted, GetTileMatrixDesc());
@@ -298,16 +302,26 @@ static void Load_TOWN()
/* Rebuild total cargo acceptance. */
UpdateTownCargoTotal(t);
}
+
+ /* Cache the aligned tile index of the centre tile. */
+ uint town_x = (TileX(t->xy) / AcceptanceMatrix::GRID) * AcceptanceMatrix::GRID;
+ uint town_y = (TileY(t->xy) / AcceptanceMatrix::GRID) * AcceptanceMatrix::GRID;
+ t->xy_aligned= TileXY(town_x, town_y);
}
}
/** Fix pointers when loading town data. */
static void Ptrs_TOWN()
{
+ Town *t;
+
+ FOR_ALL_TOWNS(t) {
+ t->PtrsCargoSourceSink();
+ }
+
/* Don't run when savegame version lower than 161. */
if (IsSavegameVersionBefore(161)) return;
- Town *t;
FOR_ALL_TOWNS(t) {
SlObject(t, _town_desc);
}