From 645ea1e1ae0fa0c1d8a5817b0c84cf5a79b43847 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 13 May 2021 23:25:47 +0200 Subject: [PATCH] - SW: better handling for bogus ladders. If there is no back sector, use the front sector of the wall as the ladder sector. This at least fixes the badly defined ladder in Wanton Destruction's first map. --- source/games/sw/src/player.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index 4db37add5..35b75051a 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -3462,7 +3462,11 @@ DoPlayerClimb(PLAYERp pp) DoPlayerZrange(pp); - ASSERT(pp->LadderSector >= 0 && pp->LadderSector <= MAXSECTORS); + if (pp->LadderSector < 0 || pp->LadderSector > MAXSECTORS) + { + Printf("Bad ladder sector!\n"); + return; + } // moving UP if (climbvel > 0) @@ -3573,8 +3577,6 @@ DoPlayerClimb(PLAYERp pp) if (wal >= 0) { - pp->LadderSector = wall[wal].nextsector; - lsp = FindNearSprite(pp->SpriteP, STAT_CLIMB_MARKER); // determine where the player is supposed to be in relation to the ladder @@ -3583,7 +3585,7 @@ DoPlayerClimb(PLAYERp pp) ny = MOVEy(100, lsp->ang); // set ladder sector - pp->LadderSector = wall[wal].nextsector; + pp->LadderSector = wall[wal].nextsector >= 0? wall[wal].nextsector : wall[wal].sector; // set players "view" distance from the ladder - needs to be farther than // the sprite @@ -3994,7 +3996,7 @@ PlayerOnLadder(PLAYERp pp) } #endif - pp->LadderSector = wall[wal].nextsector; + pp->LadderSector = wall[wal].nextsector >= 0 ? wall[wal].nextsector : wall[wal].sector; //DSPRINTF(ds, "Ladder Sector %d", pp->LadderSector); MONO_PRINT(ds);