From 78d9b781936625a1481057bb2ac115f15696e94f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 22 Nov 2021 22:20:53 +0100 Subject: [PATCH] - most of the rest of the walls. --- source/games/exhumed/src/aistuff.h | 2 +- source/games/exhumed/src/bullet.cpp | 7 ++--- source/games/exhumed/src/exhumedactor.h | 10 +++++++ source/games/exhumed/src/grenade.cpp | 4 +-- source/games/exhumed/src/lion.cpp | 2 +- source/games/exhumed/src/move.cpp | 6 ++--- source/games/exhumed/src/player.cpp | 36 ++++++++++++------------- source/games/exhumed/src/queen.cpp | 4 +-- source/games/exhumed/src/set.cpp | 9 +++---- 9 files changed, 45 insertions(+), 35 deletions(-) diff --git a/source/games/exhumed/src/aistuff.h b/source/games/exhumed/src/aistuff.h index 2e849a8ad..59ead45e3 100644 --- a/source/games/exhumed/src/aistuff.h +++ b/source/games/exhumed/src/aistuff.h @@ -236,7 +236,7 @@ void BuildNear(int x, int y, int walldist, int nSector); int PlotCourseToSprite(DExhumedActor* nSprite1, DExhumedActor* nSprite2); void CheckSectorFloor(int nSector, int z, int *x, int *y); int GetAngleToSprite(DExhumedActor* nSprite1, DExhumedActor* nSprite2); -int GetWallNormal(int nWall); +int GetWallNormal(walltype* nWall); int GetUpAngle(DExhumedActor* nSprite1, int nVal, DExhumedActor* nSprite2, int ecx); void MoveSector(sectortype* pSector, int nAngle, int *nXVel, int *nYVel); Collision AngleChase(DExhumedActor* nSprite, DExhumedActor* nSprite2, int ebx, int ecx, int push1); diff --git a/source/games/exhumed/src/bullet.cpp b/source/games/exhumed/src/bullet.cpp index 1003ff8f7..63bfbe933 100644 --- a/source/games/exhumed/src/bullet.cpp +++ b/source/games/exhumed/src/bullet.cpp @@ -484,10 +484,11 @@ HITSPRITE: } else if (hitwall > -1) { -HITWALL: - if (wall[hitwall].picnum == kEnergy1) + HITWALL: + auto pWall = &wall[hitwall]; + if (pWall->picnum == kEnergy1) { - int nSector =wall[hitwall].nextsector; + int nSector = pWall->nextsector; if (nSector > -1) { int nDamage = BulletInfo[pBullet->nType].nDamage; diff --git a/source/games/exhumed/src/exhumedactor.h b/source/games/exhumed/src/exhumedactor.h index 880fbd838..91170aedd 100644 --- a/source/games/exhumed/src/exhumedactor.h +++ b/source/games/exhumed/src/exhumedactor.h @@ -75,6 +75,16 @@ struct Collision else { index = -1; actor = Actor(value & kHitIndexMask); } return type; } + + walltype* wall() + { + return &::wall[index]; + } + + sectortype* sector() + { + return &::sector[index]; + } }; class DExhumedActor diff --git a/source/games/exhumed/src/grenade.cpp b/source/games/exhumed/src/grenade.cpp index 209a62b21..bdb3be729 100644 --- a/source/games/exhumed/src/grenade.cpp +++ b/source/games/exhumed/src/grenade.cpp @@ -82,7 +82,7 @@ void ThrowGrenade(int nPlayer, int, int, int ecx, int push1) auto nMov = movesprite(pActor, bcos(nAngle) * (pPlayerSprite->clipdist << 3), bsin(nAngle) * (pPlayerSprite->clipdist << 3), ecx, 0, 0, CLIPMASK1); if (nMov.type == kHitWall) { - nAngle = GetWallNormal(nMov.index); + nAngle = GetWallNormal(nMov.wall()); BounceGrenade(pActor, nAngle); } } @@ -330,7 +330,7 @@ void AIGrenade::Tick(RunListEvent* ev) // loc_2CF60: if (nMov.type == kHitWall) { - BounceGrenade(pActor, GetWallNormal(nMov.index)); + BounceGrenade(pActor, GetWallNormal(nMov.wall())); } else if (nMov.type == kHitSprite) { diff --git a/source/games/exhumed/src/lion.cpp b/source/games/exhumed/src/lion.cpp index b4d2571dc..a8643dd2c 100644 --- a/source/games/exhumed/src/lion.cpp +++ b/source/games/exhumed/src/lion.cpp @@ -450,7 +450,7 @@ void AILion::Tick(RunListEvent* ev) if (nMov.type == kHitWall) { pActor->nAction = 7; - pSprite->ang = (GetWallNormal(nMov.index) + 1024) & kAngleMask; + pSprite->ang = (GetWallNormal(nMov.wall()) + 1024) & kAngleMask; pActor->nCount = RandomSize(4); return; } diff --git a/source/games/exhumed/src/move.cpp b/source/games/exhumed/src/move.cpp index d3b7e35eb..c6aae9028 100644 --- a/source/games/exhumed/src/move.cpp +++ b/source/games/exhumed/src/move.cpp @@ -1245,9 +1245,9 @@ Collision AngleChase(DExhumedActor* pActor, DExhumedActor* pActor2, int ebx, int return movesprite(pActor, x >> 2, y >> 2, (z >> 13) + bsin(ecx, -5), 0, 0, nClipType); } -int GetWallNormal(int nWall) +int GetWallNormal(walltype* pWall) { - auto delta = wall[nWall].delta(); + auto delta = pWall->delta(); int nAngle = GetMyAngle(delta.x, delta.y); return (nAngle + 512) & kAngleMask; @@ -1473,7 +1473,7 @@ void AICreatureChunk::Tick(RunListEvent* ev) } else if (nVal.type == kHitWall) { - nAngle = GetWallNormal(nVal.index); + nAngle = GetWallNormal(nVal.wall()); } else { diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index 4ebe533dc..08dee55f1 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -105,22 +105,22 @@ void SetSavePoint(int nPlayer, int x, int y, int z, int nSector, int nAngle) PlayerList[nPlayer].sPlayerSave.nAngle = nAngle; } -void feebtag(int x, int y, int z, int nSector, DExhumedActor **nSprite, int nVal2, int nVal3) +void feebtag(int x, int y, int z, sectortype* pSector, DExhumedActor **nSprite, int nVal2, int nVal3) { *nSprite = nullptr; - int startwall = sector[nSector].wallptr; + auto startwall = pSector->firstWall(); - int nWalls = sector[nSector].wallnum; + int nWalls = pSector->wallnum; int var_20 = nVal2 & 2; int var_14 = nVal2 & 1; while (1) { - if (nSector != -1) + if (pSector != nullptr) { - ExhumedSectIterator it(nSector); + ExhumedSectIterator it(pSector); while (auto pActor = it.Next()) { auto pSprite = &pActor->s(); @@ -158,7 +158,7 @@ void feebtag(int x, int y, int z, int nSector, DExhumedActor **nSprite, int nVal if (nWalls < -1) return; - nSector = wall[startwall].nextsector; + pSector = startwall->nextSector(); startwall++; } } @@ -1019,23 +1019,22 @@ void AIPlayer::Tick(RunListEvent* ev) if (nMove.type == kHitSector || nMove.type == kHitWall) { - int sectnum = 0; + sectortype* sect; int nNormal = 0; if (nMove.type == kHitSector) { - sectnum = nMove.index; + sect = nMove.sector(); // Hm... Normal calculation here was broken. } - else if (nMove.type == kHitWall) + else //if (nMove.type == kHitWall) { - sectnum = wall[nMove.index].nextsector; - nNormal = GetWallNormal(nMove.index); + sect = nMove.wall()->nextSector(); + nNormal = GetWallNormal(nMove.wall()); } - if (sectnum >= 0) + if (sect != nullptr) { - auto sect = §or[sectnum]; if ((sect->hitag == 45) && bTouchFloor) { int nDiff = AngleDiff(nNormal, (pPlayerSprite->ang + 1024) & kAngleMask); @@ -1321,7 +1320,7 @@ sectdone: &nearTagSector, &nearTagWall, &nearTagSprite, (int32_t*)&nearHitDist, 1024, 2, nullptr); DExhumedActor* pActorB; - feebtag(pPlayerSprite->x, pPlayerSprite->y, pPlayerSprite->z, pPlayerSprite->sectnum, &pActorB, var_30, 768); + feebtag(pPlayerSprite->x, pPlayerSprite->y, pPlayerSprite->z, pPlayerSprite->sector(), &pActorB, var_30, 768); // Item pickup code if (pActorB != nullptr && pActorB->s().statnum >= 900) @@ -2264,14 +2263,15 @@ sectdone: { ClearSpaceBar(nPlayer); - if (nearTagWall >= 0 && wall[nearTagWall].lotag > 0) + int tag; + if (nearTagWall >= 0 && (tag = wall[nearTagWall].lotag) > 0) { - runlist_SignalRun(wall[nearTagWall].lotag - 1, nPlayer, &ExhumedAI::Use); + runlist_SignalRun(tag - 1, nPlayer, &ExhumedAI::Use); } - if (nearTagSector >= 0 && sector[nearTagSector].lotag > 0) + if (nearTagSector >= 0 && (tag = sector[nearTagSector].lotag) > 0) { - runlist_SignalRun(sector[nearTagSector].lotag - 1, nPlayer, &ExhumedAI::Use); + runlist_SignalRun(tag - 1, nPlayer, &ExhumedAI::Use); } } diff --git a/source/games/exhumed/src/queen.cpp b/source/games/exhumed/src/queen.cpp index 60ad096b9..20aeee87d 100644 --- a/source/games/exhumed/src/queen.cpp +++ b/source/games/exhumed/src/queen.cpp @@ -575,7 +575,7 @@ void AIQueenEgg::Tick(RunListEvent* ev) default: return; case kHitWall: - nAngle = GetWallNormal(nMov.index); + nAngle = GetWallNormal(nMov.wall()); break; case kHitSprite: nAngle = nMov.actor->s().ang; @@ -814,7 +814,7 @@ void AIQueenHead::Tick(RunListEvent* ev) if (nMov.exbits == 0) { if (nMov.type == kHitSprite) nNewAng = nMov.actor->s().ang; - else if (nMov.type == kHitWall) nNewAng = GetWallNormal(nMov.index); + else if (nMov.type == kHitWall) nNewAng = GetWallNormal(nMov.wall()); } else if (nMov.exbits == kHitAux2) { diff --git a/source/games/exhumed/src/set.cpp b/source/games/exhumed/src/set.cpp index e05436a0b..ece9cb901 100644 --- a/source/games/exhumed/src/set.cpp +++ b/source/games/exhumed/src/set.cpp @@ -421,14 +421,13 @@ void AISet::Tick(RunListEvent* ev) if (nMov.type == kHitWall) { - int nWall = nMov.index; - int nSector = wall[nWall].nextsector; + auto pSector = nMov.wall()->nextSector(); - if (nSector >= 0) + if (pSector) { - if ((pSprite->z - sector[nSector].floorz) < 55000) + if ((pSprite->z - pSector->floorz) < 55000) { - if (pSprite->z > sector[nSector].ceilingz) + if (pSprite->z > pSector->ceilingz) { pActor->nIndex = 1; pActor->nAction = 7;