diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 1c3363373..8936538a4 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -805,7 +805,7 @@ struct PLAYERstruct int16_t pnum; // carry along the player number - int16_t LadderSector; + sectortype* LadderSector; int lx,ly; // ladder x and y int16_t JumpDuration; int16_t WadeDepth; diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index 355695d24..27e7ec853 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -3284,9 +3284,8 @@ void DoPlayerClimb(PLAYERp pp) DoPlayerZrange(pp); - if (!validSectorIndex(pp->LadderSector)) + if (!pp->LadderSector) { - Printf("Bad ladder sector %d!\n", pp->LadderSector); return; } @@ -3312,14 +3311,14 @@ void DoPlayerClimb(PLAYERp pp) if (PlayerCeilingHit(pp, pp->hiz + Z(4))) { // put player at the ceiling - pp->posz = sector[pp->LadderSector].ceilingz + Z(4); + pp->posz = pp->LadderSector->ceilingz + Z(4); NewStateGroup(pp->Actor(), sg_PlayerNinjaClimb); } // if floor is ABOVE you && your head goes above it, do a jump up to // terrace - if (pp->posz < sector[pp->LadderSector].floorz - Z(6)) + if (pp->posz < pp->LadderSector->floorz - Z(6)) { pp->jump_speed = PLAYER_CLIMB_JUMP_AMT; RESET(pp->Flags, PF_CLIMBING|PF_WEAPON_DOWN); @@ -3410,7 +3409,7 @@ void DoPlayerClimb(PLAYERp pp) ny = MOVEy(100, lsp->ang); // set ladder sector - pp->LadderSector = wp->twoSided()? wp->nextsector : wp->sector; + pp->LadderSector = wp->twoSided()? wp->nextSector() : wp->sectorp(); // set players "view" distance from the ladder - needs to be farther than // the sprite @@ -3804,8 +3803,9 @@ bool PlayerOnLadder(PLAYERp pp) nx = MOVEx(100, lsp->ang); ny = MOVEy(100, lsp->ang); - pp->LadderSector = wall[wal].twoSided() ? wall[wal].nextsector : wall[wal].sector; - MONO_PRINT(ds); + auto wp = &wall[wal]; + + pp->LadderSector = wp->twoSided() ? wp->nextSector() : wp->sectorp(); // set players "view" distance from the ladder - needs to be farther than // the sprite diff --git a/source/games/sw/src/sector.cpp b/source/games/sw/src/sector.cpp index 2f7b5161c..1d1596fba 100644 --- a/source/games/sw/src/sector.cpp +++ b/source/games/sw/src/sector.cpp @@ -653,22 +653,15 @@ void DoSpringBoardDown(void) return; } -short FindNextSectorByTag(short sectnum, int tag) +short FindNextSectorByTag(short sect, int tag) { - short next_sectnum, startwall, endwall, j; - - startwall = sector[sectnum].wallptr; - endwall = startwall + sector[sectnum].wallnum - 1; - - for (j = startwall; j <= endwall; j++) + for(auto& wal : wallsofsector(sect)) { - next_sectnum = wall[j].nextsector; - - if (next_sectnum >= 0) + if (wal.twoSided()) { - if (sector[next_sectnum].lotag == tag) + if (wal.nextSector()->lotag == tag) { - return next_sectnum; + return sectnum(wal.nextSector()); } } } diff --git a/source/games/sw/src/track.cpp b/source/games/sw/src/track.cpp index 1ab10f0dd..7b0bf4bce 100644 --- a/source/games/sw/src/track.cpp +++ b/source/games/sw/src/track.cpp @@ -3512,7 +3512,7 @@ bool ActorTrackDecide(TRACK_POINTp tpoint, DSWActor* actor) auto wal = &wall[hit_wall]; #if DEBUG - if (wal->nextsector < 0) + if (!wal->twoSided()) { I_Error("Take out white wall ladder x = %d, y = %d",wal->x, wal->y); } diff --git a/wadsrc/static/zscript/games/sw/swgame.zs b/wadsrc/static/zscript/games/sw/swgame.zs index d07212c47..51debaa6c 100644 --- a/wadsrc/static/zscript/games/sw/swgame.zs +++ b/wadsrc/static/zscript/games/sw/swgame.zs @@ -227,7 +227,7 @@ struct SWPlayer native native int16 pnum; // carry along the player number - native int16 LadderSector; + //native int16 LadderSector; native int lx,ly; // ladder x and y native int16 JumpDuration; native int16 WadeDepth;