diff --git a/source/exhumed/src/exhumed.cpp b/source/exhumed/src/exhumed.cpp index 56e752660..8db789df0 100644 --- a/source/exhumed/src/exhumed.cpp +++ b/source/exhumed/src/exhumed.cpp @@ -645,83 +645,43 @@ bool GameInterface::CanSave() return new GameInterface; } - -// This is only the static global data. -static SavegameHelper sghexhumed("exhumed", - SV(besttarget), - SV(nCreaturesTotal), - SV(nCreaturesKilled), - SV(nFreeze), - SV(nSnakeCam), - SV(nLocalSpr), - SV(nClockVal), // kTile3603 - SV(nRedTicks), - SV(nAlarmTicks), - SV(nButtonColor), - SV(nEnergyChan), - SV(lCountDown), - SV(nEnergyTowers), - SV(totalmoves), - SV(nCurBodyNum), - SV(nBodyTotal), - SV(bSnakeCam), - SV(bSlipMode), - SV(leveltime), - nullptr); - extern short cPupData[300]; extern uint8_t* Worktile; extern int lHeadStartClock; extern short* pPupData; - -void SaveTextureState() +void SerializeState(FSerializer& arc) { - auto fw = WriteSavegameChunk("texture"); - int pupOffset = pPupData? int(pPupData - cPupData) : -1; - - // There is really no good way to restore these tiles, so it's probably best to save them as well, so that they can be reloaded with the exact state they were left in - fw->Write(&pupOffset, 4); - uint8_t loaded = !!Worktile; - fw->Write(&loaded, 1); - if (Worktile) fw->Write(Worktile, WorktileSize); - auto pixels = TileFiles.tileMakeWritable(kTile3603); - fw->Write(pixels, tileWidth(kTile3603) * tileHeight(kTile3603)); - pixels = TileFiles.tileMakeWritable(kEnergy1); - fw->Write(pixels, tileWidth(kEnergy1) * tileHeight(kEnergy1)); - pixels = TileFiles.tileMakeWritable(kEnergy2); - fw->Write(pixels, tileWidth(kEnergy2) * tileHeight(kEnergy2)); - -} - -void LoadTextureState() -{ - auto fr = ReadSavegameChunk("texture"); - int pofs; - fr.Read(&pofs, 4); - pPupData = pofs == -1 ? nullptr : cPupData + pofs; - uint8_t loaded; - fr.Read(&loaded, 1); - if (loaded) + int loaded = 0; + if (arc.BeginObject("state")) { - Worktile = TileFiles.tileCreate(kTileRamsesWorkTile, kSpiritX * 2, kSpiritY * 2); - fr.Read(Worktile, WorktileSize); + if (arc.isReading() && currentLevel->levelNumber == 20) + { + InitEnergyTile(); + } + + arc ("besttarget", besttarget) + ("creaturestotal", nCreaturesTotal) + ("creatureskilled", nCreaturesKilled) + ("freeze", nFreeze) + ("snakecam", nSnakeCam) + ("localspr", nLocalSpr) + ("clockval", nClockVal) // kTile3603 + ("redticks", nRedTicks) + ("alarmticks", nAlarmTicks) + ("buttoncolor", nButtonColor) + ("energychan", nEnergyChan) + ("countdown", lCountDown) + ("energytowers", nEnergyTowers) + ("totalmoves", totalmoves) + ("curbodynum", nCurBodyNum) + ("bodytotal", nBodyTotal) + ("snakecam", bSnakeCam) + ("slipmode", bSlipMode) + ("leveltime", leveltime) + ("cinemaseen", nCinemaSeen) + .EndObject(); } - auto pixels = TileFiles.tileMakeWritable(kTile3603); - fr.Read(pixels, tileWidth(kTile3603) * tileHeight(kTile3603)); - pixels = TileFiles.tileMakeWritable(kEnergy1); - fr.Read(pixels, tileWidth(kEnergy1) * tileHeight(kEnergy1)); - pixels = TileFiles.tileMakeWritable(kEnergy2); - fr.Read(pixels, tileWidth(kEnergy2) * tileHeight(kEnergy2)); - TileFiles.InvalidateTile(kTileRamsesWorkTile); - TileFiles.InvalidateTile(kTile3603); - TileFiles.InvalidateTile(kEnergy1); - TileFiles.InvalidateTile(kEnergy2); } - -CCMD(endit) -{ - LevelFinished(); -} END_PS_NS diff --git a/source/exhumed/src/menu.cpp b/source/exhumed/src/menu.cpp index 585168d71..af3e7014c 100644 --- a/source/exhumed/src/menu.cpp +++ b/source/exhumed/src/menu.cpp @@ -238,11 +238,4 @@ void DoEnergyTile() } } -static SavegameHelper sghmenu("menu", - SA(nCinemaSeen), - SA(energytile), - SV(nButtonColor), - SV(word_9AB5B), - nullptr); - END_PS_NS diff --git a/source/exhumed/src/save.cpp b/source/exhumed/src/save.cpp index 1e9997d27..88d94bb1a 100644 --- a/source/exhumed/src/save.cpp +++ b/source/exhumed/src/save.cpp @@ -29,6 +29,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_PS_NS +void SerializeState(FSerializer& arc); void SerializeAnim(FSerializer& arc); void SerializeBubbles(FSerializer& arc); void SerializeBullet(FSerializer& arc); @@ -62,15 +63,11 @@ void SerializeSet(FSerializer& arc); void SerializeSpider(FSerializer& arc); void SerializeWasp(FSerializer& arc); -void SaveTextureState(); -void LoadTextureState(); - static TArray sghelpers(TArray::NoInit); bool GameInterface::SaveGame() { for (auto sgh : sghelpers) sgh->Save(); - SaveTextureState(); return 1; // CHECKME } @@ -78,6 +75,7 @@ void GameInterface::SerializeGameState(FSerializer& arc) { if (arc.BeginObject("exhumed")) { + SerializeState(arc); SerializeAnim(arc); SerializeBubbles(arc); SerializeBullet(arc); @@ -117,7 +115,6 @@ bool GameInterface::LoadGame() { for (auto sgh : sghelpers) sgh->Load(); - LoadTextureState(); FinishSavegameRead(); // reset the sky in case it hasn't been done yet.