summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorglx22 <glx@openttd.org>2021-06-10 03:21:07 +0200
committerLoïc Guilloux <glx22@users.noreply.github.com>2021-07-06 22:29:08 +0200
commit6e627f35ac03008dab7729ad079b79db9df2d68b (patch)
tree469e818ea5f63a74c3a600572d7348eff948e30b
parent2c941cd8b3cb1774f4982b86735e276597a91750 (diff)
downloadopenttd-6e627f35ac03008dab7729ad079b79db9df2d68b.tar.xz
Cleanup: Remove now unneeded ChunkHandler members
-rw-r--r--src/saveload/autoreplace_sl.cpp5
-rw-r--r--src/saveload/company_sl.cpp6
-rw-r--r--src/saveload/depot_sl.cpp5
-rw-r--r--src/saveload/economy_sl.cpp5
-rw-r--r--src/saveload/gamelog_sl.cpp5
-rw-r--r--src/saveload/industry_sl.cpp5
-rw-r--r--src/saveload/linkgraph_sl.cpp5
-rw-r--r--src/saveload/map_sl.cpp5
-rw-r--r--src/saveload/misc_sl.cpp5
-rw-r--r--src/saveload/newgrf_sl.cpp5
-rw-r--r--src/saveload/object_sl.cpp5
-rw-r--r--src/saveload/order_sl.cpp15
-rw-r--r--src/saveload/saveload.cpp63
-rw-r--r--src/saveload/saveload.h21
-rw-r--r--src/saveload/settings_sl.cpp5
-rw-r--r--src/saveload/station_sl.cpp15
-rw-r--r--src/saveload/town_sl.cpp5
-rw-r--r--src/saveload/vehicle_sl.cpp5
-rw-r--r--src/saveload/waypoint_sl.cpp5
19 files changed, 42 insertions, 148 deletions
diff --git a/src/saveload/autoreplace_sl.cpp b/src/saveload/autoreplace_sl.cpp
index 6a9dd8f00..6d5e08f11 100644
--- a/src/saveload/autoreplace_sl.cpp
+++ b/src/saveload/autoreplace_sl.cpp
@@ -26,10 +26,7 @@ static const SaveLoad _engine_renew_desc[] = {
};
struct ERNWChunkHandler : ChunkHandler {
- ERNWChunkHandler() : ChunkHandler('ERNW', CH_TABLE)
- {
- this->fix_pointers = true;
- }
+ ERNWChunkHandler() : ChunkHandler('ERNW', CH_TABLE) {}
void Save() const override
{
diff --git a/src/saveload/company_sl.cpp b/src/saveload/company_sl.cpp
index fab674f8b..cc8a9f9cb 100644
--- a/src/saveload/company_sl.cpp
+++ b/src/saveload/company_sl.cpp
@@ -498,11 +498,7 @@ static const SaveLoad _company_desc[] = {
};
struct PLYRChunkHandler : ChunkHandler {
- PLYRChunkHandler() : ChunkHandler('PLYR', CH_TABLE)
- {
- this->load_check = true;
- this->fix_pointers = true;
- }
+ PLYRChunkHandler() : ChunkHandler('PLYR', CH_TABLE) {}
void Save() const override
{
diff --git a/src/saveload/depot_sl.cpp b/src/saveload/depot_sl.cpp
index ef0c406e2..2a7859211 100644
--- a/src/saveload/depot_sl.cpp
+++ b/src/saveload/depot_sl.cpp
@@ -30,10 +30,7 @@ static const SaveLoad _depot_desc[] = {
};
struct DEPTChunkHandler : ChunkHandler {
- DEPTChunkHandler() : ChunkHandler('DEPT', CH_TABLE)
- {
- this->fix_pointers = true;
- }
+ DEPTChunkHandler() : ChunkHandler('DEPT', CH_TABLE) {}
void Save() const override
{
diff --git a/src/saveload/economy_sl.cpp b/src/saveload/economy_sl.cpp
index 3ce1441ee..4625e831a 100644
--- a/src/saveload/economy_sl.cpp
+++ b/src/saveload/economy_sl.cpp
@@ -89,10 +89,7 @@ static const SaveLoad _cargopayment_desc[] = {
};
struct CAPYChunkHandler : ChunkHandler {
- CAPYChunkHandler() : ChunkHandler('CAPY', CH_TABLE)
- {
- this->fix_pointers = true;
- }
+ CAPYChunkHandler() : ChunkHandler('CAPY', CH_TABLE) {}
void Save() const override
{
diff --git a/src/saveload/gamelog_sl.cpp b/src/saveload/gamelog_sl.cpp
index 3d71f2ff9..89db17424 100644
--- a/src/saveload/gamelog_sl.cpp
+++ b/src/saveload/gamelog_sl.cpp
@@ -348,10 +348,7 @@ static const SaveLoad _gamelog_desc[] = {
};
struct GLOGChunkHandler : ChunkHandler {
- GLOGChunkHandler() : ChunkHandler('GLOG', CH_TABLE)
- {
- this->load_check = true;
- }
+ GLOGChunkHandler() : ChunkHandler('GLOG', CH_TABLE) {}
void LoadCommon(LoggedAction *&gamelog_action, uint &gamelog_actions) const
{
diff --git a/src/saveload/industry_sl.cpp b/src/saveload/industry_sl.cpp
index d70e1a4ee..6d1645e39 100644
--- a/src/saveload/industry_sl.cpp
+++ b/src/saveload/industry_sl.cpp
@@ -75,10 +75,7 @@ static const SaveLoad _industry_desc[] = {
};
struct INDYChunkHandler : ChunkHandler {
- INDYChunkHandler() : ChunkHandler('INDY', CH_TABLE)
- {
- this->fix_pointers = true;
- }
+ INDYChunkHandler() : ChunkHandler('INDY', CH_TABLE) {}
void Save() const override
{
diff --git a/src/saveload/linkgraph_sl.cpp b/src/saveload/linkgraph_sl.cpp
index 70dfb7b39..e1094326b 100644
--- a/src/saveload/linkgraph_sl.cpp
+++ b/src/saveload/linkgraph_sl.cpp
@@ -301,10 +301,7 @@ struct LGRJChunkHandler : ChunkHandler {
* Link graph schedule.
*/
struct LGRSChunkHandler : ChunkHandler {
- LGRSChunkHandler() : ChunkHandler('LGRS', CH_TABLE)
- {
- this->fix_pointers = true;
- }
+ LGRSChunkHandler() : ChunkHandler('LGRS', CH_TABLE) {}
void Save() const override
{
diff --git a/src/saveload/map_sl.cpp b/src/saveload/map_sl.cpp
index d654f3f6b..07a36d6a3 100644
--- a/src/saveload/map_sl.cpp
+++ b/src/saveload/map_sl.cpp
@@ -28,10 +28,7 @@ static const SaveLoad _map_desc[] = {
};
struct MAPSChunkHandler : ChunkHandler {
- MAPSChunkHandler() : ChunkHandler('MAPS', CH_TABLE)
- {
- this->load_check = true;
- }
+ MAPSChunkHandler() : ChunkHandler('MAPS', CH_TABLE) {}
void Save() const override
{
diff --git a/src/saveload/misc_sl.cpp b/src/saveload/misc_sl.cpp
index a7e00f88c..779e10098 100644
--- a/src/saveload/misc_sl.cpp
+++ b/src/saveload/misc_sl.cpp
@@ -96,10 +96,7 @@ static const SaveLoad _date_check_desc[] = {
/* Save load date related variables as well as persistent tick counters
* XXX: currently some unrelated stuff is just put here */
struct DATEChunkHandler : ChunkHandler {
- DATEChunkHandler() : ChunkHandler('DATE', CH_TABLE)
- {
- this->load_check = true;
- }
+ DATEChunkHandler() : ChunkHandler('DATE', CH_TABLE) {}
void Save() const override
{
diff --git a/src/saveload/newgrf_sl.cpp b/src/saveload/newgrf_sl.cpp
index 43f0bd01a..9584d503e 100644
--- a/src/saveload/newgrf_sl.cpp
+++ b/src/saveload/newgrf_sl.cpp
@@ -74,10 +74,7 @@ static const SaveLoad _grfconfig_desc[] = {
struct NGRFChunkHandler : ChunkHandler {
- NGRFChunkHandler() : ChunkHandler('NGRF', CH_TABLE)
- {
- this->load_check = true;
- }
+ NGRFChunkHandler() : ChunkHandler('NGRF', CH_TABLE) {}
void Save() const override
{
diff --git a/src/saveload/object_sl.cpp b/src/saveload/object_sl.cpp
index fc4997002..a61050303 100644
--- a/src/saveload/object_sl.cpp
+++ b/src/saveload/object_sl.cpp
@@ -30,10 +30,7 @@ static const SaveLoad _object_desc[] = {
};
struct OBJSChunkHandler : ChunkHandler {
- OBJSChunkHandler() : ChunkHandler('OBJS', CH_TABLE)
- {
- this->fix_pointers = true;
- }
+ OBJSChunkHandler() : ChunkHandler('OBJS', CH_TABLE) {}
void Save() const override
{
diff --git a/src/saveload/order_sl.cpp b/src/saveload/order_sl.cpp
index 16ee42013..9ec0d0e25 100644
--- a/src/saveload/order_sl.cpp
+++ b/src/saveload/order_sl.cpp
@@ -119,10 +119,7 @@ SaveLoadTable GetOrderDescription()
}
struct ORDRChunkHandler : ChunkHandler {
- ORDRChunkHandler() : ChunkHandler('ORDR', CH_TABLE)
- {
- this->fix_pointers = true;
- }
+ ORDRChunkHandler() : ChunkHandler('ORDR', CH_TABLE) {}
void Save() const override
{
@@ -215,10 +212,7 @@ SaveLoadTable GetOrderListDescription()
}
struct ORDLChunkHandler : ChunkHandler {
- ORDLChunkHandler() : ChunkHandler('ORDL', CH_TABLE)
- {
- this->fix_pointers = true;
- }
+ ORDLChunkHandler() : ChunkHandler('ORDL', CH_TABLE) {}
void Save() const override
{
@@ -277,10 +271,7 @@ SaveLoadTable GetOrderBackupDescription()
}
struct BKORChunkHandler : ChunkHandler {
- BKORChunkHandler() : ChunkHandler('BKOR', CH_TABLE)
- {
- this->fix_pointers = true;
- }
+ BKORChunkHandler() : ChunkHandler('BKOR', CH_TABLE) {}
void Save() const override
{
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp
index 39941c268..6e3d8f8e0 100644
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -314,10 +314,8 @@ static void SlNullPointers()
_sl_version = SAVEGAME_VERSION;
for (const ChunkHandler &ch : ChunkHandlers()) {
- if (ch.fix_pointers) {
- Debug(sl, 3, "Nulling pointers for {:c}{:c}{:c}{:c}", ch.id >> 24, ch.id >> 16, ch.id >> 8, ch.id);
- ch.FixPointers();
- }
+ Debug(sl, 3, "Nulling pointers for {:c}{:c}{:c}{:c}", ch.id >> 24, ch.id >> 16, ch.id >> 8, ch.id);
+ ch.FixPointers();
}
assert(_sl.action == SLA_NULL);
@@ -2114,45 +2112,22 @@ void SlAutolength(AutolengthProc *proc, void *arg)
if (offs != _sl.dumper->GetSize()) SlErrorCorrupt("Invalid chunk size");
}
-void ChunkHandler::Save() const
-{
- assert(this->save_proc != nullptr);
- this->save_proc();
-}
-
-void ChunkHandler::Load() const
-{
- assert(this->load_proc != nullptr);
- this->load_proc();
-}
-
-void ChunkHandler::FixPointers() const
-{
- assert(this->ptrs_proc != nullptr);
- this->ptrs_proc();
-}
-
void ChunkHandler::LoadCheck(size_t len) const
{
- if (this->load_check) {
- assert(this->load_check_proc != nullptr);
- this->load_check_proc();
- } else {
- switch (_sl.block_mode) {
- case CH_TABLE:
- case CH_SPARSE_TABLE:
- SlTableHeader({});
- FALLTHROUGH;
- case CH_ARRAY:
- case CH_SPARSE_ARRAY:
- SlSkipArray();
- break;
- case CH_RIFF:
- SlSkipBytes(len);
- break;
- default:
- NOT_REACHED();
- }
+ switch (_sl.block_mode) {
+ case CH_TABLE:
+ case CH_SPARSE_TABLE:
+ SlTableHeader({});
+ FALLTHROUGH;
+ case CH_ARRAY:
+ case CH_SPARSE_ARRAY:
+ SlSkipArray();
+ break;
+ case CH_RIFF:
+ SlSkipBytes(len);
+ break;
+ default:
+ NOT_REACHED();
}
}
@@ -2352,10 +2327,8 @@ static void SlFixPointers()
_sl.action = SLA_PTRS;
for (const ChunkHandler &ch : ChunkHandlers()) {
- if (ch.fix_pointers) {
- Debug(sl, 3, "Fixing pointers for {:c}{:c}{:c}{:c}", ch.id >> 24, ch.id >> 16, ch.id >> 8, ch.id);
- ch.FixPointers();
- }
+ Debug(sl, 3, "Fixing pointers for {:c}{:c}{:c}{:c}", ch.id >> 24, ch.id >> 16, ch.id >> 8, ch.id);
+ ch.FixPointers();
}
assert(_sl.action == SLA_PTRS);
diff --git a/src/saveload/saveload.h b/src/saveload/saveload.h
index 2f5ebba1f..7fc802713 100644
--- a/src/saveload/saveload.h
+++ b/src/saveload/saveload.h
@@ -384,7 +384,6 @@ void DoExitSave();
SaveOrLoadResult SaveWithFilter(struct SaveFilter *writer, bool threaded);
SaveOrLoadResult LoadWithFilter(struct LoadFilter *reader);
-typedef void ChunkSaveLoadProc();
typedef void AutolengthProc(void *arg);
/** Type of a chunk. */
@@ -402,37 +401,23 @@ enum ChunkType {
/** Handlers and description of chunk. */
struct ChunkHandler {
uint32 id; ///< Unique ID (4 letters).
- ChunkSaveLoadProc *save_proc; ///< Save procedure of the chunk.
- ChunkSaveLoadProc *load_proc; ///< Load procedure of the chunk.
- ChunkSaveLoadProc *ptrs_proc; ///< Manipulate pointers in the chunk.
- ChunkSaveLoadProc *load_check_proc; ///< Load procedure for game preview.
ChunkType type; ///< Type of the chunk. @see ChunkType
- bool fix_pointers = false;
- bool load_check = false;
-
ChunkHandler(uint32 id, ChunkType type) : id(id), type(type) {}
- ChunkHandler(uint32 id, ChunkSaveLoadProc *save_proc, ChunkSaveLoadProc *load_proc, ChunkSaveLoadProc *ptrs_proc, ChunkSaveLoadProc *load_check_proc, ChunkType type)
- : id(id), save_proc(save_proc), load_proc(load_proc), ptrs_proc(ptrs_proc), load_check_proc(load_check_proc), type(type)
- {
- this->fix_pointers = ptrs_proc != nullptr;
- this->load_check = load_check_proc != nullptr;
- }
-
virtual ~ChunkHandler() {}
/**
* Save the chunk.
* Must be overridden, unless Chunk type is CH_READONLY.
*/
- virtual void Save() const;
+ virtual void Save() const { NOT_REACHED(); }
/**
* Load the chunk.
* Must be overridden.
*/
- virtual void Load() const;
+ virtual void Load() const = 0;
/**
* Fix the pointers.
@@ -440,7 +425,7 @@ struct ChunkHandler {
* On load, pointers are filled with indices and need to be fixed to point to the real object.
* Must be overridden if the chunk saves any pointer.
*/
- virtual void FixPointers() const;
+ virtual void FixPointers() const {}
/**
* Load the chunk for game preview.
diff --git a/src/saveload/settings_sl.cpp b/src/saveload/settings_sl.cpp
index 53254cde7..59b00e0f0 100644
--- a/src/saveload/settings_sl.cpp
+++ b/src/saveload/settings_sl.cpp
@@ -157,10 +157,7 @@ struct OPTSChunkHandler : ChunkHandler {
};
struct PATSChunkHandler : ChunkHandler {
- PATSChunkHandler() : ChunkHandler('PATS', CH_TABLE)
- {
- this->load_check = true;
- }
+ PATSChunkHandler() : ChunkHandler('PATS', CH_TABLE) {}
void Load() const override
{
diff --git a/src/saveload/station_sl.cpp b/src/saveload/station_sl.cpp
index 9c97792ce..20d70066e 100644
--- a/src/saveload/station_sl.cpp
+++ b/src/saveload/station_sl.cpp
@@ -485,10 +485,7 @@ static const SaveLoad _old_station_desc[] = {
};
struct STNSChunkHandler : ChunkHandler {
- STNSChunkHandler() : ChunkHandler('STNS', CH_READONLY)
- {
- this->fix_pointers = true;
- }
+ STNSChunkHandler() : ChunkHandler('STNS', CH_READONLY) {}
void Load() const override
{
@@ -659,10 +656,7 @@ static const SaveLoad _station_desc[] = {
};
struct STNNChunkHandler : ChunkHandler {
- STNNChunkHandler() : ChunkHandler('STNN', CH_TABLE)
- {
- this->fix_pointers = true;
- }
+ STNNChunkHandler() : ChunkHandler('STNN', CH_TABLE) {}
void Save() const override
{
@@ -705,10 +699,7 @@ struct STNNChunkHandler : ChunkHandler {
};
struct ROADChunkHandler : ChunkHandler {
- ROADChunkHandler() : ChunkHandler('ROAD', CH_TABLE)
- {
- this->fix_pointers = true;
- }
+ ROADChunkHandler() : ChunkHandler('ROAD', CH_TABLE) {}
void Save() const override
{
diff --git a/src/saveload/town_sl.cpp b/src/saveload/town_sl.cpp
index 09c575e6a..edf38178d 100644
--- a/src/saveload/town_sl.cpp
+++ b/src/saveload/town_sl.cpp
@@ -287,10 +287,7 @@ struct HIDSChunkHandler : ChunkHandler {
};
struct CITYChunkHandler : ChunkHandler {
- CITYChunkHandler() : ChunkHandler('CITY', CH_TABLE)
- {
- this->fix_pointers = true;
- }
+ CITYChunkHandler() : ChunkHandler('CITY', CH_TABLE) {}
void Save() const override
{
diff --git a/src/saveload/vehicle_sl.cpp b/src/saveload/vehicle_sl.cpp
index 24b3a13c9..85df6efce 100644
--- a/src/saveload/vehicle_sl.cpp
+++ b/src/saveload/vehicle_sl.cpp
@@ -995,10 +995,7 @@ const static SaveLoad _vehicle_desc[] = {
};
struct VEHSChunkHandler : ChunkHandler {
- VEHSChunkHandler() : ChunkHandler('VEHS', CH_SPARSE_TABLE)
- {
- this->fix_pointers = true;
- }
+ VEHSChunkHandler() : ChunkHandler('VEHS', CH_SPARSE_TABLE) {}
void Save() const override
{
diff --git a/src/saveload/waypoint_sl.cpp b/src/saveload/waypoint_sl.cpp
index 739fd5655..e81148fa5 100644
--- a/src/saveload/waypoint_sl.cpp
+++ b/src/saveload/waypoint_sl.cpp
@@ -183,10 +183,7 @@ static const SaveLoad _old_waypoint_desc[] = {
};
struct CHKPChunkHandler : ChunkHandler {
- CHKPChunkHandler() : ChunkHandler('CHKP', CH_READONLY)
- {
- this->fix_pointers = true;
- }
+ CHKPChunkHandler() : ChunkHandler('CHKP', CH_READONLY) {}
void Load() const override
{