Use upstream/table format for game log chunk
This commit is contained in:
@@ -44,14 +44,14 @@ public:
|
||||
void LoadCheck(LoggedChange *lc) const override { this->Load(lc); }
|
||||
};
|
||||
|
||||
static char old_revision_text[GAMELOG_REVISION_LENGTH];
|
||||
static std::string revision_test;
|
||||
static char _old_revision_text[GAMELOG_REVISION_LENGTH];
|
||||
static std::string _revision_text;
|
||||
|
||||
class SlGamelogRevision : public DefaultSaveLoadHandler<SlGamelogRevision, LoggedChange> {
|
||||
public:
|
||||
inline static const SaveLoad description[] = {
|
||||
SLEG_CONDARR("revision.text", old_revision_text, SLE_UINT8, GAMELOG_REVISION_LENGTH, SL_MIN_VERSION, SLV_STRING_GAMELOG),
|
||||
SLEG_CONDSSTR("revision.text", revision_test, SLE_STR, SLV_STRING_GAMELOG, SL_MAX_VERSION),
|
||||
SLEG_CONDARR("revision.text", _old_revision_text, SLE_UINT8, GAMELOG_REVISION_LENGTH, SL_MIN_VERSION, SLV_STRING_GAMELOG),
|
||||
SLEG_CONDSSTR("revision.text", _revision_text, SLE_STR, SLV_STRING_GAMELOG, SL_MAX_VERSION),
|
||||
SLE_VAR(LoggedChange, revision.newgrf, SLE_UINT32),
|
||||
SLE_VAR(LoggedChange, revision.slver, SLE_UINT16),
|
||||
SLE_VAR(LoggedChange, revision.modified, SLE_UINT8),
|
||||
@@ -61,6 +61,7 @@ public:
|
||||
void Save(LoggedChange *lc) const override
|
||||
{
|
||||
if (lc->ct != GLCT_REVISION) return;
|
||||
_revision_text = lc->revision.text != nullptr ? lc->revision.text : "";
|
||||
SlObject(lc, this->GetDescription());
|
||||
}
|
||||
|
||||
@@ -69,9 +70,9 @@ public:
|
||||
if (lc->ct != GLCT_REVISION) return;
|
||||
SlObject(lc, this->GetLoadDescription());
|
||||
if (IsSavegameVersionBefore(SLV_STRING_GAMELOG)) {
|
||||
lc->revision.text = stredup(old_revision_text, lastof(old_revision_text));
|
||||
lc->revision.text = stredup(_old_revision_text, lastof(_old_revision_text));
|
||||
} else {
|
||||
lc->revision.text = stredup(revision_test.c_str());
|
||||
lc->revision.text = stredup(_revision_text.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -113,7 +113,7 @@ const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
|
||||
{ XSLFI_TEMPLATE_REPLACEMENT, XSCF_NULL, 9, 9, "template_replacement", nullptr, nullptr, "TRPL,TMPL" },
|
||||
{ XSLFI_MORE_RAIL_TYPES, XSCF_NULL, 0, 1, "more_rail_types", nullptr, nullptr, nullptr },
|
||||
{ XSLFI_CARGO_TYPE_ORDERS, XSCF_NULL, 3, 3, "cargo_type_orders", nullptr, nullptr, "ORDX,VEOX" },
|
||||
{ XSLFI_EXTENDED_GAMELOG, XSCF_NULL, 1, 1, "extended_gamelog", nullptr, nullptr, nullptr },
|
||||
{ XSLFI_EXTENDED_GAMELOG, XSCF_NULL, 2, 2, "extended_gamelog", nullptr, nullptr, nullptr },
|
||||
{ XSLFI_STATION_CATCHMENT_INC, XSCF_NULL, 1, 1, "station_catchment_inc", nullptr, nullptr, nullptr },
|
||||
{ XSLFI_CUSTOM_BRIDGE_HEADS, XSCF_NULL, 4, 4, "custom_bridge_heads", nullptr, nullptr, nullptr },
|
||||
{ XSLFI_CHUNNEL, XSCF_NULL, 2, 2, "chunnel", nullptr, nullptr, "TUNN" },
|
||||
|
@@ -129,24 +129,6 @@ static void Load_GLOG_common(std::vector<LoggedAction> &gamelog_actions)
|
||||
}
|
||||
}
|
||||
|
||||
static void Save_GLOG()
|
||||
{
|
||||
SlAutolength([](void *) {
|
||||
for (LoggedAction &la : _gamelog_actions) {
|
||||
SlWriteByte(la.at);
|
||||
SlObject(&la, _glog_action_desc);
|
||||
|
||||
for (LoggedChange &lc : la.changes) {
|
||||
SlWriteByte(lc.ct);
|
||||
assert((uint)lc.ct < GLCT_END);
|
||||
SlObject(&lc, _glog_desc[lc.ct]);
|
||||
}
|
||||
SlWriteByte(GLCT_NONE);
|
||||
}
|
||||
SlWriteByte(GLAT_NONE);
|
||||
}, nullptr);
|
||||
}
|
||||
|
||||
static void Load_GLOG()
|
||||
{
|
||||
Load_GLOG_common(_gamelog_actions);
|
||||
@@ -158,7 +140,7 @@ static void Check_GLOG()
|
||||
}
|
||||
|
||||
static const ChunkHandler gamelog_chunk_handlers[] = {
|
||||
{ 'GLOG', Save_GLOG, Load_GLOG, nullptr, Check_GLOG, CH_RIFF }
|
||||
MakeSaveUpstreamFeatureConditionalLoadUpstreamChunkHandler<'GLOG', XSLFI_EXTENDED_GAMELOG, 2>(Load_GLOG, nullptr, Check_GLOG),
|
||||
};
|
||||
|
||||
extern const ChunkHandlerTable _gamelog_chunk_handlers(gamelog_chunk_handlers);
|
||||
|
Reference in New Issue
Block a user