From e0f1948ccce545af64a1573c41a044b9fdff2213 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 28 Aug 2021 13:59:29 +0200 Subject: [PATCH] - wrapped all setsprite calls in Blood and adapted a few leftover uses of the index version of actPostSprite. --- source/games/blood/src/actor.cpp | 29 +++++++++++++++------------- source/games/blood/src/aiunicult.cpp | 3 ++- source/games/blood/src/bloodactor.h | 5 +++++ source/games/blood/src/nnexts.cpp | 2 +- 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index 3d9c78d3f..348460b9b 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -3938,7 +3938,7 @@ static void actImpactMissile(DBloodActor* missileActor, int hitCode) } else { - actPostSprite(pMissile->index, kStatFree); + actPostSprite(missileActor, kStatFree); } break; @@ -4047,7 +4047,7 @@ static void actImpactMissile(DBloodActor* missileActor, int hitCode) pXMissile->targetZ = pMissile->z - pSpriteHit->z; pXMissile->goalAng = getangle(pMissile->x - pSpriteHit->x, pMissile->y - pSpriteHit->y) - pSpriteHit->ang; pXMissile->state = 1; - actPostSprite(pMissile->index, kStatFlare); + actPostSprite(missileActor, kStatFlare); pMissile->cstat &= ~257; break; } @@ -4101,7 +4101,7 @@ static void actImpactMissile(DBloodActor* missileActor, int hitCode) case kMissileEctoSkull: sfxKill3DSound(pMissile, -1, -1); sfxPlay3DSound(pMissile->x, pMissile->y, pMissile->z, 522, pMissile->sectnum); - actPostSprite(pMissile->index, kStatDebris); + actPostSprite(missileActor, kStatDebris); seqSpawn(20, 3, pMissile->extra, -1); if (hitCode == 3 && actorHit && actorHit->hasX()) { @@ -6334,7 +6334,7 @@ void actCheckFlares() int y = pTarget->y + mulscale30r(Sin(pXSprite->goalAng + pTarget->ang), pTarget->clipdist * 2); int z = pTarget->z + pXSprite->targetZ; vec3_t pos = { x, y, z }; - setsprite(pSprite->index, &pos); + setActorPos(actor, &pos); actor->xvel() = target->xvel(); actor->yvel() = target->yvel(); actor->zvel() = target->zvel(); @@ -6378,21 +6378,24 @@ void actProcessSprites(void) DBloodActor* actSpawnSprite(int nSector, int x, int y, int z, int nStat, bool setextra) { + DBloodActor* actor; int nSprite = InsertSprite(nSector, nStat); - if (nSprite >= 0) sprite[nSprite].extra = -1; + if (nSprite >= 0) + { + sprite[nSprite].extra = -1; + actor = &bloodActors[nSprite]; + } else { BloodStatIterator it(kStatPurge); - nSprite = it.NextIndex(); - assert(nSprite >= 0); - assert(nSector >= 0 && nSector < kMaxSectors); - ChangeSpriteSect(nSprite, nSector); - actPostSprite(nSprite, nStat); + actor = it.Next(); + assert(actor != nullptr); + ChangeActorSect(actor, nSector); + actPostSprite(actor, nStat); } - DBloodActor* actor = &bloodActors[nSprite]; vec3_t pos = { x, y, z }; - setsprite(nSprite, &pos); + setActorPos(actor, &pos); spritetype* pSprite = &actor->s(); pSprite->type = kSpriteDecoration; if (setextra && !actor->hasX()) @@ -6473,7 +6476,7 @@ DBloodActor* actSpawnDude(DBloodActor* source, short nType, int a3, int a4) pSprite2->type = nType; pSprite2->ang = angle; vec3_t pos = { x, y, z }; - setsprite(pSprite2->index, &pos); + setActorPos(spawned, &pos); pSprite2->cstat |= 0x1101; pSprite2->clipdist = getDudeInfo(nDude + kDudeBase)->clipdist; pXSprite2->health = getDudeInfo(nDude + kDudeBase)->startHealth << 4; diff --git a/source/games/blood/src/aiunicult.cpp b/source/games/blood/src/aiunicult.cpp index 522ca141d..579529c64 100644 --- a/source/games/blood/src/aiunicult.cpp +++ b/source/games/blood/src/aiunicult.cpp @@ -1974,7 +1974,8 @@ DBloodActor* genDudeSpawn(DBloodActor* source, DBloodActor* actor, int nDist) } pDude->type = nType; pDude->ang = nAngle; - vec3_t pos = { x, y, z }; setsprite(pDude->index, &pos); + vec3_t pos = { x, y, z }; + setActorPos(spawned, &pos); pDude->cstat |= 0x1101; pDude->clipdist = dudeInfo[nType - kDudeBase].clipdist; // inherit weapon, seq and sound settings. diff --git a/source/games/blood/src/bloodactor.h b/source/games/blood/src/bloodactor.h index 1cc47b8fa..d69ec518e 100644 --- a/source/games/blood/src/bloodactor.h +++ b/source/games/blood/src/bloodactor.h @@ -352,4 +352,9 @@ inline DBloodActor* Collision::Actor(int a) return &bloodActors[a]; } +inline void setActorPos(DBloodActor* actor, vec3_t* pos) +{ + setsprite(actor->s().index, pos); +} + END_BLD_NS diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index f117dcdf5..7a9e932cb 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -288,7 +288,7 @@ static DBloodActor* nnExtSpawnDude(DBloodActor* sourceActor, DBloodActor* origin } vec3_t pos = { x, y, z }; - setsprite(pDude->index, &pos); + setActorPos(pDudeActor, &pos); pDude->type = nType; pDude->ang = angle;