diff --git a/source/games/blood/src/aiunicult.cpp b/source/games/blood/src/aiunicult.cpp index 8639f099387..227a2726176 100644 --- a/source/games/blood/src/aiunicult.cpp +++ b/source/games/blood/src/aiunicult.cpp @@ -597,7 +597,7 @@ static void unicultThinkChase(DBloodActor* actor) } } - else if (dist > 4072 && dist <= 11072 && !spriteIsUnderwater(actor, false) && pSprite->owner != (kMaxSprites - 1)) + else if (dist > 4072 && dist <= 11072 && !spriteIsUnderwater(actor, false) && !actor->GetSpecialOwner()) { switch (curWeapon) { @@ -2534,7 +2534,8 @@ bool genDudePrepare(DBloodActor* actor, int propId) } case kGenDudePropertyLeech: pExtra->pLifeLeech = nullptr; - if (pSprite->owner != kMaxSprites - 1) { + if (!actor->GetSpecialOwner()) + { BloodStatIterator it(kStatThing); while (auto actor2 = it.Next()) { diff --git a/source/games/blood/src/animatesprite.cpp b/source/games/blood/src/animatesprite.cpp index c6fff9c1507..188127d2b29 100644 --- a/source/games/blood/src/animatesprite.cpp +++ b/source/games/blood/src/animatesprite.cpp @@ -543,7 +543,7 @@ void viewProcessSprites(spritetype* tsprite, int& spritesortcnt, int32_t cX, int } int nSprite = pTSprite->owner; - if (cl_interpolate && gInterpolateSprite[nSprite] && !(pTSprite->flags&512)) + if (cl_interpolate && owneractor->interpolated && !(pTSprite->flags&512)) { pTSprite->pos = pTSprite->interpolatedvec3(gInterpolate); pTSprite->ang = pTSprite->interpolatedang(gInterpolate); diff --git a/source/games/blood/src/blood.cpp b/source/games/blood/src/blood.cpp index 48aa80c6cf7..f1bb5d4036b 100644 --- a/source/games/blood/src/blood.cpp +++ b/source/games/blood/src/blood.cpp @@ -263,7 +263,9 @@ void GameInterface::Ticker() if (newweap > 0 && newweap < WeaponSel_MaxBlood) gPlayer[i].newWeapon = newweap; } - gInterpolateSprite.Zero(); + BloodSpriteIterator it; + while (DBloodActor* act = it.Next()) act->interpolated = false; + ClearMovementInterpolations(); UpdateInterpolations(); diff --git a/source/games/blood/src/bloodactor.h b/source/games/blood/src/bloodactor.h index 9a19a4db862..5b92834638f 100644 --- a/source/games/blood/src/bloodactor.h +++ b/source/games/blood/src/bloodactor.h @@ -105,9 +105,10 @@ class DBloodActor // transient data (not written to savegame) int cumulDamage; bool explosionhackflag; // this originally hijacked the target field which is not safe when working with pointers. + bool interpolated; ConditionElement condition[2]; - DBloodActor() :index(int(this - base())) { /*assert(index >= 0 && index < kMaxSprites);*/ } + DBloodActor() :index(int(this - base())) {} DBloodActor& operator=(const DBloodActor& other) = default; void Clear() @@ -121,6 +122,7 @@ class DBloodActor basePoint = {}; xsprite = {}; hasx = false; + interpolated = false; xvel = yvel = zvel = 0; } bool hasX() { return hasx; } diff --git a/source/games/blood/src/db.cpp b/source/games/blood/src/db.cpp index f0a339fc983..a9eaa637c8d 100644 --- a/source/games/blood/src/db.cpp +++ b/source/games/blood/src/db.cpp @@ -163,8 +163,7 @@ void qinitspritelists(void) // Replace { headspritestat[i] = -1; } - int const nMaxSprites = kMaxSprites; - for (short i = 0; i < nMaxSprites; i++) + for (short i = 0; i < kMaxSprites; i++) { sprite[i].sectnum = -1; InsertSpriteStat(i, kMaxStatus); diff --git a/source/games/blood/src/gameutil.h b/source/games/blood/src/gameutil.h index 78dd7839a9d..2d44519c62d 100644 --- a/source/games/blood/src/gameutil.h +++ b/source/games/blood/src/gameutil.h @@ -58,10 +58,6 @@ enum { // by NoOne: functions to quickly check range of specifical arrays -inline bool spriRangeIsFine(int nIndex) { - return (nIndex >= 0 && nIndex < kMaxSprites); -} - inline bool sectRangeIsFine(int nIndex) { return (nIndex >= 0 && nIndex < kMaxSectors); } diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index f91840bbd18..0b8a0d236fa 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -4402,7 +4402,7 @@ bool condCheckDude(DBloodActor* aCond, int cmpOp, bool PUSH) { auto act = actor->genDudeExtra.pLifeLeech; if (!act) return false; - if (pSpr->owner == kMaxSprites - 1) return true; + if (actor->GetSpecialOwner()) return true; else if (PUSH) condPush(aCond, OBJ_SPRITE, 0, act); return false; } diff --git a/source/games/blood/src/triggers.cpp b/source/games/blood/src/triggers.cpp index 0599e3b1e41..ae39d352c54 100644 --- a/source/games/blood/src/triggers.cpp +++ b/source/games/blood/src/triggers.cpp @@ -1460,7 +1460,7 @@ void OperateTeleport(unsigned int nSector, XSECTOR *pXSector) sfxPlay3DSound(pDest, 201, -1, 0); actor->xvel = actor->yvel = actor->zvel = 0; int nSprite = actor->GetIndex(); - gInterpolateSprite.Clear(nSprite); + actor->interpolated = false; viewBackupSpriteLoc(actor); if (pPlayer) { diff --git a/source/games/blood/src/view.cpp b/source/games/blood/src/view.cpp index 208520613a9..ab296731b34 100644 --- a/source/games/blood/src/view.cpp +++ b/source/games/blood/src/view.cpp @@ -49,7 +49,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. EXTERN_CVAR(Bool, testnewrenderer) BEGIN_BLD_NS -FixedBitArray gInterpolateSprite; VIEW gPrevView[kMaxPlayers]; VIEWPOS gViewPos; int gViewIndex; diff --git a/source/games/blood/src/view.h b/source/games/blood/src/view.h index 9e4267469e4..bf93f3245c0 100644 --- a/source/games/blood/src/view.h +++ b/source/games/blood/src/view.h @@ -132,7 +132,6 @@ extern int gScreenTilt; extern int deliriumTilt, deliriumTurn, deliriumPitch; extern int gScreenTiltO, deliriumTurnO, deliriumPitchO; extern int gShowFrameRate; -extern FixedBitArray gInterpolateSprite; extern int gLastPal; extern double gInterpolate; @@ -169,19 +168,14 @@ inline void viewInterpolateWall(int nWall, walltype *pWall) StartInterpolation(nWall, Interp_Wall_Y); } -inline void viewBackupSpriteLoc(int nSprite, spritetype *pSprite) +inline void viewBackupSpriteLoc(DBloodActor* actor) { - if (!gInterpolateSprite[nSprite]) + if (!actor->interpolated) { - pSprite->backuploc(); - gInterpolateSprite.Set(nSprite); + actor->s().backuploc(); + actor->interpolated = true; } } -inline void viewBackupSpriteLoc(DBloodActor* actor) -{ - viewBackupSpriteLoc(actor->GetIndex(), &actor->s()); -} - END_BLD_NS diff --git a/source/games/blood/src/warp.cpp b/source/games/blood/src/warp.cpp index f101d4571c6..6362fb68bc6 100644 --- a/source/games/blood/src/warp.cpp +++ b/source/games/blood/src/warp.cpp @@ -198,7 +198,7 @@ int CheckLink(DBloodActor *actor) else z2 = getceilzofslope(pSprite->sectnum, pSprite->x, pSprite->y); pSprite->z += z2-z; - gInterpolateSprite.Clear(actor->GetIndex()); + actor->interpolated = false; return pUpper->type; } } @@ -225,7 +225,7 @@ int CheckLink(DBloodActor *actor) else z2 = getflorzofslope(pSprite->sectnum, pSprite->x, pSprite->y); pSprite->z += z2-z; - gInterpolateSprite.Clear(actor->GetIndex()); + actor->interpolated = false; return pLower->type; } }