From c5a3d846dd8460604681f272dff74a8b7b086701 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Tue, 3 Apr 2012 04:09:30 +0000 Subject: [PATCH] - Implement multitick viewpitch centering logic. SVN r3512 (trunk) --- src/d_net.cpp | 9 +-------- src/p_user.cpp | 20 ++++++++++++++++++-- src/r_utility.cpp | 2 +- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/d_net.cpp b/src/d_net.cpp index 648529f70..03b2ea2a1 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -2062,14 +2062,7 @@ void Net_DoCommand (int type, BYTE **stream, int player) break; case DEM_CENTERVIEW: - if (players[player].mo != NULL) - { - players[player].mo->pitch = 0; - } - if (player == consoleplayer) - { - LocalViewPitch = 0; - } + players[player].centering = true; break; case DEM_INVUSEALL: diff --git a/src/p_user.cpp b/src/p_user.cpp index 8d0c84444..bd1e04340 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -2241,9 +2241,9 @@ void P_PlayerThink (player_t *player) { if (look == -32768 << 16) { // center view - player->mo->pitch = 0; + player->centering = true; } - else + else if (!player->centering) { player->mo->pitch -= look; if (look > 0) @@ -2257,6 +2257,22 @@ void P_PlayerThink (player_t *player) } } } + if (player->centering) + { + if (abs(player->mo->pitch) > 2*ANGLE_1) + { + player->mo->pitch = FixedMul(player->mo->pitch, FRACUNIT*2/3); + } + else + { + player->mo->pitch = 0; + player->centering = false; + if (player - players == consoleplayer) + { + LocalViewPitch = 0; + } + } + } // [RH] Check for fast turn around if (cmd->ucmd.buttons & BT_TURN180 && !(player->oldbuttons & BT_TURN180)) diff --git a/src/r_utility.cpp b/src/r_utility.cpp index f23202a6b..ef05e3ef3 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -593,7 +593,7 @@ void R_InterpolateView (player_t *player, fixed_t frac, InterpolationViewer *ivi { viewangle = iview->nviewangle + (LocalViewAngle & 0xFFFF0000); - fixed_t delta = -(signed)(LocalViewPitch & 0xFFFF0000); + fixed_t delta = player->centering ? 0 : -(signed)(LocalViewPitch & 0xFFFF0000); viewpitch = iview->nviewpitch; if (delta > 0)