diff --git a/source/games/sw/src/break.cpp b/source/games/sw/src/break.cpp index 7b557cfd5..5af64a705 100644 --- a/source/games/sw/src/break.cpp +++ b/source/games/sw/src/break.cpp @@ -557,9 +557,9 @@ int AutoBreakWall(WALLp wallp, int hit_x, int hit_y, int hit_z, int ang, int typ WALLp nwp; wallp->lotag = 0; - if (wallp->nextwall >= 0) + if (wallp->twoSided()) { - nwp = &wall[wallp->nextwall]; + nwp = wallp->nextWall(); // get rid of both sides // only break ONE of the walls @@ -608,9 +608,9 @@ int AutoBreakWall(WALLp wallp, int hit_x, int hit_y, int hit_z, int ang, int typ { RESET(wallp->cstat, CSTAT_WALL_MASKED|CSTAT_WALL_1WAY|CSTAT_WALL_BLOCK_HITSCAN|CSTAT_WALL_BLOCK); wallp->overpicnum = 0; - if (wallp->nextwall >= 0) + if (wallp->twoSided()) { - nwp = &wall[wallp->nextwall]; + nwp = wallp->nextWall(); RESET(nwp->cstat, CSTAT_WALL_MASKED|CSTAT_WALL_1WAY|CSTAT_WALL_BLOCK_HITSCAN|CSTAT_WALL_BLOCK); nwp->overpicnum = 0; } @@ -619,9 +619,9 @@ int AutoBreakWall(WALLp wallp, int hit_x, int hit_y, int hit_z, int ang, int typ { RESET(wallp->cstat, CSTAT_WALL_BLOCK_HITSCAN|CSTAT_WALL_BLOCK); wallp->overpicnum = break_info->breaknum; - if (wallp->nextwall >= 0) + if (wallp->twoSided()) { - nwp = &wall[wallp->nextwall]; + nwp = wallp->nextWall(); RESET(nwp->cstat, CSTAT_WALL_BLOCK_HITSCAN|CSTAT_WALL_BLOCK); nwp->overpicnum = break_info->breaknum; } @@ -656,12 +656,12 @@ bool UserBreakWall(WALLp wp) // do it the old way and get rid of wall - assumed to be masked DoSpawnSpotsForKill(match); RESET(wp->cstat, flags); - if (wp->nextwall >= 0) + if (wp->twoSided()) RESET(wp->nextWall()->cstat, flags); // clear tags wp->hitag = wp->lotag = 0; - if (wp->nextwall >= 0) + if (wp->twoSided()) wp->nextWall()->hitag = wp->nextWall()->lotag = 0; return true; } @@ -682,7 +682,7 @@ bool UserBreakWall(WALLp wp) wp->picnum = SP_TAG5(sp); // clear tags wp->hitag = wp->lotag = 0; - if (wp->nextwall >= 0) + if (wp->twoSided()) wp->nextWall()->hitag = wp->nextWall()->lotag = 0; ret = false; } @@ -690,11 +690,11 @@ bool UserBreakWall(WALLp wp) { // clear flags RESET(wp->cstat, flags); - if (wp->nextwall >= 0) + if (wp->twoSided()) RESET(wp->nextWall()->cstat, flags); // clear tags wp->hitag = wp->lotag = 0; - if (wp->nextwall >= 0) + if (wp->twoSided()) wp->nextWall()->hitag = wp->nextWall()->lotag = 0; ret = true; @@ -706,12 +706,12 @@ bool UserBreakWall(WALLp wp) // clear flags RESET(wp->cstat, block_flags); - if (wp->nextwall >= 0) + if (wp->twoSided()) RESET(wp->nextWall()->cstat, block_flags); // clear tags wp->hitag = wp->lotag = 0; - if (wp->nextwall >= 0) + if (wp->twoSided()) wp->nextWall()->hitag = wp->nextWall()->lotag = 0; ret = false; diff --git a/source/games/sw/src/jsector.cpp b/source/games/sw/src/jsector.cpp index bff23077a..0c445ef1c 100644 --- a/source/games/sw/src/jsector.cpp +++ b/source/games/sw/src/jsector.cpp @@ -579,8 +579,8 @@ void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz, double smoothratio) w = mirror[cnt].mirrorwall; // Get wall midpoint for offset in mirror view - midx = (wall[w].x + wall[wall[w].point2].x) / 2; - midy = (wall[w].y + wall[wall[w].point2].y) / 2; + midx = (wall[w].x + wall[w].point2Wall()->x) / 2; + midy = (wall[w].y + wall[w].point2Wall()->y) / 2; // Finish finding offsets tdx = abs(midx - tx); diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index c30d6a2bd..7cc975cd1 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -3446,7 +3446,7 @@ int DoPlayerWadeSuperJump(PLAYERp pp) if (hitinfo.hitwall >= 0 && hitinfo.hitsect >= 0) { - hitinfo.hitsect = wall[hitinfo.hitwall].nextsector; + hitinfo.hitsect = hitinfo.wall()->nextsector; if (hitinfo.hitsect >= 0 && labs(sector[hitinfo.hitsect].floorz - pp->posz) < Z(50)) { @@ -3790,7 +3790,7 @@ bool PlayerOnLadder(PLAYERp pp) else { // if you hit a wall and it is not a climb wall - forget it - if (hitinfo.hitwall >= 0 && wall[hitinfo.hitwall].lotag != TAG_WALL_CLIMB) + if (hitinfo.hitwall >= 0 && hitinfo.wall()->lotag != TAG_WALL_CLIMB) return false; } } diff --git a/source/games/sw/src/sector.cpp b/source/games/sw/src/sector.cpp index 34d17fb04..259992882 100644 --- a/source/games/sw/src/sector.cpp +++ b/source/games/sw/src/sector.cpp @@ -202,7 +202,7 @@ void WallSetup(void) case TAG_WALL_LOOP_OUTER_SECONDARY: { // make sure it's a red wall - if (validWallIndex(wp->nextwall)) + if (wp->twoSided()) { WallSetupLoop(wp, TAG_WALL_LOOP_OUTER_SECONDARY, WALLFX_LOOP_OUTER | WALLFX_LOOP_OUTER_SECONDARY); } @@ -216,7 +216,7 @@ void WallSetup(void) case TAG_WALL_LOOP_OUTER: { // make sure it's a red wall - if (validWallIndex(wp->nextwall)) + if (wp->twoSided()) { WallSetupLoop(wp, TAG_WALL_LOOP_OUTER, WALLFX_LOOP_OUTER); } diff --git a/source/games/sw/src/slidor.cpp b/source/games/sw/src/slidor.cpp index 0e721f36f..838f5fc31 100644 --- a/source/games/sw/src/slidor.cpp +++ b/source/games/sw/src/slidor.cpp @@ -282,10 +282,11 @@ int DoSlidorMoveWalls(DSWActor* actor, int amt) w = startwall = sp->sector()->wallptr; endwall = startwall + sp->sector()->wallnum - 1; + auto wal = &wall[w]; do { - switch (wall[w].lotag) + switch (wal->lotag) { case TAG_WALL_SLIDOR_LEFT: @@ -294,19 +295,19 @@ int DoSlidorMoveWalls(DSWActor* actor, int amt) if (w < startwall) pw = endwall; - if (!validWallIndex(wall[w].nextwall)) + if (!wal->twoSided()) { // white wall - move 4 points - wall[w].x -= amt; + wal->x -= amt; wall[pw].x -= amt; - wall[wall[w].point2].x -= amt; - wall[wall[wall[w].point2].point2].x -= amt; + wal->point2Wall()->x -= amt; + wal->point2Wall()->point2Wall()->x -= amt; } else { // red wall - move 2 points - dragpoint(w, wall[w].x - amt, wall[w].y); - dragpoint(wall[w].point2, wall[wall[w].point2].x - amt, wall[wall[w].point2].y); + dragpoint(w, wal->x - amt, wal->y); + dragpoint(wal->point2, wal->point2Wall()->x - amt, wal->point2Wall()->y); } break; @@ -318,19 +319,19 @@ int DoSlidorMoveWalls(DSWActor* actor, int amt) if (w < startwall) pw = endwall; - if (!validWallIndex(wall[w].nextwall)) + if (!wal->twoSided()) { // white wall - move 4 points - wall[w].x += amt; + wal->x += amt; wall[pw].x += amt; - wall[wall[w].point2].x += amt; - wall[wall[wall[w].point2].point2].x += amt; + wal->point2Wall()->x += amt; + wal->point2Wall()->point2Wall()->x += amt; } else { // red wall - move 2 points - dragpoint(w, wall[w].x + amt, wall[w].y); - dragpoint(wall[w].point2, wall[wall[w].point2].x + amt, wall[wall[w].point2].y); + dragpoint(w, wal->x + amt, wal->y); + dragpoint(wal->point2, wal->point2Wall()->x + amt, wal->point2Wall()->y); } break; @@ -342,17 +343,17 @@ int DoSlidorMoveWalls(DSWActor* actor, int amt) if (w < startwall) pw = endwall; - if (!validWallIndex(wall[w].nextwall)) + if (!wal->twoSided()) { - wall[w].y -= amt; + wal->y -= amt; wall[pw].y -= amt; - wall[wall[w].point2].y -= amt; - wall[wall[wall[w].point2].point2].y -= amt; + wal->point2Wall()->y -= amt; + wal->point2Wall()->point2Wall()->y -= amt; } else { - dragpoint(w, wall[w].x, wall[w].y - amt); - dragpoint(wall[w].point2, wall[wall[w].point2].x, wall[wall[w].point2].y - amt); + dragpoint(w, wal->x, wal->y - amt); + dragpoint(wal->point2, wal->point2Wall()->x, wal->point2Wall()->y - amt); } break; @@ -364,24 +365,25 @@ int DoSlidorMoveWalls(DSWActor* actor, int amt) if (w < startwall) pw = endwall; - if (!validWallIndex(wall[w].nextwall)) + if (!wal->twoSided()) { - wall[w].y += amt; + wal->y += amt; wall[pw].y += amt; - wall[wall[w].point2].y += amt; - wall[wall[wall[w].point2].point2].y += amt; + wal->point2Wall()->y += amt; + wal->point2Wall()->point2Wall()->y += amt; } else { - dragpoint(w, wall[w].x, wall[w].y + amt); - dragpoint(wall[w].point2, wall[wall[w].point2].x, wall[wall[w].point2].y + amt); + dragpoint(w, wal->x, wal->y + amt); + dragpoint(wal->point2, wal->point2Wall()->x, wal->point2Wall()->y + amt); } break; } - w = wall[w].point2; + w = wal->point2; + wal = wal->point2Wall(); } while (w != startwall); diff --git a/source/games/sw/src/track.cpp b/source/games/sw/src/track.cpp index a9620f04b..e28d2cae5 100644 --- a/source/games/sw/src/track.cpp +++ b/source/games/sw/src/track.cpp @@ -3181,7 +3181,7 @@ bool ActorTrackDecide(TRACK_POINTp tpoint, DSWActor* actor) if (hitinfo.hitwall < 0) return false; - zdiff = labs(sp->z - sector[wall[hitinfo.hitwall].nextsector].floorz) >> 8; + zdiff = labs(sp->z - sector[hitinfo.wall()->nextsector].floorz) >> 8; u->jump_speed = PickJumpSpeed(actor, zdiff); } diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index 91464b3d2..0c471801d 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -12628,18 +12628,18 @@ int InitSwordAttack(PLAYERp pp) if (hitinfo.hitwall >= 0) { - if (wall[hitinfo.hitwall].nextsector >= 0) + if (hitinfo.wall()->nextsector >= 0) { - if (TEST(sector[wall[hitinfo.hitwall].nextsector].ceilingstat, CEILING_STAT_PLAX)) + if (TEST(sector[hitinfo.wall()->nextsector].ceilingstat, CEILING_STAT_PLAX)) { - if (hitinfo.pos.z < sector[wall[hitinfo.hitwall].nextsector].ceilingz) + if (hitinfo.pos.z < sector[hitinfo.wall()->nextsector].ceilingz) { return 0; } } } - if (wall[hitinfo.hitwall].lotag == TAG_WALL_BREAK) + if (hitinfo.wall()->lotag == TAG_WALL_BREAK) { HitBreakWall(&wall[hitinfo.hitwall], hitinfo.pos.x, hitinfo.pos.y, hitinfo.pos.z, daang, u->ID); } @@ -12831,18 +12831,18 @@ int InitFistAttack(PLAYERp pp) if (hitinfo.hitwall >= 0) { - if (wall[hitinfo.hitwall].nextsector >= 0) + if (hitinfo.wall()->nextsector >= 0) { - if (TEST(sector[wall[hitinfo.hitwall].nextsector].ceilingstat, CEILING_STAT_PLAX)) + if (TEST(sector[hitinfo.wall()->nextsector].ceilingstat, CEILING_STAT_PLAX)) { - if (hitinfo.pos.z < sector[wall[hitinfo.hitwall].nextsector].ceilingz) + if (hitinfo.pos.z < sector[hitinfo.wall()->nextsector].ceilingz) { return 0; } } } - if (wall[hitinfo.hitwall].lotag == TAG_WALL_BREAK) + if (hitinfo.wall()->lotag == TAG_WALL_BREAK) { HitBreakWall(&wall[hitinfo.hitwall], hitinfo.pos.x, hitinfo.pos.y, hitinfo.pos.z, daang, u->ID); } @@ -13543,18 +13543,18 @@ int ContinueHitscan(PLAYERp pp, short sectnum, int x, int y, int z, short ang, i if (hitinfo.hitwall >= 0) { - if (wall[hitinfo.hitwall].nextsector >= 0) + if (hitinfo.wall()->nextsector >= 0) { - if (TEST(sector[wall[hitinfo.hitwall].nextsector].ceilingstat, CEILING_STAT_PLAX)) + if (TEST(sector[hitinfo.wall()->nextsector].ceilingstat, CEILING_STAT_PLAX)) { - if (hitinfo.pos.z < sector[wall[hitinfo.hitwall].nextsector].ceilingz) + if (hitinfo.pos.z < sector[hitinfo.wall()->nextsector].ceilingz) { return 0; } } } - if (wall[hitinfo.hitwall].lotag == TAG_WALL_BREAK) + if (hitinfo.wall()->lotag == TAG_WALL_BREAK) { HitBreakWall(&wall[hitinfo.hitwall], hitinfo.pos.x, hitinfo.pos.y, hitinfo.pos.z, ang, u->ID); return 0; @@ -13700,18 +13700,18 @@ int InitShotgun(PLAYERp pp) if (hitinfo.hitwall >= 0) { - if (wall[hitinfo.hitwall].nextsector >= 0) + if (hitinfo.wall()->nextsector >= 0) { - if (TEST(sector[wall[hitinfo.hitwall].nextsector].ceilingstat, CEILING_STAT_PLAX)) + if (TEST(sector[hitinfo.wall()->nextsector].ceilingstat, CEILING_STAT_PLAX)) { - if (hitinfo.pos.z < sector[wall[hitinfo.hitwall].nextsector].ceilingz) + if (hitinfo.pos.z < sector[hitinfo.wall()->nextsector].ceilingz) { continue; } } } - if (wall[hitinfo.hitwall].lotag == TAG_WALL_BREAK) + if (hitinfo.wall()->lotag == TAG_WALL_BREAK) { HitBreakWall(&wall[hitinfo.hitwall], hitinfo.pos.x, hitinfo.pos.y, hitinfo.pos.z, ndaang, u->ID); continue; @@ -16263,11 +16263,11 @@ int InitUzi(PLAYERp pp) if (hitinfo.hitwall >= 0) { - if (wall[hitinfo.hitwall].nextsector >= 0) + if (hitinfo.wall()->nextsector >= 0) { - if (TEST(sector[wall[hitinfo.hitwall].nextsector].ceilingstat, CEILING_STAT_PLAX)) + if (TEST(sector[hitinfo.wall()->nextsector].ceilingstat, CEILING_STAT_PLAX)) { - if (hitinfo.pos.z < sector[wall[hitinfo.hitwall].nextsector].ceilingz) + if (hitinfo.pos.z < sector[hitinfo.wall()->nextsector].ceilingz) { return 0; } @@ -16275,7 +16275,7 @@ int InitUzi(PLAYERp pp) } - if (wall[hitinfo.hitwall].lotag == TAG_WALL_BREAK) + if (hitinfo.wall()->lotag == TAG_WALL_BREAK) { HitBreakWall(&wall[hitinfo.hitwall], hitinfo.pos.x, hitinfo.pos.y, hitinfo.pos.z, daang, u->ID); return 0; @@ -17201,18 +17201,18 @@ int InitTurretMgun(SECTOR_OBJECTp sop) if (hitinfo.hitwall >= 0) { - if (wall[hitinfo.hitwall].nextsector >= 0) + if (hitinfo.wall()->nextsector >= 0) { - if (TEST(sector[wall[hitinfo.hitwall].nextsector].ceilingstat, CEILING_STAT_PLAX)) + if (TEST(sector[hitinfo.wall()->nextsector].ceilingstat, CEILING_STAT_PLAX)) { - if (hitinfo.pos.z < sector[wall[hitinfo.hitwall].nextsector].ceilingz) + if (hitinfo.pos.z < sector[hitinfo.wall()->nextsector].ceilingz) { return 0; } } } - if (wall[hitinfo.hitwall].lotag == TAG_WALL_BREAK) + if (hitinfo.wall()->lotag == TAG_WALL_BREAK) { HitBreakWall(&wall[hitinfo.hitwall], hitinfo.pos.x, hitinfo.pos.y, hitinfo.pos.z, daang, 0); continue; @@ -17337,18 +17337,18 @@ int InitEnemyUzi(DSWActor* actor) if (hitinfo.hitwall >= 0) { - if (wall[hitinfo.hitwall].nextsector >= 0) + if (hitinfo.wall()->nextsector >= 0) { - if (TEST(sector[wall[hitinfo.hitwall].nextsector].ceilingstat, CEILING_STAT_PLAX)) + if (TEST(sector[hitinfo.wall()->nextsector].ceilingstat, CEILING_STAT_PLAX)) { - if (hitinfo.pos.z < sector[wall[hitinfo.hitwall].nextsector].ceilingz) + if (hitinfo.pos.z < sector[hitinfo.wall()->nextsector].ceilingz) { return 0; } } } - if (wall[hitinfo.hitwall].lotag == TAG_WALL_BREAK) + if (hitinfo.wall()->lotag == TAG_WALL_BREAK) { HitBreakWall(&wall[hitinfo.hitwall], hitinfo.pos.x, hitinfo.pos.y, hitinfo.pos.z, daang, u->ID); return 0; @@ -18582,7 +18582,7 @@ bool TestDontStick(DSWActor* actor, short hit_wall) return true; // if blocking red wallo - if (TEST(wp->cstat, CSTAT_WALL_BLOCK) && validWallIndex(wp->nextwall)) + if (TEST(wp->cstat, CSTAT_WALL_BLOCK) && wp->twoSided()) return true; return false;