diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index 56e181791..0cddb8dd0 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -4710,7 +4710,7 @@ static Collision MoveThing(DBloodActor* actor) } } } - if (CheckLink(pSprite)) GetZRange(pSprite, &ceilZ, &ceilColl, &floorZ, &floorColl, pSprite->clipdist << 2, CLIPMASK0); + if (CheckLink(actor)) GetZRange(pSprite, &ceilZ, &ceilColl, &floorZ, &floorColl, pSprite->clipdist << 2, CLIPMASK0); GetActorExtents(actor, &top, &bottom); if (bottom >= floorZ) @@ -5040,7 +5040,7 @@ void MoveDude(DBloodActor* actor) } } vec3_t const oldpos = pSprite->pos; - int nLink = CheckLink(pSprite); + int nLink = CheckLink(actor); if (nLink) { GetZRange(pSprite, &ceilZ, &ceilColl, &floorZ, &floorColl, wd, CLIPMASK0, PARALLAXCLIP_CEILING | PARALLAXCLIP_FLOOR); @@ -5469,7 +5469,7 @@ int MoveMissile(DBloodActor* actor) assert(nSector >= 0 && nSector < kMaxSectors); ChangeActorSect(actor, nSector); } - CheckLink(pSprite); + CheckLink(actor); gHitInfo.hitsect = pSprite->sectnum; gHitInfo.hitx = pSprite->x; gHitInfo.hity = pSprite->y; @@ -7328,7 +7328,7 @@ void actPostProcess(void) } } else - ChangeSpriteStat(p.sprite->s().index, nStatus); + ChangeActorStat(p.sprite, nStatus); } gPost.Clear(); } diff --git a/source/games/blood/src/callback.cpp b/source/games/blood/src/callback.cpp index 5410c193e..daea33580 100644 --- a/source/games/blood/src/callback.cpp +++ b/source/games/blood/src/callback.cpp @@ -243,7 +243,7 @@ void Respawn(DBloodActor* actor, int) // 9 case 3: { assert(pSprite->owner != kStatRespawn); assert(pSprite->owner >= 0 && pSprite->owner < kMaxStatus); - ChangeSpriteStat(actor->s().index, pSprite->owner); + ChangeActorStat(actor, pSprite->owner); pSprite->type = pSprite->inittype; pSprite->owner = -1; pSprite->flags &= ~kHitagRespawn; diff --git a/source/games/blood/src/misc.h b/source/games/blood/src/misc.h index 8fe783ab4..e13717050 100644 --- a/source/games/blood/src/misc.h +++ b/source/games/blood/src/misc.h @@ -27,6 +27,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_BLD_NS +class DBloodActor; + void playlogos(); unsigned int qrand(void); int wrand(void); @@ -61,7 +63,7 @@ struct ZONE { extern ZONE gStartZone[8]; void warpInit(void); -int CheckLink(spritetype *pSprite); +int CheckLink(DBloodActor *pSprite); int CheckLink(int *x, int *y, int *z, int *nSector); int GetOctant(int x, int y); diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index 7d24d681e..40f539bf6 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -1849,7 +1849,7 @@ void debrisMove(int listIndex) } - if ((i = CheckLink(pSprite)) != 0) + if ((i = CheckLink(actor)) != 0) { GetZRange(pSprite, &ceilZ, &ceilColl, &floorZ, &floorColl, clipDist, CLIPMASK0, PARALLAXCLIP_CEILING | PARALLAXCLIP_FLOOR); if (!(pSprite->cstat & CSTAT_SPRITE_INVISIBLE)) diff --git a/source/games/blood/src/player.cpp b/source/games/blood/src/player.cpp index cbbbe02cb..59eeb05ef 100644 --- a/source/games/blood/src/player.cpp +++ b/source/games/blood/src/player.cpp @@ -1678,7 +1678,7 @@ void playerProcess(PLAYER *pPlayer) actDamageSprite(actor, actor, kDamageFall, 500<<4); } assert(nSector >= 0 && nSector < kMaxSectors); - ChangeSpriteSect(pSprite->index, nSector); + ChangeActorSect(actor, nSector); } } ProcessInput(pPlayer); diff --git a/source/games/blood/src/triggers.cpp b/source/games/blood/src/triggers.cpp index 002ef864f..c8e378692 100644 --- a/source/games/blood/src/triggers.cpp +++ b/source/games/blood/src/triggers.cpp @@ -1442,11 +1442,10 @@ void OperateTeleport(unsigned int nSector, XSECTOR *pXSector) assert(pDest->statnum == kStatMarker); assert(pDest->type == kMarkerWarpDest); assert(pDest->sectnum >= 0 && pDest->sectnum < kMaxSectors); - int nSprite; - SectIterator it(nSector); - while ((nSprite = it.NextIndex()) >= 0) + BloodSectIterator it(nSector); + while (auto actor = it.Next()) { - spritetype *pSprite = &sprite[nSprite]; + spritetype *pSprite = &actor->s(); if (pSprite->statnum == kStatDude) { PLAYER *pPlayer; @@ -1463,9 +1462,10 @@ void OperateTeleport(unsigned int nSector, XSECTOR *pXSector) pSprite->y = pDest->y; pSprite->z += sector[pDest->sectnum].floorz-sector[nSector].floorz; pSprite->ang = pDest->ang; - ChangeSpriteSect(nSprite, pDest->sectnum); + ChangeActorSect(actor, pDest->sectnum); sfxPlay3DSound(pDest, 201, -1, 0); - xvel[nSprite] = yvel[nSprite] = zvel[nSprite] = 0; + actor->xvel() = actor->yvel() = actor->zvel() = 0; + int nSprite = actor->s().index; gInterpolateSprite.Clear(nSprite); viewBackupSpriteLoc(nSprite, pSprite); if (pPlayer) diff --git a/source/games/blood/src/warp.cpp b/source/games/blood/src/warp.cpp index f13197a02..0c277e562 100644 --- a/source/games/blood/src/warp.cpp +++ b/source/games/blood/src/warp.cpp @@ -175,14 +175,15 @@ void warpInit(void) } } -int CheckLink(spritetype *pSprite) +int CheckLink(DBloodActor *actor) { + auto pSprite = &actor->s(); int nSector = pSprite->sectnum; - int nUpper = gUpperLink[nSector]; - int nLower = gLowerLink[nSector]; - if (nUpper >= 0) + auto aUpper = getUpperLink(nSector); + auto aLower = getLowerLink(nSector); + if (aUpper) { - spritetype *pUpper = &sprite[nUpper]; + spritetype* pUpper = &aUpper->s(); int z; if (pUpper->type == kMarkerUpLink) z = pUpper->z; @@ -190,11 +191,11 @@ int CheckLink(spritetype *pSprite) z = getflorzofslope(pSprite->sectnum, pSprite->x, pSprite->y); if (z <= pSprite->z) { - nLower = pUpper->owner; - assert(nLower >= 0 && nLower < kMaxSprites); - spritetype *pLower = &sprite[nLower]; + aLower = aUpper->GetOwner(); + assert(aLower); + spritetype *pLower = &aLower->s(); assert(pLower->sectnum >= 0 && pLower->sectnum < kMaxSectors); - ChangeSpriteSect(pSprite->index, pLower->sectnum); + ChangeActorSect(actor, pLower->sectnum); pSprite->x += pLower->x-pUpper->x; pSprite->y += pLower->y-pUpper->y; int z2; @@ -207,9 +208,9 @@ int CheckLink(spritetype *pSprite) return pUpper->type; } } - if (nLower >= 0) + if (aLower) { - spritetype *pLower = &sprite[nLower]; + spritetype *pLower = &aLower->s(); int z; if (pLower->type == kMarkerLowLink) z = pLower->z; @@ -217,11 +218,11 @@ int CheckLink(spritetype *pSprite) z = getceilzofslope(pSprite->sectnum, pSprite->x, pSprite->y); if (z >= pSprite->z) { - nUpper = pLower->owner; - assert(nUpper >= 0 && nUpper < kMaxSprites); - spritetype *pUpper = &sprite[nUpper]; + aUpper = aLower->GetOwner(); + assert(aUpper); + spritetype *pUpper = &aUpper->s(); assert(pUpper->sectnum >= 0 && pUpper->sectnum < kMaxSectors); - ChangeSpriteSect(pSprite->index, pUpper->sectnum); + ChangeActorSect(actor, pUpper->sectnum); pSprite->x += pUpper->x-pLower->x; pSprite->y += pUpper->y-pLower->y; int z2;