Codechange #8258: Remove unused town cargo caches from the savegame

pull/192/head
dP 4 years ago committed by Charles Pigott
parent a10013dd00
commit 452e1e3328

@ -302,6 +302,7 @@ enum SaveLoadVersion : uint16 {
SLV_MULTITILE_DOCKS, ///< 216 PR#7380 Multiple docks per station. SLV_MULTITILE_DOCKS, ///< 216 PR#7380 Multiple docks per station.
SLV_TRADING_AGE, ///< 217 PR#7780 Configurable company trading age. SLV_TRADING_AGE, ///< 217 PR#7780 Configurable company trading age.
SLV_ENDING_YEAR, ///< 218 PR#7747 v1.10 Configurable ending year. SLV_ENDING_YEAR, ///< 218 PR#7747 v1.10 Configurable ending year.
SLV_REMOVE_TOWN_CARGO_CACHE, ///< 219 PR#8258 Remove town cargo acceptance and production caches.
SL_MAX_VERSION, ///< Highest possible saveload version SL_MAX_VERSION, ///< Highest possible saveload version
}; };

@ -20,7 +20,6 @@
#include "../safeguards.h" #include "../safeguards.h"
/* TODO: Remove acceptance matrix from the savegame completely. */
typedef TileMatrix<CargoTypes, 4> AcceptanceMatrix; typedef TileMatrix<CargoTypes, 4> AcceptanceMatrix;
/** /**
@ -193,10 +192,8 @@ static const SaveLoad _town_desc[] = {
SLE_CONDLST(Town, psa_list, REF_STORAGE, SLV_161, SL_MAX_VERSION), SLE_CONDLST(Town, psa_list, REF_STORAGE, SLV_161, SL_MAX_VERSION),
SLE_CONDNULL(4, SLV_166, SLV_EXTEND_CARGOTYPES), ///< cargo_produced, no longer in use SLE_CONDNULL(4, SLV_166, SLV_EXTEND_CARGOTYPES), ///< cargo_produced, no longer in use
SLE_CONDNULL(8, SLV_EXTEND_CARGOTYPES, SL_MAX_VERSION), ///< cargo_produced, no longer in use SLE_CONDNULL(8, SLV_EXTEND_CARGOTYPES, SLV_REMOVE_TOWN_CARGO_CACHE), ///< cargo_produced, no longer in use
SLE_CONDNULL(30, SLV_2, SLV_REMOVE_TOWN_CARGO_CACHE), ///< old reserved space
/* reserve extra space in savegame here. (currently 30 bytes) */
SLE_CONDNULL(30, SLV_2, SL_MAX_VERSION),
SLE_END() SLE_END()
}; };
@ -252,12 +249,6 @@ static void RealSave_Town(Town *t)
for (int i = TE_BEGIN; i < NUM_TE; i++) { for (int i = TE_BEGIN; i < NUM_TE; i++) {
SlObject(&t->received[i], _town_received_desc); SlObject(&t->received[i], _town_received_desc);
} }
if (IsSavegameVersionBefore(SLV_166)) return;
/* Write an empty matrix to avoid bumping savegame version. */
AcceptanceMatrix dummy;
SlObject(&dummy, GetTileMatrixDesc());
} }
static void Save_TOWN() static void Save_TOWN()
@ -288,14 +279,14 @@ static void Load_TOWN()
SlErrorCorrupt("Invalid town name generator"); SlErrorCorrupt("Invalid town name generator");
} }
if (IsSavegameVersionBefore(SLV_166)) continue; if (!IsSavegameVersionBefore(SLV_166) && IsSavegameVersionBefore(SLV_REMOVE_TOWN_CARGO_CACHE)) {
/* Discard now unused acceptance matrix. */
/* Discard acceptance matrix to avoid bumping savegame version. */
AcceptanceMatrix dummy; AcceptanceMatrix dummy;
SlObject(&dummy, GetTileMatrixDesc()); SlObject(&dummy, GetTileMatrixDesc());
if (dummy.area.w != 0) { if (dummy.area.w != 0) {
uint arr_len = dummy.area.w / AcceptanceMatrix::GRID * dummy.area.h / AcceptanceMatrix::GRID; uint arr_len = dummy.area.w / AcceptanceMatrix::GRID * dummy.area.h / AcceptanceMatrix::GRID;
for (arr_len *= 4; arr_len != 0; arr_len--) SlReadByte(); SlSkipBytes(4 * arr_len);
}
} }
} }
} }

Loading…
Cancel
Save