Merge branch 'openttd'

This commit is contained in:
dP
2024-02-19 04:42:57 +05:30
183 changed files with 9531 additions and 5695 deletions

View File

@@ -251,6 +251,7 @@ static const std::vector<ChunkHandlerRef> &ChunkHandlers()
extern const ChunkHandlerTable _object_chunk_handlers;
extern const ChunkHandlerTable _persistent_storage_chunk_handlers;
extern const ChunkHandlerTable _water_region_chunk_handlers;
extern const ChunkHandlerTable _randomizer_chunk_handlers;
/** List of all chunks in a savegame. */
static const ChunkHandlerTable _chunk_handler_tables[] = {
@@ -289,6 +290,7 @@ static const std::vector<ChunkHandlerRef> &ChunkHandlers()
_object_chunk_handlers,
_persistent_storage_chunk_handlers,
_water_region_chunk_handlers,
_randomizer_chunk_handlers,
};
static std::vector<ChunkHandlerRef> _chunk_handlers;
@@ -622,9 +624,16 @@ static inline byte SlCalcConvFileLen(VarType conv)
{
static const byte conv_file_size[] = {0, 1, 1, 2, 2, 4, 4, 8, 8, 2};
uint8_t type = GetVarFileType(conv);
assert(type < lengthof(conv_file_size));
return conv_file_size[type];
switch (GetVarFileType(conv)) {
case SLE_FILE_STRING:
return SlReadArrayLength();
default:
uint8_t type = GetVarFileType(conv);
if (type >= lengthof(conv_file_size)) fmt::println("{}", type);
assert(type < lengthof(conv_file_size));
return conv_file_size[type];
}
}
/** Return the size in bytes of a reference (pointer) */
@@ -1863,7 +1872,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, SLE_FILE_U8 | SLE_VAR_NULL, slc.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, 0, nullptr, 0, nullptr});
} else {
auto sld_it = key_lookup.find(slc.name);
/* If this branch triggers, it means that an entry in the