- InputPacket: Change q16horz to horz, changing type from fixed_t to float.

This commit is contained in:
Mitchell Richters 2020-10-07 18:22:07 +11:00
parent d16b4651bb
commit 6a30d6880e
14 changed files with 43 additions and 43 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->horizon.horiz, input.q16horz, &pPlayer->input.actions, scaleAdjust); sethorizon(&pPlayer->horizon.horiz, input.horz, &pPlayer->input.actions, scaleAdjust);
} }
playerProcessHelpers(&pPlayer->q16ang, &pPlayer->angAdjust, &pPlayer->angTarget, scaleAdjust); playerProcessHelpers(&pPlayer->q16ang, &pPlayer->angAdjust, &pPlayer->angTarget, scaleAdjust);

View file

@ -766,7 +766,7 @@ void playerStart(int nPlayer, int bNewLevel)
pInput->actions = 0; pInput->actions = 0;
pInput->fvel = 0; pInput->fvel = 0;
pInput->svel = 0; pInput->svel = 0;
pInput->q16horz = 0; pInput->horz = 0;
pPlayer->flickerEffect = 0; pPlayer->flickerEffect = 0;
pPlayer->quakeEffect = 0; pPlayer->quakeEffect = 0;
pPlayer->tiltEffect = 0; pPlayer->tiltEffect = 0;
@ -1557,7 +1557,7 @@ void ProcessInput(PLAYER *pPlayer)
if (cl_syncinput) if (cl_syncinput)
{ {
sethorizon(&pPlayer->horizon.horiz, pInput->q16horz, &pInput->actions, 1); sethorizon(&pPlayer->horizon.horiz, pInput->horz, &pInput->actions, 1);
} }
int nSector = pSprite->sectnum; int nSector = pSprite->sectnum;

View file

@ -229,7 +229,7 @@ static void fakeProcessInput(PLAYER *pPlayer, InputPacket *pInput)
if (pInput->actions & SB_LOOK_DOWN) if (pInput->actions & SB_LOOK_DOWN)
predict.at20 = max(predict.at20-IntToFixed(4), IntToFixed(-60)); predict.at20 = max(predict.at20-IntToFixed(4), IntToFixed(-60));
} }
predict.at20 = clamp(predict.at20+pInput->q16horz, IntToFixed(-60), IntToFixed(60)); predict.at20 = clamp(predict.at20+pInput->horz, IntToFixed(-60), IntToFixed(60));
if (predict.at20 > 0) if (predict.at20 > 0)
predict.at24 = FloatToFixed(fmulscale30(120., Sinf(FixedToFloat(predict.at20) * 8.))); predict.at24 = FloatToFixed(fmulscale30(120., Sinf(FixedToFloat(predict.at20) * 8.)));

View file

@ -1037,7 +1037,7 @@ void NetUpdate (void)
int svel = 0; int svel = 0;
int fvel = 0; int fvel = 0;
int64_t q16avel = 0; int64_t q16avel = 0;
int64_t q16horz = 0; float horz = 0;
for (j = 0; j < ticdup; ++j) for (j = 0; j < ticdup; ++j)
{ {
@ -1045,13 +1045,13 @@ void NetUpdate (void)
svel += localcmds[modp].ucmd.svel; svel += localcmds[modp].ucmd.svel;
fvel += localcmds[modp].ucmd.fvel; fvel += localcmds[modp].ucmd.fvel;
q16avel += localcmds[modp].ucmd.q16avel; q16avel += localcmds[modp].ucmd.q16avel;
q16horz += localcmds[modp].ucmd.q16horz; horz += localcmds[modp].ucmd.horz;
} }
svel /= ticdup; svel /= ticdup;
fvel /= ticdup; fvel /= ticdup;
q16avel /= ticdup; q16avel /= ticdup;
q16horz /= ticdup; horz /= ticdup;
for (j = 0; j < ticdup; ++j) for (j = 0; j < ticdup; ++j)
{ {
@ -1059,7 +1059,7 @@ void NetUpdate (void)
localcmds[modp].ucmd.svel = svel; localcmds[modp].ucmd.svel = svel;
localcmds[modp].ucmd.fvel = fvel; localcmds[modp].ucmd.fvel = fvel;
localcmds[modp].ucmd.q16avel = q16avel; localcmds[modp].ucmd.q16avel = q16avel;
localcmds[modp].ucmd.q16horz = q16horz; localcmds[modp].ucmd.horz = horz;
} }
Net_NewMakeTic (); Net_NewMakeTic ();

