diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index fd28562cc..2bac19642 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -4907,7 +4907,7 @@ void MoveDude(DBloodActor* actor) XSECTOR* pHitXSector = pHitSector->hasX()? &pHitSector->xs() : nullptr; if (pDudeInfo->lockOut && pHitXSector && pHitXSector->Wallpush && !pHitXSector->Key && !pHitXSector->dudeLockout && !pHitXSector->state && !pHitXSector->busy && !pPlayer) - trTriggerSector(pHitWall->nextsector, pHitXSector, kCmdSectorPush); + trTriggerSector(pHitSector, kCmdSectorPush); if (top < pHitSector->ceilingz || bottom > pHitSector->floorz) { @@ -4935,14 +4935,14 @@ void MoveDude(DBloodActor* actor) XSECTOR* pXOldSector = pOldSector->hasX()? &pOldSector->xs() : nullptr; if (pXOldSector && pXOldSector->Exit && (pPlayer || !pXOldSector->dudeLockout)) - trTriggerSector(pSprite->sectnum, pXOldSector, kCmdSectorExit); + trTriggerSector(pOldSector, kCmdSectorExit); ChangeActorSect(actor, nSector); if (pXSector && pXSector->Enter && (pPlayer || !pXSector->dudeLockout)) { if (pSector->type == kSectorTeleport) pXSector->actordata = actor; - trTriggerSector(nSector, pXSector, kCmdSectorEnter); + trTriggerSector(pSector, kCmdSectorEnter); } nSector = pSprite->sectnum; diff --git a/source/games/blood/src/callback.cpp b/source/games/blood/src/callback.cpp index 4dc35bc80..dae802876 100644 --- a/source/games/blood/src/callback.cpp +++ b/source/games/blood/src/callback.cpp @@ -351,11 +351,14 @@ void EnemyBubble(DBloodActor* actor, int) // 11 void CounterCheck(DBloodActor*, int nSector) // 12 { if (!validSectorIndex(nSector)) return; - if (sector[nSector].type != kSectorCounter) return; - if (sector[nSector].extra <= 0) return; + auto pSector = §or[nSector]; + if (pSector->type != kSectorCounter) return; + if (pSector->extra <= 0) return; - XSECTOR *pXSector = &xsector[sector[nSector].extra]; - int nReq = pXSector->waitTimeA; int nType = pXSector->data; int nCount = 0; + XSECTOR *pXSector = &xsector[pSector->extra]; + int nReq = pXSector->waitTimeA; + int nType = pXSector->data; + int nCount = 0; if (!nType || !nReq) return; BloodSectIterator it(nSector); @@ -369,7 +372,7 @@ void CounterCheck(DBloodActor*, int nSector) // 12 return; } else { //pXSector->waitTimeA = 0; //do not reset necessary objects counter to zero - trTriggerSector(nSector, pXSector, kCmdOn); + trTriggerSector(pSector, kCmdOn); pXSector->locked = 1; //lock sector, so it can be opened again later } } diff --git a/source/games/blood/src/eventq.cpp b/source/games/blood/src/eventq.cpp index da2c9d24d..e4548eaeb 100644 --- a/source/games/blood/src/eventq.cpp +++ b/source/games/blood/src/eventq.cpp @@ -48,7 +48,6 @@ static std::multiset queue; static int GetBucketChannel(const RXBUCKET* pBucket) { - int nXIndex; switch (pBucket->type) { case SS_SECTOR: diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index 752cc3b84..4dde1a3a2 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -457,8 +457,7 @@ void nnExtTriggerObject(int objType, int objIndex, DBloodActor* objActor, int co switch (objType) { case OBJ_SECTOR: - if (!xsectRangeIsFine(sector[objIndex].extra)) break; - trTriggerSector(objIndex, &xsector[sector[objIndex].extra], command); + trTriggerSector(§or[objIndex], command); break; case OBJ_WALL: trTriggerWall(&wall[objIndex], command); @@ -3038,7 +3037,7 @@ void useTeleportTarget(DBloodActor* sourceactor, DBloodActor* actor) { if (pXSector->Enter && (pPlayer || (isDude && !pXSector->dudeLockout))) - trTriggerSector(pSource->sectnum, pXSector, kCmdSectorEnter); + trTriggerSector(pSource->sector(), kCmdSectorEnter); if (pXSector->Underwater) { diff --git a/source/games/blood/src/player.cpp b/source/games/blood/src/player.cpp index 206926f04..7eeb7fe36 100644 --- a/source/games/blood/src/player.cpp +++ b/source/games/blood/src/player.cpp @@ -1518,7 +1518,7 @@ void ProcessInput(PLAYER *pPlayer) sndStartSample(snd, 255, 2, 0); } if (!key || pPlayer->hasKey[key]) - trTriggerSector(a2, pXSector, kCmdSpritePush); + trTriggerSector(§or[a2], kCmdSpritePush); else if (pPlayer == gMe) { viewSetMessage(GStrings("TXTB_KEY")); @@ -2050,7 +2050,7 @@ int playerDamageSprite(DBloodActor* source, PLAYER *pPlayer, DAMAGE_TYPE nDamage { powerupClear(pPlayer); if (nXSector > 0 && xsector[nXSector].Exit) - trTriggerSector(pSprite->sectnum, &xsector[nXSector], kCmdSectorExit); + trTriggerSector(pSprite->sector(), kCmdSectorExit); pSprite->flags |= 7; for (int p = connecthead; p >= 0; p = connectpoint2[p]) { diff --git a/source/games/blood/src/triggers.cpp b/source/games/blood/src/triggers.cpp index eb5f5d1ed..032bb56be 100644 --- a/source/games/blood/src/triggers.cpp +++ b/source/games/blood/src/triggers.cpp @@ -1717,20 +1717,21 @@ void LinkWall(int nWall, XWALL *pXWall, EVENT event) SetWallState(nWall, pXWall, FixedToInt(nBusy)); } -void trTriggerSector(unsigned int nSector, XSECTOR *pXSector, int command) { - assert(nSector < (unsigned int)numsectors); +void trTriggerSector(sectortype* pSector, int command) +{ + auto pXSector = &pSector->xs(); if (!pXSector->locked && !pXSector->isTriggered) { if (pXSector->triggerOnce) pXSector->isTriggered = 1; if (pXSector->decoupled && pXSector->txID > 0) - evSendSector(nSector,pXSector->txID, (COMMAND_ID)pXSector->command); + evSendSector(sectnum(pSector),pXSector->txID, (COMMAND_ID)pXSector->command); else { EVENT event; event.cmd = command; - OperateSector(nSector, pXSector, event); + OperateSector(sectnum(pSector), pXSector, event); } } diff --git a/source/games/blood/src/triggers.h b/source/games/blood/src/triggers.h index bf3712fc5..aefb16389 100644 --- a/source/games/blood/src/triggers.h +++ b/source/games/blood/src/triggers.h @@ -53,7 +53,7 @@ struct BUSY { extern BUSY gBusy[kMaxBusyCount]; extern int gBusyCount; -void trTriggerSector(unsigned int nSector, XSECTOR *pXSector, int command); +void trTriggerSector(sectortype *pSector, int command); void trMessageSector(unsigned int nSector, EVENT event); void trTriggerWall(walltype*, int command); void trMessageWall(unsigned int nWall, EVENT event);