- gamecontrol: Initial setup of PlayerHorizon struct and deployment within Duke.

* Started with the most complicated game first.
* Struct made up of fixedhoriz class units.
* Append currently outgoing function names with `2` at the end to avoid conflict.
This commit is contained in:
Mitchell Richters 2020-10-07 17:12:37 +11:00
parent 0e3604ac9e
commit f39939d114
24 changed files with 275 additions and 157 deletions

View file

@ -56,7 +56,7 @@ void GameInterface::GetInput(InputPacket* packet, ControlInfo* const hidInput)
if (gView->pXSprite->health != 0) if (gView->pXSprite->health != 0)
{ {
applylook(&pPlayer->q16ang, &pPlayer->q16look_ang, &pPlayer->q16rotscrnang, &pPlayer->spin, input.q16avel, &pPlayer->input.actions, scaleAdjust, pPlayer->posture != 0); applylook(&pPlayer->q16ang, &pPlayer->q16look_ang, &pPlayer->q16rotscrnang, &pPlayer->spin, input.q16avel, &pPlayer->input.actions, scaleAdjust, pPlayer->posture != 0);
sethorizon(&pPlayer->q16horiz, input.q16horz, &pPlayer->input.actions, scaleAdjust); sethorizon2(&pPlayer->q16horiz, input.q16horz, &pPlayer->input.actions, scaleAdjust);
} }
playerProcessHelpers(&pPlayer->q16ang, &pPlayer->angAdjust, &pPlayer->angTarget, &pPlayer->q16horiz, &pPlayer->horizAdjust, &pPlayer->horizTarget, scaleAdjust); playerProcessHelpers(&pPlayer->q16ang, &pPlayer->angAdjust, &pPlayer->angTarget, &pPlayer->q16horiz, &pPlayer->horizAdjust, &pPlayer->horizTarget, scaleAdjust);

View file

@ -1364,7 +1364,7 @@ void ProcessInput(PLAYER *pPlayer)
} }
pPlayer->deathTime += 4; pPlayer->deathTime += 4;
if (!bSeqStat) if (!bSeqStat)
playerAddHoriz(&pPlayer->q16horiz, &pPlayer->horizAdjust, FixedToFloat(mulscale16(0x8000-(Cos(ClipHigh(pPlayer->deathTime<<3, 1024))>>15), gi->playerHorizMax()) - pPlayer->q16horiz)); playerAddHoriz2(&pPlayer->q16horiz, &pPlayer->horizAdjust, FixedToFloat(mulscale16(0x8000-(Cos(ClipHigh(pPlayer->deathTime<<3, 1024))>>15), gi->playerHorizMax()) - pPlayer->q16horiz));
if (pPlayer->curWeapon) if (pPlayer->curWeapon)
pInput->setNewWeapon(pPlayer->curWeapon); pInput->setNewWeapon(pPlayer->curWeapon);
if (pInput->actions & SB_OPEN) if (pInput->actions & SB_OPEN)
@ -1558,7 +1558,7 @@ void ProcessInput(PLAYER *pPlayer)
if (cl_syncinput) if (cl_syncinput)
{ {
sethorizon(&pPlayer->q16horiz, pInput->q16horz, &pInput->actions, 1); sethorizon2(&pPlayer->q16horiz, pInput->q16horz, &pInput->actions, 1);
} }
int nSector = pSprite->sectnum; int nSector = pSprite->sectnum;

View file

