diff options
author | Patric Stout <truebrain@openttd.org> | 2021-06-07 11:35:21 +0200 |
---|---|---|
committer | Patric Stout <github@truebrain.nl> | 2021-07-02 22:21:58 +0200 |
commit | 3826703bc3807c8af7372b550760fcd8286b9a6c (patch) | |
tree | fdb2aa3b283050d4f9f94325e5df5794d851c124 /src/saveload/game_sl.cpp | |
parent | cdb3dd0493749dd5c62378f318ea61bcb85f988f (diff) | |
download | openttd-3826703bc3807c8af7372b550760fcd8286b9a6c.tar.xz |
Add: store headers for chunks with SL_STRUCTLIST
Diffstat (limited to 'src/saveload/game_sl.cpp')
-rw-r--r-- | src/saveload/game_sl.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/saveload/game_sl.cpp b/src/saveload/game_sl.cpp index 059e17333..f0083cb88 100644 --- a/src/saveload/game_sl.cpp +++ b/src/saveload/game_sl.cpp @@ -123,6 +123,7 @@ public: inline static const SaveLoad description[] = { SLEG_SSTR("string", _game_saveload_string, SLE_STR | SLF_ALLOW_CONTROL), }; + inline const static SaveLoadCompatTable compat_description = _game_language_string_sl_compat; void Save(LanguageStrings *ls) const override { @@ -139,7 +140,7 @@ public: uint32 length = IsSavegameVersionBefore(SLV_SAVELOAD_LIST_LENGTH) ? _game_saveload_strings : (uint32)SlGetStructListLength(UINT32_MAX); for (uint32 i = 0; i < length; i++) { - SlObject(nullptr, this->GetDescription()); + SlObject(nullptr, this->GetLoadDescription()); ls->lines.emplace_back(_game_saveload_string); } } @@ -153,12 +154,14 @@ static const SaveLoad _game_language_desc[] = { static void Load_GSTR() { + const std::vector<SaveLoad> slt = SlCompatTableHeader(_game_language_desc, _game_language_sl_compat); + delete _current_data; _current_data = new GameStrings(); while (SlIterateArray() != -1) { LanguageStrings ls; - SlObject(&ls, _game_language_desc); + SlObject(&ls, slt); _current_data->raw_strings.push_back(std::move(ls)); } @@ -175,6 +178,8 @@ static void Load_GSTR() static void Save_GSTR() { + SlTableHeader(_game_language_desc); + if (_current_data == nullptr) return; for (uint i = 0; i < _current_data->raw_strings.size(); i++) { @@ -184,7 +189,7 @@ static void Save_GSTR() } static const ChunkHandler game_chunk_handlers[] = { - { 'GSTR', Save_GSTR, Load_GSTR, nullptr, nullptr, CH_ARRAY }, + { 'GSTR', Save_GSTR, Load_GSTR, nullptr, nullptr, CH_TABLE }, { 'GSDT', Save_GSDT, Load_GSDT, nullptr, nullptr, CH_TABLE }, }; |