- Exhumed: Cut q16horiz over to PlayerHorizon struct.

This commit is contained in:
Mitchell Richters 2020-10-07 17:40:59 +11:00
parent c03131f8d1
commit 6da756cc9f
7 changed files with 42 additions and 36 deletions

View file

@ -97,7 +97,7 @@ struct PlayerHorizon
adjustment = 0; adjustment = 0;
} }
void settarget(double value) void settarget(double value, bool backup = false)
{ {
if (!cl_syncinput) if (!cl_syncinput)
{ {
@ -107,6 +107,7 @@ struct PlayerHorizon
else else
{ {
horiz = q16horiz(FloatToFixed(value)); horiz = q16horiz(FloatToFixed(value));
if (backup) ohoriz = horiz;
} }
} }

View file

@ -739,7 +739,7 @@ loc_flag:
// loc_27266: // loc_27266:
case kWeaponSword: case kWeaponSword:
{ {
nHeight += -PlayerList[nLocalPlayer].q16horiz >> 10; nHeight += -PlayerList[nLocalPlayer].horizon.horiz.asq16() >> 10;
theZ += nHeight; theZ += nHeight;
@ -844,7 +844,7 @@ loc_flag:
} }
case kWeaponPistol: case kWeaponPistol:
{ {
int var_50 = PlayerList[nLocalPlayer].q16horiz >> 14; int var_50 = PlayerList[nLocalPlayer].horizon.horiz.asq16() >> 14;
nHeight -= var_50; nHeight -= var_50;
if (sPlayerInput[nPlayer].nTarget >= 0 && cl_autoaim) if (sPlayerInput[nPlayer].nTarget >= 0 && cl_autoaim)
@ -859,7 +859,7 @@ loc_flag:
case kWeaponGrenade: 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; break;
} }
case kWeaponStaff: case kWeaponStaff:

View file

@ -129,10 +129,15 @@ void GameInterface::GetInput(InputPacket* packet, ControlInfo* const hidInput)
if (!nFreeze) if (!nFreeze)
{ {
applylook(&pPlayer->q16angle, &pPlayer->q16look_ang, &pPlayer->q16rotscrnang, &pPlayer->spin, input.q16avel, &sPlayerInput[nLocalPlayer].actions, scaleAdjust, eyelevel[nLocalPlayer] > -14080); 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); UpdatePlayerSpriteAngle(pPlayer);
} }

View file

@ -50,12 +50,12 @@ static int osdcmd_warptocoords(CCmdFuncPtr parm)
if (parm->numparms >= 4) if (parm->numparms >= 4)
{ {
nPlayer->q16angle = IntToFixed(atoi(parm->parms[3])); nPlayer->oq16angle = nPlayer->q16angle = IntToFixed(atoi(parm->parms[3]));
} }
if (parm->numparms == 5) 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; return CCMD_OK;

View file

@ -336,9 +336,9 @@ void RestartPlayer(short nPlayer)
PlayerList[nPlayer].opos = sprite[nSprite].pos; PlayerList[nPlayer].opos = sprite[nSprite].pos;
PlayerList[nPlayer].oq16angle = PlayerList[nPlayer].q16angle; PlayerList[nPlayer].oq16angle = PlayerList[nPlayer].q16angle;
PlayerList[nPlayer].oq16horiz = PlayerList[nPlayer].q16horiz;
PlayerList[nPlayer].oq16look_ang = PlayerList[nPlayer].q16look_ang = 0; PlayerList[nPlayer].oq16look_ang = PlayerList[nPlayer].q16look_ang = 0;
PlayerList[nPlayer].oq16rotscrnang = PlayerList[nPlayer].q16rotscrnang = 0; PlayerList[nPlayer].oq16rotscrnang = PlayerList[nPlayer].q16rotscrnang = 0;
PlayerList[nPlayer].horizon.backup();
nPlayerFloorSprite[nPlayer] = floorspr; nPlayerFloorSprite[nPlayer] = floorspr;
@ -438,7 +438,7 @@ void RestartPlayer(short nPlayer)
nYDamage[nPlayer] = 0; nYDamage[nPlayer] = 0;
nXDamage[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; nBreathTimer[nPlayer] = 90;
nTauntTimer[nPlayer] = RandomSize(3) + 3; nTauntTimer[nPlayer] = RandomSize(3) + 3;
@ -535,7 +535,7 @@ void StartDeathSeq(int nPlayer, int nVal)
StopFiringWeapon(nPlayer); StopFiringWeapon(nPlayer);
PlayerList[nPlayer].oq16horiz = PlayerList[nPlayer].q16horiz = 0; PlayerList[nPlayer].horizon.ohoriz = PlayerList[nPlayer].horizon.horiz = q16horiz(0);
oeyelevel[nPlayer] = eyelevel[nPlayer] = -14080; oeyelevel[nPlayer] = eyelevel[nPlayer] = -14080;
nPlayerInvisible[nPlayer] = 0; nPlayerInvisible[nPlayer] = 0;
dVertPan[nPlayer] = 15; dVertPan[nPlayer] = 15;
@ -726,12 +726,12 @@ void FuncPlayer(int a, int nDamage, int nRun)
short nSprite2; short nSprite2;
PlayerList[nPlayer].angAdjust = 0; PlayerList[nPlayer].angAdjust = 0;
PlayerList[nPlayer].horizAdjust = 0;
PlayerList[nPlayer].opos = sprite[nPlayerSprite].pos; PlayerList[nPlayer].opos = sprite[nPlayerSprite].pos;
PlayerList[nPlayer].oq16angle = PlayerList[nPlayer].q16angle; PlayerList[nPlayer].oq16angle = PlayerList[nPlayer].q16angle;
PlayerList[nPlayer].oq16horiz = PlayerList[nPlayer].q16horiz;
PlayerList[nPlayer].oq16look_ang = PlayerList[nPlayer].q16look_ang; PlayerList[nPlayer].oq16look_ang = PlayerList[nPlayer].q16look_ang;
PlayerList[nPlayer].oq16rotscrnang = PlayerList[nPlayer].q16rotscrnang; PlayerList[nPlayer].oq16rotscrnang = PlayerList[nPlayer].q16rotscrnang;
PlayerList[nPlayer].horizon.backup();
PlayerList[nPlayer].horizon.resetadjustment();
oeyelevel[nPlayer] = eyelevel[nPlayer]; oeyelevel[nPlayer] = eyelevel[nPlayer];
switch (nMessage) switch (nMessage)
@ -1050,8 +1050,7 @@ void FuncPlayer(int a, int nDamage, int nRun)
PlayerList[nPlayer].oq16angle = PlayerList[nPlayer].q16angle; PlayerList[nPlayer].oq16angle = PlayerList[nPlayer].q16angle;
sprite[nPlayerSprite].ang = ang; sprite[nPlayerSprite].ang = ang;
playerSetHoriz2(&PlayerList[nPlayer].q16horiz, &PlayerList[nPlayer].horizTarget, 0); PlayerList[nPlayer].horizon.settarget(0, true);
PlayerList[nPlayer].oq16horiz = PlayerList[nPlayer].q16horiz;
lPlayerXVel = 0; lPlayerXVel = 0;
lPlayerYVel = 0; lPlayerYVel = 0;
@ -1069,11 +1068,11 @@ void FuncPlayer(int a, int nDamage, int nRun)
if (currentLevel->levelNumber == 11) if (currentLevel->levelNumber == 11)
{ {
playerSetHoriz2(&PlayerList[nPlayer].q16horiz, &PlayerList[nPlayer].horizTarget, 46); PlayerList[nPlayer].horizon.settarget(46);
} }
else 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; 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; sPlayerInput[nPlayer].actions |= SB_CENTERVIEW;
} }
} }
@ -2669,7 +2668,7 @@ loc_1BD2E:
if (cl_syncinput) if (cl_syncinput)
{ {
Player* pPlayer = &PlayerList[nPlayer]; 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 else // else, player's health is less than 0
@ -2789,20 +2788,20 @@ loc_1BD2E:
} }
else 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); eyelevel[nPlayer] -= (dVertPan[nPlayer] << 8);
} }
else 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)) if (!(SectFlag[sprite[nPlayerSprite].sectnum] & kSectUnderwater))
{ {

View file

@ -20,6 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define __player_h__ #define __player_h__
#include "compat.h" #include "compat.h"
#include "gamecontrol.h"
BEGIN_PS_NS BEGIN_PS_NS
@ -69,13 +70,13 @@ struct Player
short field_3C; short field_3C;
short nRun; short nRun;
PlayerHorizon horizon;
fixed_t oq16angle, q16angle; fixed_t oq16angle, q16angle;
fixed_t oq16horiz, q16horiz;
fixed_t oq16look_ang, q16look_ang; fixed_t oq16look_ang, q16look_ang;
fixed_t oq16rotscrnang, q16rotscrnang; fixed_t oq16rotscrnang, q16rotscrnang;
fixed_t spin; fixed_t spin;
fixed_t angTarget, horizTarget; fixed_t angTarget;
double angAdjust, horizAdjust; double angAdjust;
vec3_t opos; vec3_t opos;
}; };