@ -1568,7 +1568,7 @@ void processMovement(InputPacket* currInput, InputPacket* inputBuffer, ControlIn
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void sethorizon(fixed_t* q16horiz, fixed_t const q16horz, ESyncBits* actions, double const scaleAdjust) void sethorizon2(fixed_t* q16horiz, fixed_t const q16horz, ESyncBits* actions, double const scaleAdjust)
{ {
// Calculate adjustment as true pitch (Fixed point math really sucks...) // Calculate adjustment as true pitch (Fixed point math really sucks...)
double horizAngle = HorizToPitch(*q16horiz); double horizAngle = HorizToPitch(*q16horiz);
@ -1628,6 +1628,73 @@ void sethorizon(fixed_t* q16horiz, fixed_t const q16horz, ESyncBits* actions, do
*q16horiz = clamp(PitchToHoriz(horizAngle), gi->playerHorizMin(), gi->playerHorizMax()); *q16horiz = clamp(PitchToHoriz(horizAngle), gi->playerHorizMin(), gi->playerHorizMax());
} }
//---------------------------------------------------------------------------
//
// Player's horizon function, called from game's ticker or from gi->GetInput() as required.
//
//---------------------------------------------------------------------------
static double const aimamount = HorizToPitch(250. / GameTicRate);
static double const lookamount = HorizToPitch(500. / GameTicRate);
void sethorizon(fixedhoriz* horiz, fixed_t const q16horz, ESyncBits* actions, double const scaleAdjust)
{
// Store current horizon as true pitch.
double pitch = horiz->aspitch();
if (q16horz)
{
*actions &= ~SB_CENTERVIEW;
pitch += FixedToFloat(q16horz);
}
// this is the locked type
if (*actions & (SB_AIM_UP|SB_AIM_DOWN))
{
*actions &= ~SB_CENTERVIEW;
if (*actions & SB_AIM_DOWN)
pitch -= scaleAdjust * aimamount;
if (*actions & SB_AIM_UP)
pitch += scaleAdjust * aimamount;
}
// this is the unlocked type
if (*actions & (SB_LOOK_UP|SB_LOOK_DOWN))
{
*actions |= SB_CENTERVIEW;
if (*actions & SB_LOOK_DOWN)
pitch -= scaleAdjust * lookamount;
if (*actions & SB_LOOK_UP)
pitch += scaleAdjust * lookamount;
}
// clamp pitch after processing
pitch = clamp(pitch, -90, 90);
// return to center if conditions met.
if ((*actions & SB_CENTERVIEW) && !(*actions & (SB_LOOK_UP|SB_LOOK_DOWN)))
{
if (abs(pitch) > 0.1375)
{
// move pitch back to 0
pitch += -scaleAdjust * pitch * (9. / GameTicRate);
}
else
{
// not looking anymore because pitch is back at 0
pitch = 0;
*actions &= ~SB_CENTERVIEW;
}
}
// clamp before returning
*horiz = q16horiz(clamp(PitchToHoriz(pitch), gi->playerHorizMin(), gi->playerHorizMax()));
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// //
// Player's angle function, called from game's ticker or from gi->GetInput() as required. // Player's angle function, called from game's ticker or from gi->GetInput() as required.
@ -1722,7 +1789,7 @@ void playerSetAngle(fixed_t* q16ang, fixed_t* helper, double adjustment)
} }
} }
void playerAddHoriz(fixed_t* q16horiz, double* helper, double adjustment) void playerAddHoriz2(fixed_t* q16horiz, double* helper, double adjustment)
{ {
if (!cl_syncinput) if (!cl_syncinput)
{ {
@ -1734,7 +1801,7 @@ void playerAddHoriz(fixed_t* q16horiz, double* helper, double adjustment)
} }
} }
void playerSetHoriz(fixed_t* q16horiz, fixed_t* helper, double adjustment) void playerSetHoriz2(fixed_t* q16horiz, fixed_t* helper, double adjustment)
{ {
if (!cl_syncinput) if (!cl_syncinput)
{ {

View file

@ -68,13 +68,87 @@ void CompleteLevel(MapRecord* map);
int getincangle(int c, int n); int getincangle(int c, int n);
fixed_t getincangleq16(fixed_t c, fixed_t n); fixed_t getincangleq16(fixed_t c, fixed_t n);
struct PlayerHorizon
{
fixedhoriz horiz, ohoriz, horizoff, ohorizoff;
fixed_t target;
double adjustment;
void backup()
{
ohoriz = horiz;
ohorizoff = horizoff;
}
void addadjustment(double value)
{
if (!cl_syncinput)
{
adjustment += value;
}
else
{
horiz += q16horiz(FloatToFixed(value));
}
}
void resetadjustment()
{
adjustment = 0;
}
void settarget(double value)
{
if (!cl_syncinput)
{
target = FloatToFixed(value);
if (target == 0) target += 1;
}
else
{
horiz = q16horiz(FloatToFixed(value));
}
}
void processhelpers(double const scaleAdjust)
{
if (target)
{
horiz += q16horiz(xs_CRoundToInt(scaleAdjust * (target - horiz.asq16())));
if (abs(horiz.asq16() - target) < FRACUNIT)
{
horiz = q16horiz(target);
target = 0;
}
}
else if (adjustment)
{
horiz += q16horiz(FloatToFixed(scaleAdjust * adjustment));
}
}
fixedhoriz sum()
{
return horiz + horizoff;
}
fixedhoriz interpolatedsum(double const smoothratio)
{
fixedhoriz prev = ohoriz + ohorizoff;
fixedhoriz curr = horiz + horizoff;
return q16horiz(prev.asq16() + mulscale16(curr.asq16() - prev.asq16(), smoothratio));
}
};
void processMovement(InputPacket* currInput, InputPacket* inputBuffer, ControlInfo* const hidInput, double const scaleAdjust, int const drink_amt = 0, bool const allowstrafe = true, double const turnscale = 1); void processMovement(InputPacket* currInput, InputPacket* inputBuffer, ControlInfo* const hidInput, double const scaleAdjust, int const drink_amt = 0, bool const allowstrafe = true, double const turnscale = 1);
void sethorizon(fixed_t* q16horiz, fixed_t const q16horz, ESyncBits* actions, double const scaleAdjust); void sethorizon(fixedhoriz* horiz, fixed_t const q16horz, ESyncBits* actions, double const scaleAdjust);
void sethorizon2(fixed_t* q16horiz, fixed_t const q16horz, ESyncBits* actions, double const scaleAdjust);
void applylook(fixed_t* q16ang, fixed_t* q16look_ang, fixed_t* q16rotscrnang, fixed_t* spin, fixed_t const q16avel, ESyncBits* actions, double const scaleAdjust, bool const crouching); void applylook(fixed_t* q16ang, fixed_t* q16look_ang, fixed_t* q16rotscrnang, fixed_t* spin, fixed_t const q16avel, ESyncBits* actions, double const scaleAdjust, bool const crouching);
void playerAddAngle(fixed_t* q16ang, double* helper, double adjustment); void playerAddAngle(fixed_t* q16ang, double* helper, double adjustment);
void playerSetAngle(fixed_t* q16ang, fixed_t* helper, double adjustment); void playerSetAngle(fixed_t* q16ang, fixed_t* helper, double adjustment);
void playerAddHoriz(fixed_t* q16horiz, double* helper, double adjustment); void playerAddHoriz2(fixed_t* q16horiz, double* helper, double adjustment);
void playerSetHoriz(fixed_t* q16horiz, fixed_t* helper, double adjustment); void playerSetHoriz2(fixed_t* q16horiz, fixed_t* helper, double adjustment);
void playerProcessHelpers(fixed_t* q16ang, double* angAdjust, fixed_t* angTarget, fixed_t* q16horiz, double* horizAdjust, fixed_t* horizTarget, double const scaleAdjust); void playerProcessHelpers(fixed_t* q16ang, double* angAdjust, fixed_t* angTarget, fixed_t* q16horiz, double* horizAdjust, fixed_t* horizTarget, double const scaleAdjust);
struct UserConfig struct UserConfig

View file

@ -129,7 +129,7 @@ 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);
sethorizon(&pPlayer->q16horiz, input.q16horz, &sPlayerInput[nLocalPlayer].actions, scaleAdjust); sethorizon2(&pPlayer->q16horiz, input.q16horz, &sPlayerInput[nLocalPlayer].actions, scaleAdjust);
} }
playerProcessHelpers(&pPlayer->q16angle, &pPlayer->angAdjust, &pPlayer->angTarget, &pPlayer->q16horiz, &pPlayer->horizAdjust, &pPlayer->horizTarget, scaleAdjust); playerProcessHelpers(&pPlayer->q16angle, &pPlayer->angAdjust, &pPlayer->angTarget, &pPlayer->q16horiz, &pPlayer->horizAdjust, &pPlayer->horizTarget, scaleAdjust);

View file

@ -1050,7 +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;
playerSetHoriz(&PlayerList[nPlayer].q16horiz, &PlayerList[nPlayer].horizTarget, 0); playerSetHoriz2(&PlayerList[nPlayer].q16horiz, &PlayerList[nPlayer].horizTarget, 0);
PlayerList[nPlayer].oq16horiz = PlayerList[nPlayer].q16horiz; PlayerList[nPlayer].oq16horiz = PlayerList[nPlayer].q16horiz;
lPlayerXVel = 0; lPlayerXVel = 0;
@ -1069,11 +1069,11 @@ void FuncPlayer(int a, int nDamage, int nRun)
if (currentLevel->levelNumber == 11) if (currentLevel->levelNumber == 11)
{ {
playerSetHoriz(&PlayerList[nPlayer].q16horiz, &PlayerList[nPlayer].horizTarget, 46); playerSetHoriz2(&PlayerList[nPlayer].q16horiz, &PlayerList[nPlayer].horizTarget, 46);
} }
else else
{ {
playerSetHoriz(&PlayerList[nPlayer].q16horiz, &PlayerList[nPlayer].horizTarget, 11); playerSetHoriz2(&PlayerList[nPlayer].q16horiz, &PlayerList[nPlayer].horizTarget, 11);
} }
} }
} }
@ -2669,7 +2669,7 @@ loc_1BD2E:
if (cl_syncinput) if (cl_syncinput)
{ {
Player* pPlayer = &PlayerList[nPlayer]; Player* pPlayer = &PlayerList[nPlayer];
sethorizon(&pPlayer->q16horiz, sPlayerInput[nPlayer].pan, &sPlayerInput[nLocalPlayer].actions, 1); sethorizon2(&pPlayer->q16horiz, 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
@ -2791,16 +2791,16 @@ loc_1BD2E:
{ {
if (PlayerList[nPlayer].q16horiz < 0) if (PlayerList[nPlayer].q16horiz < 0)
{ {
playerSetHoriz(&PlayerList[nPlayer].q16horiz, &PlayerList[nPlayer].horizTarget, 0); playerSetHoriz2(&PlayerList[nPlayer].q16horiz, &PlayerList[nPlayer].horizTarget, 0);
eyelevel[nPlayer] -= (dVertPan[nPlayer] << 8); eyelevel[nPlayer] -= (dVertPan[nPlayer] << 8);
} }
else else
{ {
playerAddHoriz(&PlayerList[nPlayer].q16horiz, &PlayerList[nPlayer].horizAdjust, dVertPan[nPlayer]); playerAddHoriz2(&PlayerList[nPlayer].q16horiz, &PlayerList[nPlayer].horizAdjust, dVertPan[nPlayer]);
if (PlayerList[nPlayer].q16horiz > gi->playerHorizMax()) if (PlayerList[nPlayer].q16horiz > gi->playerHorizMax())
{ {
playerSetHoriz(&PlayerList[nPlayer].q16horiz, &PlayerList[nPlayer].horizTarget, gi->playerHorizMax()); playerSetHoriz2(&PlayerList[nPlayer].q16horiz, &PlayerList[nPlayer].horizTarget, gi->playerHorizMax());
} }
else if (PlayerList[nPlayer].q16horiz <= 0) else if (PlayerList[nPlayer].q16horiz <= 0)
{ {

View file

@ -1852,7 +1852,7 @@ void moveweapons_d(void)
if (s->picnum == SPIT) if (s->picnum == SPIT)
{ {
playerAddHoriz(&ps[p].q16horiz, &ps[p].horizAdjust, 32); ps[p].horizon.addadjustment(32);
ps[p].sync.actions |= SB_CENTERVIEW; ps[p].sync.actions |= SB_CENTERVIEW;
if (ps[p].loogcnt == 0) if (ps[p].loogcnt == 0)
@ -2504,7 +2504,7 @@ static void greenslime(int i)
s->z = ps[p].posz + ps[p].pyoff - t[2] + (8 << 8); s->z = ps[p].posz + ps[p].pyoff - t[2] + (8 << 8);
s->z += -ps[p].getq16horiz() >> 12; s->z += -ps[p].horizon.horiz.asq16() >> 12;
if (t[2] > 512) if (t[2] > 512)
t[2] -= 128; t[2] -= 128;

View file

@ -1399,7 +1399,7 @@ void moveweapons_r(void)
guts_r(s, RABBITJIBC, 2, myconnectindex); guts_r(s, RABBITJIBC, 2, myconnectindex);
} }
playerAddHoriz(&ps[p].q16horiz, &ps[p].horizAdjust, 32); ps[p].horizon.addadjustment(32);
ps[p].sync.actions |= SB_CENTERVIEW; ps[p].sync.actions |= SB_CENTERVIEW;
if (ps[p].loogcnt == 0) if (ps[p].loogcnt == 0)

View file

@ -119,7 +119,7 @@ static int osdcmd_warptocoords(CCmdFuncPtr parm)
if (parm->numparms == 5) if (parm->numparms == 5)
{ {
p->oq16horiz = p->q16horiz = IntToFixed(atoi(parm->parms[4])); p->horizon.ohoriz = p->horizon.horiz = buildhoriz(atoi(parm->parms[4]));
} }
return CCMD_OK; return CCMD_OK;

View file

@ -242,7 +242,6 @@ int* animateptr(int i);
void backuppos(player_struct* p, bool noclipping = false); void backuppos(player_struct* p, bool noclipping = false);
void backuplook(player_struct* p); void backuplook(player_struct* p);
void backupview(player_struct* p);
void backupweapon(player_struct* p); void backupweapon(player_struct* p);
void resetinputhelpers(player_struct* p); void resetinputhelpers(player_struct* p);
void checkhardlanding(player_struct* p); void checkhardlanding(player_struct* p);

View file

@ -330,16 +330,21 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, int sActor, int sPl
break; break;
case PLAYER_HORIZ: case PLAYER_HORIZ:
if (bSet) playerSetHoriz(&ps[iPlayer].q16horiz, &ps[iPlayer].horizTarget - 100, lValue); if (bSet) ps[iPlayer].horizon.settarget(lValue - 100);
else SetGameVarID((int)lVar2, FixedToInt(ps[iPlayer].q16horiz + 100), sActor, sPlayer); else SetGameVarID((int)lVar2, ps[iPlayer].horizon.horiz.asbuild() + 100, sActor, sPlayer);
break; break;
case PLAYER_OHORIZ: case PLAYER_OHORIZ:
if (!bSet) SetGameVarID((int)lVar2, FixedToInt(ps[iPlayer].q16horiz + 100), sActor, sPlayer); if (!bSet) SetGameVarID((int)lVar2, ps[iPlayer].horizon.ohoriz.asbuild() + 100, sActor, sPlayer);
break;
case PLAYER_HORIZOFF:
if (bSet) ps[iPlayer].horizon.horizoff = buildhoriz(lValue);
else SetGameVarID((int)lVar2, ps[iPlayer].horizon.horizoff.asbuild(), sActor, sPlayer);
break; break;
case PLAYER_OHORIZOFF: case PLAYER_OHORIZOFF:
if (!bSet) SetGameVarID((int)lVar2, FixedToInt(ps[iPlayer].q16horizoff), sActor, sPlayer); if (!bSet) SetGameVarID((int)lVar2, ps[iPlayer].horizon.ohorizoff.asbuild(), sActor, sPlayer);
break; break;
case PLAYER_INVDISPTIME: case PLAYER_INVDISPTIME:
@ -520,11 +525,6 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, int sActor, int sPl
else SetGameVarID((int)lVar2, ps[iPlayer].tipincs, sActor, sPlayer); else SetGameVarID((int)lVar2, ps[iPlayer].tipincs, sActor, sPlayer);
break; break;
case PLAYER_HORIZOFF:
if (bSet) ps[iPlayer].q16horizoff = IntToFixed(lValue);
else SetGameVarID((int)lVar2, FixedToInt(ps[iPlayer].q16horizoff), sActor, sPlayer);
break;
case PLAYER_WANTWEAPONFIRE: case PLAYER_WANTWEAPONFIRE:
if (bSet) ps[iPlayer].wantweaponfire = lValue; if (bSet) ps[iPlayer].wantweaponfire = lValue;
else SetGameVarID((int)lVar2, ps[iPlayer].wantweaponfire, sActor, sPlayer); else SetGameVarID((int)lVar2, ps[iPlayer].wantweaponfire, sActor, sPlayer);
@ -2246,10 +2246,10 @@ int ParseState::parse(void)
ps[g_p].last_extra = g_sp->extra = max_player_health; ps[g_p].last_extra = g_sp->extra = max_player_health;
ps[g_p].wantweaponfire = -1; ps[g_p].wantweaponfire = -1;
ps[g_p].sethoriz(0); ps[g_p].horizon.ohoriz = ps[g_p].horizon.horiz = q16horiz(0);
ps[g_p].on_crane = -1; ps[g_p].on_crane = -1;
ps[g_p].frag_ps = g_p; ps[g_p].frag_ps = g_p;
ps[g_p].sethorizoff(0); ps[g_p].horizon.ohorizoff = ps[g_p].horizon.horizoff = q16horiz(0);
ps[g_p].opyoff = 0; ps[g_p].opyoff = 0;
ps[g_p].wackedbyactor = -1; ps[g_p].wackedbyactor = -1;
ps[g_p].shield_amount = max_armour_amount; ps[g_p].shield_amount = max_armour_amount;

View file

@ -191,15 +191,15 @@ inline void backupplayer(player_struct* p)
{ {
backuppos(p); backuppos(p);
backuplook(p); backuplook(p);
backupview(p); p->horizon.backup();
} }
// the weapon display code uses this. // the weapon display code uses this.
inline double get16thOfHoriz(int snum, bool interpolate, double smoothratio) inline double get16thOfHoriz(int snum, bool interpolate, double smoothratio)
{ {
struct player_struct *p = &ps[snum]; struct player_struct *p = &ps[snum];
fixed_t ohorz = p->oq16horiz - p->oq16horizoff; fixed_t ohorz = p->horizon.ohoriz.asq16() - p->horizon.ohorizoff.asq16();
fixed_t horz = p->q16horiz - p->q16horizoff; fixed_t horz = p->horizon.horiz.asq16() - p->horizon.horizoff.asq16();
return (!interpolate ? horz : ohorz + fmulscale16(horz - ohorz, smoothratio)) * (0.0625 / FRACUNIT); return (!interpolate ? horz : ohorz + fmulscale16(horz - ohorz, smoothratio)) * (0.0625 / FRACUNIT);
} }

View file

@ -923,10 +923,15 @@ void GameInterface::GetInput(InputPacket* packet, ControlInfo* const hidInput)
calcviewpitch(p, scaleAdjust); calcviewpitch(p, scaleAdjust);
processq16avel(p, &input.q16avel); processq16avel(p, &input.q16avel);
applylook(&p->q16ang, &p->q16look_ang, &p->q16rotscrnang, &p->one_eighty_count, input.q16avel, &p->sync.actions, scaleAdjust, p->crouch_toggle || p->sync.actions & SB_CROUCH); applylook(&p->q16ang, &p->q16look_ang, &p->q16rotscrnang, &p->one_eighty_count, input.q16avel, &p->sync.actions, scaleAdjust, p->crouch_toggle || p->sync.actions & SB_CROUCH);
sethorizon(&p->q16horiz, input.q16horz, &p->sync.actions, scaleAdjust); sethorizon(&p->horizon.horiz, input.q16horz, &p->sync.actions, scaleAdjust);
} }
playerProcessHelpers(&p->q16ang, &p->angAdjust, &p->angTarget, &p->q16horiz, &p->horizAdjust, &p->horizTarget, scaleAdjust); // temporary vals to pass through to playerProcessHelpers().
fixed_t horiz = 0;
fixed_t target = 0;
double adjust = 0;
playerProcessHelpers(&p->q16ang, &p->angAdjust, &p->angTarget, &horiz, &adjust, &target, scaleAdjust);
p->horizon.processhelpers(scaleAdjust);
} }
if (packet) if (packet)

View file

@ -91,30 +91,30 @@ void calcviewpitch(player_struct *p, double factor)
{ {
int psect = p->cursectnum; int psect = p->cursectnum;
int psectlotag = sector[psect].lotag; int psectlotag = sector[psect].lotag;
if (p->aim_mode == 0 && p->on_ground && psectlotag != ST_2_UNDERWATER && (sector[psect].floorstat & 2)) if (p->aim_mode == 0 && p->on_ground && psectlotag != ST_2_UNDERWATER && (sector[psect].floorstat & 2))
{ {
int x = p->posx + (sintable[(p->getang() + 512) & 2047] >> 5); int x = p->posx + (sintable[(p->getang() + 512) & 2047] >> 5);
int y = p->posy + (sintable[p->getang() & 2047] >> 5); int y = p->posy + (sintable[p->getang() & 2047] >> 5);
short tempsect = psect; short tempsect = psect;
updatesector(x, y, &tempsect); updatesector(x, y, &tempsect);
if (tempsect >= 0) if (tempsect >= 0)
{ {
int k = getflorzofslope(psect, x, y); int k = getflorzofslope(psect, x, y);
if (psect == tempsect || abs(getflorzofslope(tempsect, x, y) - k) <= (4 << 8)) if (psect == tempsect || abs(getflorzofslope(tempsect, x, y) - k) <= (4 << 8))
p->addhorizoff(factor * mulscale16(p->truefz - k, 160)); p->horizon.horizoff += q16horiz(FloatToFixed(factor * mulscale16(p->truefz - k, 160)));
} }
} }
if (p->q16horizoff > 0) if (p->horizon.horizoff.asq16() > 0)
{ {
p->addhorizoff(-factor * FixedToFloat((p->q16horizoff >> 3) + FRACUNIT)); p->horizon.horizoff += q16horiz(xs_CRoundToInt(-factor * ((p->horizon.horizoff.asq16() >> 3) + FRACUNIT)));
if (p->q16horizoff < 0) p->q16horizoff = 0; if (p->horizon.horizoff.asq16() < 0) p->horizon.horizoff = q16horiz(0);
} }
else if (p->q16horizoff < 0) else if (p->horizon.horizoff.asq16() < 0)
{ {
p->addhorizoff(-factor * FixedToFloat((p->q16horizoff >> 3) + FRACUNIT)); p->horizon.horizoff += q16horiz(xs_CRoundToInt(-factor * ((p->horizon.horizoff.asq16() >> 3) + FRACUNIT)));
if (p->q16horizoff > 0) p->q16horizoff = 0; if (p->horizon.horizoff.asq16() > 0) p->horizon.horizoff = q16horiz(0);
} }
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -164,7 +164,7 @@ void forceplayerangle(int snum)
n = 128 - (krand() & 255); n = 128 - (krand() & 255);
playerAddHoriz(&p->q16horiz, &p->horizAdjust, 64); p->horizon.addadjustment(64);
p->sync.actions |= SB_CENTERVIEW; p->sync.actions |= SB_CENTERVIEW;
p->setlookang(n >> 1); p->setlookang(n >> 1);
p->setrotscrnang(n >> 1); p->setrotscrnang(n >> 1);
@ -375,7 +375,7 @@ int aim(spritetype* s, int aang)
if (sdist > 512 && sdist < smax) if (sdist > 512 && sdist < smax)
{ {
if (s->picnum == TILE_APLAYER) if (s->picnum == TILE_APLAYER)
a = (abs(scale(sp->z - s->z, 10, sdist) - ps[s->yvel].gethorizsum()) < 100); a = (abs(scale(sp->z - s->z, 10, sdist) - ps[s->yvel].horizon.sum().asbuild()) < 100);
else a = 1; else a = 1;
cans = cansee(sp->x, sp->y, sp->z - (32 << 8) + actorinfo[sp->picnum].aimoffset, sp->sectnum, s->x, s->y, s->z - (32 << 8), s->sectnum); cans = cansee(sp->x, sp->y, sp->z - (32 << 8) + actorinfo[sp->picnum].aimoffset, sp->sectnum, s->x, s->y, s->z - (32 << 8), s->sectnum);
@ -406,7 +406,7 @@ void dokneeattack(int snum, int pi, const std::initializer_list<int> & respawnli
if (p->knee_incs > 0) if (p->knee_incs > 0)
{ {
p->knee_incs++; p->knee_incs++;
playerAddHoriz(&p->q16horiz, &p->horizAdjust, -48); p->horizon.addadjustment(-48);
p->sync.actions |= SB_CENTERVIEW; p->sync.actions |= SB_CENTERVIEW;
if (p->knee_incs > 15) if (p->knee_incs > 15)
{ {
@ -649,8 +649,7 @@ void playerisdead(int snum, int psectlotag, int fz, int cz)
backupplayer(p); backupplayer(p);
p->sethoriz(0); p->horizon.horizoff = p->horizon.horiz = q16horiz(0);
p->q16horizoff = 0;
updatesector(p->posx, p->posy, &p->cursectnum); updatesector(p->posx, p->posy, &p->cursectnum);
@ -844,18 +843,6 @@ void backuplook(player_struct* p)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void backupview(player_struct* p)
{
p->oq16horiz = p->q16horiz;
p->oq16horizoff = p->q16horizoff;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void backupweapon(player_struct* p) void backupweapon(player_struct* p)
{ {
p->oweapon_sway = p->weapon_sway; p->oweapon_sway = p->weapon_sway;
@ -873,7 +860,7 @@ void backupweapon(player_struct* p)
void resetinputhelpers(player_struct* p) void resetinputhelpers(player_struct* p)
{ {
p->horizAdjust = 0; p->horizon.resetadjustment();
p->angAdjust = 0; p->angAdjust = 0;
} }
@ -887,7 +874,7 @@ void checkhardlanding(player_struct* p)
{ {
if (p->hard_landing > 0) if (p->hard_landing > 0)
{ {
playerAddHoriz(&p->q16horiz, &p->horizAdjust, -(p->hard_landing << 4)); p->horizon.addadjustment(-(p->hard_landing << 4));
p->hard_landing--; p->hard_landing--;
} }
} }

View file

@ -166,7 +166,7 @@ void shoot_d(int i, int atwith)
} }
else else
{ {
zvel = -mulscale16(ps[p].getq16horizsum(), 98); zvel = -mulscale16(ps[p].horizon.sum().asq16(), 98);
sx += sintable[(sa + 860) & 0x7FF] / 448; sx += sintable[(sa + 860) & 0x7FF] / 448;
sy += sintable[(sa + 348) & 0x7FF] / 448; sy += sintable[(sa + 348) & 0x7FF] / 448;
sz += (3 << 8); sz += (3 << 8);
@ -224,7 +224,7 @@ void shoot_d(int i, int atwith)
} }
else else
{ {
zvel = -mulscale16(ps[p].getq16horizsum(), 81); zvel = -mulscale16(ps[p].horizon.sum().asq16(), 81);
if (sprite[ps[p].i].xvel != 0) if (sprite[ps[p].i].xvel != 0)
vel = (int)((((512 - (1024 vel = (int)((((512 - (1024
- abs(abs(getangle(sx - ps[p].oposx, sy - ps[p].oposy) - sa) - 1024))) - abs(abs(getangle(sx - ps[p].oposx, sy - ps[p].oposy) - sa) - 1024)))
@ -292,7 +292,7 @@ void shoot_d(int i, int atwith)
{ {
if (p >= 0) if (p >= 0)
{ {
zvel = -ps[p].getq16horizsum() >> 11; zvel = -ps[p].horizon.sum().asq16() >> 11;
sz += (6 << 8); sz += (6 << 8);
sa += 15; sa += 15;
} }
@ -464,14 +464,14 @@ void shoot_d(int i, int atwith)
if (j == -1) if (j == -1)
{ {
// no target // no target
zvel = -ps[p].getq16horizsum() >> 11; zvel = -ps[p].horizon.sum().asq16() >> 11;
} }
zvel += (zRange / 2) - (krand() & (zRange - 1)); zvel += (zRange / 2) - (krand() & (zRange - 1));
} }
else if (j == -1) else if (j == -1)
{ {
sa += 16 - (krand() & 31); sa += 16 - (krand() & 31);
zvel = -ps[p].getq16horizsum() >> 11; zvel = -ps[p].horizon.sum().asq16() >> 11;
zvel += 128 - (krand() & 255); zvel += 128 - (krand() & 255);
} }
@ -681,7 +681,7 @@ void shoot_d(int i, int atwith)
sa = getangle(sprite[j].x - sx, sprite[j].y - sy); sa = getangle(sprite[j].x - sx, sprite[j].y - sy);
} }
else else
zvel = -mulscale16(ps[p].getq16horizsum(), 98); zvel = -mulscale16(ps[p].horizon.sum().asq16(), 98);
} }
else else
{ {
@ -769,7 +769,7 @@ void shoot_d(int i, int atwith)
if (sprite[j].picnum != RECON) if (sprite[j].picnum != RECON)
sa = getangle(sprite[j].x - sx, sprite[j].y - sy); sa = getangle(sprite[j].x - sx, sprite[j].y - sy);
} }
else zvel = -mulscale16(ps[p].getq16horizsum(), 81); else zvel = -mulscale16(ps[p].horizon.sum().asq16(), 81);
if (atwith == RPG) if (atwith == RPG)
S_PlayActorSound(RPG_SHOOT, i); S_PlayActorSound(RPG_SHOOT, i);
@ -914,7 +914,7 @@ void shoot_d(int i, int atwith)
case HANDHOLDINGLASER: case HANDHOLDINGLASER:
if (p >= 0) if (p >= 0)
zvel = -ps[p].getq16horizsum() >> 11; zvel = -ps[p].horizon.sum().asq16() >> 11;
else zvel = 0; else zvel = 0;
hitscan(sx, sy, sz - ps[p].pyoff, sect, hitscan(sx, sy, sz - ps[p].pyoff, sect,
@ -1015,7 +1015,7 @@ void shoot_d(int i, int atwith)
else else
{ {
sa += 16 - (krand() & 31); sa += 16 - (krand() & 31);
zvel = -ps[p].getq16horizsum() >> 11; zvel = -ps[p].horizon.sum().asq16() >> 11;
zvel += 128 - (krand() & 255); zvel += 128 - (krand() & 255);
} }
@ -1090,7 +1090,7 @@ void shoot_d(int i, int atwith)
zvel = ((sprite[j].z - sz - dal - (4 << 8)) * 768) / (ldist(&sprite[ps[p].i], &sprite[j])); zvel = ((sprite[j].z - sz - dal - (4 << 8)) * 768) / (ldist(&sprite[ps[p].i], &sprite[j]));
sa = getangle(sprite[j].x - sx, sprite[j].y - sy); sa = getangle(sprite[j].x - sx, sprite[j].y - sy);
} }
else zvel = -mulscale16(ps[p].getq16horizsum(), 98); else zvel = -mulscale16(ps[p].horizon.sum().asq16(), 98);
} }
else if (s->statnum != 3) else if (s->statnum != 3)
{ {
@ -1940,7 +1940,7 @@ int operateTripbomb(int snum)
hitscan(p->posx, p->posy, p->posz, hitscan(p->posx, p->posy, p->posz,
p->cursectnum, sintable[(p->getang() + 512) & 2047], p->cursectnum, sintable[(p->getang() + 512) & 2047],
sintable[p->getang() & 2047], -p->getq16horizsum() >> 11, sintable[p->getang() & 2047], -p->horizon.sum().asq16() >> 11,
&sect, &hw, &hitsp, &sx, &sy, &sz, CLIPMASK1); &sect, &hw, &hitsp, &sx, &sy, &sz, CLIPMASK1);
if (sect < 0 || hitsp >= 0) if (sect < 0 || hitsp >= 0)
@ -2122,12 +2122,12 @@ static void operateweapon(int snum, ESyncBits actions, int psect)
if (p->on_ground && (actions & SB_CROUCH)) if (p->on_ground && (actions & SB_CROUCH))
{ {
k = 15; k = 15;
i = mulscale16(p->getq16horizsum(), 20); i = mulscale16(p->horizon.sum().asq16(), 20);
} }
else else
{ {
k = 140; k = 140;
i = -512 - mulscale16(p->getq16horizsum(), 20); i = -512 - mulscale16(p->horizon.sum().asq16(), 20);
} }
j = EGS(p->cursectnum, j = EGS(p->cursectnum,
@ -2707,7 +2707,7 @@ void processinput_d(int snum)
if (cl_syncinput) if (cl_syncinput)
{ {
backupview(p); p->horizon.backup();
calcviewpitch(p, 1); calcviewpitch(p, 1);
} }
@ -3072,7 +3072,7 @@ HORIZONLY:
if (cl_syncinput) if (cl_syncinput)
{ {
sethorizon(&p->q16horiz, PlayerHorizon(snum), &p->sync.actions, 1); sethorizon(&p->horizon.horiz, PlayerHorizon(snum), &p->sync.actions, 1);
} }
checkhardlanding(p); checkhardlanding(p);

View file

@ -154,7 +154,7 @@ void shoot_r(int i, int atwith)
{ {
if (p >= 0) if (p >= 0)
{ {
zvel = -ps[p].getq16horizsum() >> 11; zvel = -ps[p].horizon.sum().asq16() >> 11;
sz += (6 << 8); sz += (6 << 8);
sa += 15; sa += 15;
} }
@ -333,7 +333,7 @@ void shoot_r(int i, int atwith)
if (j == -1) if (j == -1)
{ {
sa += 16 - (krand() & 31); sa += 16 - (krand() & 31);
zvel = -ps[p].getq16horizsum() >> 11; zvel = -ps[p].horizon.sum().asq16() >> 11;
zvel += 128 - (krand() & 255); zvel += 128 - (krand() & 255);
} }
} }
@ -343,7 +343,7 @@ void shoot_r(int i, int atwith)
sa += 64 - (krand() & 127); sa += 64 - (krand() & 127);
else else
sa += 16 - (krand() & 31); sa += 16 - (krand() & 31);
if (j == -1) zvel = -ps[p].getq16horizsum() >> 11; if (j == -1) zvel = -ps[p].horizon.sum().asq16() >> 11;
zvel += 128 - (krand() & 255); zvel += 128 - (krand() & 255);
} }
sz -= (2 << 8); sz -= (2 << 8);
@ -602,7 +602,7 @@ void shoot_r(int i, int atwith)
sa = getangle(sprite[j].x - sx, sprite[j].y - sy); sa = getangle(sprite[j].x - sx, sprite[j].y - sy);
} }
else else
zvel = -mulscale16(ps[p].getq16horizsum(), 98); zvel = -mulscale16(ps[p].horizon.sum().asq16(), 98);
} }
else else
{ {
@ -693,7 +693,7 @@ void shoot_r(int i, int atwith)
{ {
sx += sintable[(s->ang + 512 + 160) & 2047] >> 7; sx += sintable[(s->ang + 512 + 160) & 2047] >> 7;
sy += sintable[(s->ang + 160) & 2047] >> 7; sy += sintable[(s->ang + 160) & 2047] >> 7;
zvel = -mulscale16(ps[p].getq16horizsum(), 98); zvel = -mulscale16(ps[p].horizon.sum().asq16(), 98);
} }
} }
else else
@ -804,7 +804,7 @@ void shoot_r(int i, int atwith)
if (sprite[j].picnum != RECON) if (sprite[j].picnum != RECON)
sa = getangle(sprite[j].x - sx, sprite[j].y - sy); sa = getangle(sprite[j].x - sx, sprite[j].y - sy);
} }
else zvel = -mulscale16(ps[p].getq16horizsum(), 81); else zvel = -mulscale16(ps[p].horizon.sum().asq16(), 81);
if (atwith == RPG) if (atwith == RPG)
S_PlayActorSound(RPG_SHOOT, i); S_PlayActorSound(RPG_SHOOT, i);
else if (isRRRA()) else if (isRRRA())
@ -1476,7 +1476,7 @@ void checkweapons_r(struct player_struct* p)
sprite[j].owner = p->ammo_amount[MOTORCYCLE_WEAPON]; sprite[j].owner = p->ammo_amount[MOTORCYCLE_WEAPON];
p->OnMotorcycle = 0; p->OnMotorcycle = 0;
p->gotweapon.Clear(MOTORCYCLE_WEAPON); p->gotweapon.Clear(MOTORCYCLE_WEAPON);
p->sethoriz(0); p->horizon.horiz = q16horiz(0);
p->moto_do_bump = 0; p->moto_do_bump = 0;
p->MotoSpeed = 0; p->MotoSpeed = 0;
p->TiltStatus = 0; p->TiltStatus = 0;
@ -1492,7 +1492,7 @@ void checkweapons_r(struct player_struct* p)
sprite[j].owner = p->ammo_amount[BOAT_WEAPON]; sprite[j].owner = p->ammo_amount[BOAT_WEAPON];
p->OnBoat = 0; p->OnBoat = 0;
p->gotweapon.Clear(BOAT_WEAPON); p->gotweapon.Clear(BOAT_WEAPON);
p->sethoriz(0); p->horizon.horiz = q16horiz(0);
p->moto_do_bump = 0; p->moto_do_bump = 0;
p->MotoSpeed = 0; p->MotoSpeed = 0;
p->TiltStatus = 0; p->TiltStatus = 0;
@ -1762,7 +1762,7 @@ static void onMotorcycle(int snum, ESyncBits &actions)
} }
if (horiz != 0) if (horiz != 0)
{ {
playerAddHoriz(&p->q16horiz, &p->horizAdjust, horiz - FixedToFloat(p->q16horiz)); p->horizon.addadjustment(horiz - FixedToFloat(p->horizon.horiz.asq16()));
} }
if (p->MotoSpeed >= 20 && p->on_ground == 1 && (var74 || var7c)) if (p->MotoSpeed >= 20 && p->on_ground == 1 && (var74 || var7c))
@ -2091,7 +2091,7 @@ static void onBoat(int snum, ESyncBits &actions)
} }
if (horiz != 0) if (horiz != 0)
{ {
playerAddHoriz(&p->q16horiz, &p->horizAdjust, horiz - FixedToFloat(p->q16horiz)); p->horizon.addadjustment(horiz - FixedToFloat(p->horizon.horiz.asq16()));
} }
if (p->MotoSpeed > 0 && p->on_ground == 1 && (varbc || varc4)) if (p->MotoSpeed > 0 && p->on_ground == 1 && (varbc || varc4))
@ -2843,12 +2843,12 @@ static void operateweapon(int snum, ESyncBits actions, int psect)
if (p->on_ground && (actions & SB_CROUCH) && !p->OnMotorcycle) if (p->on_ground && (actions & SB_CROUCH) && !p->OnMotorcycle)
{ {
k = 15; k = 15;
i = -mulscale16(p->getq16horizsum(), 20); i = -mulscale16(p->horizon.sum().asq16(), 20);
} }
else else
{ {
k = 140; k = 140;
i = -512 - -mulscale16(p->getq16horizsum(), 20); i = -512 - -mulscale16(p->horizon.sum().asq16(), 20);
} }
j = EGS(p->cursectnum, j = EGS(p->cursectnum,
@ -3066,7 +3066,7 @@ static void operateweapon(int snum, ESyncBits actions, int psect)
case RIFLEGUN_WEAPON: case RIFLEGUN_WEAPON:
p->kickback_pic++; p->kickback_pic++;
playerAddHoriz(&p->q16horiz, &p->horizAdjust, 1); p->horizon.addadjustment(1);
p->recoil++; p->recoil++;
if (p->kickback_pic <= 12) if (p->kickback_pic <= 12)
@ -3238,7 +3238,7 @@ static void operateweapon(int snum, ESyncBits actions, int psect)
{ {
p->posxv -= sintable[(p->getang() + 512) & 2047] << 4; p->posxv -= sintable[(p->getang() + 512) & 2047] << 4;
p->posyv -= sintable[p->getang() & 2047] << 4; p->posyv -= sintable[p->getang() & 2047] << 4;
playerAddHoriz(&p->q16horiz, &p->horizAdjust, 20); p->horizon.addadjustment(20);
p->recoil += 20; p->recoil += 20;
} }
if (p->kickback_pic > 20) if (p->kickback_pic > 20)
@ -3253,12 +3253,12 @@ static void operateweapon(int snum, ESyncBits actions, int psect)
if (p->on_ground && (actions & SB_CROUCH) && !p->OnMotorcycle) if (p->on_ground && (actions & SB_CROUCH) && !p->OnMotorcycle)
{ {
k = 15; k = 15;
i = mulscale16(p->getq16horizsum(), 20); i = mulscale16(p->horizon.sum().asq16(), 20);
} }
else else
{ {
k = 32; k = 32;
i = -512 - mulscale16(p->getq16horizsum(), 20); i = -512 - mulscale16(p->horizon.sum().asq16(), 20);
} }
j = EGS(p->cursectnum, j = EGS(p->cursectnum,
@ -3535,7 +3535,7 @@ void processinput_r(int snum)
if (cl_syncinput) if (cl_syncinput)
{ {
backupview(p); p->horizon.backup();
calcviewpitch(p, 1); calcviewpitch(p, 1);
} }
@ -4092,12 +4092,12 @@ HORIZONLY:
if (!d) if (!d)
d = 1; d = 1;
p->recoil -= d; p->recoil -= d;
playerAddHoriz(&p->q16horiz, &p->horizAdjust, -d); p->horizon.addadjustment(-d);
} }
if (cl_syncinput) if (cl_syncinput)
{ {
sethorizon(&p->q16horiz, PlayerHorizon(snum), &p->sync.actions, 1); sethorizon(&p->horizon.horiz, PlayerHorizon(snum), &p->sync.actions, 1);
} }
checkhardlanding(p); checkhardlanding(p);
@ -4181,7 +4181,7 @@ void OnMotorcycle(struct player_struct *p, int motosprite)
p->gotweapon.Set(MOTORCYCLE_WEAPON); p->gotweapon.Set(MOTORCYCLE_WEAPON);
p->posxv = 0; p->posxv = 0;
p->posyv = 0; p->posyv = 0;
p->sethoriz(0); p->horizon.horiz = q16horiz(0);
} }
if (!S_CheckActorSoundPlaying(p->i,186)) if (!S_CheckActorSoundPlaying(p->i,186))
S_PlayActorSound(186, p->i); S_PlayActorSound(186, p->i);
@ -4212,7 +4212,7 @@ void OffMotorcycle(struct player_struct *p)
p->gotweapon.Clear(MOTORCYCLE_WEAPON); p->gotweapon.Clear(MOTORCYCLE_WEAPON);
p->curr_weapon = p->last_full_weapon; p->curr_weapon = p->last_full_weapon;
checkavailweapon(p); checkavailweapon(p);
p->sethoriz(0); p->horizon.horiz = q16horiz(0);
p->moto_do_bump = 0; p->moto_do_bump = 0;
p->MotoSpeed = 0; p->MotoSpeed = 0;
p->TiltStatus = 0; p->TiltStatus = 0;
@ -4258,7 +4258,7 @@ void OnBoat(struct player_struct *p, int boatsprite)
p->gotweapon.Set(BOAT_WEAPON); p->gotweapon.Set(BOAT_WEAPON);
p->posxv = 0; p->posxv = 0;
p->posyv = 0; p->posyv = 0;
p->sethoriz(0); p->horizon.horiz = q16horiz(0);
} }
} }
@ -4277,7 +4277,7 @@ void OffBoat(struct player_struct *p)
p->gotweapon.Clear(BOAT_WEAPON); p->gotweapon.Clear(BOAT_WEAPON);
p->curr_weapon = p->last_full_weapon; p->curr_weapon = p->last_full_weapon;
checkavailweapon(p); checkavailweapon(p);
p->sethoriz(0); p->horizon.horiz = q16horiz(0);
p->moto_do_bump = 0; p->moto_do_bump = 0;
p->MotoSpeed = 0; p->MotoSpeed = 0;
p->TiltStatus = 0; p->TiltStatus = 0;

View file

@ -333,12 +333,12 @@ void operateweapon_ww(int snum, ESyncBits actions, int psect)
if (p->on_ground && (actions & SB_CROUCH)) if (p->on_ground && (actions & SB_CROUCH))
{ {
k = 15; k = 15;
i = mulscale16(p->getq16horizsum(), 20); i = mulscale16(p->horizon.sum().asq16(), 20);
} }
else else
{ {
k = 140; k = 140;
i = -512 - mulscale16(p->getq16horizsum(), 20); i = -512 - mulscale16(p->horizon.sum().asq16(), 20);
} }
j = EGS(p->cursectnum, j = EGS(p->cursectnum,

View file

@ -55,8 +55,8 @@ void resetmys()
myz = omyz = ps[myconnectindex].posz; myz = omyz = ps[myconnectindex].posz;
myxvel = myyvel = myzvel = 0; myxvel = myyvel = myzvel = 0;
q16myang = oq16myang = ps[myconnectindex].q16ang; q16myang = oq16myang = ps[myconnectindex].q16ang;
q16myhoriz = oq16myhoriz = ps[myconnectindex].q16horiz; q16myhoriz = oq16myhoriz = ps[myconnectindex].horizon.horiz.asq16();
q16myhorizoff = oq16myhorizoff = ps[myconnectindex].q16horizoff; q16myhorizoff = oq16myhorizoff = ps[myconnectindex].horizon.horizoff.asq16();
mycursectnum = ps[myconnectindex].cursectnum; mycursectnum = ps[myconnectindex].cursectnum;
myjumpingcounter = ps[myconnectindex].jumping_counter; myjumpingcounter = ps[myconnectindex].jumping_counter;
myjumpingtoggle = ps[myconnectindex].jumping_toggle; myjumpingtoggle = ps[myconnectindex].jumping_toggle;

View file

@ -112,10 +112,8 @@ void resetplayerstats(int snum)
p->footprintpal = 0; p->footprintpal = 0;
p->footprintshade = 0; p->footprintshade = 0;
p->jumping_toggle = 0; p->jumping_toggle = 0;
p->sethoriz(40); //!! p->horizon.ohoriz = p->horizon.horiz = q16horiz(40);
p->oq16horiz = p->q16horiz; p->horizon.ohorizoff = p->horizon.horizoff = q16horiz(0);
p->sethorizoff(0);
p->oq16horizoff = p->q16horizoff;
p->bobcounter = 0; p->bobcounter = 0;
p->on_ground = 0; p->on_ground = 0;
p->player_par = 0; p->player_par = 0;

View file

@ -574,9 +574,7 @@ void displayrooms(int snum, double smoothratio)
if (cl_syncinput) if (cl_syncinput)
{ {
// Original code for when the values are passed through the sync struct // Original code for when the values are passed through the sync struct
fixed_t ohorz = (p->oq16horiz + p->oq16horizoff); choriz = p->horizon.interpolatedsum(smoothratio);
fixed_t horz = (p->q16horiz + p->q16horizoff);
choriz = q16horiz(ohorz + xs_CRoundToInt(fmulscale16(horz - ohorz, smoothratio)));
fixed_t oang = (p->oq16ang + p->oq16look_ang); fixed_t oang = (p->oq16ang + p->oq16look_ang);
fixed_t ang = (p->q16ang + p->q16look_ang); fixed_t ang = (p->q16ang + p->q16look_ang);
@ -586,7 +584,7 @@ void displayrooms(int snum, double smoothratio)
{ {
// This is for real time updating of the view direction. // This is for real time updating of the view direction.
cang = q16ang(p->q16ang + p->q16look_ang); cang = q16ang(p->q16ang + p->q16look_ang);
choriz = q16horiz(p->q16horiz + p->q16horizoff); choriz = p->horizon.sum();
} }
} }

View file

@ -114,8 +114,8 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, player_struct& w,
("posy", w.posy) ("posy", w.posy)
("posz", w.posz) ("posz", w.posz)
("q16ang", w.q16ang) ("q16ang", w.q16ang)
("q16horiz", w.q16horiz) //("q16horiz", w.horizon.horiz.asq16())
("q16horizoff", w.q16horizoff) //("q16horizoff", w.horizon.horizoff.asq16())
("q16rotscrnang", w.q16rotscrnang) ("q16rotscrnang", w.q16rotscrnang)
("q16look_ang", w.q16look_ang) ("q16look_ang", w.q16look_ang)
("one_eighty_count", w.one_eighty_count) ("one_eighty_count", w.one_eighty_count)
@ -285,8 +285,8 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, player_struct& w,
w.invdisptime = 0; w.invdisptime = 0;
w.oq16ang = w.q16ang; w.oq16ang = w.q16ang;
w.oq16horiz = w.q16horiz; //w.horizon.ohoriz = w.horizon.horiz;
w.oq16horizoff = w.q16horizoff; //w.horizon.ohorizoff = w.horizon.horizoff;
w.oq16rotscrnang = w.q16rotscrnang; w.oq16rotscrnang = w.q16rotscrnang;
w.oposx = w.posx; w.oposx = w.posx;
w.oposy = w.posy; w.oposy = w.posy;
@ -297,8 +297,6 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, player_struct& w,
w.okickback_pic = w.kickback_pic; w.okickback_pic = w.kickback_pic;
w.orandom_club_frame = w.random_club_frame; w.orandom_club_frame = w.random_club_frame;
w.ohard_landing = w.hard_landing; w.ohard_landing = w.hard_landing;
w.horizAdjust = 0;
w.angAdjust = 0;
w.sync.actions &= SB_CENTERVIEW; // this is the only bit we need to preserve. w.sync.actions &= SB_CENTERVIEW; // this is the only bit we need to preserve.
} }
return arc; return arc;

View file

@ -438,7 +438,7 @@ void initshell(int j, int i, bool isshell)
a = ps[snum].getang() - (krand() & 63) + 8; //Fine tune a = ps[snum].getang() - (krand() & 63) + 8; //Fine tune
t[0] = krand() & 1; t[0] = krand() & 1;
sp->z = (3 << 8) + ps[snum].pyoff + ps[snum].posz - (ps[snum].getq16horizsum() >> 12) + (!isshell ? (3 << 8) : 0); sp->z = (3 << 8) + ps[snum].pyoff + ps[snum].posz - (ps[snum].horizon.sum().asq16() >> 12) + (!isshell ? (3 << 8) : 0);
sp->zvel = -(krand() & 255); sp->zvel = -(krand() & 255);
} }
else else

View file

@ -95,11 +95,14 @@ struct player_struct
struct { int32_t posx, posy, posz; }; struct { int32_t posx, posy, posz; };
}; };
// input handles angle and horizon as fixed16 numbers. We need to account for that as well. // input handles angle as fixed16 numbers. We need to account for that as well.
fixed_t q16ang, q16horiz, q16horizoff, q16rotscrnang, q16look_ang; fixed_t q16ang, q16rotscrnang, q16look_ang;
fixed_t oq16ang, oq16horiz, oq16horizoff, oq16rotscrnang, oq16look_ang; // These are only needed with synchronous mouse input. fixed_t oq16ang, oq16rotscrnang, oq16look_ang; // These are only needed with synchronous mouse input.
fixed_t one_eighty_count; fixed_t one_eighty_count;
// player's horison struct.
PlayerHorizon horizon;
// using a bit field for this to save a bit of space. // using a bit field for this to save a bit of space.
FixedBitArray<MAX_WEAPONS> gotweapon; FixedBitArray<MAX_WEAPONS> gotweapon;
@ -207,12 +210,12 @@ struct player_struct
int8_t crouch_toggle; int8_t crouch_toggle;
// input stuff. // input stuff.
double horizAdjust, angAdjust; double angAdjust;
fixed_t horizTarget, angTarget; fixed_t angTarget;
InputPacket sync; InputPacket sync;
// Access helpers for the widened angle and horizon fields. // Access helpers for the widened angle fields.
void setlookang(int b) { q16look_ang = IntToFixed(b); } void setlookang(int b) { q16look_ang = IntToFixed(b); }
void addlookang(int b) { q16look_ang += IntToFixed(b); } void addlookang(int b) { q16look_ang += IntToFixed(b); }
void addlookang(double b) { q16look_ang += FloatToFixed(b); } void addlookang(double b) { q16look_ang += FloatToFixed(b); }
@ -224,17 +227,6 @@ struct player_struct
void setang(int v) { q16ang = IntToFixed(v); } void setang(int v) { q16ang = IntToFixed(v); }
void addang(int v) { q16ang = (q16ang + IntToFixed(v)) & 0x7FFFFFF; } void addang(int v) { q16ang = (q16ang + IntToFixed(v)) & 0x7FFFFFF; }
void setoang(int v) { oq16ang = IntToFixed(v); } void setoang(int v) { oq16ang = IntToFixed(v); }
void addhoriz(int v) { q16horiz += (IntToFixed(v)); }
void addhorizoff(int v) { q16horiz += (IntToFixed(v)); }
void addhorizoff(double v) { q16horiz += FloatToFixed(v); }
void sethoriz(int v) { q16horiz = IntToFixed(v); }
void sethorizoff(int v) { q16horizoff = IntToFixed(v); }
int gethoriz() { return FixedToInt(q16horiz); }
int gethorizof() { return FixedToInt(q16horizoff); }
int gethorizsum() { return FixedToInt(q16horiz + q16horizoff); }
int getq16horiz() { return q16horiz; }
int getq16horizof() { return q16horizoff; }
int getq16horizsum() { return q16horiz + q16horizoff; }
}; };

