From 9343e3f9c4a2bdcecd9a43504303d4bf0e9f4e3a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 24 Nov 2021 00:35:46 +0100 Subject: [PATCH] - handle most cansee calls. --- source/games/blood/src/ai.cpp | 24 ++++++++++++------------ source/games/blood/src/aibat.cpp | 11 +++++------ source/games/blood/src/aibeast.cpp | 6 +++--- source/games/blood/src/aiboneel.cpp | 11 +++++------ source/games/blood/src/aiburn.cpp | 2 +- source/games/blood/src/aicaleb.cpp | 4 ++-- source/games/blood/src/aicerber.cpp | 10 +++++----- source/games/blood/src/aicult.cpp | 4 ++-- source/games/blood/src/aigarg.cpp | 8 ++++---- source/games/blood/src/aighost.cpp | 8 ++++---- source/games/blood/src/aigilbst.cpp | 4 ++-- source/games/blood/src/aihand.cpp | 2 +- source/games/blood/src/aihound.cpp | 2 +- source/games/blood/src/aiinnoc.cpp | 2 +- source/games/blood/src/aipod.cpp | 2 +- source/games/blood/src/airat.cpp | 2 +- source/games/blood/src/aispid.cpp | 2 +- source/games/blood/src/aitchern.cpp | 10 +++++----- source/games/blood/src/aiunicult.cpp | 10 +++++----- source/games/blood/src/aizomba.cpp | 8 ++++---- source/games/blood/src/aizombf.cpp | 2 +- source/games/blood/src/nnexts.cpp | 4 ++-- 22 files changed, 68 insertions(+), 70 deletions(-) diff --git a/source/games/blood/src/ai.cpp b/source/games/blood/src/ai.cpp index 464f9a926..cc7317945 100644 --- a/source/games/blood/src/ai.cpp +++ b/source/games/blood/src/ai.cpp @@ -148,12 +148,12 @@ bool CanMove(DBloodActor* actor, DBloodActor* target, int nAngle, int nRange) } x += MulScale(nRange, Cos(nAngle), 30); y += MulScale(nRange, Sin(nAngle), 30); - int nSector = pSprite->sectnum; - assert(validSectorIndex(nSector)); - if (!FindSector(x, y, z, &nSector)) + auto pSector = pSprite->sector(); + assert(pSector); + if (!FindSector(x, y, z, &pSector)) return false; - int floorZ = getflorzofslope(nSector, x, y); - auto pXSector = sector[nSector].hasX()? §or[nSector].xs() : nullptr; + int floorZ = getflorzofslopeptr(pSector, x, y); + auto pXSector = pSector->hasX()? &pSector->xs() : nullptr; bool Underwater = 0; bool Water = 0; bool Depth = 0; @@ -164,11 +164,11 @@ bool CanMove(DBloodActor* actor, DBloodActor* target, int nAngle, int nRange) Underwater = 1; if (pXSector->Depth) Depth = 1; - if (sector[nSector].type == kSectorDamage || pXSector->damageType > 0) + if (pSector->type == kSectorDamage || pXSector->damageType > 0) Crusher = 1; } - auto Upper = getUpperLink(nSector); - auto Lower = getLowerLink(nSector); + auto Upper = pSector->upperLink; + auto Lower = pSector->lowerLink; if (Upper != nullptr) { if (Upper->s().type == kMarkerUpWater || Upper->s().type == kMarkerUpGoo) @@ -1536,13 +1536,13 @@ void aiThinkTarget(DBloodActor* actor) int x = pPlayer->pSprite->x; int y = pPlayer->pSprite->y; int z = pPlayer->pSprite->z; - int nSector = pPlayer->pSprite->sectnum; + auto pSector = pPlayer->pSprite->sector(); int dx = x - pSprite->x; int dy = y - pSprite->y; int nDist = approxDist(dx, dy); if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist) continue; - if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sectnum)) + if (!cansee(x, y, z, pSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sector())) continue; int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; @@ -1584,13 +1584,13 @@ void aiLookForTarget(DBloodActor* actor) int x = pPlayer->pSprite->x; int y = pPlayer->pSprite->y; int z = pPlayer->pSprite->z; - int nSector = pPlayer->pSprite->sectnum; + auto pSector = pPlayer->pSprite->sector(); int dx = x - pSprite->x; int dy = y - pSprite->y; int nDist = approxDist(dx, dy); if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist) continue; - if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sectnum)) + if (!cansee(x, y, z, pSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sector())) continue; int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) diff --git a/source/games/blood/src/aibat.cpp b/source/games/blood/src/aibat.cpp index 6633b100c..d075bd52d 100644 --- a/source/games/blood/src/aibat.cpp +++ b/source/games/blood/src/aibat.cpp @@ -104,13 +104,13 @@ static void batThinkTarget(DBloodActor* actor) int x = pPlayer->pSprite->x; int y = pPlayer->pSprite->y; int z = pPlayer->pSprite->z; - int nSector = pPlayer->pSprite->sectnum; + auto pSector = pPlayer->pSprite->sector(); int dx = x - pSprite->x; int dy = y - pSprite->y; int nDist = approxDist(dx, dy); if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist) continue; - if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sectnum)) + if (!cansee(x, y, z, pSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sector())) continue; int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) @@ -182,7 +182,7 @@ static void batThinkPonder(DBloodActor* actor) int height2 = (getDudeInfo(pTarget->type)->eyeHeight * pTarget->yrepeat) << 2; int top, bottom; GetActorExtents(actor, &top, &bottom); - if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) + if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector())) { aiSetTarget(actor, actor->GetTarget()); if (height2 - height < 0x3000 && nDist < 0x1800 && nDist > 0xc00 && abs(nDeltaAngle) < 85) @@ -295,7 +295,7 @@ static void batThinkChase(DBloodActor* actor) int height2 = (pDudeInfo->eyeHeight * pTarget->yrepeat) << 2; int top, bottom; GetActorExtents(actor, &top, &bottom); - if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) + if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector())) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { @@ -425,7 +425,6 @@ void batMoveToCeil(DBloodActor* actor) int x = pSprite->x; int y = pSprite->y; int z = pSprite->z; - int nSector = pSprite->sectnum; if (z - pXSprite->targetZ < 0x1000) { DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats; @@ -434,7 +433,7 @@ void batMoveToCeil(DBloodActor* actor) aiNewState(actor, &batIdle); } else - aiSetTarget(actor, x, y, sector[nSector].ceilingz); + aiSetTarget(actor, x, y, pSprite->sector()->ceilingz); } END_BLD_NS diff --git a/source/games/blood/src/aibeast.cpp b/source/games/blood/src/aibeast.cpp index 93969f99f..a13511161 100644 --- a/source/games/blood/src/aibeast.cpp +++ b/source/games/blood/src/aibeast.cpp @@ -88,7 +88,7 @@ void StompSeqCallback(int, DBloodActor* actor1) int y = pSprite->y; int z = pSprite->z; int vc = 400; - int nSector = pSprite->sectnum; + auto nSector = pSprite->sectnum; int v1c = 5 + 2 * gGameOptions.nDifficulty; int v10 = 25 + 30 * gGameOptions.nDifficulty; const bool newSectCheckMethod = !cl_bloodvanillaenemies && !VanillaMode(); // use new sector checking logic @@ -250,7 +250,7 @@ static void beastThinkChase(DBloodActor* actor) { int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2; - if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) + if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector())) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { @@ -385,7 +385,7 @@ static void beastThinkSwimChase(DBloodActor* actor) int height = pDudeInfo->eyeHeight + pSprite->z; int top, bottom; GetActorExtents(actor, &top, &bottom); - if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) + if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector())) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { diff --git a/source/games/blood/src/aiboneel.cpp b/source/games/blood/src/aiboneel.cpp index 6308e5318..895d7a912 100644 --- a/source/games/blood/src/aiboneel.cpp +++ b/source/games/blood/src/aiboneel.cpp @@ -117,13 +117,13 @@ static void eelThinkTarget(DBloodActor* actor) int x = pPlayer->pSprite->x; int y = pPlayer->pSprite->y; int z = pPlayer->pSprite->z; - int nSector = pPlayer->pSprite->sectnum; + auto pSector = pPlayer->pSprite->sector(); int dx = x - pSprite->x; int dy = y - pSprite->y; int nDist = approxDist(dx, dy); if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist) continue; - if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sectnum)) + if (!cansee(x, y, z, pSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sector())) continue; int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) @@ -196,7 +196,7 @@ static void eelThinkPonder(DBloodActor* actor) int height2 = (getDudeInfo(pTarget->type)->eyeHeight * pTarget->yrepeat) << 2; int top, bottom; GetActorExtents(actor, &top, &bottom); - if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) + if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector())) { aiSetTarget(actor, actor->GetTarget()); if (height2 - height < -0x2000 && nDist < 0x1800 && nDist > 0xc00 && abs(nDeltaAngle) < 85) @@ -308,7 +308,7 @@ static void eelThinkChase(DBloodActor* actor) GetActorExtents(actor, &top, &bottom); int top2, bottom2; GetSpriteExtents(pTarget, &top2, &bottom2); - if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) + if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector())) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { @@ -428,7 +428,6 @@ void eelMoveToCeil(DBloodActor* actor) int x = pSprite->x; int y = pSprite->y; int z = pSprite->z; - int nSector = pSprite->sectnum; if (z - pXSprite->targetZ < 0x1000) { DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats; @@ -437,7 +436,7 @@ void eelMoveToCeil(DBloodActor* actor) aiNewState(actor, &eelIdle); } else - aiSetTarget(actor, x, y, sector[nSector].ceilingz); + aiSetTarget(actor, x, y, pSprite->sector()->ceilingz); } END_BLD_NS diff --git a/source/games/blood/src/aiburn.cpp b/source/games/blood/src/aiburn.cpp index 6fecf03f7..c6cec6e5a 100644 --- a/source/games/blood/src/aiburn.cpp +++ b/source/games/blood/src/aiburn.cpp @@ -199,7 +199,7 @@ static void burnThinkChase(DBloodActor* actor) { int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2; - if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) + if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector())) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { diff --git a/source/games/blood/src/aicaleb.cpp b/source/games/blood/src/aicaleb.cpp index 0a44a080c..167e4a2dc 100644 --- a/source/games/blood/src/aicaleb.cpp +++ b/source/games/blood/src/aicaleb.cpp @@ -158,7 +158,7 @@ static void calebThinkChase(DBloodActor* actor) { int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2; - if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) + if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector())) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { @@ -261,7 +261,7 @@ static void calebThinkSwimChase(DBloodActor* actor) int height = pDudeInfo->eyeHeight + pSprite->z; int top, bottom; GetActorExtents(actor, &top, &bottom); - if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) + if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector())) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { diff --git a/source/games/blood/src/aicerber.cpp b/source/games/blood/src/aicerber.cpp index 96466728f..60f9b8575 100644 --- a/source/games/blood/src/aicerber.cpp +++ b/source/games/blood/src/aicerber.cpp @@ -127,7 +127,7 @@ void cerberusBurnSeqCallback(int, DBloodActor* actor) if (abs(nDeltaAngle) <= tt1.at8) { int tz = pSprite2->z - pSprite->z; - if (cansee(x, y, z, pSprite->sectnum, x2, y2, z2, pSprite2->sectnum)) + if (cansee(x, y, z, pSprite->sector(), x2, y2, z2, pSprite2->sector())) { nClosest = nDist2; aim.dx = bcos(nAngle); @@ -208,7 +208,7 @@ void cerberusBurnSeqCallback2(int, DBloodActor* actor) DUDEINFO* pDudeInfo2 = getDudeInfo(pSprite2->type); int height = (pDudeInfo2->aimHeight * pSprite2->yrepeat) << 2; int tz = (z2 - height) - z; - if (cansee(x, y, z, pSprite->sectnum, x2, y2, z2, pSprite2->sectnum)) + if (cansee(x, y, z, pSprite->sector(), x2, y2, z2, pSprite2->sector())) { nClosest = nDist2; aim.dx = bcos(nAngle); @@ -272,13 +272,13 @@ static void cerberusThinkTarget(DBloodActor* actor) int x = pPlayer->pSprite->x; int y = pPlayer->pSprite->y; int z = pPlayer->pSprite->z; - int nSector = pPlayer->pSprite->sectnum; + auto pSector = pPlayer->pSprite->sector(); int dx = x - pSprite->x; int dy = y - pSprite->y; int nDist = approxDist(dx, dy); if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist) continue; - if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sectnum)) + if (!cansee(x, y, z, pSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sector())) continue; int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) @@ -388,7 +388,7 @@ static void cerberusThinkChase(DBloodActor* actor) { int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2; - if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) + if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector())) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { aiSetTarget(actor, actor->GetTarget()); diff --git a/source/games/blood/src/aicult.cpp b/source/games/blood/src/aicult.cpp index 6ea02852e..189e46ae4 100644 --- a/source/games/blood/src/aicult.cpp +++ b/source/games/blood/src/aicult.cpp @@ -179,7 +179,7 @@ void sub_68230(int, DBloodActor* actor) static bool TargetNearExplosion(spritetype* pSprite) { - BloodSectIterator it(pSprite->sectnum); + BloodSectIterator it(pSprite->sector()); while (auto actor = it.Next()) { if (actor->s().type == kThingArmedTNTStick || actor->s().statnum == kStatExplosion) @@ -284,7 +284,7 @@ static void cultThinkChase(DBloodActor* actor) { int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2; - if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) + if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector())) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { diff --git a/source/games/blood/src/aigarg.cpp b/source/games/blood/src/aigarg.cpp index c0167f5b9..2dff4e658 100644 --- a/source/games/blood/src/aigarg.cpp +++ b/source/games/blood/src/aigarg.cpp @@ -156,7 +156,7 @@ void BlastSSeqCallback(int, DBloodActor* actor) if (abs(nDeltaAngle) <= tt.at8) { int tz = pSprite2->z - pSprite->z; - if (cansee(x, y, z, pSprite->sectnum, x2, y2, z2, pSprite2->sectnum)) + if (cansee(x, y, z, pSprite->sector(), x2, y2, z2, pSprite2->sector())) { nClosest = nDist2; aim.dx = bcos(nAngle); @@ -229,13 +229,13 @@ static void gargThinkTarget(DBloodActor* actor) int x = pPlayer->pSprite->x; int y = pPlayer->pSprite->y; int z = pPlayer->pSprite->z; - int nSector = pPlayer->pSprite->sectnum; + auto pSector = pPlayer->pSprite->sector(); int dx = x - pSprite->x; int dy = y - pSprite->y; int nDist = approxDist(dx, dy); if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist) continue; - if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sectnum)) + if (!cansee(x, y, z, pSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sector())) continue; int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) @@ -382,7 +382,7 @@ static void gargThinkChase(DBloodActor* actor) int height2 = (pDudeInfo->eyeHeight * pTarget->yrepeat) << 2; int top, bottom; GetActorExtents(actor, &top, &bottom); - if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) + if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector())) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { diff --git a/source/games/blood/src/aighost.cpp b/source/games/blood/src/aighost.cpp index d27adcd7e..677a931e7 100644 --- a/source/games/blood/src/aighost.cpp +++ b/source/games/blood/src/aighost.cpp @@ -142,7 +142,7 @@ void ghostBlastSeqCallback(int, DBloodActor* actor) if (abs(nDeltaAngle) <= tt.at8) { int tz = pSprite2->z - pSprite->z; - if (cansee(x, y, z, pSprite->sectnum, x2, y2, z2, pSprite2->sectnum)) + if (cansee(x, y, z, pSprite->sector(), x2, y2, z2, pSprite2->sector())) { nClosest = nDist2; aim.dx = bcos(nAngle); @@ -209,13 +209,13 @@ static void ghostThinkTarget(DBloodActor* actor) int x = pPlayer->pSprite->x; int y = pPlayer->pSprite->y; int z = pPlayer->pSprite->z; - int nSector = pPlayer->pSprite->sectnum; + auto pSector = pPlayer->pSprite->sector(); int dx = x - pSprite->x; int dy = y - pSprite->y; int nDist = approxDist(dx, dy); if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist) continue; - if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sectnum)) + if (!cansee(x, y, z, pSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sector())) continue; int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) @@ -362,7 +362,7 @@ static void ghostThinkChase(DBloodActor* actor) int height2 = (pDudeInfo->eyeHeight * pTarget->yrepeat) << 2; int top, bottom; GetActorExtents(actor, &top, &bottom); - if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) + if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector())) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { diff --git a/source/games/blood/src/aigilbst.cpp b/source/games/blood/src/aigilbst.cpp index 444895312..887d4b546 100644 --- a/source/games/blood/src/aigilbst.cpp +++ b/source/games/blood/src/aigilbst.cpp @@ -147,7 +147,7 @@ static void gillThinkChase(DBloodActor* actor) { int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2; - if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) + if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector())) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { @@ -250,7 +250,7 @@ static void gillThinkSwimChase(DBloodActor* actor) int height = pDudeInfo->eyeHeight + pSprite->z; int top, bottom; GetActorExtents(actor, &top, &bottom); - if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) + if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector())) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { diff --git a/source/games/blood/src/aihand.cpp b/source/games/blood/src/aihand.cpp index 4d2c2e4fc..4c9fc9535 100644 --- a/source/games/blood/src/aihand.cpp +++ b/source/games/blood/src/aihand.cpp @@ -110,7 +110,7 @@ static void handThinkChase(DBloodActor* actor) { int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2; - if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) + if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector())) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { diff --git a/source/games/blood/src/aihound.cpp b/source/games/blood/src/aihound.cpp index 83d9ccb6d..6e070a7da 100644 --- a/source/games/blood/src/aihound.cpp +++ b/source/games/blood/src/aihound.cpp @@ -132,7 +132,7 @@ static void houndThinkChase(DBloodActor* actor) { int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2; - if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) + if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector())) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { diff --git a/source/games/blood/src/aiinnoc.cpp b/source/games/blood/src/aiinnoc.cpp index c1cb0b370..ecb31e926 100644 --- a/source/games/blood/src/aiinnoc.cpp +++ b/source/games/blood/src/aiinnoc.cpp @@ -96,7 +96,7 @@ static void innocThinkChase(DBloodActor* actor) { int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2; - if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) + if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector())) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { diff --git a/source/games/blood/src/aipod.cpp b/source/games/blood/src/aipod.cpp index 8a1fad0f6..d35154f59 100644 --- a/source/games/blood/src/aipod.cpp +++ b/source/games/blood/src/aipod.cpp @@ -212,7 +212,7 @@ static void aiPodChase(DBloodActor* actor) { int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2; - if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) + if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector())) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { diff --git a/source/games/blood/src/airat.cpp b/source/games/blood/src/airat.cpp index 1c6dec930..4475b814e 100644 --- a/source/games/blood/src/airat.cpp +++ b/source/games/blood/src/airat.cpp @@ -106,7 +106,7 @@ static void ratThinkChase(DBloodActor* actor) { int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2; - if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) + if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector())) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { diff --git a/source/games/blood/src/aispid.cpp b/source/games/blood/src/aispid.cpp index aa03c1156..483c198e8 100644 --- a/source/games/blood/src/aispid.cpp +++ b/source/games/blood/src/aispid.cpp @@ -220,7 +220,7 @@ static void spidThinkChase(DBloodActor* actor) int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2; - if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) { + if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector())) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { aiSetTarget(actor, actor->GetTarget()); diff --git a/source/games/blood/src/aitchern.cpp b/source/games/blood/src/aitchern.cpp index 7d5e6ebb8..13fc2197e 100644 --- a/source/games/blood/src/aitchern.cpp +++ b/source/games/blood/src/aitchern.cpp @@ -109,7 +109,7 @@ void sub_71BD4(int, DBloodActor* actor) if (abs(nDeltaAngle) <= tt.at8) { int tz = pSprite2->z - pSprite->z; - if (cansee(x, y, z, pSprite->sectnum, x2, y2, z2, pSprite2->sectnum)) + if (cansee(x, y, z, pSprite->sector(), x2, y2, z2, pSprite2->sector())) { nClosest = nDist2; aim.dx = bcos(nAngle); @@ -183,7 +183,7 @@ void sub_720AC(int, DBloodActor* actor) if (abs(nDeltaAngle) <= tt.at8) { int tz = pSprite2->z - pSprite->z; - if (cansee(x, y, z, pSprite->sectnum, x2, y2, z2, pSprite2->sectnum)) + if (cansee(x, y, z, pSprite->sector(), x2, y2, z2, pSprite2->sector())) { nClosest = nDist2; aim.dx = bcos(nAngle); @@ -237,13 +237,13 @@ static void sub_725A4(DBloodActor* actor) int x = pPlayer->pSprite->x; int y = pPlayer->pSprite->y; int z = pPlayer->pSprite->z; - int nSector = pPlayer->pSprite->sectnum; + auto pSector = pPlayer->pSprite->sector(); int dx = x - pSprite->x; int dy = y - pSprite->y; int nDist = approxDist(dx, dy); if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist) continue; - if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sectnum)) + if (!cansee(x, y, z, pSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sector())) continue; int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) @@ -320,7 +320,7 @@ static void sub_72934(DBloodActor* actor) { int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2; - if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) + if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector())) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { diff --git a/source/games/blood/src/aiunicult.cpp b/source/games/blood/src/aiunicult.cpp index 7abaf5f53..f5634a174 100644 --- a/source/games/blood/src/aiunicult.cpp +++ b/source/games/blood/src/aiunicult.cpp @@ -544,8 +544,8 @@ static void unicultThinkChase(DBloodActor* actor) int losAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int eyeAboveZ = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2; - if (dist > pDudeInfo->seeDist || !cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, - pSprite->x, pSprite->y, pSprite->z - eyeAboveZ, pSprite->sectnum)) + if (dist > pDudeInfo->seeDist || !cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), + pSprite->x, pSprite->y, pSprite->z - eyeAboveZ, pSprite->sector())) { if (spriteIsUnderwater(actor, false)) aiGenDudeNewState(actor, &genDudeSearchW); else aiGenDudeNewState(actor, &genDudeSearchL); @@ -606,8 +606,8 @@ static void unicultThinkChase(DBloodActor* actor) } int ldist = aiFightGetTargetDist(targetactor, pDudeInfo, actLeech); - if (ldist > 3 || !cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, - pLeech->x, pLeech->y, pLeech->z, pLeech->sectnum) || actLeech->GetTarget() == nullptr) + if (ldist > 3 || !cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), + pLeech->x, pLeech->y, pLeech->z, pLeech->sector()) || actLeech->GetTarget() == nullptr) { aiGenDudeNewState(actor, &genDudeThrow2); genDudeThrow2.nextState = &genDudeDodgeShortL; @@ -1845,7 +1845,7 @@ void dudeLeechOperate(DBloodActor* actor, const EVENT& event) int x = pTarget->x; int y = pTarget->y; int z = pTarget->z; int nDist = approxDist(x - pSprite->x, y - pSprite->y); - if (nDist != 0 && cansee(pSprite->x, pSprite->y, top, pSprite->sectnum, x, y, z, pTarget->sectnum)) + if (nDist != 0 && cansee(pSprite->x, pSprite->y, top, pSprite->sector(), x, y, z, pTarget->sector())) { int t = DivScale(nDist, 0x1aaaaa, 12); x += (actTarget->xvel * t) >> 12; diff --git a/source/games/blood/src/aizomba.cpp b/source/games/blood/src/aizomba.cpp index 031c2d857..c01d5f02d 100644 --- a/source/games/blood/src/aizomba.cpp +++ b/source/games/blood/src/aizomba.cpp @@ -141,7 +141,7 @@ static void zombaThinkChase(DBloodActor* actor) { int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2; - if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) + if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector())) { if (abs(nDeltaAngle) <= pDudeInfo->periphery) { @@ -188,7 +188,7 @@ static void zombaThinkPonder(DBloodActor* actor) { int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2; - if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) + if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector())) { if (abs(nDeltaAngle) <= pDudeInfo->periphery) { @@ -223,13 +223,13 @@ static void myThinkTarget(DBloodActor* actor) int x = pPlayer->pSprite->x; int y = pPlayer->pSprite->y; int z = pPlayer->pSprite->z; - int nSector = pPlayer->pSprite->sectnum; + auto pSector = pPlayer->pSprite->sector(); int dx = x - pSprite->x; int dy = y - pSprite->y; int nDist = approxDist(dx, dy); if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist) continue; - if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sectnum)) + if (!cansee(x, y, z, pSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sector())) continue; int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) diff --git a/source/games/blood/src/aizombf.cpp b/source/games/blood/src/aizombf.cpp index 2c1f9d419..1e5f304ee 100644 --- a/source/games/blood/src/aizombf.cpp +++ b/source/games/blood/src/aizombf.cpp @@ -138,7 +138,7 @@ static void zombfThinkChase(DBloodActor* actor) { int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024; int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2; - if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) + if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector())) { if (abs(nDeltaAngle) <= pDudeInfo->periphery) { diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index 3eb671e9e..7c8e7cd6e 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -8123,10 +8123,10 @@ void aiPatrolAlarmLite(DBloodActor* actor, DBloodActor* targetactor) int eaz2 = (getDudeInfo(pTarget->type)->eyeHeight * pTarget->yrepeat) << 2; int nDist = approxDist(pDude->x - pSprite->x, pDude->y - pSprite->y); - if (nDist >= kPatrolAlarmSeeDist || !cansee(pSprite->x, pSprite->y, zt1, pSprite->sectnum, pDude->x, pDude->y, pDude->z - eaz2, pDude->sectnum)) + if (nDist >= kPatrolAlarmSeeDist || !cansee(pSprite->x, pSprite->y, zt1, pSprite->sector(), pDude->x, pDude->y, pDude->z - eaz2, pDude->sector())) { nDist = approxDist(pDude->x - pTarget->x, pDude->y - pTarget->y); - if (nDist >= kPatrolAlarmSeeDist || !cansee(pTarget->x, pTarget->y, zt2, pTarget->sectnum, pDude->x, pDude->y, pDude->z - eaz2, pDude->sectnum)) + if (nDist >= kPatrolAlarmSeeDist || !cansee(pTarget->x, pTarget->y, zt2, pTarget->sector(), pDude->x, pDude->y, pDude->z - eaz2, pDude->sector())) continue; }