View file

@ -49,7 +49,7 @@ short nQuake[kMaxPlayers] = { 0 };
short nChunkTotal = 0; short nChunkTotal = 0;
fixed_t nCameraa; fixed_t nCameraa;
fixed_t nCamerapan; fixedhoriz nCamerapan;
short nViewTop; short nViewTop;
bool bCamera = false; bool bCamera = false;
@ -236,7 +236,7 @@ void DrawView(double smoothRatio, bool sceneonly)
int playerZ; int playerZ;
short nSector; short nSector;
fixed_t nAngle; fixed_t nAngle;
fixed_t pan; fixedhoriz pan;
fixed_t q16rotscrnang; fixed_t q16rotscrnang;
fixed_t dang = IntToFixed(1024); fixed_t dang = IntToFixed(1024);
@ -313,7 +313,7 @@ void DrawView(double smoothRatio, bool sceneonly)
{ {
if (nSnakeCam >= 0 && !sceneonly) if (nSnakeCam >= 0 && !sceneonly)
{ {
pan = 0; pan = q16horiz(0);
viewz = playerZ; viewz = playerZ;
} }
else else
@ -323,11 +323,11 @@ void DrawView(double smoothRatio, bool sceneonly)
if (!cl_syncinput) if (!cl_syncinput)
{ {
pan = PlayerList[nLocalPlayer].q16horiz; pan = PlayerList[nLocalPlayer].horizon.sum();
} }
else else
{ {
pan = PlayerList[nLocalPlayer].oq16horiz + xs_CRoundToInt(fmulscale16(PlayerList[nLocalPlayer].q16horiz - PlayerList[nLocalPlayer].oq16horiz, smoothRatio)); pan = PlayerList[nLocalPlayer].horizon.interpolatedsum(smoothRatio);
} }
if (viewz > floorZ) if (viewz > floorZ)
@ -344,11 +344,11 @@ void DrawView(double smoothRatio, bool sceneonly)
-2000 * Sin(inita), -2000 * Sin(inita),
4, 0, 0, CLIPMASK1); 4, 0, 0, CLIPMASK1);
pan = 0; pan = q16horiz(0);
viewz = playerZ; viewz = playerZ;
} }
pan = clamp(pan, gi->playerHorizMin(), gi->playerHorizMax()); pan = q16horiz(clamp(pan.asq16(), gi->playerHorizMin(), gi->playerHorizMax()));
nCamerax = playerX; nCamerax = playerX;
nCameray = playerY; 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(); analyzesprites();
renderDrawMasks(); renderDrawMasks();