diff --git a/source/games/exhumed/src/aistuff.h b/source/games/exhumed/src/aistuff.h index b4b4db151..5dcd70b9e 100644 --- a/source/games/exhumed/src/aistuff.h +++ b/source/games/exhumed/src/aistuff.h @@ -162,13 +162,9 @@ void FillItems(short nPlayer); void UseItem(short nPlayer, short nItem); void UseCurItem(short nPlayer); int GrabItem(short nPlayer, short nItem); -void DropMagic(short nSprite); -inline void DropMagic(DExhumedActor* actor) -{ - DropMagic(actor->GetSpriteIndex()); -} +void DropMagic(DExhumedActor* actor); void InitItems(); -void StartRegenerate(short nSprite); +void StartRegenerate(DExhumedActor* nSprite); void DoRegenerates(); // lavadude diff --git a/source/games/exhumed/src/items.cpp b/source/games/exhumed/src/items.cpp index ad8a30ca2..bd5f66959 100644 --- a/source/games/exhumed/src/items.cpp +++ b/source/games/exhumed/src/items.cpp @@ -105,16 +105,14 @@ short x/y repeat */ -short nRegenerates; -short nFirstRegenerate; +TArray Regenerates; short nMagicCount; void SerializeItems(FSerializer& arc) { if (arc.BeginObject("items")) { - arc("regenerates", nRegenerates) - ("first", nFirstRegenerate) + arc("regenerates", Regenerates) ("magiccount", nMagicCount) .EndObject(); } @@ -330,9 +328,9 @@ int GrabItem(short nPlayer, short nItem) return 1; } -void DropMagic(short nSprite) +void DropMagic(DExhumedActor* pActor) { - auto pSprite = &sprite[nSprite]; + auto pSprite = &pActor->s(); if (lFinaleStart) { return; @@ -364,59 +362,30 @@ void DropMagic(short nSprite) void InitItems() { - nRegenerates = 0; - nFirstRegenerate = -1; + Regenerates.Clear(); nMagicCount = 0; } -void StartRegenerate(short nSprite) +void StartRegenerate(DExhumedActor* pActor) { - spritetype *pSprite = &sprite[nSprite]; + spritetype *pSprite = &pActor->s(); - int edi = -1; + DExhumedActor* pCurr = nullptr; - int nReg = nFirstRegenerate; - - int i = 0; - -// for (int i = 0; i < nRegenerates; i++) - while (1) + auto pos = Regenerates.Find(pActor); + if (pos >= Regenerates.Size()) { - if (i >= nRegenerates) - { - // ?? CHECKME - pSprite->xvel = pSprite->xrepeat; - pSprite->zvel = pSprite->shade; - pSprite->yvel = pSprite->pal; - break; - } - else - { - if (nReg != nSprite) - { - edi = nReg; - nReg = sprite[nReg].ang; - i++; - continue; - } - else - { - if (edi == -1) - { - nFirstRegenerate = pSprite->ang; - } - else - { - sprite[edi].ang = pSprite->ang; - } - - nRegenerates--; - } - } + // ?? CHECKME + pSprite->xvel = pSprite->xrepeat; + pSprite->zvel = pSprite->shade; + pSprite->yvel = pSprite->pal; + } + else + { + Regenerates.Delete(pos); } pSprite->extra = 1350; - pSprite->ang = nFirstRegenerate; if (!(currentLevel->gameflags & LEVEL_EX_MULTI)) { @@ -428,17 +397,15 @@ void StartRegenerate(short nSprite) pSprite->yrepeat = 1; pSprite->pal = 1; - nRegenerates++; - nFirstRegenerate = nSprite; + Regenerates.Push(pActor); } void DoRegenerates() { - int nSprite = nFirstRegenerate; - auto pSprite = &sprite[nSprite]; - - for (int i = nRegenerates; i > 0; i--, nSprite = pSprite->ang) + for(unsigned i = 0; i < Regenerates.Size(); i++) { + auto pActor = Regenerates[i]; + auto pSprite = &pActor->s(); if (pSprite->extra > 0) { pSprite->extra--; @@ -446,7 +413,7 @@ void DoRegenerates() if (pSprite->extra <= 0) { BuildAnim(nullptr, 38, 0, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, 64, 4); - D3PlayFX(StaticSound[kSoundTorchOn], nSprite); + D3PlayFX(StaticSound[kSoundTorchOn], pActor); } else { continue; @@ -468,7 +435,6 @@ void DoRegenerates() pSprite->pal = (uint8_t)pSprite->yvel; pSprite->yvel = pSprite->zvel; // setting to 0 pSprite->xvel = pSprite->zvel; // setting to 0 - nRegenerates--; if (pSprite->statnum == kStatExplodeTrigger) { pSprite->cstat = 0x101; @@ -476,10 +442,8 @@ void DoRegenerates() else { pSprite->cstat = 0; } - - if (nRegenerates == 0) { - nFirstRegenerate = -1; - } + Regenerates.Delete(i); + i--; } } END_PS_NS diff --git a/source/games/exhumed/src/object.cpp b/source/games/exhumed/src/object.cpp index 5d66903f0..32e9ab443 100644 --- a/source/games/exhumed/src/object.cpp +++ b/source/games/exhumed/src/object.cpp @@ -2143,7 +2143,7 @@ void AIObject::Tick(RunListEvent* ev) } else { - StartRegenerate(nSprite); + StartRegenerate(pActor); pObject->nHealth = 120; pSprite->x = sprite[pObject->field_10].x; diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index 671978ed0..19b8b80f3 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -1404,7 +1404,7 @@ sectdone: } else { - StartRegenerate(nValB); + StartRegenerate(pActorB); } do_default_b: // loc_1BA74