Changeset - r25702:89c61c19a4db
[Not reviewed]
master
0 8 0
Patric Stout - 3 years ago 2021-06-14 11:57:53
truebrain@openttd.org
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.
8 files changed with 11 insertions and 10 deletions:
0 comments (0 inline, 0 general)
src/saveload/economy_sl.cpp
Show inline comments
 
@@ -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 },
 
};
 

	
src/saveload/engine_sl.cpp
Show inline comments
 
@@ -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);
src/saveload/saveload.cpp
Show inline comments
 
@@ -1897,10 +1897,10 @@ static void SlLoadCheckChunk(const Chunk
 
 */
 
static void SlSaveChunk(const ChunkHandler &ch)
 
{
 
	if (ch.type == CH_READONLY) return;
 

	
 
	ChunkSaveLoadProc *proc = ch.save_proc;
 

	
 
	/* Don't save any chunk information if there is no save handler. */
 
	if (proc == nullptr) return;
 
	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);
src/saveload/saveload.h
Show inline comments
 
@@ -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. */
src/saveload/station_sl.cpp
Show inline comments
 
@@ -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 },
 
};
src/saveload/strings_sl.cpp
Show inline comments
 
@@ -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);
src/saveload/waypoint_sl.cpp
Show inline comments
 
@@ -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);
src/settings.cpp
Show inline comments
 
@@ -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 },
 
};
 

	
0 comments (0 inline, 0 general)