From 96b6bb21ef30c17116359d8376b552a5eaea9280 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 23 Nov 2021 23:04:21 +0100 Subject: [PATCH] - several smaller places. This gets rid of the less frequent names to look for. --- source/games/blood/src/actor.cpp | 5 ++-- source/games/blood/src/gameutil.cpp | 34 +++++++++++----------- source/games/blood/src/gameutil.h | 2 +- source/games/blood/src/nnexts.cpp | 9 +++--- source/games/blood/src/nnexts.h | 2 +- source/games/blood/src/prediction.cpp | 4 +-- source/games/blood/src/triggers.cpp | 41 +++++++++++++-------------- 7 files changed, 47 insertions(+), 50 deletions(-) diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index 9ac3db99d..3ee8cf4e6 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -3840,7 +3840,6 @@ void actHitcodeToData(int a1, HITINFO* pHitInfo, DBloodActor** pActor, walltype* { assert(pHitInfo != nullptr); DBloodActor* actor = nullptr; - int nWall = -1; walltype* pWall = nullptr; switch (a1) { @@ -4899,7 +4898,7 @@ void MoveDude(DBloodActor* actor) if (pDudeInfo->lockOut && pHitXWall && pHitXWall->triggerPush && !pHitXWall->key && !pHitXWall->dudeLockout && !pHitXWall->state && !pHitXWall->busy && !pPlayer) trTriggerWall(pHitWall, kCmdWallPush); - if (pHitWall->nextsector != -1) + if (pHitWall->twoSided()) { sectortype* pHitSector = pHitWall->nextSector(); XSECTOR* pHitXSector = pHitSector->hasX()? &pHitSector->xs() : nullptr; @@ -6821,7 +6820,7 @@ bool actCanSplatWall(walltype* pWall) int nType = pWall->type; if (nType >= kWallBase && nType < kWallMax) return 0; - if (pWall->nextsector != -1) + if (pWall->twoSided()) { sectortype* pSector = pWall->nextSector(); if (pSector->type >= kSectorBase && pSector->type < kSectorMax) return 0; diff --git a/source/games/blood/src/gameutil.cpp b/source/games/blood/src/gameutil.cpp index 5c0d2eaed..940345b59 100644 --- a/source/games/blood/src/gameutil.cpp +++ b/source/games/blood/src/gameutil.cpp @@ -49,13 +49,13 @@ bool FindSector(int nX, int nY, int nZ, int *nSector) } for (auto& wal : wallsofsector(*nSector)) { - int nOSector = wal.nextsector; - if (nOSector >= 0 && inside(nX, nY, nOSector)) + auto pOSector = wal.nextSector(); + if (pOSector != nullptr && inside(nX, nY, pOSector)) { - getzsofslope(nOSector, nX, nY, &nZCeil, &nZFloor); + getzsofslopeptr(pOSector, nX, nY, &nZCeil, &nZFloor); if (nZ >= nZCeil && nZ <= nZFloor) { - *nSector = nOSector; + *nSector = sectnum(pOSector); return 1; } } @@ -84,10 +84,10 @@ bool FindSector(int nX, int nY, int *nSector) } for (auto& wal : wallsofsector(*nSector)) { - int nOSector = wal.nextsector; - if (nOSector >= 0 && inside(nX, nY, nOSector)) + auto pOSector = wal.nextSector(); + if (pOSector != nullptr && inside(nX, nY, pOSector)) { - *nSector = nOSector; + *nSector = sectnum(pOSector); return 1; } } @@ -368,7 +368,7 @@ int HitScan(DBloodActor *actor, int z, int dx, int dy, int dz, unsigned int nMas { auto pWall = gHitInfo.hitWall; - if (pWall->nextsector == -1) + if (!pWall->twoSided()) return 0; int nZCeil, nZFloor; getzsofslopeptr(pWall->nextSector(), gHitInfo.hitx, gHitInfo.hity, &nZCeil, &nZFloor); @@ -724,19 +724,19 @@ BitArray GetClosestSpriteSectors(int nSector, int x, int y, int nDist, TArraydata3 == 3 || pXSource->data3 == 2) { - if (pWall->nextwall < 0) { + if (!pWall->twoSided()) { if (pXSource->data3 == 3) seqSpawn(pXSource->data2, SS_WALL, pWall, -1); @@ -4122,7 +4122,7 @@ bool condCheckWall(DBloodActor* aCond, int cmpOp, bool PUSH) else if (PUSH) condPush(aCond, pWall->nextSector()); return true; case 20: - if (!validWallIndex(pWall->nextwall)) return false; + if (!pWall->twoSided()) return false; else if (PUSH) condPush(aCond, pWall->nextWall()); return true; case 25: // next wall belongs to sector? (Note: This was 'sector of next wall' which is same as case 15 because we do not allow bad links!) @@ -5974,9 +5974,8 @@ bool modernTypeOperateSprite(DBloodActor* actor, const EVENT& event) // //--------------------------------------------------------------------------- -bool modernTypeOperateWall(int nWall, walltype* pWall, XWALL* pXWall, EVENT event) +bool modernTypeOperateWall(walltype* pWall, const EVENT& event) { - switch (pWall->type) { case kSwitchOneWay: @@ -5988,7 +5987,7 @@ bool modernTypeOperateWall(int nWall, walltype* pWall, XWALL* pXWall, EVENT even SetWallState(pWall, 1); break; default: - SetWallState(pWall, pXWall->restState ^ 1); + SetWallState(pWall, pWall->xw().restState ^ 1); break; } return true; diff --git a/source/games/blood/src/nnexts.h b/source/games/blood/src/nnexts.h index 7c5d8fd10..8f6637216 100644 --- a/source/games/blood/src/nnexts.h +++ b/source/games/blood/src/nnexts.h @@ -334,7 +334,7 @@ void trPlayerCtrlStopScene(PLAYER* pPlayer); void modernTypeTrigger(int type, sectortype*sect, walltype* wal, DBloodActor* actor, const EVENT& event); bool modernTypeOperateSector(int nSector, sectortype* pSector, XSECTOR* pXSector, const EVENT& event); bool modernTypeOperateSprite(DBloodActor*, const EVENT& event); -bool modernTypeOperateWall(int nWall, walltype* pWall, XWALL* pXWall, EVENT event); +bool modernTypeOperateWall(walltype* pWall, const EVENT& event); void modernTypeSendCommand(DBloodActor* nSprite, int channel, COMMAND_ID command); // ------------------------------------------------------------------------- // bool playerSizeShrink(PLAYER* pPlayer, int divider); diff --git a/source/games/blood/src/prediction.cpp b/source/games/blood/src/prediction.cpp index 218bf1f66..c7e05e3ae 100644 --- a/source/games/blood/src/prediction.cpp +++ b/source/games/blood/src/prediction.cpp @@ -402,9 +402,9 @@ static void fakeMoveDude(spritetype *pSprite) { int nHitWall = predict.at75.hit.index; walltype *pHitWall = &wall[nHitWall]; - if (pHitWall->nextsector != -1) + if (pHitWall->twoSided()) { - sectortype *pHitSector = §or[pHitWall->nextsector]; + sectortype *pHitSector = &pHitWall->nextSector(); if (top < pHitSector->ceilingz || bottom > pHitSector->floorz) { // ??? diff --git a/source/games/blood/src/triggers.cpp b/source/games/blood/src/triggers.cpp index 766db547c..d1d94cbce 100644 --- a/source/games/blood/src/triggers.cpp +++ b/source/games/blood/src/triggers.cpp @@ -616,8 +616,8 @@ void OperateSprite(DBloodActor* actor, EVENT event) void SetupGibWallState(walltype *pWall, XWALL *pXWall) { walltype *pWall2 = NULL; - if (pWall->nextwall >= 0) - pWall2 = &wall[pWall->nextwall]; + if (pWall->twoSided()) + pWall2 = pWall->nextWall(); if (pXWall->state) { pWall->cstat &= ~65; @@ -659,7 +659,7 @@ void OperateWall(walltype* pWall, EVENT event) { } #ifdef NOONE_EXTENSIONS - if (gModernMap && modernTypeOperateWall(wallnum(pWall), pWall, pXWall, event)) + if (gModernMap && modernTypeOperateWall(pWall, event)) return; #endif @@ -775,7 +775,7 @@ void DragPoint(walltype* pWall, int x, int y) auto prevWall = pWall; do { - if (prevWall->nextwall >= 0) + if (prevWall->twoSided()) { prevWall = prevWall->nextWall()->point2Wall(); prevWall->sectorp()->dirty = 255; @@ -789,7 +789,7 @@ void DragPoint(walltype* pWall, int x, int y) do { auto lw = lastwall(prevWall); - if (lw->nextwall >= 0) + if (lw->twoSided()) { prevWall = lw->nextWall(); prevWall->sectorp()->dirty = 255; @@ -1704,12 +1704,12 @@ void LinkSprite(DBloodActor* actor, EVENT event) } } -void LinkWall(int nWall, XWALL *pXWall, EVENT event) +void LinkWall(walltype* pWall, const EVENT& event) { int nBusy = GetSourceBusy(event); - pXWall->busy = nBusy; - if ((pXWall->busy & 0xffff) == 0) - SetWallState(&wall[nWall], FixedToInt(nBusy)); + pWall->xw().busy = nBusy; + if ((pWall->xw().busy & 0xffff) == 0) + SetWallState(pWall, FixedToInt(nBusy)); } void trTriggerSector(sectortype* pSector, int command) @@ -1806,7 +1806,7 @@ void trMessageWall(walltype* pWall, const EVENT& event) { switch (event.cmd) { case kCmdLink: - LinkWall(wallnum(pWall), pXWall, event); + LinkWall(pWall, event); break; #ifdef NOONE_EXTENSIONS case kCmdModernUse: @@ -1925,22 +1925,21 @@ void ProcessMotion(void) void AlignSlopes(void) { - sectortype *pSector; - int nSector; - for (pSector = §or[0], nSector = 0; nSector < numsectors; nSector++, pSector++) + for(auto& sect : sectors()) { - if (pSector->slopewallofs) + if (sect.slopewallofs) { - walltype *pWall = &wall[pSector->wallptr+pSector->slopewallofs]; - walltype *pWall2 = &wall[pWall->point2]; - int nNextSector = pWall->nextsector; - if (nNextSector >= 0) + walltype *pWall = sect.firstWall() + sect.slopewallofs; + walltype *pWall2 = pWall->point2Wall(); + if (pWall->twoSided()) { + auto pNextSector = pWall->nextSector(); + int x = (pWall->x+pWall2->x)/2; int y = (pWall->y+pWall2->y)/2; - viewInterpolateSector(pSector); - alignflorslope(nSector, x, y, getflorzofslope(nNextSector, x, y)); - alignceilslope(nSector, x, y, getceilzofslope(nNextSector, x, y)); + viewInterpolateSector(§); + alignflorslope(§, x, y, getflorzofslopeptr(pNextSector, x, y)); + alignceilslope(§, x, y, getceilzofslopeptr(pNextSector, x, y)); } } }