Add: store headers for most savegame chunks
When a header is added, the chunk changes from CH_ARRAY type to CH_TABLE type.
This commit is contained in:
committed by
Patric Stout
parent
7dd5fd6ed4
commit
cdb3dd0493
@@ -9,9 +9,11 @@
|
||||
|
||||
#include "../stdafx.h"
|
||||
#include "../debug.h"
|
||||
#include "saveload.h"
|
||||
#include "../string_func.h"
|
||||
|
||||
#include "saveload.h"
|
||||
#include "compat/game_sl_compat.h"
|
||||
|
||||
#include "../string_func.h"
|
||||
#include "../game/game.hpp"
|
||||
#include "../game/game_config.hpp"
|
||||
#include "../network/network.h"
|
||||
@@ -25,7 +27,7 @@ static int _game_saveload_version;
|
||||
static std::string _game_saveload_settings;
|
||||
static bool _game_saveload_is_random;
|
||||
|
||||
static const SaveLoad _game_script[] = {
|
||||
static const SaveLoad _game_script_desc[] = {
|
||||
SLEG_SSTR("name", _game_saveload_name, SLE_STR),
|
||||
SLEG_SSTR("settings", _game_saveload_settings, SLE_STR),
|
||||
SLEG_VAR("version", _game_saveload_version, SLE_UINT32),
|
||||
@@ -48,19 +50,21 @@ static void SaveReal_GSDT(int *index_ptr)
|
||||
_game_saveload_is_random = config->IsRandom();
|
||||
_game_saveload_settings = config->SettingsToString();
|
||||
|
||||
SlObject(nullptr, _game_script);
|
||||
SlObject(nullptr, _game_script_desc);
|
||||
Game::Save();
|
||||
}
|
||||
|
||||
static void Load_GSDT()
|
||||
{
|
||||
const std::vector<SaveLoad> slt = SlCompatTableHeader(_game_script_desc, _game_script_sl_compat);
|
||||
|
||||
/* Free all current data */
|
||||
GameConfig::GetConfig(GameConfig::SSS_FORCE_GAME)->Change(nullptr);
|
||||
|
||||
if (SlIterateArray() == -1) return;
|
||||
|
||||
_game_saveload_version = -1;
|
||||
SlObject(nullptr, _game_script);
|
||||
SlObject(nullptr, slt);
|
||||
|
||||
if (_networking && !_network_server) {
|
||||
GameInstance::LoadEmpty();
|
||||
@@ -104,6 +108,7 @@ static void Load_GSDT()
|
||||
|
||||
static void Save_GSDT()
|
||||
{
|
||||
SlTableHeader(_game_script_desc);
|
||||
SlSetArrayIndex(0);
|
||||
SlAutolength((AutolengthProc *)SaveReal_GSDT, nullptr);
|
||||
}
|
||||
@@ -180,7 +185,7 @@ static void Save_GSTR()
|
||||
|
||||
static const ChunkHandler game_chunk_handlers[] = {
|
||||
{ 'GSTR', Save_GSTR, Load_GSTR, nullptr, nullptr, CH_ARRAY },
|
||||
{ 'GSDT', Save_GSDT, Load_GSDT, nullptr, nullptr, CH_ARRAY },
|
||||
{ 'GSDT', Save_GSDT, Load_GSDT, nullptr, nullptr, CH_TABLE },
|
||||
};
|
||||
|
||||
extern const ChunkHandlerTable _game_chunk_handlers(game_chunk_handlers);
|
||||
|
||||
Reference in New Issue
Block a user