diff --git a/source/exhumed/src/lavadude.cpp b/source/exhumed/src/lavadude.cpp index bad732cda..eef4a3e0c 100644 --- a/source/exhumed/src/lavadude.cpp +++ b/source/exhumed/src/lavadude.cpp @@ -25,8 +25,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_PS_NS -enum { kMaxLavas = 20 }; - struct Lava { short nSprite; @@ -35,12 +33,32 @@ struct Lava short nTarget; short nHealth; short nFrame; - short nChannel; + short nIndex; }; -Lava LavaList[kMaxLavas]; +TArray LavaList; + +FSerializer& Serialize(FSerializer& arc, const char* keyname, Lava& w, Lava* def) +{ + if (arc.BeginObject(keyname)) + { + arc("health", w.nHealth) + ("frame", w.nFrame) + ("action", w.nAction) + ("sprite", w.nSprite) + ("target", w.nTarget) + ("run", w.nRun) + ("channel", w.nIndex) + .EndObject(); + } + return arc; +} + +void SerializeLavadude(FSerializer& arc) +{ + arc("lavadude", LavaList); +} -short LavaCount = 0; static actionSeq LavadudeSeq[] = { {0, 1}, @@ -54,15 +72,9 @@ static actionSeq LavadudeSeq[] = { {42, 1} }; -static SavegameHelper sghlava("lavadude", - SA(LavaList), - SV(LavaCount), - nullptr); - - void InitLava() { - LavaCount = 0; + LavaList.Clear(); } int BuildLavaLimb(int nSprite, int edx, int ebx) @@ -142,12 +154,7 @@ void FuncLavaLimb(int a, int, int nRun) int BuildLava(short nSprite, int x, int y, int, short nSector, short nAngle, int nChannel) { - short nLava = LavaCount; - LavaCount++; - - if (nLava >= kMaxLavas) { - return -1; - } + auto nLava = LavaList.Reserve(1); if (nSprite == -1) { @@ -192,7 +199,7 @@ int BuildLava(short nSprite, int x, int y, int, short nSector, short nAngle, int LavaList[nLava].nHealth = 4000; LavaList[nLava].nSprite = nSprite; LavaList[nLava].nTarget = -1; - LavaList[nLava].nChannel = nChannel; + LavaList[nLava].nIndex = nChannel; LavaList[nLava].nFrame = 0; sprite[nSprite].owner = runlist_AddRunRec(sprite[nSprite].lotag - 1, nLava | 0x150000); @@ -206,7 +213,7 @@ int BuildLava(short nSprite, int x, int y, int, short nSector, short nAngle, int void FuncLava(int a, int nDamage, int nRun) { short nLava = RunData[nRun].nVal; - assert(nLava >= 0 && nLava < kMaxLavas); + assert(nLava >= 0 && nLava < LavaList.Size()); short nAction = LavaList[nLava].nAction; short nSeq = LavadudeSeq[nAction].a + SeqOffsets[kSeqLavag]; @@ -461,7 +468,7 @@ void FuncLava(int a, int nDamage, int nRun) ecx++; } while (ecx < 20); - runlist_ChangeChannel(LavaList[nLava].nChannel, 1); + runlist_ChangeChannel(LavaList[nLava].nIndex, 1); } } else