From b1c3d1b2e7e3db62a2a720e6f4714702e7976f0d Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 2 Apr 2023 05:20:36 -0700 Subject: [PATCH 1/2] noclip command: toggle MF_NOCLIPHEIGHT in spectator --- src/d_netcmd.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 1101172a2..1287aa99d 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -5606,12 +5606,22 @@ static void Got_Cheat(UINT8 **cp, INT32 playernum) if (!P_MobjWasRemoved(player->mo)) { - player->mo->flags ^= MF_NOCLIP; + UINT32 noclipFlags = MF_NOCLIP; - if (!(player->mo->flags & MF_NOCLIP)) + if (player->spectator) { + noclipFlags |= MF_NOCLIPHEIGHT; + } + + if (player->mo->flags & MF_NOCLIP) + { + player->mo->flags &= ~(noclipFlags); status = "off"; } + else + { + player->mo->flags |= noclipFlags; + } } CV_CheaterWarning(targetPlayer, va("noclip %s", status)); From 652fb5452e5f87192056e01ac93e3914a5436c24 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 2 Apr 2023 05:21:01 -0700 Subject: [PATCH 2/2] MF_NOCLIPHEIGHT: remove restrictions on first-person camera Fixes spectator noclip camera being clamped to floor/ceiling heights. --- src/p_mobj.c | 5 +++-- src/p_user.c | 19 +++++++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 1604257ca..4322e8478 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2839,8 +2839,9 @@ void P_PlayerZMovement(mobj_t *mo) P_AdjustMobjFloorZ_PolyObjs(mo, mo->subsector); // check for smooth step up - if ((mo->eflags & MFE_VERTICALFLIP && mo->z + mo->height > mo->ceilingz) - || (!(mo->eflags & MFE_VERTICALFLIP) && mo->z < mo->floorz)) + if (!(mo->flags & MF_NOCLIPHEIGHT) + && ((mo->eflags & MFE_VERTICALFLIP && mo->z + mo->height > mo->ceilingz) + || (!(mo->eflags & MFE_VERTICALFLIP) && mo->z < mo->floorz))) { if (mo->eflags & MFE_VERTICALFLIP) mo->player->viewheight -= (mo->z+mo->height) - mo->ceilingz; diff --git a/src/p_user.c b/src/p_user.c index 7529c12ad..9f539f541 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -220,12 +220,20 @@ void P_CalcHeight(player_t *player) if (mo->eflags & MFE_VERTICALFLIP) { player->viewz = mo->z + mo->height - player->viewheight; + + if (mo->flags & MF_NOCLIPHEIGHT) + return; + if (player->viewz < mo->floorz + FixedMul(FRACUNIT, mo->scale)) player->viewz = mo->floorz + FixedMul(FRACUNIT, mo->scale); } else { player->viewz = mo->z + player->viewheight; + + if (mo->flags & MF_NOCLIPHEIGHT) + return; + if (player->viewz > mo->ceilingz - FixedMul(FRACUNIT, mo->scale)) player->viewz = mo->ceilingz - FixedMul(FRACUNIT, mo->scale); } @@ -2300,10 +2308,13 @@ static void P_SpectatorMovement(player_t *player) else if (cmd->buttons & BT_BRAKE) player->mo->z -= 32*mapobjectscale; - if (player->mo->z > player->mo->ceilingz - player->mo->height) - player->mo->z = player->mo->ceilingz - player->mo->height; - if (player->mo->z < player->mo->floorz) - player->mo->z = player->mo->floorz; + if (!(player->mo->flags & MF_NOCLIPHEIGHT)) + { + if (player->mo->z > player->mo->ceilingz - player->mo->height) + player->mo->z = player->mo->ceilingz - player->mo->height; + if (player->mo->z < player->mo->floorz) + player->mo->z = player->mo->floorz; + } player->mo->momx = player->mo->momy = player->mo->momz = 0; if (cmd->forwardmove != 0)