From b99ac8c4a012cbdbc2537eda747998a2bd6fbc58 Mon Sep 17 00:00:00 2001 From: terminx Date: Tue, 17 Sep 2019 03:21:17 +0000 Subject: [PATCH] This should help with some of the player movement fuckery This fixes the bug that let you jump through the ticket booth window in E1L1 and the problems jumping into vents when run mode is disabled. git-svn-id: https://svn.eduke32.com/eduke32@8119 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/duke3d/src/player.cpp | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/source/duke3d/src/player.cpp b/source/duke3d/src/player.cpp index 90cc60164..bed005d5b 100644 --- a/source/duke3d/src/player.cpp +++ b/source/duke3d/src/player.cpp @@ -4669,32 +4669,28 @@ void P_ProcessInput(int playerNum) pPlayer->cursectnum = 0; } - int sectorLotag = sector[pPlayer->cursectnum].lotag; // sectorLotag can be set to 0 later on, but the same block sets spritebridge to 1 - int stepHeight = (sectorLotag == ST_1_ABOVE_WATER && pPlayer->spritebridge != 1) ? pPlayer->autostep_sbw : pPlayer->autostep; + int sectorLotag = sector[pPlayer->cursectnum].lotag; + int getZRangeOffset = ((TEST_SYNC_KEY(playerBits, SK_CROUCH) || (sectorLotag == ST_1_ABOVE_WATER && pPlayer->spritebridge != 1))) ? pPlayer->autostep_sbw : pPlayer->autostep; + int const stepHeight = getZRangeOffset; + + // we want to take these into account for getzrange() but not for the clipmove() call below + if (!pPlayer->on_ground) + getZRangeOffset = pPlayer->autostep_sbw; int32_t floorZ, ceilZ, highZhit, lowZhit, dummy; if (sectorLotag != ST_2_UNDERWATER) { - if (pPlayer->pos.z + stepHeight > actor[pPlayer->i].floorz - PMINHEIGHT) - stepHeight -= (pPlayer->pos.z + stepHeight) - (actor[pPlayer->i].floorz - PMINHEIGHT); - else if (!pPlayer->on_ground) - stepHeight -= (pPlayer->jumping_counter << 1) + (pPlayer->jumping_counter >> 1); - - stepHeight = max(stepHeight, 0); + if (pPlayer->pos.z + getZRangeOffset > actor[pPlayer->i].floorz - PMINHEIGHT) + getZRangeOffset -= klabs((pPlayer->pos.z + getZRangeOffset) - (actor[pPlayer->i].floorz - PMINHEIGHT)); + else if (pPlayer->pos.z + getZRangeOffset < actor[pPlayer->i].ceilingz + PMINHEIGHT) + getZRangeOffset += klabs((actor[pPlayer->i].ceilingz + PMINHEIGHT) - (pPlayer->pos.z + getZRangeOffset)); } - else stepHeight = 0; - pPlayer->pos.z += stepHeight; + pPlayer->pos.z += getZRangeOffset; getzrange(&pPlayer->pos, pPlayer->cursectnum, &ceilZ, &highZhit, &floorZ, &lowZhit, pPlayer->clipdist - GETZRANGECLIPDISTOFFSET, CLIPMASK0); - pPlayer->pos.z -= stepHeight; - - int32_t ceilZ2 = ceilZ; - getzrange(&pPlayer->pos, pPlayer->cursectnum, &ceilZ, &highZhit, &dummy, &dummy, pPlayer->clipdist - GETZRANGECLIPDISTOFFSET, CSTAT_SPRITE_ALIGNMENT_FLOOR << 16); - - if ((highZhit & 49152) == 49152 && (sprite[highZhit & (MAXSPRITES - 1)].cstat & CSTAT_SPRITE_BLOCK) != CSTAT_SPRITE_BLOCK) - ceilZ = ceilZ2; + pPlayer->pos.z -= getZRangeOffset; pPlayer->spritebridge = 0; pPlayer->sbs = 0;