diff --git a/source/exhumed/src/bubbles.cpp b/source/exhumed/src/bubbles.cpp index 588415613..bed931175 100644 --- a/source/exhumed/src/bubbles.cpp +++ b/source/exhumed/src/bubbles.cpp @@ -47,34 +47,51 @@ struct machine short _4; }; -short BubbleCount = 0; - -short nFreeCount; short nMachineCount; - -uint8_t nBubblesFree[kMaxBubbles]; machine Machine[kMaxMachines]; -Bubble BubbleList[kMaxBubbles]; -static SavegameHelper sghbubbles("bubbles", - SV(BubbleCount), - SV(nFreeCount), - SV(nMachineCount), - SA(nBubblesFree), - SA(Machine), - SA(BubbleList), - nullptr); +FreeListArray BubbleList; + +FSerializer& Serialize(FSerializer& arc, const char* keyname, Bubble& w, Bubble* def) +{ + if (arc.BeginObject(keyname)) + { + arc("seq", w.nSeq) + ("frame", w.nFrame) + ("run", w.nRun) + ("sprite", w.nSprite) + .EndObject(); + } + return arc; +} + +FSerializer& Serialize(FSerializer& arc, const char* keyname, machine& w, machine* def) +{ + if (arc.BeginObject(keyname)) + { + arc("at0", w._0) + ("at4", w._4) + ("sprite", w.nSprite) + .EndObject(); + } + return arc; +} + +void SerializeBubbles(FSerializer& arc) +{ + if (arc.BeginObject("bubbles")) + { + arc ("machinecount", nMachineCount) + ("list", BubbleList) + .Array("machines", Machine, nMachineCount) + .EndObject(); + } +} void InitBubbles() { - BubbleCount = 0; nMachineCount = 0; - - for (int i = 0; i < kMaxBubbles; i++) { - nBubblesFree[i] = i; - } - - nFreeCount = kMaxBubbles; + BubbleList.Clear(); } void DestroyBubble(short nBubble) @@ -87,14 +104,12 @@ void DestroyBubble(short nBubble) mydeletesprite(nSprite); - nBubblesFree[nFreeCount] = nBubble; - - nFreeCount++; + BubbleList.Release(nBubble); } -short GetBubbleSprite(short nBubble) +short GetBubbleSprite(int nBubble) { - return BubbleList[nBubble].nSprite; + return BubbleList[nBubble & 0xffff].nSprite; } int BuildBubble(int x, int y, int z, short nSector) @@ -104,14 +119,11 @@ int BuildBubble(int x, int y, int z, short nSector) nSize -= 4; } - if (nFreeCount <= 0) { + int nBubble = BubbleList.Get(); + if (nBubble < 0) { return -1; } - nFreeCount--; - - uint8_t nBubble = nBubblesFree[nFreeCount]; - int nSprite = insertsprite(nSector, 402); assert(nSprite >= 0 && nSprite < kMaxSprites); diff --git a/source/exhumed/src/gun.cpp b/source/exhumed/src/gun.cpp index 6293362a8..5334409fd 100644 --- a/source/exhumed/src/gun.cpp +++ b/source/exhumed/src/gun.cpp @@ -59,13 +59,19 @@ Weapon WeaponInfo[] = { short nTemperature[kMaxPlayers]; short nMinAmmo[] = { 0, 24, 51, 50, 1, 0, 0 }; -short word_96E26 = 0; +short isRed = 0; -static SavegameHelper sghgun("gun", - SA(nTemperature), - SV(word_96E26), - nullptr); +void SerializeGun(FSerializer& arc) +{ + if (arc.BeginObject("gun")) + { + arc.Array("temperature", nTemperature, kMaxPlayers) + ("isred", isRed) + .EndObject(); + + } +} void RestoreMinAmmo(short nPlayer) { @@ -947,11 +953,11 @@ void DrawWeapons(double smooth) if (nDouble) { - if (word_96E26) { + if (isRed) { nPal = kPalRedBrite; } - word_96E26 = word_96E26 == 0; + isRed = isRed == 0; } nPal = RemapPLU(nPal); diff --git a/source/exhumed/src/save.cpp b/source/exhumed/src/save.cpp index c080e2fc0..494b31bcd 100644 --- a/source/exhumed/src/save.cpp +++ b/source/exhumed/src/save.cpp @@ -30,6 +30,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_PS_NS void SerializeAnim(FSerializer& arc); +void SerializeBubbles(FSerializer& arc); +void SerializeGun(FSerializer& arc); void SerializeItems(FSerializer& arc); void SerializeMove(FSerializer& arc); void SerializeLighting(FSerializer& arc); @@ -74,6 +76,8 @@ void GameInterface::SerializeGameState(FSerializer& arc) if (arc.BeginObject("exhumed")) { SerializeAnim(arc); + SerializeBubbles(arc); + SerializeGun(arc); SerializeItems(arc); SerializeMove(arc); SerializeLighting(arc);