View file

@ -160,7 +160,7 @@ int UnpackUserCmd (InputPacket *ucmd, const InputPacket *basis, uint8_t **stream
if (flags & UCMDF_BUTTONS) if (flags & UCMDF_BUTTONS)
ucmd->actions = ESyncBits::FromInt(ReadLong(stream)); ucmd->actions = ESyncBits::FromInt(ReadLong(stream));
if (flags & UCMDF_PITCH) if (flags & UCMDF_PITCH)
ucmd->q16horz = ReadLong(stream); ucmd->horz = ReadLong(stream);
if (flags & UCMDF_YAW) if (flags & UCMDF_YAW)
ucmd->q16avel = ReadLong(stream); ucmd->q16avel = ReadLong(stream);
if (flags & UCMDF_FORWARDMOVE) if (flags & UCMDF_FORWARDMOVE)
@ -193,10 +193,10 @@ int PackUserCmd (const InputPacket *ucmd, const InputPacket *basis, uint8_t **st
flags |= UCMDF_BUTTONS; flags |= UCMDF_BUTTONS;
WriteLong(ucmd->actions, stream); WriteLong(ucmd->actions, stream);
} }
if (ucmd->q16horz != basis->q16horz) if (ucmd->horz != basis->horz)
{ {
flags |= UCMDF_PITCH; flags |= UCMDF_PITCH;
WriteLong (ucmd->q16horz, stream); WriteLong (ucmd->horz, stream);
} }
if (ucmd->q16avel != basis->q16avel) if (ucmd->q16avel != basis->q16avel)
{ {
@ -236,7 +236,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, InputPacket &cmd, Inpu
if (arc.BeginObject(key)) if (arc.BeginObject(key))
{ {
arc("actions", cmd.actions) arc("actions", cmd.actions)
("horz", cmd.q16horz) ("horz", cmd.horz)
("avel", cmd.q16avel) ("avel", cmd.q16avel)
("fvel", cmd.fvel) ("fvel", cmd.fvel)
("svwl", cmd.svel) ("svwl", cmd.svel)
@ -250,7 +250,7 @@ int WriteUserCmdMessage (InputPacket *ucmd, const InputPacket *basis, uint8_t **
if (basis == NULL) if (basis == NULL)
{ {
if (ucmd->actions != 0 || if (ucmd->actions != 0 ||
ucmd->q16horz != 0 || ucmd->horz != 0 ||
ucmd->q16avel != 0 || ucmd->q16avel != 0 ||
ucmd->fvel != 0 || ucmd->fvel != 0 ||
ucmd->svel != 0) ucmd->svel != 0)
@ -261,7 +261,7 @@ int WriteUserCmdMessage (InputPacket *ucmd, const InputPacket *basis, uint8_t **
} }
else else
if (ucmd->actions != basis->actions || if (ucmd->actions != basis->actions ||
ucmd->q16horz != basis->q16horz || ucmd->horz != basis->horz ||
ucmd->q16avel != basis->q16avel || ucmd->q16avel != basis->q16avel ||
ucmd->fvel != basis->fvel || ucmd->fvel != basis->fvel ||
ucmd->svel != basis->svel) ucmd->svel != basis->svel)

View file

@ -1457,18 +1457,18 @@ void processMovement(InputPacket* currInput, InputPacket* inputBuffer, ControlIn
currInput->q16avel += FloatToFixed(hidInput->mouseturnx + (scaleAdjust * hidInput->dyaw)); currInput->q16avel += FloatToFixed(hidInput->mouseturnx + (scaleAdjust * hidInput->dyaw));
if (!(inputBuffer->actions & SB_AIMMODE)) if (!(inputBuffer->actions & SB_AIMMODE))
currInput->q16horz -= FloatToFixed(hidInput->mouseturny); currInput->horz -= hidInput->mouseturny;
else else
currInput->fvel -= xs_CRoundToInt(hidInput->mousemovey * mousevelscale); currInput->fvel -= xs_CRoundToInt(hidInput->mousemovey * mousevelscale);
if (invertmouse) if (invertmouse)
currInput->q16horz = -currInput->q16horz; currInput->horz = -currInput->horz;
if (invertmousex) if (invertmousex)
currInput->q16avel = -currInput->q16avel; currInput->q16avel = -currInput->q16avel;
// process remaining controller input. // process remaining controller input.
currInput->q16horz -= FloatToFixed(scaleAdjust * hidInput->dpitch); currInput->horz -= scaleAdjust * hidInput->dpitch;
currInput->svel -= xs_CRoundToInt(scaleAdjust * hidInput->dx * keymove * cntrlvelscale); currInput->svel -= xs_CRoundToInt(scaleAdjust * hidInput->dx * keymove * cntrlvelscale);
currInput->fvel -= xs_CRoundToInt(scaleAdjust * hidInput->dz * keymove * cntrlvelscale); currInput->fvel -= xs_CRoundToInt(scaleAdjust * hidInput->dz * keymove * cntrlvelscale);
@ -1559,7 +1559,7 @@ void processMovement(InputPacket* currInput, InputPacket* inputBuffer, ControlIn
inputBuffer->fvel = clamp(inputBuffer->fvel + currInput->fvel, -keymove, keymove); inputBuffer->fvel = clamp(inputBuffer->fvel + currInput->fvel, -keymove, keymove);
inputBuffer->svel = clamp(inputBuffer->svel + currInput->svel, -keymove, keymove); inputBuffer->svel = clamp(inputBuffer->svel + currInput->svel, -keymove, keymove);
inputBuffer->q16avel += currInput->q16avel; inputBuffer->q16avel += currInput->q16avel;
inputBuffer->q16horz += currInput->q16horz; inputBuffer->horz += currInput->horz;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -1571,15 +1571,15 @@ void processMovement(InputPacket* currInput, InputPacket* inputBuffer, ControlIn
static double const aimamount = HorizToPitch(250. / GameTicRate); static double const aimamount = HorizToPitch(250. / GameTicRate);
static double const lookamount = HorizToPitch(500. / GameTicRate); static double const lookamount = HorizToPitch(500. / GameTicRate);
void sethorizon(fixedhoriz* horiz, fixed_t const q16horz, ESyncBits* actions, double const scaleAdjust) void sethorizon(fixedhoriz* horiz, float const horz, ESyncBits* actions, double const scaleAdjust)
{ {
// Store current horizon as true pitch. // Store current horizon as true pitch.
double pitch = horiz->aspitch(); double pitch = horiz->aspitch();
if (q16horz) if (horz)
{ {
*actions &= ~SB_CENTERVIEW; *actions &= ~SB_CENTERVIEW;
pitch += FixedToFloat(q16horz); pitch += horz;
} }
// this is the locked type // this is the locked type

View file

@ -143,7 +143,7 @@ struct PlayerHorizon
}; };
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(fixedhoriz* horiz, fixed_t const q16horz, ESyncBits* actions, double const scaleAdjust); void sethorizon(fixedhoriz* horiz, float const horz, 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);

View file

@ -73,7 +73,7 @@ struct InputPacket
int16_t svel; int16_t svel;
int16_t fvel; int16_t fvel;
fixed_t q16avel; fixed_t q16avel;
fixed_t q16horz; float horz;
ESyncBits actions; ESyncBits actions;

View file

@ -429,7 +429,7 @@ void GameInterface::Ticker()
if (oldactions & SB_CENTERVIEW) sPlayerInput[nLocalPlayer].actions |= SB_CENTERVIEW; if (oldactions & SB_CENTERVIEW) sPlayerInput[nLocalPlayer].actions |= SB_CENTERVIEW;
sPlayerInput[nLocalPlayer].nAngle = localInput.q16avel; sPlayerInput[nLocalPlayer].nAngle = localInput.q16avel;
sPlayerInput[nLocalPlayer].pan = localInput.q16horz; sPlayerInput[nLocalPlayer].pan = localInput.horz;
Ra[nLocalPlayer].nTarget = besttarget; Ra[nLocalPlayer].nTarget = besttarget;

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->horizon.horiz, input.q16horz, &sPlayerInput[nLocalPlayer].actions, scaleAdjust); sethorizon(&pPlayer->horizon.horiz, input.horz, &sPlayerInput[nLocalPlayer].actions, scaleAdjust);
} }
playerProcessHelpers(&pPlayer->q16angle, &pPlayer->angAdjust, &pPlayer->angTarget, scaleAdjust); playerProcessHelpers(&pPlayer->q16angle, &pPlayer->angAdjust, &pPlayer->angTarget, scaleAdjust);

View file

@ -164,9 +164,9 @@ inline fixed_t PlayerInputAngVel(int pl)
return ps[pl].sync.q16avel; return ps[pl].sync.q16avel;
} }
inline fixed_t PlayerHorizon(int pl) inline float PlayerHorizon(int pl)
{ {
return ps[pl].sync.q16horz; return ps[pl].sync.horz;
} }
inline void clearfriction() inline void clearfriction()

View file

@ -823,8 +823,8 @@ static void FinalizeInput(int playerNum, InputPacket& input, bool vehicle)
{ {
// neutralize all movement when blocked or in automap follow mode // neutralize all movement when blocked or in automap follow mode
loc.fvel = loc.svel = 0; loc.fvel = loc.svel = 0;
loc.q16avel = loc.q16horz = 0; loc.q16avel = loc.horz = 0;
input.q16avel = input.q16horz = 0; input.q16avel = input.horz = 0;
} }
else else
{ {
@ -860,12 +860,12 @@ static void FinalizeInput(int playerNum, InputPacket& input, bool vehicle)
if (p->newowner == -1 && !(p->sync.actions & SB_CENTERVIEW)) if (p->newowner == -1 && !(p->sync.actions & SB_CENTERVIEW))
{ {
// input.q16horz already added to loc in processMovement() // input.horz already added to loc in processMovement()
loc.q16horz = clamp(loc.q16horz, IntToFixed(-MAXHORIZVEL), IntToFixed(MAXHORIZVEL)); loc.horz = clamp(loc.horz, -MAXHORIZVEL, MAXHORIZVEL);
} }
else else
{ {
loc.q16horz = input.q16horz = 0; loc.horz = input.horz = 0;
} }
} }
} }
@ -923,7 +923,7 @@ 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->horizon.horiz, input.q16horz, &p->sync.actions, scaleAdjust); sethorizon(&p->horizon.horiz, input.horz, &p->sync.actions, scaleAdjust);
} }
playerProcessHelpers(&p->q16ang, &p->angAdjust, &p->angTarget, scaleAdjust); playerProcessHelpers(&p->q16ang, &p->angAdjust, &p->angTarget, scaleAdjust);

