Saveload: Use table format for debug info
No longer add wrapper text around config
This commit is contained in:
@@ -17,17 +17,6 @@
|
|||||||
|
|
||||||
#include "../safeguards.h"
|
#include "../safeguards.h"
|
||||||
|
|
||||||
static void Save_DBGL()
|
|
||||||
{
|
|
||||||
if (_savegame_DBGL_data != nullptr) {
|
|
||||||
size_t length = strlen(_savegame_DBGL_data);
|
|
||||||
SlSetLength(length);
|
|
||||||
MemoryDumper::GetCurrent()->CopyBytes(reinterpret_cast<const uint8_t *>(_savegame_DBGL_data), length);
|
|
||||||
} else {
|
|
||||||
SlSetLength(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void Load_DBGL()
|
static void Load_DBGL()
|
||||||
{
|
{
|
||||||
size_t length = SlGetFieldLength();
|
size_t length = SlGetFieldLength();
|
||||||
@@ -50,21 +39,6 @@ static void Check_DBGL()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Save_DBGC()
|
|
||||||
{
|
|
||||||
extern std::string _config_file_text;
|
|
||||||
const char header[] = "*** openttd.cfg start ***\n";
|
|
||||||
const char footer[] = "*** openttd.cfg end ***\n";
|
|
||||||
if (_save_DBGC_data) {
|
|
||||||
SlSetLength(lengthof(header) + _config_file_text.size() + lengthof(footer) - 2);
|
|
||||||
MemoryDumper::GetCurrent()->CopyBytes(reinterpret_cast<const uint8_t *>(header), lengthof(header) - 1);
|
|
||||||
MemoryDumper::GetCurrent()->CopyBytes(reinterpret_cast<const uint8_t *>(_config_file_text.data()), _config_file_text.size());
|
|
||||||
MemoryDumper::GetCurrent()->CopyBytes(reinterpret_cast<const uint8_t *>(footer), lengthof(footer) - 1);
|
|
||||||
} else {
|
|
||||||
SlSetLength(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void Load_DBGC()
|
static void Load_DBGC()
|
||||||
{
|
{
|
||||||
size_t length = SlGetFieldLength();
|
size_t length = SlGetFieldLength();
|
||||||
@@ -87,9 +61,56 @@ static void Check_DBGC()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void Save_DBGD()
|
||||||
|
{
|
||||||
|
if (!SlIsTableChunk()) {
|
||||||
|
SlSkipChunkContents();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<NamedSaveLoad> nsl;
|
||||||
|
if (_save_DBGC_data) {
|
||||||
|
extern std::string _config_file_text;
|
||||||
|
nsl.push_back(NSLT("config", SLEG_SSTR(_config_file_text, SLE_STR | SLF_ALLOW_CONTROL | SLF_ALLOW_NEWLINE)));
|
||||||
|
}
|
||||||
|
if (_savegame_DBGL_data != nullptr) {
|
||||||
|
nsl.push_back(NSLT("log", SLEG_STR(_savegame_DBGL_data, SLE_STR | SLF_ALLOW_CONTROL | SLF_ALLOW_NEWLINE)));
|
||||||
|
}
|
||||||
|
SlSaveTableObjectChunk(nsl);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Load_DBGD()
|
||||||
|
{
|
||||||
|
if (!SlIsTableChunk()) {
|
||||||
|
SlSkipChunkContents();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const NamedSaveLoad nsl[] = {
|
||||||
|
NSLT("config", SLEG_SSTR(_loadgame_DBGC_data, SLE_STR | SLF_ALLOW_CONTROL | SLF_ALLOW_NEWLINE)),
|
||||||
|
NSLT("log", SLEG_SSTR(_loadgame_DBGL_data, SLE_STR | SLF_ALLOW_CONTROL | SLF_ALLOW_NEWLINE)),
|
||||||
|
};
|
||||||
|
SlLoadTableOrRiffFiltered(nsl);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Check_DBGD()
|
||||||
|
{
|
||||||
|
if (!SlIsTableChunk() || !_load_check_data.want_debug_data) {
|
||||||
|
SlSkipChunkContents();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const NamedSaveLoad nsl[] = {
|
||||||
|
NSLT("config", SLEG_SSTR(_load_check_data.debug_config_data, SLE_STR | SLF_ALLOW_CONTROL | SLF_ALLOW_NEWLINE)),
|
||||||
|
NSLT("log", SLEG_SSTR(_load_check_data.debug_log_data, SLE_STR | SLF_ALLOW_CONTROL | SLF_ALLOW_NEWLINE)),
|
||||||
|
};
|
||||||
|
SlLoadTableOrRiffFiltered(nsl);
|
||||||
|
}
|
||||||
|
|
||||||
extern const ChunkHandler debug_chunk_handlers[] = {
|
extern const ChunkHandler debug_chunk_handlers[] = {
|
||||||
{ 'DBGL', Save_DBGL, Load_DBGL, nullptr, Check_DBGL, CH_RIFF },
|
{ 'DBGL', nullptr, Load_DBGL, nullptr, Check_DBGL, CH_UNUSED },
|
||||||
{ 'DBGC', Save_DBGC, Load_DBGC, nullptr, Check_DBGC, CH_RIFF },
|
{ 'DBGC', nullptr, Load_DBGC, nullptr, Check_DBGC, CH_UNUSED },
|
||||||
|
{ 'DBGD', Save_DBGD, Load_DBGD, nullptr, Check_DBGD, CH_TABLE },
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const ChunkHandlerTable _debug_chunk_handlers(debug_chunk_handlers);
|
extern const ChunkHandlerTable _debug_chunk_handlers(debug_chunk_handlers);
|
||||||
|
@@ -138,7 +138,7 @@ const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
|
|||||||
{ XSLFI_ROAD_LAYOUT_CHANGE_CTR, XSCF_NULL, 1, 1, "road_layout_change_ctr", nullptr, nullptr, nullptr },
|
{ XSLFI_ROAD_LAYOUT_CHANGE_CTR, XSCF_NULL, 1, 1, "road_layout_change_ctr", nullptr, nullptr, nullptr },
|
||||||
{ XSLFI_TOWN_CARGO_MATRIX, XSCF_NULL, 0, 1, "town_cargo_matrix", nullptr, nullptr, nullptr },
|
{ XSLFI_TOWN_CARGO_MATRIX, XSCF_NULL, 0, 1, "town_cargo_matrix", nullptr, nullptr, nullptr },
|
||||||
{ XSLFI_STATE_CHECKSUM, XSCF_NULL, 1, 1, "state_checksum", nullptr, nullptr, nullptr },
|
{ XSLFI_STATE_CHECKSUM, XSCF_NULL, 1, 1, "state_checksum", nullptr, nullptr, nullptr },
|
||||||
{ XSLFI_DEBUG, XSCF_IGNORABLE_ALL, 1, 1, "debug", nullptr, nullptr, "DBGL,DBGC" },
|
{ XSLFI_DEBUG, XSCF_IGNORABLE_ALL, 2, 2, "debug", nullptr, nullptr, "DBGD" },
|
||||||
{ XSLFI_FLOW_STAT_FLAGS, XSCF_NULL, 1, 1, "flow_stat_flags", nullptr, nullptr, nullptr },
|
{ XSLFI_FLOW_STAT_FLAGS, XSCF_NULL, 1, 1, "flow_stat_flags", nullptr, nullptr, nullptr },
|
||||||
{ XSLFI_SPEED_RESTRICTION, XSCF_NULL, 1, 1, "speed_restriction", nullptr, nullptr, "VESR" },
|
{ XSLFI_SPEED_RESTRICTION, XSCF_NULL, 1, 1, "speed_restriction", nullptr, nullptr, "VESR" },
|
||||||
{ XSLFI_STATION_GOODS_EXTRA, XSCF_NULL, 1, 1, "station_goods_extra", nullptr, nullptr, nullptr },
|
{ XSLFI_STATION_GOODS_EXTRA, XSCF_NULL, 1, 1, "station_goods_extra", nullptr, nullptr, nullptr },
|
||||||
|
Reference in New Issue
Block a user