From 4e1e9ca0c9ce330653e435169fe2a6c4484ec770 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 4 Sep 2021 23:27:21 +0200 Subject: [PATCH] - proper actor managements in SEQINST. --- source/games/blood/src/actor.cpp | 16 ++-- source/games/blood/src/ai.cpp | 4 +- source/games/blood/src/aiunicult.cpp | 14 +-- source/games/blood/src/blood.cpp | 2 +- source/games/blood/src/callback.cpp | 8 +- source/games/blood/src/nnexts.cpp | 4 +- source/games/blood/src/player.cpp | 14 +-- source/games/blood/src/seq.cpp | 126 +++++++++++++++++++-------- source/games/blood/src/seq.h | 10 +-- source/games/blood/src/triggers.cpp | 19 ++-- 10 files changed, 134 insertions(+), 83 deletions(-) diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index 365d3dcdc..4d97314c7 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -2512,7 +2512,7 @@ static void actInitDudes() } - if (getSequence(seqStartId)) seqSpawn(seqStartId, 3, pSprite->extra); + if (getSequence(seqStartId)) seqSpawn(seqStartId, act); } aiInit(); } @@ -3767,20 +3767,20 @@ static int actDamageThing(DBloodActor* source, DBloodActor* actor, int damage, D } break; case kTrapMachinegun: - seqSpawn(28, 3, pSprite->extra, -1); + seqSpawn(28, actor, -1); break; case kThingFluorescent: - seqSpawn(12, 3, pSprite->extra, -1); + seqSpawn(12, actor, -1); GibSprite(actor, GIBTYPE_6, nullptr, nullptr); break; case kThingSpiderWeb: - seqSpawn(15, 3, pSprite->extra, -1); + seqSpawn(15, actor, -1); break; case kThingMetalGrate: - seqSpawn(21, 3, pSprite->extra, -1); + seqSpawn(21, actor, -1); GibSprite(actor, GIBTYPE_4, nullptr, nullptr); break; @@ -3799,7 +3799,7 @@ static int actDamageThing(DBloodActor* source, DBloodActor* actor, int damage, D break; case 1: - seqSpawn(26, 3, pSprite->extra, nTreeToGibClient); + seqSpawn(26, actor, nTreeToGibClient); sfxPlay3DSound(actor, 351, -1, 0); break; } @@ -4101,7 +4101,7 @@ static void actImpactMissile(DBloodActor* missileActor, int hitCode) sfxKill3DSound(pMissile, -1, -1); sfxPlay3DSound(pMissile->x, pMissile->y, pMissile->z, 522, pMissile->sectnum); actPostSprite(missileActor, kStatDebris); - seqSpawn(20, 3, pMissile->extra, -1); + seqSpawn(20, missileActor, -1); if (hitCode == 3 && actorHit && actorHit->hasX()) { if (pSpriteHit->statnum == kStatDude) @@ -4116,7 +4116,7 @@ static void actImpactMissile(DBloodActor* missileActor, int hitCode) actPostSprite(missileActor, kStatDebris); pMissile->cstat &= ~16; pMissile->type = kSpriteDecoration; - seqSpawn(20, 3, pMissile->extra, -1); + seqSpawn(20, missileActor, -1); if (hitCode == 3 && actorHit && actorHit->hasX()) { if (pSpriteHit->statnum == kStatDude) diff --git a/source/games/blood/src/ai.cpp b/source/games/blood/src/ai.cpp index 4044a853d..9062b67d3 100644 --- a/source/games/blood/src/ai.cpp +++ b/source/games/blood/src/ai.cpp @@ -49,7 +49,7 @@ bool dudeIsPlayingSeq(DBloodActor* actor, int nSeq) if (pSprite->statnum == kStatDude && pSprite->type >= kDudeBase && pSprite->type < kDudeMax) { DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); - if (seqGetID(3, pSprite->extra) == pDudeInfo->seqStartID + nSeq && seqGetStatus(3, pSprite->extra) >= 0) + if (seqGetID(actor) == pDudeInfo->seqStartID + nSeq && seqGetStatus(actor) >= 0) return true; } return false; @@ -1675,7 +1675,7 @@ void aiProcessDudes(void) if (pExtra->slaveCount > 0) updateTargetOfSlaves(actor); if (pExtra->pLifeLeech != nullptr) updateTargetOfLeech(actor); if (pXSprite->stateTimer == 0 && pXSprite->aiState && pXSprite->aiState->nextState - && (pXSprite->aiState->stateTicks > 0 || seqGetStatus(3, pSprite->extra) < 0)) + && (pXSprite->aiState->stateTicks > 0 || seqGetStatus(actor) < 0)) { aiGenDudeNewState(actor, pXSprite->aiState->nextState); } diff --git a/source/games/blood/src/aiunicult.cpp b/source/games/blood/src/aiunicult.cpp index 1f3f01117..9fe90fc1b 100644 --- a/source/games/blood/src/aiunicult.cpp +++ b/source/games/blood/src/aiunicult.cpp @@ -121,7 +121,7 @@ static void forcePunch(DBloodActor* actor) { auto pXSprite = &actor->x(); auto pSprite = &actor->s(); - if (actor->genDudeExtra.forcePunch && seqGetStatus(3, pSprite->extra) == -1) + if (actor->genDudeExtra.forcePunch && seqGetStatus(actor) == -1) punchCallback(0, actor); } @@ -1044,7 +1044,7 @@ static void unicultThinkChase(DBloodActor* actor) } else { - if (seqGetID(3, pSprite->extra) == pXSprite->data2 + ((state < 3) ? 8 : 6)) + if (seqGetID(actor) == pXSprite->data2 + ((state < 3) ? 8 : 6)) { if (state == 1) pXSprite->aiState->nextState = &genDudeChaseW; else if (state == 2) pXSprite->aiState->nextState = &genDudeChaseD; @@ -1313,7 +1313,7 @@ void aiGenDudeNewState(DBloodActor* actor, AISTATE* pAIState) int stateSeq = pXSprite->data2 + pAIState->seqId; if (pAIState->seqId >= 0 && getSequence(stateSeq)) { - seqSpawn(stateSeq, 3, pSprite->extra, pAIState->funcId); + seqSpawn(stateSeq, actor, pAIState->funcId); } if (pAIState->enterFunc) @@ -1931,7 +1931,7 @@ bool doExplosion(DBloodActor* actor, int nType) else if (nType <= 6) { nSeq = 4; nSnd = 303; } else if (nType == 7) { nSeq = 4; nSnd = 303; } - seqSpawn(nSeq, 3, pExplosion->extra, -1); + seqSpawn(nSeq, actExplosion, -1); sfxPlay3DSound(actExplosion, nSnd, -1, 0); return true; @@ -1983,7 +1983,7 @@ DBloodActor* genDudeSpawn(DBloodActor* source, DBloodActor* actor, int nDist) pXDude->data3 = 0; // spawn seq - seqSpawn(genDudeSeqStartId(spawned), 3, pDude->extra, -1); + seqSpawn(genDudeSeqStartId(spawned), spawned, -1); // inherit movement speed. pXDude->busyTime = pXSource->busyTime; @@ -2132,7 +2132,7 @@ void genDudeTransform(DBloodActor* actor) genDudePrepare(actor, kGenDudePropertyMass); [[fallthrough]]; // go below default: - seqSpawn(seqId, 3, pSprite->extra, -1); + seqSpawn(seqId, actor, -1); // save target auto target = actor->GetTarget(); @@ -2568,7 +2568,7 @@ bool genDudePrepare(DBloodActor* actor, int propId) } case kGenDudePropertySpriteSize: { if (seqGetStatus(actor) == -1) - seqSpawn(pXSprite->data2 + pXSprite->aiState->seqId, 3, pSprite->extra, -1); + seqSpawn(pXSprite->data2 + pXSprite->aiState->seqId, actor, -1); // make sure dudes aren't in the floor or ceiling int zTop, zBot; GetSpriteExtents(pSprite, &zTop, &zBot); diff --git a/source/games/blood/src/blood.cpp b/source/games/blood/src/blood.cpp index db313ea6e..3aa6e589f 100644 --- a/source/games/blood/src/blood.cpp +++ b/source/games/blood/src/blood.cpp @@ -107,7 +107,7 @@ void StartLevel(MapRecord* level, bool newgame) for (int i = connecthead; i >= 0; i = connectpoint2[i]) { memcpy(&gPlayerTemp[i], &gPlayer[i], sizeof(PLAYER)); - gHealthTemp[i] = xsprite[gPlayer[i].pSprite->extra].health; + gHealthTemp[i] = gPlayer[i].actor()->x().health; } } memset(xsprite, 0, sizeof(xsprite)); diff --git a/source/games/blood/src/callback.cpp b/source/games/blood/src/callback.cpp index c3be9333b..45415b6bb 100644 --- a/source/games/blood/src/callback.cpp +++ b/source/games/blood/src/callback.cpp @@ -263,10 +263,10 @@ void Respawn(DBloodActor* actor, int) // 9 default: pSprite->clipdist = getDudeInfo(nType + kDudeBase)->clipdist; if (getSequence(getDudeInfo(nType + kDudeBase)->seqStartID)) - seqSpawn(getDudeInfo(nType + kDudeBase)->seqStartID, 3, pSprite->extra, -1); + seqSpawn(getDudeInfo(nType + kDudeBase)->seqStartID, actor, -1); break; case kDudeModernCustom: - seqSpawn(genDudeSeqStartId(actor), 3, pSprite->extra, -1); + seqSpawn(genDudeSeqStartId(actor), actor, -1); break; } @@ -279,7 +279,7 @@ void Respawn(DBloodActor* actor, int) // 9 pSprite->clipdist = getDudeInfo(nType + kDudeBase)->clipdist; pXSprite->health = getDudeInfo(nType + kDudeBase)->startHealth << 4; if (getSequence(getDudeInfo(nType + kDudeBase)->seqStartID)) - seqSpawn(getDudeInfo(nType + kDudeBase)->seqStartID, 3, pSprite->extra, -1); + seqSpawn(getDudeInfo(nType + kDudeBase)->seqStartID, actor, -1); #endif aiInitSprite(actor); pXSprite->key = 0; @@ -475,7 +475,7 @@ void sleeveStopBouncing(DBloodActor* actor) { auto pSprite = &actor->s(); actor->xvel = actor->yvel = actor->zvel = 0; - if (pSprite->extra > 0) seqKill(3, pSprite->extra); + if (pSprite->extra > 0) seqKill(actor); sfxKill3DSound(pSprite, -1, -1); switch (pSprite->type) { diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index 1a10b34ef..02ec134fa 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -300,7 +300,7 @@ static DBloodActor* nnExtSpawnDude(DBloodActor* sourceActor, DBloodActor* origin pXDude->health = getDudeInfo(nType)->startHealth << 4; if (fileSystem.FindResource(getDudeInfo(nType)->seqStartID, "SEQ")) - seqSpawn(getDudeInfo(nType)->seqStartID, 3, pDude->extra, -1); + seqSpawn(getDudeInfo(nType)->seqStartID, pDudeActor, -1); // add a way to inherit some values of spawner by dude. if (pSource->flags & kModernTypeFlag1) { @@ -1519,7 +1519,7 @@ int getSpriteMassBySize(DBloodActor* actor) } else { - seqId = seqGetID(3, pSprite->extra); + seqId = seqGetID(actor); } SPRITEMASS* cached = &actor->spriteMass; diff --git a/source/games/blood/src/player.cpp b/source/games/blood/src/player.cpp index acbd83e13..eed678905 100644 --- a/source/games/blood/src/player.cpp +++ b/source/games/blood/src/player.cpp @@ -564,8 +564,8 @@ void packNextItem(PLAYER* pPlayer) char playerSeqPlaying(PLAYER * pPlayer, int nSeq) { - int nCurSeq = seqGetID(3, pPlayer->pSprite->extra); - if (pPlayer->pDudeInfo->seqStartID+nSeq == nCurSeq && seqGetStatus(3,pPlayer->pSprite->extra) >= 0) + int nCurSeq = seqGetID(pPlayer->actor()); + if (pPlayer->pDudeInfo->seqStartID+nSeq == nCurSeq && seqGetStatus(pPlayer->actor()) >= 0) return 1; return 0; } @@ -670,7 +670,7 @@ void playerStart(int nPlayer, int bNewLevel) pPlayer->pDudeInfo = pDudeInfo; playerSetRace(pPlayer, kModeHuman); playerResetPosture(pPlayer); - seqSpawn(pDudeInfo->seqStartID, 3, pSprite->extra, -1); + seqSpawn(pDudeInfo->seqStartID, actor, -1); if (pPlayer == gMe) actor->s().cstat2 |= CSTAT2_SPRITE_MAPPED; int top, bottom; @@ -1390,14 +1390,14 @@ void ProcessInput(PLAYER *pPlayer) if (bSeqStat) { if (pPlayer->deathTime > 360) - seqSpawn(pPlayer->pDudeInfo->seqStartID+14, 3, pPlayer->pSprite->extra, nPlayerSurviveClient); + seqSpawn(pPlayer->pDudeInfo->seqStartID+14, pPlayer->actor(), nPlayerSurviveClient); } - else if (seqGetStatus(3, pPlayer->pSprite->extra) < 0) + else if (seqGetStatus(pPlayer->actor()) < 0) { if (pPlayer->pSprite) pPlayer->pSprite->type = kThingBloodChunks; actPostSprite(pPlayer->actor(), kStatThing); - seqSpawn(pPlayer->pDudeInfo->seqStartID+15, 3, pPlayer->pSprite->extra, -1); + seqSpawn(pPlayer->pDudeInfo->seqStartID+15, pPlayer->actor(), -1); playerReset(pPlayer); if (gGameOptions.nGameType == 0 && numplayers == 1) { @@ -2093,7 +2093,7 @@ int playerDamageSprite(DBloodActor* source, PLAYER *pPlayer, DAMAGE_TYPE nDamage } assert(getSequence(pDudeInfo->seqStartID + nDeathSeqID) != NULL); - seqSpawn(pDudeInfo->seqStartID+nDeathSeqID, 3, nXSprite, nKneelingPlayer); + seqSpawn(pDudeInfo->seqStartID+nDeathSeqID, pPlayer->actor(), nKneelingPlayer); return nDamage; } diff --git a/source/games/blood/src/seq.cpp b/source/games/blood/src/seq.cpp index 2e82bd676..fb67bca23 100644 --- a/source/games/blood/src/seq.cpp +++ b/source/games/blood/src/seq.cpp @@ -30,6 +30,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "blood.h" #include "files.h" +#include "eventq.h" +#include "callback.h" BEGIN_BLD_NS @@ -256,14 +258,10 @@ void UpdateMasked(int nXWall, SEQFRAME* pFrame) // //--------------------------------------------------------------------------- -void UpdateSprite(int nXSprite, SEQFRAME* pFrame) +void UpdateSprite(DBloodActor* actor, SEQFRAME* pFrame) { - assert(nXSprite > 0 && nXSprite < kMaxXSprites); - int nSprite = xsprite[nXSprite].reference; - if (!(nSprite >= 0 && nSprite < kMaxSprites)) return; // sprite may have been deleted already. - - spritetype* pSprite = &sprite[nSprite]; - assert(pSprite->extra == nXSprite); + spritetype* pSprite = &actor->s(); + assert(actor->hasX()); if (pSprite->flags & 2) { if (tileHeight(pSprite->picnum) != tileHeight(seqGetTile(pFrame)) || tileTopOffset(pSprite->picnum) != tileTopOffset(seqGetTile(pFrame)) @@ -275,7 +273,7 @@ void UpdateSprite(int nXSprite, SEQFRAME* pFrame) pSprite->pal = pFrame->palette; pSprite->shade = pFrame->shade; - int scale = xsprite[nXSprite].scale; // SEQ size scaling + int scale = actor->x().scale; // SEQ size scaling if (pFrame->xrepeat) { if (scale) pSprite->xrepeat = ClipRange(MulScale(pFrame->xrepeat, scale, 8), 0, 255); else pSprite->xrepeat = pFrame->xrepeat; @@ -340,17 +338,18 @@ void SEQINST::Update() switch (type) { case 0: - UpdateWall(index, &pSequence->frames[frameIndex]); + UpdateWall(seqindex, &pSequence->frames[frameIndex]); break; case 1: - UpdateCeiling(index, &pSequence->frames[frameIndex]); + UpdateCeiling(seqindex, &pSequence->frames[frameIndex]); break; case 2: - UpdateFloor(index, &pSequence->frames[frameIndex]); + UpdateFloor(seqindex, &pSequence->frames[frameIndex]); break; case 3: { - UpdateSprite(index, &pSequence->frames[frameIndex]); + if (!actor) break; + UpdateSprite(actor, &pSequence->frames[frameIndex]); if (pSequence->frames[frameIndex].playsound) { int sound = pSequence->soundId; @@ -359,13 +358,12 @@ void SEQINST::Update() if (!VanillaMode() && pSequence->frames[frameIndex].soundRange > 0) sound += Random(((pSequence->frames[frameIndex].soundRange == 1) ? 2 : pSequence->frames[frameIndex].soundRange)); - sfxPlay3DSound(&sprite[xsprite[index].reference], sound, -1, 0); + sfxPlay3DSound(actor, sound, -1, 0); } // by NoOne: add surfaceSound trigger feature - spritetype* pSprite = &sprite[xsprite[index].reference]; - auto actor = &bloodActors[pSprite->index]; + spritetype* pSprite = &actor->s(); if (!VanillaMode() && pSequence->frames[frameIndex].surfaceSound && actor->zvel == 0 && actor->xvel != 0) { if (gUpperLink[pSprite->sectnum] >= 0) break; // don't play surface sound for stacked sectors @@ -402,7 +400,7 @@ void SEQINST::Update() break; } case 4: - UpdateMasked(index, &pSequence->frames[frameIndex]); + UpdateMasked(seqindex, &pSequence->frames[frameIndex]); break; } @@ -410,7 +408,7 @@ void SEQINST::Update() if (pSequence->frames[frameIndex].trigger && callback != -1) { assert(type == 3); - seqClientCallback[callback](type, &bloodActors[xsprite[index].reference]); + if (type == 3) seqClientCallback[callback](type, actor); } } @@ -428,7 +426,8 @@ struct ActiveList void clear() { list.Clear(); } int getSize() { return list.Size(); } SEQINST* getInst(int num) { return &list[num]; } - int getIndex(int num) { return list[num].index; } + int getIndex(int num) { return list[num].seqindex; } + DBloodActor* getActor(int num) { return list[num].actor; } int getType(int num) { return list[num].type; } void remove(int num) @@ -447,7 +446,16 @@ struct ActiveList { for (auto& n : list) { - if (n.type == type && n.index == index) return &n; + if (n.type == type && n.seqindex == index) return &n; + } + return nullptr; + } + + SEQINST* get(DBloodActor* actor) + { + for (auto& n : list) + { + if (n.type == 3 && n.actor == actor) return &n; } return nullptr; } @@ -457,13 +465,27 @@ struct ActiveList for (unsigned i = 0; i < list.Size(); i++) { auto& n = list[i]; - if (n.type == type && n.index == index) + if (n.type == type && n.seqindex == index) { remove(i); return; } } } + + void remove(DBloodActor* actor) + { + for (unsigned i = 0; i < list.Size(); i++) + { + auto& n = list[i]; + if (n.type == 3 && n.actor == actor) + { + remove(i); + return; + } + } + } + }; static ActiveList activeList; @@ -481,21 +503,26 @@ SEQINST* GetInstance(int type, int nXIndex) SEQINST* GetInstance(DBloodActor* actor) { - return activeList.get(SS_SPRITE, actor->s().extra); + return activeList.get(actor); } int seqGetStatus(DBloodActor* actor) { - return seqGetStatus(SS_SPRITE, actor->s().extra); + SEQINST* pInst = activeList.get(actor); + if (pInst) return pInst->frameIndex; + return -1; } int seqGetID(DBloodActor* actor) { - return seqGetID(3, actor->s().index); + SEQINST* pInst = activeList.get(actor); + if (pInst) return pInst->nSeqID; + return -1; } void seqKill(int type, int nXIndex) { + assert(type != SS_SPRITE); activeList.remove(type, nXIndex); } @@ -506,7 +533,7 @@ void seqKillAll() void seqKill(DBloodActor* actor) { - activeList.remove(SS_SPRITE, actor->s().extra); + activeList.remove(actor); } @@ -583,6 +610,7 @@ Seq* getSequence(int res_id) void seqSpawn(int nSeqID, int type, int nXIndex, int callback) { + assert(type != SS_SPRITE); Seq* pSequence = getSequence(nSeqID); if (pSequence == nullptr) return; @@ -605,13 +633,38 @@ void seqSpawn(int nSeqID, int type, int nXIndex, int callback) pInst->timeCounter = (short)pSequence->ticksPerFrame; pInst->frameIndex = 0; pInst->type = type; - pInst->index = nXIndex; + pInst->seqindex = nXIndex; + pInst->actor = nullptr; pInst->Update(); } -void seqSpawn(int a1, DBloodActor* actor, int a4) +void seqSpawn(int nSeqID, DBloodActor* actor, int callback) { - seqSpawn(a1, 3, actor->s().extra, a4); + Seq* pSequence = getSequence(nSeqID); + + if (pSequence == nullptr) return; + + SEQINST* pInst = activeList.get(actor); + if (!pInst) + { + pInst = activeList.getNew(); + } + else + { + // already playing this sequence? + if (pInst->nSeqID == nSeqID) + return; + } + + pInst->pSequence = pSequence; + pInst->nSeqID = nSeqID; + pInst->callback = callback; + pInst->timeCounter = (short)pSequence->ticksPerFrame; + pInst->frameIndex = 0; + pInst->type = SS_SPRITE; + pInst->seqindex = 0; + pInst->actor = actor; + pInst->Update(); } //--------------------------------------------------------------------------- @@ -646,7 +699,8 @@ void seqProcess(int nTicks) { SEQINST* pInst = activeList.getInst(i); Seq* pSeq = pInst->pSequence; - int index = pInst->index; + int index = pInst->seqindex; + auto actor = pInst->actor; assert(pInst->frameIndex < pSeq->nFrames); @@ -664,17 +718,16 @@ void seqProcess(int nTicks) { if (pInst->type == SS_SPRITE) { - int nSprite = xsprite[index].reference; - if (nSprite >= 0 && nSprite < kMaxSprites) + if (actor) { - evKillActor(&bloodActors[nSprite]); - if ((sprite[nSprite].hitag & kAttrRespawn) != 0 && (sprite[nSprite].inittype >= kDudeBase && sprite[nSprite].inittype < kDudeMax)) - evPostActor(&bloodActors[nSprite], gGameOptions.nMonsterRespawnTime, kCallbackRespawn); - else deletesprite(nSprite); // safe to not use actPostSprite here + evKillActor(actor); + if ((actor->s().hitag & kAttrRespawn) != 0 && (actor->s().inittype >= kDudeBase && actor->s().inittype < kDudeMax)) + evPostActor(actor, gGameOptions.nMonsterRespawnTime, kCallbackRespawn); + else DeleteSprite(actor); // safe to not use actPostSprite here } } - if (pInst->type == SS_MASKED) + else if (pInst->type == SS_MASKED) { int nWall = xwall[index].reference; assert(nWall >= 0 && nWall < kMaxWalls); @@ -706,7 +759,8 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, SEQINST& w, SEQINS { if (arc.BeginObject(keyname)) { - arc("index", w.index) + arc("index", w.seqindex) + ("actor", w.actor) ("type", w.type) ("callback", w.callback) ("seqid", w.nSeqID) diff --git a/source/games/blood/src/seq.h b/source/games/blood/src/seq.h index bb75b4c67..4591d3a7a 100644 --- a/source/games/blood/src/seq.h +++ b/source/games/blood/src/seq.h @@ -72,16 +72,12 @@ struct Seq { } }; -struct ACTIVE -{ - uint8_t type; - unsigned short xindex; -}; - +class DBloodActor; struct SEQINST { Seq* pSequence; - int index, type; + DBloodActor* actor; + int seqindex, type; int nSeqID; int callback; diff --git a/source/games/blood/src/triggers.cpp b/source/games/blood/src/triggers.cpp index adc94f137..b9003b14b 100644 --- a/source/games/blood/src/triggers.cpp +++ b/source/games/blood/src/triggers.cpp @@ -323,11 +323,11 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) switch (event.cmd) { case kCmdOff: if (!SetSpriteState(nSprite, pXSprite, 0)) break; - seqSpawn(40, 3, pSprite->extra, -1); + seqSpawn(40, actor, -1); break; case kCmdOn: if (!SetSpriteState(nSprite, pXSprite, 1)) break; - seqSpawn(38, 3, pSprite->extra, nMGunOpenClient); + seqSpawn(38, actor, nMGunOpenClient); if (pXSprite->data1 > 0) pXSprite->data2 = pXSprite->data1; break; @@ -368,12 +368,12 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) switch (event.cmd) { case kCmdOff: if (!SetSpriteState(nSprite, pXSprite, 0)) break; - seqSpawn(40, 3, pSprite->extra, -1); + seqSpawn(40, actor, -1); sfxKill3DSound(pSprite, 0, -1); break; case kCmdOn: if (!SetSpriteState(nSprite, pXSprite, 1)) break; - seqSpawn(38, 3, pSprite->extra, -1); + seqSpawn(38, actor, -1); sfxPlay3DSound(pSprite, 441, 0, 0); break; } @@ -385,11 +385,11 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) break; case kCmdOn: if (!SetSpriteState(nSprite, pXSprite, 1)) break; - seqSpawn(37, 3, pSprite->extra, -1); + seqSpawn(37, actor, -1); break; default: SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1); - if (pXSprite->state) seqSpawn(37, 3, pSprite->extra, -1); + if (pXSprite->state) seqSpawn(37, actor, -1); break; } break; @@ -2202,6 +2202,7 @@ void InitGenerator(int nSprite) void ActivateGenerator(int nSprite) { assert(nSprite < kMaxSprites); + auto actor = &bloodActors[nSprite]; spritetype *pSprite = &sprite[nSprite]; assert(pSprite->statnum != kMaxStatus); int nXSprite = pSprite->extra; @@ -2224,10 +2225,10 @@ void ActivateGenerator(int nSprite) FireballTrapSeqCallback(3, &bloodActors[nSprite]); break; case 1: - seqSpawn(35, 3, nXSprite, nFireballTrapClient); + seqSpawn(35, actor, nFireballTrapClient); break; case 2: - seqSpawn(36, 3, nXSprite, nFireballTrapClient); + seqSpawn(36, actor, nFireballTrapClient); break; } break; @@ -2275,7 +2276,7 @@ void MGunFireSeqCallback(int, DBloodActor* actor) void MGunOpenSeqCallback(int, DBloodActor* actor) { - seqSpawn(39, 3, actor->s().extra, nMGunFireClient); + seqSpawn(39, actor, nMGunFireClient); }