diff --git a/CHANGELOG.md b/CHANGELOG.md index 04d386156..64537c591 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,7 @@ - **Teleporter Zoom and BFG "explosion" shake affecting all players in multiplayer** - **Explosion shake being stopped by the menu during demo playback and netgames** - **View snapping when teleporting to Automap pointer while crouching** +- **View clipping through floor when landing while crouching** - **Fixed a demo desync** caused by a failed weapon autoswitch when picking up ammo - **_View Height_ increments not being applied immediately** - **Tweaked dark menu background and Automap overlay algorithm** (fixes very low values) diff --git a/src/p_user.c b/src/p_user.c index d90bcb707..5ed2dc24a 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -179,7 +179,7 @@ void P_CalcHeight (player_t* player) player->viewheight += breathing_val; } - + if (player->viewheight > view) { player->viewheight = view; @@ -201,9 +201,20 @@ void P_CalcHeight (player_t* player) } } - // [Nugget] Account for crouching - player->viewz = player->mo->z + player->viewheight + bob - player->crouchoffset; - + player->viewz = player->mo->z + player->viewheight + bob; + + // [Nugget] Account for crouching, but don't clip view through the floor + if (player->crouchoffset) + { + fixed_t crouchoffset = player->crouchoffset; + + if ((player->viewz - crouchoffset) < (player->mo->floorz + FRACUNIT)) + { crouchoffset = player->viewz - (player->mo->floorz + FRACUNIT); } + + // Do clip view through the floor if not because of crouching + player->viewz -= MAX(0, crouchoffset); + } + if (player->viewz > player->mo->ceilingz-4*FRACUNIT) player->viewz = player->mo->ceilingz-4*FRACUNIT; }