mirror of https://github.com/OpenTTD/OpenTTD.git
Change: rework several CH_RIFF chunks to use CH_ARRAY instead
This adds two byte extra to those chunks, and might feel a bit silly at first. But in later changes we will prefix CH_ARRAY with a table header, and then this change shines. Without this, we could still add headers to these chunks, but any external reader wouldn't know if the CH_RIFF has them or not. This way is much more practical, as they are now more like any other chunk.
This commit is contained in:
parent
b9ab9e4d05
commit
88edfd4ef1
|
@ -18,13 +18,17 @@
|
||||||
|
|
||||||
extern std::vector<TileIndex> _animated_tiles;
|
extern std::vector<TileIndex> _animated_tiles;
|
||||||
|
|
||||||
|
static const SaveLoad _animated_tile_desc[] = {
|
||||||
|
SLEG_VECTOR(_animated_tiles, SLE_UINT32),
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save the ANIT chunk.
|
* Save the ANIT chunk.
|
||||||
*/
|
*/
|
||||||
static void Save_ANIT()
|
static void Save_ANIT()
|
||||||
{
|
{
|
||||||
SlSetLength(_animated_tiles.size() * sizeof(_animated_tiles.front()));
|
SlSetArrayIndex(0);
|
||||||
SlCopy(_animated_tiles.data(), _animated_tiles.size(), SLE_UINT32);
|
SlGlobList(_animated_tile_desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,10 +49,17 @@ static void Load_ANIT()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint count = (uint)SlGetFieldLength() / sizeof(_animated_tiles.front());
|
if (IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY)) {
|
||||||
_animated_tiles.clear();
|
size_t count = SlGetFieldLength() / sizeof(_animated_tiles.front());
|
||||||
_animated_tiles.resize(_animated_tiles.size() + count);
|
_animated_tiles.clear();
|
||||||
SlCopy(_animated_tiles.data(), count, SLE_UINT32);
|
_animated_tiles.resize(_animated_tiles.size() + count);
|
||||||
|
SlCopy(_animated_tiles.data(), count, SLE_UINT32);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SlIterateArray() == -1) return;
|
||||||
|
SlGlobList(_animated_tile_desc);
|
||||||
|
if (SlIterateArray() != -1) SlErrorCorrupt("Too many ANIT entries");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,7 +67,7 @@ static void Load_ANIT()
|
||||||
* the animated tile table.
|
* the animated tile table.
|
||||||
*/
|
*/
|
||||||
static const ChunkHandler animated_tile_chunk_handlers[] = {
|
static const ChunkHandler animated_tile_chunk_handlers[] = {
|
||||||
{ 'ANIT', Save_ANIT, Load_ANIT, nullptr, nullptr, CH_RIFF },
|
{ 'ANIT', Save_ANIT, Load_ANIT, nullptr, nullptr, CH_ARRAY },
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const ChunkHandlerTable _animated_tile_chunk_handlers(animated_tile_chunk_handlers);
|
extern const ChunkHandlerTable _animated_tile_chunk_handlers(animated_tile_chunk_handlers);
|
||||||
|
|
|
@ -44,6 +44,8 @@ static const SaveLoad _cheats_desc[] = {
|
||||||
*/
|
*/
|
||||||
static void Save_CHTS()
|
static void Save_CHTS()
|
||||||
{
|
{
|
||||||
|
SlSetArrayIndex(0);
|
||||||
|
|
||||||
SlSetLength(std::size(_cheats_desc));
|
SlSetLength(std::size(_cheats_desc));
|
||||||
SlObject(&_cheats, _cheats_desc);
|
SlObject(&_cheats, _cheats_desc);
|
||||||
}
|
}
|
||||||
|
@ -67,12 +69,14 @@ static void Load_CHTS()
|
||||||
if (count == 0) break;
|
if (count == 0) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() == -1) return;
|
||||||
SlObject(&_cheats, slt);
|
SlObject(&_cheats, slt);
|
||||||
|
if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() != -1) SlErrorCorrupt("Too many CHTS entries");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Chunk handlers related to cheats. */
|
/** Chunk handlers related to cheats. */
|
||||||
static const ChunkHandler cheat_chunk_handlers[] = {
|
static const ChunkHandler cheat_chunk_handlers[] = {
|
||||||
{ 'CHTS', Save_CHTS, Load_CHTS, nullptr, nullptr, CH_RIFF },
|
{ 'CHTS', Save_CHTS, Load_CHTS, nullptr, nullptr, CH_ARRAY },
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const ChunkHandlerTable _cheat_chunk_handlers(cheat_chunk_handlers);
|
extern const ChunkHandlerTable _cheat_chunk_handlers(cheat_chunk_handlers);
|
||||||
|
|
|
@ -51,13 +51,17 @@ static const SaveLoad _economy_desc[] = {
|
||||||
/** Economy variables */
|
/** Economy variables */
|
||||||
static void Save_ECMY()
|
static void Save_ECMY()
|
||||||
{
|
{
|
||||||
|
SlSetArrayIndex(0);
|
||||||
SlObject(&_economy, _economy_desc);
|
SlObject(&_economy, _economy_desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Economy variables */
|
/** Economy variables */
|
||||||
static void Load_ECMY()
|
static void Load_ECMY()
|
||||||
{
|
{
|
||||||
|
if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() == -1) return;
|
||||||
SlObject(&_economy, _economy_desc);
|
SlObject(&_economy, _economy_desc);
|
||||||
|
if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() != -1) SlErrorCorrupt("Too many ECMY entries");
|
||||||
|
|
||||||
StartupIndustryDailyChanges(IsSavegameVersionBefore(SLV_102)); // old savegames will need to be initialized
|
StartupIndustryDailyChanges(IsSavegameVersionBefore(SLV_102)); // old savegames will need to be initialized
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +102,7 @@ static const ChunkHandler economy_chunk_handlers[] = {
|
||||||
{ 'CAPY', Save_CAPY, Load_CAPY, Ptrs_CAPY, nullptr, CH_ARRAY },
|
{ 'CAPY', Save_CAPY, Load_CAPY, Ptrs_CAPY, nullptr, CH_ARRAY },
|
||||||
{ 'PRIC', nullptr, Load_PRIC, nullptr, nullptr, CH_RIFF },
|
{ 'PRIC', nullptr, Load_PRIC, nullptr, nullptr, CH_RIFF },
|
||||||
{ 'CAPR', nullptr, Load_CAPR, nullptr, nullptr, CH_RIFF },
|
{ 'CAPR', nullptr, Load_CAPR, nullptr, nullptr, CH_RIFF },
|
||||||
{ 'ECMY', Save_ECMY, Load_ECMY, nullptr, nullptr, CH_RIFF },
|
{ 'ECMY', Save_ECMY, Load_ECMY, nullptr, nullptr, CH_ARRAY },
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const ChunkHandlerTable _economy_chunk_handlers(economy_chunk_handlers);
|
extern const ChunkHandlerTable _economy_chunk_handlers(economy_chunk_handlers);
|
||||||
|
|
|
@ -57,14 +57,14 @@ static void Load_GSDT()
|
||||||
/* Free all current data */
|
/* Free all current data */
|
||||||
GameConfig::GetConfig(GameConfig::SSS_FORCE_GAME)->Change(nullptr);
|
GameConfig::GetConfig(GameConfig::SSS_FORCE_GAME)->Change(nullptr);
|
||||||
|
|
||||||
if ((CompanyID)SlIterateArray() == (CompanyID)-1) return;
|
if (SlIterateArray() == -1) return;
|
||||||
|
|
||||||
_game_saveload_version = -1;
|
_game_saveload_version = -1;
|
||||||
SlObject(nullptr, _game_script);
|
SlObject(nullptr, _game_script);
|
||||||
|
|
||||||
if (_networking && !_network_server) {
|
if (_networking && !_network_server) {
|
||||||
GameInstance::LoadEmpty();
|
GameInstance::LoadEmpty();
|
||||||
if ((CompanyID)SlIterateArray() != (CompanyID)-1) SlErrorCorrupt("Too many GameScript configs");
|
if (SlIterateArray() != -1) SlErrorCorrupt("Too many GameScript configs");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ static void Load_GSDT()
|
||||||
Game::StartNew();
|
Game::StartNew();
|
||||||
Game::Load(_game_saveload_version);
|
Game::Load(_game_saveload_version);
|
||||||
|
|
||||||
if ((CompanyID)SlIterateArray() != (CompanyID)-1) SlErrorCorrupt("Too many GameScript configs");
|
if (SlIterateArray() != -1) SlErrorCorrupt("Too many GameScript configs");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Save_GSDT()
|
static void Save_GSDT()
|
||||||
|
|
|
@ -139,12 +139,21 @@ static const SaveLoad _industry_builder_desc[] = {
|
||||||
SLEG_VAR(_industry_builder.wanted_inds, SLE_UINT32),
|
SLEG_VAR(_industry_builder.wanted_inds, SLE_UINT32),
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Load/save industry builder. */
|
/** Save industry builder. */
|
||||||
static void LoadSave_IBLD()
|
static void Save_IBLD()
|
||||||
{
|
{
|
||||||
|
SlSetArrayIndex(0);
|
||||||
SlGlobList(_industry_builder_desc);
|
SlGlobList(_industry_builder_desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Load industry builder. */
|
||||||
|
static void Load_IBLD()
|
||||||
|
{
|
||||||
|
if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() == -1) return;
|
||||||
|
SlGlobList(_industry_builder_desc);
|
||||||
|
if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() != -1) SlErrorCorrupt("Too many IBLD entries");
|
||||||
|
}
|
||||||
|
|
||||||
/** Description of the data to save and load in #IndustryTypeBuildData. */
|
/** Description of the data to save and load in #IndustryTypeBuildData. */
|
||||||
static const SaveLoad _industrytype_builder_desc[] = {
|
static const SaveLoad _industrytype_builder_desc[] = {
|
||||||
SLE_VAR(IndustryTypeBuildData, probability, SLE_UINT32),
|
SLE_VAR(IndustryTypeBuildData, probability, SLE_UINT32),
|
||||||
|
@ -177,11 +186,11 @@ static void Load_ITBL()
|
||||||
}
|
}
|
||||||
|
|
||||||
static const ChunkHandler industry_chunk_handlers[] = {
|
static const ChunkHandler industry_chunk_handlers[] = {
|
||||||
{ 'INDY', Save_INDY, Load_INDY, Ptrs_INDY, nullptr, CH_ARRAY },
|
{ 'INDY', Save_INDY, Load_INDY, Ptrs_INDY, nullptr, CH_ARRAY },
|
||||||
{ 'IIDS', Save_IIDS, Load_IIDS, nullptr, nullptr, CH_ARRAY },
|
{ 'IIDS', Save_IIDS, Load_IIDS, nullptr, nullptr, CH_ARRAY },
|
||||||
{ 'TIDS', Save_TIDS, Load_TIDS, nullptr, nullptr, CH_ARRAY },
|
{ 'TIDS', Save_TIDS, Load_TIDS, nullptr, nullptr, CH_ARRAY },
|
||||||
{ 'IBLD', LoadSave_IBLD, LoadSave_IBLD, nullptr, nullptr, CH_RIFF },
|
{ 'IBLD', Save_IBLD, Load_IBLD, nullptr, nullptr, CH_ARRAY },
|
||||||
{ 'ITBL', Save_ITBL, Load_ITBL, nullptr, nullptr, CH_ARRAY },
|
{ 'ITBL', Save_ITBL, Load_ITBL, nullptr, nullptr, CH_ARRAY },
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const ChunkHandlerTable _industry_chunk_handlers(industry_chunk_handlers);
|
extern const ChunkHandlerTable _industry_chunk_handlers(industry_chunk_handlers);
|
||||||
|
|
|
@ -287,6 +287,7 @@ static void Load_LGRJ()
|
||||||
*/
|
*/
|
||||||
static void Save_LGRS()
|
static void Save_LGRS()
|
||||||
{
|
{
|
||||||
|
SlSetArrayIndex(0);
|
||||||
SlObject(&LinkGraphSchedule::instance, GetLinkGraphScheduleDesc());
|
SlObject(&LinkGraphSchedule::instance, GetLinkGraphScheduleDesc());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,7 +296,9 @@ static void Save_LGRS()
|
||||||
*/
|
*/
|
||||||
static void Load_LGRS()
|
static void Load_LGRS()
|
||||||
{
|
{
|
||||||
|
if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() == -1) return;
|
||||||
SlObject(&LinkGraphSchedule::instance, GetLinkGraphScheduleDesc());
|
SlObject(&LinkGraphSchedule::instance, GetLinkGraphScheduleDesc());
|
||||||
|
if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() != -1) SlErrorCorrupt("Too many LGRS entries");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -309,7 +312,7 @@ static void Ptrs_LGRS()
|
||||||
static const ChunkHandler linkgraph_chunk_handlers[] = {
|
static const ChunkHandler linkgraph_chunk_handlers[] = {
|
||||||
{ 'LGRP', Save_LGRP, Load_LGRP, nullptr, nullptr, CH_ARRAY },
|
{ 'LGRP', Save_LGRP, Load_LGRP, nullptr, nullptr, CH_ARRAY },
|
||||||
{ 'LGRJ', Save_LGRJ, Load_LGRJ, nullptr, nullptr, CH_ARRAY },
|
{ 'LGRJ', Save_LGRJ, Load_LGRJ, nullptr, nullptr, CH_ARRAY },
|
||||||
{ 'LGRS', Save_LGRS, Load_LGRS, Ptrs_LGRS, nullptr, CH_RIFF }
|
{ 'LGRS', Save_LGRS, Load_LGRS, Ptrs_LGRS, nullptr, CH_ARRAY },
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const ChunkHandlerTable _linkgraph_chunk_handlers(linkgraph_chunk_handlers);
|
extern const ChunkHandlerTable _linkgraph_chunk_handlers(linkgraph_chunk_handlers);
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
static uint32 _map_dim_x;
|
static uint32 _map_dim_x;
|
||||||
static uint32 _map_dim_y;
|
static uint32 _map_dim_y;
|
||||||
|
|
||||||
static const SaveLoad _map_dimensions[] = {
|
static const SaveLoad _map_desc[] = {
|
||||||
SLEG_CONDVAR(_map_dim_x, SLE_UINT32, SLV_6, SL_MAX_VERSION),
|
SLEG_CONDVAR(_map_dim_x, SLE_UINT32, SLV_6, SL_MAX_VERSION),
|
||||||
SLEG_CONDVAR(_map_dim_y, SLE_UINT32, SLV_6, SL_MAX_VERSION),
|
SLEG_CONDVAR(_map_dim_y, SLE_UINT32, SLV_6, SL_MAX_VERSION),
|
||||||
};
|
};
|
||||||
|
@ -29,18 +29,26 @@ static void Save_MAPS()
|
||||||
{
|
{
|
||||||
_map_dim_x = MapSizeX();
|
_map_dim_x = MapSizeX();
|
||||||
_map_dim_y = MapSizeY();
|
_map_dim_y = MapSizeY();
|
||||||
SlGlobList(_map_dimensions);
|
|
||||||
|
SlSetArrayIndex(0);
|
||||||
|
SlGlobList(_map_desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Load_MAPS()
|
static void Load_MAPS()
|
||||||
{
|
{
|
||||||
SlGlobList(_map_dimensions);
|
if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() == -1) return;
|
||||||
|
SlGlobList(_map_desc);
|
||||||
|
if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() != -1) SlErrorCorrupt("Too many MAPS entries");
|
||||||
|
|
||||||
AllocateMap(_map_dim_x, _map_dim_y);
|
AllocateMap(_map_dim_x, _map_dim_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Check_MAPS()
|
static void Check_MAPS()
|
||||||
{
|
{
|
||||||
SlGlobList(_map_dimensions);
|
if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() == -1) return;
|
||||||
|
SlGlobList(_map_desc);
|
||||||
|
if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() != -1) SlErrorCorrupt("Too many MAPS entries");
|
||||||
|
|
||||||
_load_check_data.map_size_x = _map_dim_x;
|
_load_check_data.map_size_x = _map_dim_x;
|
||||||
_load_check_data.map_size_y = _map_dim_y;
|
_load_check_data.map_size_y = _map_dim_y;
|
||||||
}
|
}
|
||||||
|
@ -295,7 +303,7 @@ static void Save_MAP8()
|
||||||
|
|
||||||
|
|
||||||
static const ChunkHandler map_chunk_handlers[] = {
|
static const ChunkHandler map_chunk_handlers[] = {
|
||||||
{ 'MAPS', Save_MAPS, Load_MAPS, nullptr, Check_MAPS, CH_RIFF },
|
{ 'MAPS', Save_MAPS, Load_MAPS, nullptr, Check_MAPS, CH_ARRAY },
|
||||||
{ 'MAPT', Save_MAPT, Load_MAPT, nullptr, nullptr, CH_RIFF },
|
{ 'MAPT', Save_MAPT, Load_MAPT, nullptr, nullptr, CH_RIFF },
|
||||||
{ 'MAPH', Save_MAPH, Load_MAPH, nullptr, nullptr, CH_RIFF },
|
{ 'MAPH', Save_MAPH, Load_MAPH, nullptr, nullptr, CH_RIFF },
|
||||||
{ 'MAPO', Save_MAP1, Load_MAP1, nullptr, nullptr, CH_RIFF },
|
{ 'MAPO', Save_MAP1, Load_MAP1, nullptr, nullptr, CH_RIFF },
|
||||||
|
|
|
@ -118,14 +118,28 @@ static const SaveLoad _date_check_desc[] = {
|
||||||
|
|
||||||
/* Save load date related variables as well as persistent tick counters
|
/* Save load date related variables as well as persistent tick counters
|
||||||
* XXX: currently some unrelated stuff is just put here */
|
* XXX: currently some unrelated stuff is just put here */
|
||||||
static void SaveLoad_DATE()
|
static void Save_DATE()
|
||||||
{
|
{
|
||||||
|
SlSetArrayIndex(0);
|
||||||
SlGlobList(_date_desc);
|
SlGlobList(_date_desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void Load_DATE_common(const SaveLoadTable &slt)
|
||||||
|
{
|
||||||
|
if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() == -1) return;
|
||||||
|
SlGlobList(slt);
|
||||||
|
if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() != -1) SlErrorCorrupt("Too many DATE entries");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Load_DATE()
|
||||||
|
{
|
||||||
|
Load_DATE_common(_date_desc);
|
||||||
|
}
|
||||||
|
|
||||||
static void Check_DATE()
|
static void Check_DATE()
|
||||||
{
|
{
|
||||||
SlGlobList(_date_check_desc);
|
Load_DATE_common(_date_check_desc);
|
||||||
|
|
||||||
if (IsSavegameVersionBefore(SLV_31)) {
|
if (IsSavegameVersionBefore(SLV_31)) {
|
||||||
_load_check_data.current_date += DAYS_TILL_ORIGINAL_BASE_YEAR;
|
_load_check_data.current_date += DAYS_TILL_ORIGINAL_BASE_YEAR;
|
||||||
}
|
}
|
||||||
|
@ -140,14 +154,22 @@ static const SaveLoad _view_desc[] = {
|
||||||
SLEG_VAR(_saved_scrollpos_zoom, SLE_UINT8),
|
SLEG_VAR(_saved_scrollpos_zoom, SLE_UINT8),
|
||||||
};
|
};
|
||||||
|
|
||||||
static void SaveLoad_VIEW()
|
static void Save_VIEW()
|
||||||
{
|
{
|
||||||
|
SlSetArrayIndex(0);
|
||||||
SlGlobList(_view_desc);
|
SlGlobList(_view_desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void Load_VIEW()
|
||||||
|
{
|
||||||
|
if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() == -1) return;
|
||||||
|
SlGlobList(_view_desc);
|
||||||
|
if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() != -1) SlErrorCorrupt("Too many DATE entries");
|
||||||
|
}
|
||||||
|
|
||||||
static const ChunkHandler misc_chunk_handlers[] = {
|
static const ChunkHandler misc_chunk_handlers[] = {
|
||||||
{ 'DATE', SaveLoad_DATE, SaveLoad_DATE, nullptr, Check_DATE, CH_RIFF },
|
{ 'DATE', Save_DATE, Load_DATE, nullptr, Check_DATE, CH_ARRAY },
|
||||||
{ 'VIEW', SaveLoad_VIEW, SaveLoad_VIEW, nullptr, nullptr, CH_RIFF },
|
{ 'VIEW', Save_VIEW, Load_VIEW, nullptr, nullptr, CH_ARRAY },
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const ChunkHandlerTable _misc_chunk_handlers(misc_chunk_handlers);
|
extern const ChunkHandlerTable _misc_chunk_handlers(misc_chunk_handlers);
|
||||||
|
|
|
@ -331,6 +331,7 @@ enum SaveLoadVersion : uint16 {
|
||||||
SLV_GROUP_REPLACE_WAGON_REMOVAL, ///< 291 PR#7441 Per-group wagon removal flag.
|
SLV_GROUP_REPLACE_WAGON_REMOVAL, ///< 291 PR#7441 Per-group wagon removal flag.
|
||||||
SLV_CUSTOM_SUBSIDY_DURATION, ///< 292 PR#9081 Configurable subsidy duration.
|
SLV_CUSTOM_SUBSIDY_DURATION, ///< 292 PR#9081 Configurable subsidy duration.
|
||||||
SLV_SAVELOAD_LIST_LENGTH, ///< 293 PR#9374 Consistency in list length with SL_STRUCT / SL_STRUCTLIST / SL_DEQUE / SL_REFLIST.
|
SLV_SAVELOAD_LIST_LENGTH, ///< 293 PR#9374 Consistency in list length with SL_STRUCT / SL_STRUCTLIST / SL_DEQUE / SL_REFLIST.
|
||||||
|
SLV_RIFF_TO_ARRAY, ///< 294 PR#9375 Changed many CH_RIFF chunks to CH_ARRAY chunks.
|
||||||
|
|
||||||
SL_MAX_VERSION, ///< Highest possible saveload version
|
SL_MAX_VERSION, ///< Highest possible saveload version
|
||||||
};
|
};
|
||||||
|
|
|
@ -2045,7 +2045,9 @@ static void LoadSettings(const SettingTable &settings, void *object)
|
||||||
{
|
{
|
||||||
const std::vector<SaveLoad> slt = GetSettingsDesc(settings, true);
|
const std::vector<SaveLoad> slt = GetSettingsDesc(settings, true);
|
||||||
|
|
||||||
|
if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() == -1) return;
|
||||||
SlObject(object, slt);
|
SlObject(object, slt);
|
||||||
|
if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() != -1) SlErrorCorrupt("Too many settings entries");
|
||||||
|
|
||||||
/* Ensure all IntSettings are valid (min/max could have changed between versions etc). */
|
/* Ensure all IntSettings are valid (min/max could have changed between versions etc). */
|
||||||
for (auto &sd : settings) {
|
for (auto &sd : settings) {
|
||||||
|
@ -2070,6 +2072,7 @@ static void SaveSettings(const SettingTable &settings, void *object)
|
||||||
{
|
{
|
||||||
const std::vector<SaveLoad> slt = GetSettingsDesc(settings, false);
|
const std::vector<SaveLoad> slt = GetSettingsDesc(settings, false);
|
||||||
|
|
||||||
|
SlSetArrayIndex(0);
|
||||||
SlObject(object, slt);
|
SlObject(object, slt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2102,8 +2105,8 @@ static void Save_PATS()
|
||||||
}
|
}
|
||||||
|
|
||||||
static const ChunkHandler setting_chunk_handlers[] = {
|
static const ChunkHandler setting_chunk_handlers[] = {
|
||||||
{ 'OPTS', nullptr, Load_OPTS, nullptr, nullptr, CH_RIFF },
|
{ 'OPTS', nullptr, Load_OPTS, nullptr, nullptr, CH_RIFF },
|
||||||
{ 'PATS', Save_PATS, Load_PATS, nullptr, Check_PATS, CH_RIFF },
|
{ 'PATS', Save_PATS, Load_PATS, nullptr, Check_PATS, CH_ARRAY },
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const ChunkHandlerTable _setting_chunk_handlers(setting_chunk_handlers);
|
extern const ChunkHandlerTable _setting_chunk_handlers(setting_chunk_handlers);
|
||||||
|
|
Loading…
Reference in New Issue