mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Remove unused size field from struct SaveLoad (#12859)
parent
6006e832f2
commit
65c666cb57
|
@ -1776,7 +1776,7 @@ std::vector<SaveLoad> SlTableHeader(const SaveLoadTable &slt)
|
|||
}
|
||||
|
||||
/* We don't know this field, so read to nothing. */
|
||||
saveloads.push_back({key, saveload_type, ((VarType)type & SLE_FILE_TYPE_MASK) | SLE_VAR_NULL, 1, SL_MIN_VERSION, SL_MAX_VERSION, 0, nullptr, 0, handler});
|
||||
saveloads.push_back({key, saveload_type, ((VarType)type & SLE_FILE_TYPE_MASK) | SLE_VAR_NULL, 1, SL_MIN_VERSION, SL_MAX_VERSION, nullptr, 0, handler});
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1883,7 +1883,7 @@ std::vector<SaveLoad> SlCompatTableHeader(const SaveLoadTable &slt, const SaveLo
|
|||
/* In old savegames there can be data we no longer care for. We
|
||||
* skip this by simply reading the amount of bytes indicated and
|
||||
* send those to /dev/null. */
|
||||
saveloads.push_back({"", SL_NULL, GetVarFileType(slc.null_type) | SLE_VAR_NULL, slc.null_length, slc.version_from, slc.version_to, 0, nullptr, 0, nullptr});
|
||||
saveloads.push_back({"", SL_NULL, GetVarFileType(slc.null_type) | SLE_VAR_NULL, slc.null_length, slc.version_from, slc.version_to, nullptr, 0, nullptr});
|
||||
} else {
|
||||
auto sld_it = key_lookup.find(slc.name);
|
||||
/* If this branch triggers, it means that an entry in the
|
||||
|
|
|
@ -707,7 +707,6 @@ struct SaveLoad {
|
|||
uint16_t length; ///< (Conditional) length of the variable (eg. arrays) (max array size is 65536 elements).
|
||||
SaveLoadVersion version_from; ///< Save/load the variable starting from this savegame version.
|
||||
SaveLoadVersion version_to; ///< Save/load the variable before this savegame version.
|
||||
size_t size; ///< The sizeof size.
|
||||
SaveLoadAddrProc *address_proc; ///< Callback proc the get the actual variable address in memory.
|
||||
size_t extra_data; ///< Extra data for the callback proc.
|
||||
std::shared_ptr<SaveLoadHandler> handler; ///< Custom handler for Save/Load procs.
|
||||
|
@ -823,7 +822,7 @@ inline constexpr bool SlCheckVarSize(SaveLoadType cmd, VarType type, size_t leng
|
|||
* @note In general, it is better to use one of the SLE_* macros below.
|
||||
*/
|
||||
#define SLE_GENERAL_NAME(cmd, name, base, variable, type, length, from, to, extra) \
|
||||
SaveLoad {name, cmd, type, length, from, to, cpp_sizeof(base, variable), [] (void *b, size_t) -> void * { \
|
||||
SaveLoad {name, cmd, type, length, from, to, [] (void *b, size_t) -> void * { \
|
||||
static_assert(SlCheckVarSize(cmd, type, length, sizeof(static_cast<base *>(b)->variable))); \
|
||||
assert(b != nullptr); \
|
||||
return const_cast<void *>(static_cast<const void *>(std::addressof(static_cast<base *>(b)->variable))); \
|
||||
|
@ -1052,7 +1051,7 @@ inline constexpr bool SlCheckVarSize(SaveLoadType cmd, VarType type, size_t leng
|
|||
* @note In general, it is better to use one of the SLEG_* macros below.
|
||||
*/
|
||||
#define SLEG_GENERAL(name, cmd, variable, type, length, from, to, extra) \
|
||||
SaveLoad {name, cmd, type, length, from, to, sizeof(variable), [] (void *, size_t) -> void * { \
|
||||
SaveLoad {name, cmd, type, length, from, to, [] (void *, size_t) -> void * { \
|
||||
static_assert(SlCheckVarSize(cmd, type, length, sizeof(variable))); \
|
||||
return static_cast<void *>(std::addressof(variable)); }, extra, nullptr}
|
||||
|
||||
|
@ -1104,7 +1103,7 @@ inline constexpr bool SlCheckVarSize(SaveLoadType cmd, VarType type, size_t leng
|
|||
* @param from First savegame version that has the struct.
|
||||
* @param to Last savegame version that has the struct.
|
||||
*/
|
||||
#define SLEG_CONDSTRUCT(name, handler, from, to) SaveLoad {name, SL_STRUCT, 0, 0, from, to, 0, nullptr, 0, std::make_shared<handler>()}
|
||||
#define SLEG_CONDSTRUCT(name, handler, from, to) SaveLoad {name, SL_STRUCT, 0, 0, from, to, nullptr, 0, std::make_shared<handler>()}
|
||||
|
||||
/**
|
||||
* Storage of a global reference list in some savegame versions.
|
||||
|
@ -1133,7 +1132,7 @@ inline constexpr bool SlCheckVarSize(SaveLoadType cmd, VarType type, size_t leng
|
|||
* @param from First savegame version that has the list.
|
||||
* @param to Last savegame version that has the list.
|
||||
*/
|
||||
#define SLEG_CONDSTRUCTLIST(name, handler, from, to) SaveLoad {name, SL_STRUCTLIST, 0, 0, from, to, 0, nullptr, 0, std::make_shared<handler>()}
|
||||
#define SLEG_CONDSTRUCTLIST(name, handler, from, to) SaveLoad {name, SL_STRUCTLIST, 0, 0, from, to, nullptr, 0, std::make_shared<handler>()}
|
||||
|
||||
/**
|
||||
* Storage of a global variable in every savegame version.
|
||||
|
|
|
@ -84,7 +84,7 @@ static std::vector<SaveLoad> GetSettingsDesc(const SettingTable &settings, bool
|
|||
if (is_loading && (sd->flags & SF_NO_NETWORK_SYNC) && _networking && !_network_server) {
|
||||
if (IsSavegameVersionBefore(SLV_TABLE_CHUNKS)) {
|
||||
/* We don't want to read this setting, so we do need to skip over it. */
|
||||
saveloads.push_back({sd->GetName(), sd->save.cmd, GetVarFileType(sd->save.conv) | SLE_VAR_NULL, sd->save.length, sd->save.version_from, sd->save.version_to, 0, nullptr, 0, nullptr});
|
||||
saveloads.push_back({sd->GetName(), sd->save.cmd, GetVarFileType(sd->save.conv) | SLE_VAR_NULL, sd->save.length, sd->save.version_from, sd->save.version_to, nullptr, 0, nullptr});
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue