diff --git a/source/core/gamecontrol.h b/source/core/gamecontrol.h index 61d048dd5..d9f3b8238 100644 --- a/source/core/gamecontrol.h +++ b/source/core/gamecontrol.h @@ -97,7 +97,7 @@ struct PlayerHorizon adjustment = 0; } - void settarget(double value) + void settarget(double value, bool backup = false) { if (!cl_syncinput) { @@ -107,6 +107,7 @@ struct PlayerHorizon else { horiz = q16horiz(FloatToFixed(value)); + if (backup) ohoriz = horiz; } } diff --git a/source/exhumed/src/gun.cpp b/source/exhumed/src/gun.cpp index d9f091aec..db4ecd8c8 100644 --- a/source/exhumed/src/gun.cpp +++ b/source/exhumed/src/gun.cpp @@ -739,7 +739,7 @@ loc_flag: // loc_27266: case kWeaponSword: { - nHeight += -PlayerList[nLocalPlayer].q16horiz >> 10; + nHeight += -PlayerList[nLocalPlayer].horizon.horiz.asq16() >> 10; theZ += nHeight; @@ -844,7 +844,7 @@ loc_flag: } case kWeaponPistol: { - int var_50 = PlayerList[nLocalPlayer].q16horiz >> 14; + int var_50 = PlayerList[nLocalPlayer].horizon.horiz.asq16() >> 14; nHeight -= var_50; if (sPlayerInput[nPlayer].nTarget >= 0 && cl_autoaim) @@ -859,7 +859,7 @@ loc_flag: case kWeaponGrenade: { - ThrowGrenade(nPlayer, ebp, ebx, nHeight - 2560, FixedToInt(PlayerList[nLocalPlayer].q16horiz)); + ThrowGrenade(nPlayer, ebp, ebx, nHeight - 2560, FixedToInt(PlayerList[nLocalPlayer].horizon.horiz.asq16())); break; } case kWeaponStaff: diff --git a/source/exhumed/src/input.cpp b/source/exhumed/src/input.cpp index 7de74f7cf..a4cd2459e 100644 --- a/source/exhumed/src/input.cpp +++ b/source/exhumed/src/input.cpp @@ -129,10 +129,15 @@ void GameInterface::GetInput(InputPacket* packet, ControlInfo* const hidInput) if (!nFreeze) { applylook(&pPlayer->q16angle, &pPlayer->q16look_ang, &pPlayer->q16rotscrnang, &pPlayer->spin, input.q16avel, &sPlayerInput[nLocalPlayer].actions, scaleAdjust, eyelevel[nLocalPlayer] > -14080); - sethorizon2(&pPlayer->q16horiz, input.q16horz, &sPlayerInput[nLocalPlayer].actions, scaleAdjust); + sethorizon(&pPlayer->horizon.horiz, input.q16horz, &sPlayerInput[nLocalPlayer].actions, scaleAdjust); } - playerProcessHelpers(&pPlayer->q16angle, &pPlayer->angAdjust, &pPlayer->angTarget, &pPlayer->q16horiz, &pPlayer->horizAdjust, &pPlayer->horizTarget, scaleAdjust); + // temporary vals to pass through to playerProcessHelpers(). + fixed_t horiz = 0; + fixed_t target = 0; + double adjust = 0; + playerProcessHelpers(&pPlayer->q16angle, &pPlayer->angAdjust, &pPlayer->angTarget, &horiz, &adjust, &target, scaleAdjust); + pPlayer->horizon.processhelpers(scaleAdjust); UpdatePlayerSpriteAngle(pPlayer); } diff --git a/source/exhumed/src/osdcmds.cpp b/source/exhumed/src/osdcmds.cpp index 34ec72d51..d44ea289d 100644 --- a/source/exhumed/src/osdcmds.cpp +++ b/source/exhumed/src/osdcmds.cpp @@ -50,12 +50,12 @@ static int osdcmd_warptocoords(CCmdFuncPtr parm) if (parm->numparms >= 4) { - nPlayer->q16angle = IntToFixed(atoi(parm->parms[3])); + nPlayer->oq16angle = nPlayer->q16angle = IntToFixed(atoi(parm->parms[3])); } if (parm->numparms == 5) { - nPlayer->q16horiz = IntToFixed(atoi(parm->parms[4])); + nPlayer->horizon.ohoriz = nPlayer->horizon.horiz = buildhoriz(atoi(parm->parms[4])); } return CCMD_OK; diff --git a/source/exhumed/src/player.cpp b/source/exhumed/src/player.cpp index 77ab49e6e..3300fa015 100644 --- a/source/exhumed/src/player.cpp +++ b/source/exhumed/src/player.cpp @@ -336,9 +336,9 @@ void RestartPlayer(short nPlayer) PlayerList[nPlayer].opos = sprite[nSprite].pos; PlayerList[nPlayer].oq16angle = PlayerList[nPlayer].q16angle; - PlayerList[nPlayer].oq16horiz = PlayerList[nPlayer].q16horiz; PlayerList[nPlayer].oq16look_ang = PlayerList[nPlayer].q16look_ang = 0; PlayerList[nPlayer].oq16rotscrnang = PlayerList[nPlayer].q16rotscrnang = 0; + PlayerList[nPlayer].horizon.backup(); nPlayerFloorSprite[nPlayer] = floorspr; @@ -438,7 +438,7 @@ void RestartPlayer(short nPlayer) nYDamage[nPlayer] = 0; nXDamage[nPlayer] = 0; - PlayerList[nPlayer].oq16horiz = PlayerList[nPlayer].q16horiz = 0; + PlayerList[nPlayer].horizon.ohoriz = PlayerList[nPlayer].horizon.horiz = q16horiz(0); nBreathTimer[nPlayer] = 90; nTauntTimer[nPlayer] = RandomSize(3) + 3; @@ -535,7 +535,7 @@ void StartDeathSeq(int nPlayer, int nVal) StopFiringWeapon(nPlayer); - PlayerList[nPlayer].oq16horiz = PlayerList[nPlayer].q16horiz = 0; + PlayerList[nPlayer].horizon.ohoriz = PlayerList[nPlayer].horizon.horiz = q16horiz(0); oeyelevel[nPlayer] = eyelevel[nPlayer] = -14080; nPlayerInvisible[nPlayer] = 0; dVertPan[nPlayer] = 15; @@ -726,12 +726,12 @@ void FuncPlayer(int a, int nDamage, int nRun) short nSprite2; PlayerList[nPlayer].angAdjust = 0; - PlayerList[nPlayer].horizAdjust = 0; PlayerList[nPlayer].opos = sprite[nPlayerSprite].pos; PlayerList[nPlayer].oq16angle = PlayerList[nPlayer].q16angle; - PlayerList[nPlayer].oq16horiz = PlayerList[nPlayer].q16horiz; PlayerList[nPlayer].oq16look_ang = PlayerList[nPlayer].q16look_ang; PlayerList[nPlayer].oq16rotscrnang = PlayerList[nPlayer].q16rotscrnang; + PlayerList[nPlayer].horizon.backup(); + PlayerList[nPlayer].horizon.resetadjustment(); oeyelevel[nPlayer] = eyelevel[nPlayer]; switch (nMessage) @@ -1050,8 +1050,7 @@ void FuncPlayer(int a, int nDamage, int nRun) PlayerList[nPlayer].oq16angle = PlayerList[nPlayer].q16angle; sprite[nPlayerSprite].ang = ang; - playerSetHoriz2(&PlayerList[nPlayer].q16horiz, &PlayerList[nPlayer].horizTarget, 0); - PlayerList[nPlayer].oq16horiz = PlayerList[nPlayer].q16horiz; + PlayerList[nPlayer].horizon.settarget(0, true); lPlayerXVel = 0; lPlayerYVel = 0; @@ -1069,11 +1068,11 @@ void FuncPlayer(int a, int nDamage, int nRun) if (currentLevel->levelNumber == 11) { - playerSetHoriz2(&PlayerList[nPlayer].q16horiz, &PlayerList[nPlayer].horizTarget, 46); + PlayerList[nPlayer].horizon.settarget(46); } else { - playerSetHoriz2(&PlayerList[nPlayer].q16horiz, &PlayerList[nPlayer].horizTarget, 11); + PlayerList[nPlayer].horizon.settarget(11); } } } @@ -1101,7 +1100,7 @@ void FuncPlayer(int a, int nDamage, int nRun) zVelB = -zVelB; } - if (zVelB > 512 && PlayerList[nPlayer].q16horiz != 0 && (sPlayerInput[nPlayer].actions & (SB_AIMMODE))) { + if (zVelB > 512 && PlayerList[nPlayer].horizon.horiz.asq16() != 0 && (sPlayerInput[nPlayer].actions & (SB_AIMMODE))) { sPlayerInput[nPlayer].actions |= SB_CENTERVIEW; } } @@ -2669,7 +2668,7 @@ loc_1BD2E: if (cl_syncinput) { Player* pPlayer = &PlayerList[nPlayer]; - sethorizon2(&pPlayer->q16horiz, sPlayerInput[nPlayer].pan, &sPlayerInput[nLocalPlayer].actions, 1); + sethorizon(&pPlayer->horizon.horiz, sPlayerInput[nPlayer].pan, &sPlayerInput[nLocalPlayer].actions, 1); } } else // else, player's health is less than 0 @@ -2789,20 +2788,20 @@ loc_1BD2E: } else { - if (PlayerList[nPlayer].q16horiz < 0) + if (PlayerList[nPlayer].horizon.horiz.asq16() < 0) { - playerSetHoriz2(&PlayerList[nPlayer].q16horiz, &PlayerList[nPlayer].horizTarget, 0); + PlayerList[nPlayer].horizon.settarget(0); eyelevel[nPlayer] -= (dVertPan[nPlayer] << 8); } else { - playerAddHoriz2(&PlayerList[nPlayer].q16horiz, &PlayerList[nPlayer].horizAdjust, dVertPan[nPlayer]); + PlayerList[nPlayer].horizon.addadjustment(dVertPan[nPlayer]); - if (PlayerList[nPlayer].q16horiz > gi->playerHorizMax()) + if (PlayerList[nPlayer].horizon.horiz.asq16() > gi->playerHorizMax()) { - playerSetHoriz2(&PlayerList[nPlayer].q16horiz, &PlayerList[nPlayer].horizTarget, gi->playerHorizMax()); + PlayerList[nPlayer].horizon.settarget(gi->playerHorizMax()); } - else if (PlayerList[nPlayer].q16horiz <= 0) + else if (PlayerList[nPlayer].horizon.horiz.asq16() <= 0) { if (!(SectFlag[sprite[nPlayerSprite].sectnum] & kSectUnderwater)) { diff --git a/source/exhumed/src/player.h b/source/exhumed/src/player.h index 40293001a..242009b54 100644 --- a/source/exhumed/src/player.h +++ b/source/exhumed/src/player.h @@ -20,6 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #define __player_h__ #include "compat.h" +#include "gamecontrol.h" BEGIN_PS_NS @@ -69,13 +70,13 @@ struct Player short field_3C; short nRun; + PlayerHorizon horizon; fixed_t oq16angle, q16angle; - fixed_t oq16horiz, q16horiz; fixed_t oq16look_ang, q16look_ang; fixed_t oq16rotscrnang, q16rotscrnang; fixed_t spin; - fixed_t angTarget, horizTarget; - double angAdjust, horizAdjust; + fixed_t angTarget; + double angAdjust; vec3_t opos; }; diff --git a/source/exhumed/src/view.cpp b/source/exhumed/src/view.cpp index a47a5e704..3f526a297 100644 --- a/source/exhumed/src/view.cpp +++ b/source/exhumed/src/view.cpp @@ -49,7 +49,7 @@ short nQuake[kMaxPlayers] = { 0 }; short nChunkTotal = 0; fixed_t nCameraa; -fixed_t nCamerapan; +fixedhoriz nCamerapan; short nViewTop; bool bCamera = false; @@ -236,7 +236,7 @@ void DrawView(double smoothRatio, bool sceneonly) int playerZ; short nSector; fixed_t nAngle; - fixed_t pan; + fixedhoriz pan; fixed_t q16rotscrnang; fixed_t dang = IntToFixed(1024); @@ -313,7 +313,7 @@ void DrawView(double smoothRatio, bool sceneonly) { if (nSnakeCam >= 0 && !sceneonly) { - pan = 0; + pan = q16horiz(0); viewz = playerZ; } else @@ -323,11 +323,11 @@ void DrawView(double smoothRatio, bool sceneonly) if (!cl_syncinput) { - pan = PlayerList[nLocalPlayer].q16horiz; + pan = PlayerList[nLocalPlayer].horizon.sum(); } else { - pan = PlayerList[nLocalPlayer].oq16horiz + xs_CRoundToInt(fmulscale16(PlayerList[nLocalPlayer].q16horiz - PlayerList[nLocalPlayer].oq16horiz, smoothRatio)); + pan = PlayerList[nLocalPlayer].horizon.interpolatedsum(smoothRatio); } if (viewz > floorZ) @@ -344,11 +344,11 @@ void DrawView(double smoothRatio, bool sceneonly) -2000 * Sin(inita), 4, 0, 0, CLIPMASK1); - pan = 0; + pan = q16horiz(0); viewz = playerZ; } - pan = clamp(pan, gi->playerHorizMin(), gi->playerHorizMax()); + pan = q16horiz(clamp(pan.asq16(), gi->playerHorizMin(), gi->playerHorizMax())); nCamerax = playerX; nCameray = playerY; @@ -404,7 +404,7 @@ void DrawView(double smoothRatio, bool sceneonly) } } - renderDrawRoomsQ16(nCamerax, nCameray, viewz, nCameraa, nCamerapan, nSector); + renderDrawRoomsQ16(nCamerax, nCameray, viewz, nCameraa, nCamerapan.asq16(), nSector); analyzesprites(); renderDrawMasks();