From a8f2af72571c0975f5327dbb8408d0b9a235fed8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 3 Oct 2023 09:21:08 +0200 Subject: [PATCH] SW: fix serialization of panel sprites --- source/games/sw/src/save.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/source/games/sw/src/save.cpp b/source/games/sw/src/save.cpp index 100552b87..9647ac070 100644 --- a/source/games/sw/src/save.cpp +++ b/source/games/sw/src/save.cpp @@ -484,8 +484,6 @@ void DSWPlayer::Serialize(FSerializer& arc) ("WpnFlags", WpnFlags) .Array("WpnAmmo", WpnAmmo, countof(WpnAmmo)) ("WpnNum", WpnNum) - ("panelnext", PanelSpriteList.Next) - ("panelprev", PanelSpriteList.Prev) ("curwpn", CurWpn) .Array("wpn", Wpn, countof(Wpn)) ("WpnRocketType", WpnRocketType) @@ -536,7 +534,6 @@ void DSWPlayer::Serialize(FSerializer& arc) ("keypressbits", KeyPressBits) ("chops", Chops); - SerializeCodePtr(arc, "DoPlayerAction", (void**)&DoPlayerAction); if (arc.isReading()) { @@ -544,7 +541,6 @@ void DSWPlayer::Serialize(FSerializer& arc) obob_z = bob_z; memset(cookieQuote, 0, sizeof(cookieQuote)); // no need to remember this. StartColor = 0; - } } @@ -1063,9 +1059,9 @@ void GameInterface::SerializeGameState(FSerializer& arc) pspAsArray.Clear(); Saveable_Init(); + preSerializePanelSprites(arc); if (arc.BeginObject("state")) { - preSerializePanelSprites(arc); so_serializeinterpolations(arc); arc("numplayers", numplayers) ("skill", Skill) @@ -1107,10 +1103,27 @@ void GameInterface::SerializeGameState(FSerializer& arc) ("parallaxys", parallaxyscale_override) ("pskybits", pskybits_override) ; - postSerializePanelSprites(arc); arc.EndObject(); } + // these cannot be deferred to writing out the actors because we need to fill in pspAsArray before calling postSerializePanelSprites. + // The organization of this list is a mess and needs to be refactored into something workable. + if (arc.BeginArray("playerpanelsprites")) + { + for (int i = 0; i < MAXPLAYERS; i++) + { + if (arc.BeginObject(nullptr)) + { + auto p = getPlayer(i); + arc("panelnext", p->PanelSpriteList.Next) + ("panelprev", p->PanelSpriteList.Prev) + .EndObject(); + } + } + arc.EndArray(); + } + postSerializePanelSprites(arc); + if (arc.isReading()) { DoTheCache();