mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-11 13:10:45 +00:00
Codechange: mark chunks that are not stored as CH_READONLY
This makes it easier to spot chunks that have a save_proc that is a nullptr, but also prevents confusion, where it looks like the CH_ type of a chunk has influence on how it is being read. It is not, it is only used for saving.
This commit is contained in:
parent
4c4b55ecbd
commit
8e91527251
@ -100,8 +100,8 @@ static void Ptrs_CAPY()
|
||||
|
||||
static const ChunkHandler economy_chunk_handlers[] = {
|
||||
{ 'CAPY', Save_CAPY, Load_CAPY, Ptrs_CAPY, nullptr, CH_ARRAY },
|
||||
{ 'PRIC', nullptr, Load_PRIC, nullptr, nullptr, CH_RIFF },
|
||||
{ 'CAPR', nullptr, Load_CAPR, nullptr, nullptr, CH_RIFF },
|
||||
{ 'PRIC', nullptr, Load_PRIC, nullptr, nullptr, CH_READONLY },
|
||||
{ 'CAPR', nullptr, Load_CAPR, nullptr, nullptr, CH_READONLY },
|
||||
{ 'ECMY', Save_ECMY, Load_ECMY, nullptr, nullptr, CH_ARRAY },
|
||||
};
|
||||
|
||||
|
@ -196,7 +196,7 @@ static void Load_EIDS()
|
||||
static const ChunkHandler engine_chunk_handlers[] = {
|
||||
{ 'EIDS', Save_EIDS, Load_EIDS, nullptr, nullptr, CH_ARRAY },
|
||||
{ 'ENGN', Save_ENGN, Load_ENGN, nullptr, nullptr, CH_ARRAY },
|
||||
{ 'ENGS', nullptr, Load_ENGS, nullptr, nullptr, CH_RIFF },
|
||||
{ 'ENGS', nullptr, Load_ENGS, nullptr, nullptr, CH_READONLY },
|
||||
};
|
||||
|
||||
extern const ChunkHandlerTable _engine_chunk_handlers(engine_chunk_handlers);
|
||||
|
@ -1897,10 +1897,10 @@ static void SlLoadCheckChunk(const ChunkHandler &ch)
|
||||
*/
|
||||
static void SlSaveChunk(const ChunkHandler &ch)
|
||||
{
|
||||
ChunkSaveLoadProc *proc = ch.save_proc;
|
||||
if (ch.type == CH_READONLY) return;
|
||||
|
||||
/* Don't save any chunk information if there is no save handler. */
|
||||
if (proc == nullptr) return;
|
||||
ChunkSaveLoadProc *proc = ch.save_proc;
|
||||
assert(proc != nullptr);
|
||||
|
||||
SlWriteUint32(ch.id);
|
||||
Debug(sl, 2, "Saving chunk {:c}{:c}{:c}{:c}", ch.id >> 24, ch.id >> 16, ch.id >> 8, ch.id);
|
||||
|
@ -388,6 +388,7 @@ enum ChunkType {
|
||||
CH_RIFF = 0,
|
||||
CH_ARRAY = 1,
|
||||
CH_SPARSE_ARRAY = 2,
|
||||
CH_READONLY, ///< Chunk is never saved.
|
||||
};
|
||||
|
||||
/** Handlers and description of chunk. */
|
||||
|
@ -703,7 +703,7 @@ static void Ptrs_ROADSTOP()
|
||||
}
|
||||
|
||||
static const ChunkHandler station_chunk_handlers[] = {
|
||||
{ 'STNS', nullptr, Load_STNS, Ptrs_STNS, nullptr, CH_ARRAY },
|
||||
{ 'STNS', nullptr, Load_STNS, Ptrs_STNS, nullptr, CH_READONLY },
|
||||
{ 'STNN', Save_STNN, Load_STNN, Ptrs_STNN, nullptr, CH_ARRAY },
|
||||
{ 'ROAD', Save_ROADSTOP, Load_ROADSTOP, Ptrs_ROADSTOP, nullptr, CH_ARRAY },
|
||||
};
|
||||
|
@ -132,7 +132,7 @@ static void Load_NAME()
|
||||
|
||||
/** Chunk handlers related to strings. */
|
||||
static const ChunkHandler name_chunk_handlers[] = {
|
||||
{ 'NAME', nullptr, Load_NAME, nullptr, nullptr, CH_ARRAY },
|
||||
{ 'NAME', nullptr, Load_NAME, nullptr, nullptr, CH_READONLY },
|
||||
};
|
||||
|
||||
extern const ChunkHandlerTable _name_chunk_handlers(name_chunk_handlers);
|
||||
|
@ -225,7 +225,7 @@ static void Ptrs_WAYP()
|
||||
}
|
||||
|
||||
static const ChunkHandler waypoint_chunk_handlers[] = {
|
||||
{ 'CHKP', nullptr, Load_WAYP, Ptrs_WAYP, nullptr, CH_ARRAY },
|
||||
{ 'CHKP', nullptr, Load_WAYP, Ptrs_WAYP, nullptr, CH_READONLY },
|
||||
};
|
||||
|
||||
extern const ChunkHandlerTable _waypoint_chunk_handlers(waypoint_chunk_handlers);
|
||||
|
@ -2105,7 +2105,7 @@ static void Save_PATS()
|
||||
}
|
||||
|
||||
static const ChunkHandler setting_chunk_handlers[] = {
|
||||
{ 'OPTS', nullptr, Load_OPTS, nullptr, nullptr, CH_RIFF },
|
||||
{ 'OPTS', nullptr, Load_OPTS, nullptr, nullptr, CH_READONLY },
|
||||
{ 'PATS', Save_PATS, Load_PATS, nullptr, Check_PATS, CH_ARRAY },
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user