diff --git a/source/games/blood/src/_polymost.cpp b/source/games/blood/src/_polymost.cpp index 2dd996fe7..555235a0c 100644 --- a/source/games/blood/src/_polymost.cpp +++ b/source/games/blood/src/_polymost.cpp @@ -216,8 +216,8 @@ void DrawMirrors(int x, int y, int z, fixed_t a, fixed_t horiz, int smooth, int pWall->nextsector = mirrorsector; wall[mirrorwall[0]].nextwall = nWall; wall[mirrorwall[0]].nextsector = nSector; - wall[mirrorwall[0]].x = wall[pWall->point2].x; - wall[mirrorwall[0]].y = wall[pWall->point2].y; + wall[mirrorwall[0]].x = pWall->point2Wall()->x; + wall[mirrorwall[0]].y = pWall->point2Wall()->y; wall[mirrorwall[1]].x = pWall->x; wall[mirrorwall[1]].y = pWall->y; wall[mirrorwall[2]].x = wall[mirrorwall[1]].x + (wall[mirrorwall[1]].x - wall[mirrorwall[0]].x) * 16; @@ -229,8 +229,8 @@ void DrawMirrors(int x, int y, int z, fixed_t a, fixed_t horiz, int smooth, int int cx, cy, ca; if (GetWallType(nWall) == kWallStack) { - cx = x - (wall[pWall->hitag].x - wall[pWall->point2].x); - cy = y - (wall[pWall->hitag].y - wall[pWall->point2].y); + cx = x - (wall[pWall->hitag].x - pWall->point2Wall()->x); + cy = y - (wall[pWall->hitag].y - pWall->point2Wall()->y); ca = a; } else diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index 37f9bea9b..6c5d7d4d5 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -6827,7 +6827,7 @@ bool actCanSplatWall(int nWall) if (pWall->nextsector != -1) { - sectortype* pSector = §or[pWall->nextsector]; + sectortype* pSector = pWall->nextSector(); if (pSector->type >= kSectorBase && pSector->type < kSectorMax) return 0; } return 1; diff --git a/source/games/blood/src/gameutil.cpp b/source/games/blood/src/gameutil.cpp index 5c008e2a3..c5caf7218 100644 --- a/source/games/blood/src/gameutil.cpp +++ b/source/games/blood/src/gameutil.cpp @@ -516,7 +516,7 @@ int VectorScan(DBloodActor *actor, int nOffset, int nZOffset, int dx, int dy, in if (pWall->nextsector == -1) return 0; sectortype *pSector = §or[gHitInfo.hitsect]; - sectortype *pSectorNext = §or[pWall->nextsector]; + sectortype *pSectorNext = pWall->nextSector(); int nZCeil, nZFloor; getzsofslope(pWall->nextsector, gHitInfo.hitx, gHitInfo.hity, &nZCeil, &nZFloor); if (gHitInfo.hitz <= nZCeil) @@ -546,10 +546,10 @@ int VectorScan(DBloodActor *actor, int nOffset, int nZOffset, int dx, int dy, in nOffset = (nOffset*pWall->yrepeat) / 8; nOffset += int((nSizY*pWall->ypan_) / 256); - int nLength = approxDist(pWall->x - wall[pWall->point2].x, pWall->y - wall[pWall->point2].y); + int nLength = approxDist(pWall->x - pWall->point2Wall()->x, pWall->y - pWall->point2Wall()->y); int nHOffset; if (pWall->cstat & 8) - nHOffset = approxDist(gHitInfo.hitx - wall[pWall->point2].x, gHitInfo.hity - wall[pWall->point2].y); + nHOffset = approxDist(gHitInfo.hitx - pWall->point2Wall()->x, gHitInfo.hity - pWall->point2Wall()->y); else nHOffset = approxDist(gHitInfo.hitx - pWall->x, gHitInfo.hity - pWall->y); diff --git a/source/games/blood/src/gib.cpp b/source/games/blood/src/gib.cpp index d0685353c..1f70d30b3 100644 --- a/source/games/blood/src/gib.cpp +++ b/source/games/blood/src/gib.cpp @@ -254,8 +254,8 @@ GIBLIST gibList[] = { void gibCalcWallArea(int a1, int &a2, int &a3, int &a4, int &a5, int &a6, int &a7, int &a8) { walltype *pWall = &wall[a1]; - a2 = (pWall->x+wall[pWall->point2].x)>>1; - a3 = (pWall->y+wall[pWall->point2].y)>>1; + a2 = (pWall->x+pWall->point2Wall()->x)>>1; + a3 = (pWall->y+pWall->point2Wall()->y)>>1; int nSector = sectorofwall(a1); int32_t ceilZ, floorZ; getzsofslope(nSector, a2, a3, &ceilZ, &floorZ); @@ -264,8 +264,8 @@ void gibCalcWallArea(int a1, int &a2, int &a3, int &a4, int &a5, int &a6, int &a ceilZ = ClipLow(ceilZ, ceilZ2); floorZ = ClipHigh(floorZ, floorZ2); a7 = floorZ-ceilZ; - a5 = wall[pWall->point2].x-pWall->x; - a6 = wall[pWall->point2].y-pWall->y; + a5 = pWall->point2Wall()->x-pWall->x; + a6 = pWall->point2Wall()->y-pWall->y; a8 = (a7>>8)*approxDist(a5>>4, a6>>4); a4 = (ceilZ+floorZ)>>1; } @@ -484,8 +484,8 @@ void GibWall(int nWall, GIBTYPE nGibType, CGibVelocity *pVel) int cx, cy, cz, wx, wy, wz; walltype *pWall = &wall[nWall]; - cx = (pWall->x+wall[pWall->point2].x)>>1; - cy = (pWall->y+wall[pWall->point2].y)>>1; + cx = (pWall->x+pWall->point2Wall()->x)>>1; + cy = (pWall->y+pWall->point2Wall()->y)>>1; int nSector = sectorofwall(nWall); int32_t ceilZ, floorZ; getzsofslope(nSector, cx, cy, &ceilZ, &floorZ); @@ -495,8 +495,8 @@ void GibWall(int nWall, GIBTYPE nGibType, CGibVelocity *pVel) ceilZ = ClipLow(ceilZ, ceilZ2); floorZ = ClipHigh(floorZ, floorZ2); wz = floorZ-ceilZ; - wx = wall[pWall->point2].x-pWall->x; - wy = wall[pWall->point2].y-pWall->y; + wx = pWall->point2Wall()->x-pWall->x; + wy = pWall->point2Wall()->y-pWall->y; cz = (ceilZ+floorZ)>>1; GIBLIST *pGib = &gibList[nGibType]; diff --git a/source/games/blood/src/mirrors.cpp b/source/games/blood/src/mirrors.cpp index 3d12ab5da..35e672da7 100644 --- a/source/games/blood/src/mirrors.cpp +++ b/source/games/blood/src/mirrors.cpp @@ -50,30 +50,32 @@ void InitMirrors(void) } for (int i = numwalls - 1; i >= 0; i--) { + auto pWalli = &wall[i]; if (mirrorcnt == 16) break; int nTile = 4080+mirrorcnt; - if (wall[i].overpicnum == 504) + if (pWalli->overpicnum == 504) { - if (wall[i].extra > 0 && GetWallType(i) == kWallStack) + if (pWalli->extra > 0 && GetWallType(i) == kWallStack) { - wall[i].overpicnum = nTile; + pWalli->overpicnum = nTile; mirror[mirrorcnt].wallnum = i; mirror[mirrorcnt].type = 0; - wall[i].cstat |= 32; - int tmp = wall[i].xw().data; + pWalli->cstat |= 32; + int tmp = pWalli->xw().data; int j; for (j = numwalls - 1; j >= 0; j--) { if (j == i) continue; - if (wall[j].extra > 0 && GetWallType(i) == kWallStack) + auto pWallj = &wall[j]; + if (pWallj->extra > 0 && GetWallType(i) == kWallStack) { - if (tmp != wall[j].xw().data) + if (tmp != pWallj->xw().data) continue; - wall[i].hitag = j; - wall[j].hitag = i; + pWalli->hitag = j; + pWallj->hitag = i; mirror[mirrorcnt].link = j; break; } @@ -85,20 +87,20 @@ void InitMirrors(void) else { mirrorcnt++; - wall[i].portalflags = PORTAL_WALL_VIEW; - wall[i].portalnum = j; + pWalli->portalflags = PORTAL_WALL_VIEW; + pWalli->portalnum = j; } } continue; } - if (wall[i].picnum == 504) + if (pWalli->picnum == 504) { mirror[mirrorcnt].link = i; mirror[mirrorcnt].wallnum = i; - wall[i].picnum = nTile; + pWalli->picnum = nTile; mirror[mirrorcnt].type = 0; - wall[i].cstat |= 32; - wall[i].portalflags = PORTAL_WALL_MIRROR; + pWalli->cstat |= 32; + pWalli->portalflags = PORTAL_WALL_MIRROR; mirrorcnt++; continue; } @@ -147,12 +149,13 @@ void InitMirrors(void) for (int i = 0; i < 4; i++) { mirrorwall[i] = numwalls+i; - wall[mirrorwall[i]].picnum = 504; - wall[mirrorwall[i]].overpicnum = 504; - wall[mirrorwall[i]].cstat = 0; - wall[mirrorwall[i]].nextsector = -1; - wall[mirrorwall[i]].nextwall = -1; - wall[mirrorwall[i]].point2 = numwalls+i+1; + auto pWall = &wall[mirrorwall[i]]; + pWall->picnum = 504; + pWall->overpicnum = 504; + pWall->cstat = 0; + pWall->nextsector = -1; + pWall->nextwall = -1; + pWall->point2 = numwalls+i+1; } wall[mirrorwall[3]].point2 = mirrorwall[0]; sector[mirrorsector].ceilingpicnum = 504; @@ -215,12 +218,13 @@ void SerializeMirrors(FSerializer& arc) } for (int i = 0; i < 4; i++) { - wall[mirrorwall[i]].picnum = 504; - wall[mirrorwall[i]].overpicnum = 504; - wall[mirrorwall[i]].cstat = 0; - wall[mirrorwall[i]].nextsector = -1; - wall[mirrorwall[i]].nextwall = -1; - wall[mirrorwall[i]].point2 = numwalls + i + 1; + auto pWall = &wall[mirrorwall[i]]; + pWall->picnum = 504; + pWall->overpicnum = 504; + pWall->cstat = 0; + pWall->nextsector = -1; + pWall->nextwall = -1; + pWall->point2 = numwalls + i + 1; } wall[mirrorwall[3]].point2 = mirrorwall[0]; sector[mirrorsector].ceilingpicnum = 504; diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index bea370e7c..5fd23a756 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -1972,9 +1972,9 @@ void windGenStopWindOnSectors(DBloodActor* sourceactor) { spritetype* pSource = &sourceactor->s(); auto pXSource = &sourceactor->x(); - if (pXSource->txID <= 0 && xsectRangeIsFine(sector[pSource->sectnum].extra)) + if (pXSource->txID <= 0 && pSource->sector()->hasX()) { - xsector[sector[pSource->sectnum].extra].windVel = 0; + pSource->sector()->xs().windVel = 0; return; } @@ -3800,9 +3800,9 @@ bool condCheckMixed(DBloodActor* aCond, const EVENT& event, int cmpOp, bool PUSH case 15: // x-index is fine? switch (objType) { - case OBJ_WALL: return xwallRangeIsFine(wall[objIndex].extra); + case OBJ_WALL: return wall[objIndex].hasX(); case OBJ_SPRITE: return objActor && objActor->hasX(); - case OBJ_SECTOR: return xsectRangeIsFine(sector[objIndex].extra); + case OBJ_SECTOR: return sector[objIndex].hasX(); } break; case 20: // type in a range? @@ -4771,10 +4771,10 @@ void modernTypeTrigger(int destObjType, int destObjIndex, DBloodActor* destactor switch (destObjType) { case OBJ_SECTOR: - if (!xsectRangeIsFine(sector[destObjIndex].extra)) return; + if (!sector[destObjIndex].hasX()) return; break; case OBJ_WALL: - if (!xwallRangeIsFine(wall[destObjIndex].extra)) return; + if (!wall[destObjIndex].hasX()) return; break; case OBJ_SPRITE: { @@ -5297,15 +5297,15 @@ void sectorKillSounds(int nSector) void sectorPauseMotion(int nSector) { - if (!xsectRangeIsFine(sector[nSector].extra)) return; - XSECTOR* pXSector = &xsector[sector[nSector].extra]; + if (!sector[nSector].hasX()) return; + XSECTOR* pXSector = §or[nSector].xs(); pXSector->unused1 = 1; evKillSector(nSector); sectorKillSounds(nSector); if ((pXSector->busy == 0 && !pXSector->state) || (pXSector->busy == 65536 && pXSector->state)) - SectorEndSound(nSector, xsector[sector[nSector].extra].state); + SectorEndSound(nSector, pXSector->state); } //--------------------------------------------------------------------------- @@ -5316,21 +5316,22 @@ void sectorPauseMotion(int nSector) void sectorContinueMotion(int nSector, EVENT event) { - if (!xsectRangeIsFine(sector[nSector].extra)) return; - else if (gBusyCount >= kMaxBusyCount) + auto pSector = §or[nSector]; + if (!pSector->hasX()) return; + else if (gBusyCount >= kMaxBusyCount) { Printf(PRINT_HIGH, "Failed to continue motion for sector #%d. Max (%d) busy objects count reached!", nSector, kMaxBusyCount); return; } - XSECTOR* pXSector = &xsector[sector[nSector].extra]; + XSECTOR* pXSector = &pSector->xs(); pXSector->unused1 = 0; int busyTimeA = pXSector->busyTimeA; int waitTimeA = pXSector->waitTimeA; int busyTimeB = pXSector->busyTimeB; int waitTimeB = pXSector->waitTimeB; - if (sector[nSector].type == kSectorPath) + if (pSector->type == kSectorPath) { if (!pXSector->marker0) return; busyTimeA = busyTimeB = pXSector->marker0->x().busyTime; @@ -5379,7 +5380,7 @@ void sectorContinueMotion(int nSector, EVENT event) //bool crush = pXSector->Crush; int busyFunc = BUSYID_0; - switch (sector[nSector].type) + switch (pSector->type) { case kSectorZMotion: busyFunc = BUSYID_2; @@ -5402,7 +5403,7 @@ void sectorContinueMotion(int nSector, EVENT event) busyFunc = BUSYID_7; break; default: - I_Error("Unsupported sector type %d", sector[nSector].type); + I_Error("Unsupported sector type %d", pSector->type); break; }