From c182900425243203295896e23b8da3fc1871d2d4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 19 Nov 2021 15:46:20 +0100 Subject: [PATCH] - cleanup of trTriggerWall's API. --- source/games/blood/src/actor.cpp | 19 +++++++++---------- source/games/blood/src/nnexts.cpp | 3 +-- source/games/blood/src/player.cpp | 5 +++-- source/games/blood/src/triggers.cpp | 1 + source/games/blood/src/triggers.h | 4 ---- 5 files changed, 14 insertions(+), 18 deletions(-) diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index 90c487a70..9a081d23f 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -4909,7 +4909,7 @@ void MoveDude(DBloodActor* actor) if (pHitWall->extra > 0) pHitXWall = &pHitWall->xw(); if (pDudeInfo->lockOut && pHitXWall && pHitXWall->triggerPush && !pHitXWall->key && !pHitXWall->dudeLockout && !pHitXWall->state && !pHitXWall->busy && !pPlayer) - trTriggerWall(nHitWall, pHitXWall, kCmdWallPush); + trTriggerWall(pHitWall, kCmdWallPush); if (pHitWall->nextsector != -1) { @@ -5396,12 +5396,12 @@ int MoveMissile(DBloodActor* actor) if (cliptype == 4) { walltype* pWall = &wall[gHitInfo.hitwall]; - if (pWall->extra > 0) + if (pWall->hasX()) { XWALL* pXWall = &pWall->xw(); if (pXWall->triggerVector) { - trTriggerWall(gHitInfo.hitwall, pXWall, kCmdWallImpact); + trTriggerWall(pWall, kCmdWallImpact); if (!(pWall->cstat & 64)) { cliptype = -1; @@ -5938,8 +5938,7 @@ static void actCheckExplosion() for (auto& nWall : affectedXWalls) { - XWALL* pXWall = &wall[nWall].xw(); - trTriggerWall(nWall, pXWall, kCmdWallImpact); + trTriggerWall(&wall[nWall], kCmdWallImpact); } BloodStatIterator it1(kStatDude); @@ -6949,12 +6948,12 @@ void actFireVector(DBloodActor* shooter, int a2, int a3, int a4, int a5, int a6, { int nWall = gHitInfo.hitwall; assert(nWall >= 0 && nWall < kMaxWalls); - nSurf = surfType[wall[nWall].overpicnum]; - if (wall[nWall].hasX()) + auto pWall = &wall[nWall]; + nSurf = surfType[pWall->overpicnum]; + if (pWall->hasX()) { - XWALL* pXWall = &wall->xw(); - if (pXWall->triggerVector) - trTriggerWall(nWall, pXWall, kCmdWallImpact); + if (pWall->xw().triggerVector) + trTriggerWall(pWall, kCmdWallImpact); } break; } diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index 35365709b..6c7960c61 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -461,8 +461,7 @@ void nnExtTriggerObject(int objType, int objIndex, DBloodActor* objActor, int co trTriggerSector(objIndex, &xsector[sector[objIndex].extra], command); break; case OBJ_WALL: - if (wall[objIndex].hasX()) - trTriggerWall(objIndex, &wall[objIndex].xw(), command); + trTriggerWall(&wall[objIndex], command); break; case OBJ_SPRITE: if (!objActor || !objActor->hasX()) break; diff --git a/source/games/blood/src/player.cpp b/source/games/blood/src/player.cpp index 2bfafdbc9..245f470f3 100644 --- a/source/games/blood/src/player.cpp +++ b/source/games/blood/src/player.cpp @@ -1531,7 +1531,8 @@ void ProcessInput(PLAYER *pPlayer) break; case 0: { - XWALL *pXWall = &xwall[a3]; + auto pWall = &wall[a2]; + auto pXWall = &pWall->xw(); int key = pXWall->key; if (pXWall->locked && pPlayer == gMe) { @@ -1542,7 +1543,7 @@ void ProcessInput(PLAYER *pPlayer) sndStartSample(snd, 255, 2, 0); } if (!key || pPlayer->hasKey[key]) - trTriggerWall(a2, pXWall, kCmdWallPush); + trTriggerWall(pWall, kCmdWallPush); else if (pPlayer == gMe) { viewSetMessage(GStrings("TXTB_KEY")); diff --git a/source/games/blood/src/triggers.cpp b/source/games/blood/src/triggers.cpp index b2dfb7073..eb5f5d1ed 100644 --- a/source/games/blood/src/triggers.cpp +++ b/source/games/blood/src/triggers.cpp @@ -1738,6 +1738,7 @@ void trTriggerSector(unsigned int nSector, XSECTOR *pXSector, int command) { void trTriggerWall(walltype* pWall, int command) { + if (!pWall->hasX()) return; auto pXWall = &pWall->xw(); if (!pXWall->locked && !pXWall->isTriggered) { diff --git a/source/games/blood/src/triggers.h b/source/games/blood/src/triggers.h index a04197d41..bf3712fc5 100644 --- a/source/games/blood/src/triggers.h +++ b/source/games/blood/src/triggers.h @@ -56,10 +56,6 @@ extern int gBusyCount; void trTriggerSector(unsigned int nSector, XSECTOR *pXSector, int command); void trMessageSector(unsigned int nSector, EVENT event); void trTriggerWall(walltype*, int command); -inline void trTriggerWall(unsigned int nWall, XWALL* pXWall, int command) -{ - trTriggerWall(&wall[nWall], command); -} void trMessageWall(unsigned int nWall, EVENT event); void trTriggerSprite(DBloodActor* actor, int command); void trMessageSprite(DBloodActor* actor, EVENT event);