View file

@ -1741,7 +1741,7 @@ DoPlayerHorizon(PLAYERp pp, fixed_t const q16horz, double const scaleAdjust)
PlayerAutoLook(pp, scaleAdjust); PlayerAutoLook(pp, scaleAdjust);
// apply default horizon from backend // apply default horizon from backend
sethorizon(&pp->q16horiz, q16horz, &pp->input.actions, scaleAdjust); sethorizon2(&pp->q16horiz, q16horz, &pp->input.actions, scaleAdjust);
} }
void void
@ -6140,12 +6140,12 @@ DoPlayerDeathHoriz(PLAYERp pp, short target, short speed)
{ {
if ((pp->q16horiz - IntToFixed(target)) > FRACUNIT) if ((pp->q16horiz - IntToFixed(target)) > FRACUNIT)
{ {
playerAddHoriz(&pp->q16horiz, &pp->horizAdjust, -speed); playerAddHoriz2(&pp->q16horiz, &pp->horizAdjust, -speed);
} }
if ((IntToFixed(target) - pp->q16horiz) > FRACUNIT) if ((IntToFixed(target) - pp->q16horiz) > FRACUNIT)
{ {
playerAddHoriz(&pp->q16horiz, &pp->horizAdjust, speed); playerAddHoriz2(&pp->q16horiz, &pp->horizAdjust, speed);
} }
} }