From 013eadfd9fa61f1172f64d40e51844733e1ca8ce Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 6 May 2021 10:51:39 +0200 Subject: [PATCH] - genDudePrepare --- source/games/blood/src/actor.cpp | 2 +- source/games/blood/src/ai.cpp | 2 +- source/games/blood/src/aiunicult.cpp | 34 ++++++++++++++-------------- source/games/blood/src/aiunicult.h | 4 ++-- source/games/blood/src/callback.cpp | 2 +- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index a5621dca0..3e8d3df7c 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -2482,7 +2482,7 @@ static void actInitDudes() case kDudeModernCustom: case kDudeModernCustomBurning: pSprite->cstat |= 4096 + CSTAT_SPRITE_BLOCK_HITSCAN + CSTAT_SPRITE_BLOCK; - seqStartId = genDudeSeqStartId(pXSprite); // Custom Dude stores its SEQ in data2 + seqStartId = genDudeSeqStartId(act); // Custom Dude stores its SEQ in data2 pXSprite->sysData1 = pXSprite->data3; // move sndStartId to sysData1, because data3 used by the game; pXSprite->data3 = 0; break; diff --git a/source/games/blood/src/ai.cpp b/source/games/blood/src/ai.cpp index 2cff6cf54..835946bcb 100644 --- a/source/games/blood/src/ai.cpp +++ b/source/games/blood/src/ai.cpp @@ -1901,7 +1901,7 @@ void aiInitSprite(DBloodActor* actor) case kDudeModernCustomBurning: if (!gModernMap) break; aiGenDudeInitSprite(pSprite, pXSprite); - genDudePrepare(pSprite, kGenDudePropertyAll); + genDudePrepare(actor, kGenDudePropertyAll); break; #endif default: diff --git a/source/games/blood/src/aiunicult.cpp b/source/games/blood/src/aiunicult.cpp index 16c762ed9..d331df08c 100644 --- a/source/games/blood/src/aiunicult.cpp +++ b/source/games/blood/src/aiunicult.cpp @@ -188,7 +188,7 @@ void genDudeUpdate(DBloodActor* actor) { GENDUDEEXTRA* pExtra = &actor->genDudeExtra(); for (int i = 0; i < kGenDudePropertyMax; i++) { - if (pExtra->updReq[i]) genDudePrepare(&actor->s(), i); + if (pExtra->updReq[i]) genDudePrepare(actor, i); } } @@ -1987,7 +1987,7 @@ DBloodActor* genDudeSpawn(DBloodActor* source, DBloodActor* actor, int nDist) pXDude->data3 = 0; // spawn seq - seqSpawn(genDudeSeqStartId(pXDude), 3, pDude->extra, -1); + seqSpawn(genDudeSeqStartId(spawned), 3, pDude->extra, -1); // inherit movement speed. pXDude->busyTime = pXSource->busyTime; @@ -2132,8 +2132,8 @@ void genDudeTransform(DBloodActor* actor) break; case kDudeModernCustom: case kDudeModernCustomBurning: - seqId = genDudeSeqStartId(pXSprite); - genDudePrepare(pSprite, kGenDudePropertyMass); + seqId = genDudeSeqStartId(actor); + genDudePrepare(actor, kGenDudePropertyMass); [[fallthrough]]; // go below default: seqSpawn(seqId, 3, pSprite->extra, -1); @@ -2343,19 +2343,20 @@ bool canWalk(DBloodActor* actor) // //--------------------------------------------------------------------------- -int genDudeSeqStartId(XSPRITE* pXSprite) { - if (genDudePrepare(&sprite[pXSprite->reference], kGenDudePropertyStates)) return pXSprite->data2; +int genDudeSeqStartId(DBloodActor* actor) +{ + if (genDudePrepare(actor, kGenDudePropertyStates)) return actor->x().data2; else return kGenDudeDefaultSeq; } -bool genDudePrepare(spritetype* pSprite, int propId) { - if (!spriRangeIsFine(pSprite->index)) { - Printf(PRINT_HIGH, "!spriRangeIsFine(pSprite->index)"); - return false; - } else if (!xspriRangeIsFine(pSprite->extra)) { - Printf(PRINT_HIGH, "!xspriRangeIsFine(pSprite->extra)"); - return false; - } else if (pSprite->type != kDudeModernCustom) { +bool genDudePrepare(DBloodActor* actor, int propId) +{ + if (!actor || !actor->hasX()) return false; + + auto const pSprite = &actor->s(); + auto const pXSprite = &actor->x(); + + if (pSprite->type != kDudeModernCustom) { Printf(PRINT_HIGH, "pSprite->type != kDudeModernCustom"); return false; } else if (propId < kGenDudePropertyAll || propId >= kGenDudePropertyMax) { @@ -2363,9 +2364,8 @@ bool genDudePrepare(spritetype* pSprite, int propId) { return false; } - auto actor = &bloodActors[pSprite->index]; - XSPRITE* pXSprite = &xsprite[pSprite->extra]; - GENDUDEEXTRA* pExtra = &gGenDudeExtra[pSprite->index]; pExtra->updReq[propId] = false; + GENDUDEEXTRA* pExtra = &actor->genDudeExtra(); + pExtra->updReq[propId] = false; switch (propId) { case kGenDudePropertyAll: diff --git a/source/games/blood/src/aiunicult.h b/source/games/blood/src/aiunicult.h index 98c6d78c1..b4baa9c12 100644 --- a/source/games/blood/src/aiunicult.h +++ b/source/games/blood/src/aiunicult.h @@ -225,8 +225,8 @@ short inRecoil(AISTATE* aiState); short inSearch(AISTATE* aiState); short inChase(AISTATE* aiState); short inDuck(AISTATE* aiState); -int genDudeSeqStartId(XSPRITE* pXSprite); -bool genDudePrepare(spritetype* pSprite, int propId); +int genDudeSeqStartId(DBloodActor* pXSprite); +bool genDudePrepare(DBloodActor* pSprite, int propId); void genDudeUpdate(DBloodActor* pSprite); void genDudePostDeath(spritetype* pSprite, DAMAGE_TYPE damageType, int damage); void aiGenDudeInitSprite(spritetype* pSprite, XSPRITE* pXSprite); diff --git a/source/games/blood/src/callback.cpp b/source/games/blood/src/callback.cpp index f86f8185d..c8aea97a6 100644 --- a/source/games/blood/src/callback.cpp +++ b/source/games/blood/src/callback.cpp @@ -262,7 +262,7 @@ void Respawn(int nSprite) // 9 seqSpawn(getDudeInfo(nType + kDudeBase)->seqStartID, 3, pSprite->extra, -1); break; case kDudeModernCustom: - seqSpawn(genDudeSeqStartId(pXSprite), 3, pSprite->extra, -1); + seqSpawn(genDudeSeqStartId(actor), 3, pSprite->extra, -1); break; }