Skip to content

Commit 0c702f5

Browse files
committed
Engine: fix prescanning GUIs in saves
1 parent 9308f68 commit 0c702f5

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

Common/game/customproperties.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,26 @@ PropertyError ReadValues(StringIMap &map, Stream *in)
9494
return kPropertyErr_NoError;
9595
}
9696

97+
PropertyError SkipValues(Stream *in)
98+
{
99+
PropertyVersion version = (PropertyVersion)in->ReadInt32();
100+
if (version < kPropertyVersion_Initial || version > kPropertyVersion_Current)
101+
{
102+
return kPropertyErr_UnsupportedFormat;
103+
}
104+
105+
int count = in->ReadInt32();
106+
// NOTE: handle Editor's mistake where it could save empty property bag with version 1
107+
if ((version == kPropertyVersion_Initial) && count > 0)
108+
return kPropertyErr_UnsupportedFormat;
109+
for (int i = 0; i < count; ++i)
110+
{
111+
StrUtil::SkipString(in); // name
112+
StrUtil::SkipString(in); // value
113+
}
114+
return kPropertyErr_NoError;
115+
}
116+
97117
void WriteValues(const StringIMap &map, Stream *out)
98118
{
99119
out->WriteInt32(kPropertyVersion_Current);

Common/game/customproperties.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ namespace Properties
8282
// Reads property values from the stream and assign them to map.
8383
// The non-matching existing map items, if any, are NOT erased.
8484
PropertyError ReadValues(StringIMap &map, Stream *in);
85+
// Skip serialized properties
86+
PropertyError SkipValues(Stream *in);
8587
// Writes property values chunk to the stream
8688
void WriteValues(const StringIMap &map, Stream *out);
8789

Common/gui/guimain.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,11 @@ void GUIMain::SkipSavestate(Stream *in, GuiSvgVersion svg_version, std::vector<C
745745
(*ctrl_refs)[i].second = ref_packed & 0xFFFF;
746746
}
747747
}
748+
749+
if (svg_version >= kGuiSvgVersion_400)
750+
{
751+
in->Seek(15 * sizeof(int32_t));
752+
}
748753
}
749754

750755
void GUIMain::WriteToSavegame(Common::Stream *out) const

Engine/game/savegame_components.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,9 @@ HSaveError PrescanGUI(Stream *in, int32_t cmp_ver, soff_t /*cmp_size*/, const Pr
900900
for (uint32_t i = 0; i < guis_read; ++i)
901901
{
902902
GUIMain::SkipSavestate(in, svg_ver, &guictrl_refs_old[i]);
903+
if (svg_ver >= kGuiSvgVersion_40008)
904+
Properties::SkipValues(in);
905+
903906
assert_buf.Format("GUI %u Controls", i);
904907
if (i < guis.size() &&
905908
!AssertGameContent(err, guictrl_refs_old[i].size(), guis[i].GetControlCount(), assert_buf.GetCStr(), r_data.Result, r_data.DataCounts.GUIControls[i]))

0 commit comments

Comments
 (0)