View file

@ -34,7 +34,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
BEGIN_SW_NS BEGIN_SW_NS
void DoPlayerHorizon(PLAYERp pp, fixed_t const q16horz, double const scaleAdjust); void DoPlayerHorizon(PLAYERp pp, float const horz, double const scaleAdjust);
void DoPlayerTurn(PLAYERp pp, fixed_t const q16avel, double const scaleAdjust); void DoPlayerTurn(PLAYERp pp, fixed_t const q16avel, double const scaleAdjust);
void DoPlayerTurnVehicle(PLAYERp pp, fixed_t q16avel, int z, int floor_dist); void DoPlayerTurnVehicle(PLAYERp pp, fixed_t q16avel, int z, int floor_dist);
void DoPlayerTurnTurret(PLAYERp pp, fixed_t q16avel); void DoPlayerTurnTurret(PLAYERp pp, fixed_t q16avel);
@ -212,7 +212,7 @@ void GameInterface::GetInput(InputPacket *packet, ControlInfo* const hidInput)
{ {
if (TEST(pp->Flags2, PF2_INPUT_CAN_AIM)) if (TEST(pp->Flags2, PF2_INPUT_CAN_AIM))
{ {
DoPlayerHorizon(pp, input.q16horz, scaleAdjust); DoPlayerHorizon(pp, input.horz, scaleAdjust);
} }
if (TEST(pp->Flags2, PF2_INPUT_CAN_TURN_GENERAL)) if (TEST(pp->Flags2, PF2_INPUT_CAN_TURN_GENERAL))

View file

@ -1734,14 +1734,14 @@ PlayerAutoLook(PLAYERp pp, double const scaleAdjust)
} }
void void
DoPlayerHorizon(PLAYERp pp, fixed_t const q16horz, double const scaleAdjust) DoPlayerHorizon(PLAYERp pp, float const horz, double const scaleAdjust)
{ {
// Fixme: This should probably be made optional. // Fixme: This should probably be made optional.
if (cl_slopetilting) if (cl_slopetilting)
PlayerAutoLook(pp, scaleAdjust); PlayerAutoLook(pp, scaleAdjust);
// apply default horizon from backend // apply default horizon from backend
sethorizon(&pp->horizon.horiz, q16horz, &pp->input.actions, scaleAdjust); sethorizon(&pp->horizon.horiz, horz, &pp->input.actions, scaleAdjust);
} }
void void
@ -2298,7 +2298,7 @@ DoPlayerMove(PLAYERp pp)
} }
else else
{ {
DoPlayerHorizon(pp, pp->input.q16horz, 1); DoPlayerHorizon(pp, pp->input.horz, 1);
} }
if (pp->cursectnum >= 0 && TEST(sector[pp->cursectnum].extra, SECTFX_DYNAMIC_AREA)) if (pp->cursectnum >= 0 && TEST(sector[pp->cursectnum].extra, SECTFX_DYNAMIC_AREA))
@ -2514,7 +2514,7 @@ DoPlayerMoveBoat(PLAYERp pp)
} }
else else
{ {
DoPlayerHorizon(pp, pp->input.q16horz, 1); DoPlayerHorizon(pp, pp->input.horz, 1);
} }
} }
#endif #endif
@ -3008,7 +3008,7 @@ DoPlayerMoveVehicle(PLAYERp pp)
} }
else else
{ {
DoPlayerHorizon(pp, pp->input.q16horz, 1); DoPlayerHorizon(pp, pp->input.horz, 1);
} }
DoTankTreads(pp); DoTankTreads(pp);
@ -3045,7 +3045,7 @@ DoPlayerMoveTurret(PLAYERp pp)
} }
else else
{ {
DoPlayerHorizon(pp, pp->input.q16horz, 1); DoPlayerHorizon(pp, pp->input.horz, 1);
} }
} }
@ -3624,7 +3624,7 @@ DoPlayerClimb(PLAYERp pp)
} }
else else
{ {
DoPlayerHorizon(pp, pp->input.q16horz, 1); DoPlayerHorizon(pp, pp->input.horz, 1);
} }
if (FAF_ConnectArea(pp->cursectnum)) if (FAF_ConnectArea(pp->cursectnum))
@ -7038,7 +7038,7 @@ void ChopsCheck(PLAYERp pp)
{ {
if (!M_Active() && !TEST(pp->Flags, PF_DEAD) && !pp->sop_riding && numplayers <= 1) if (!M_Active() && !TEST(pp->Flags, PF_DEAD) && !pp->sop_riding && numplayers <= 1)
{ {
if (pp->input.actions & ~SB_RUN || pp->input.fvel || pp->input.svel || pp->input.q16avel || pp->input.q16horz || if (pp->input.actions & ~SB_RUN || pp->input.fvel || pp->input.svel || pp->input.q16avel || pp->input.horz ||
TEST(pp->Flags, PF_CLIMBING | PF_FALLING | PF_DIVING)) TEST(pp->Flags, PF_CLIMBING | PF_FALLING | PF_DIVING))
{ {
// Hit a input key or other reason to stop chops // Hit a input key or other reason to stop chops