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
 
@@ -97,12 +97,12 @@ 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 },
 
};
 

	
 
extern const ChunkHandlerTable _economy_chunk_handlers(economy_chunk_handlers);
src/saveload/engine_sl.cpp
Show inline comments
 
@@ -193,10 +193,10 @@ 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
 
@@ -1894,16 +1894,16 @@ static void SlLoadCheckChunk(const Chunk
 
 * Save a chunk of data (eg. vehicles, stations, etc.). Each chunk is
 
 * prefixed by an ID identifying it, followed by data, and terminator where appropriate
 
 * @param ch The chunkhandler that will be used for the operation
 
 */
 
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);
 

	
 
	_sl.block_mode = ch.type;
 
	switch (ch.type) {
src/saveload/saveload.h
Show inline comments
 
@@ -385,12 +385,13 @@ typedef void AutolengthProc(void *arg);
 

	
 
/** Type of a chunk. */
 
enum ChunkType {
 
	CH_RIFF = 0,
 
	CH_ARRAY = 1,
 
	CH_SPARSE_ARRAY = 2,
 
	CH_READONLY, ///< Chunk is never saved.
 
};
 

	
 
/** Handlers and description of chunk. */
 
struct ChunkHandler {
 
	uint32 id;                          ///< Unique ID (4 letters).
 
	ChunkSaveLoadProc *save_proc;       ///< Save procedure of the chunk.
src/saveload/station_sl.cpp
Show inline comments
 
@@ -700,12 +700,12 @@ static void Ptrs_ROADSTOP()
 
	for (RoadStop *rs : RoadStop::Iterate()) {
 
		SlObject(rs, _roadstop_desc);
 
	}
 
}
 

	
 
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 },
 
};
 

	
 
extern const ChunkHandlerTable _station_chunk_handlers(station_chunk_handlers);
src/saveload/strings_sl.cpp
Show inline comments
 
@@ -129,10 +129,10 @@ static void Load_NAME()
 
		_old_name_array[LEN_OLD_STRINGS * index + LEN_OLD_STRINGS - 1] = '\0';
 
	}
 
}
 

	
 
/** 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
 
@@ -222,10 +222,10 @@ static void Ptrs_WAYP()
 
			wp.name = CopyFromOldName(wp.string_id);
 
		}
 
	}
 
}
 

	
 
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
 
@@ -2102,13 +2102,13 @@ static void Check_PATS()
 
static void Save_PATS()
 
{
 
	SaveSettings(_settings, &_settings_game);
 
}
 

	
 
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 },
 
};
 

	
 
extern const ChunkHandlerTable _setting_chunk_handlers(setting_chunk_handlers);
 

	
 
static bool IsSignedVarMemType(VarType vt)
0 comments (0 inline, 0 general)