From 6a30d6880e3c7238adf22979daf0ad165d1c01c9 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Wed, 7 Oct 2020 18:22:07 +1100 Subject: [PATCH] - InputPacket: Change `q16horz` to `horz`, changing type from fixed_t to float. --- source/blood/src/controls.cpp | 2 +- source/blood/src/player.cpp | 4 ++-- source/blood/src/prediction.cpp | 2 +- source/core/d_net.cpp | 8 ++++---- source/core/d_protocol.cpp | 12 ++++++------ source/core/gamecontrol.cpp | 14 +++++++------- source/core/gamecontrol.h | 2 +- source/core/packet.h | 2 +- source/exhumed/src/exhumed.cpp | 2 +- source/exhumed/src/input.cpp | 2 +- source/games/duke/src/inlines.h | 4 ++-- source/games/duke/src/input.cpp | 12 ++++++------ source/sw/src/input.cpp | 4 ++-- source/sw/src/player.cpp | 16 ++++++++-------- 14 files changed, 43 insertions(+), 43 deletions(-) diff --git a/source/blood/src/controls.cpp b/source/blood/src/controls.cpp index ab3fde3a9..a85adc29a 100644 --- a/source/blood/src/controls.cpp +++ b/source/blood/src/controls.cpp @@ -56,7 +56,7 @@ void GameInterface::GetInput(InputPacket* packet, ControlInfo* const hidInput) if (gView->pXSprite->health != 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); diff --git a/source/blood/src/player.cpp b/source/blood/src/player.cpp index 40b4c9191..8371d6dc9 100644 --- a/source/blood/src/player.cpp +++ b/source/blood/src/player.cpp @@ -766,7 +766,7 @@ void playerStart(int nPlayer, int bNewLevel) pInput->actions = 0; pInput->fvel = 0; pInput->svel = 0; - pInput->q16horz = 0; + pInput->horz = 0; pPlayer->flickerEffect = 0; pPlayer->quakeEffect = 0; pPlayer->tiltEffect = 0; @@ -1557,7 +1557,7 @@ void ProcessInput(PLAYER *pPlayer) 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; diff --git a/source/blood/src/prediction.cpp b/source/blood/src/prediction.cpp index ecf90826b..43fac3ecb 100644 --- a/source/blood/src/prediction.cpp +++ b/source/blood/src/prediction.cpp @@ -229,7 +229,7 @@ static void fakeProcessInput(PLAYER *pPlayer, InputPacket *pInput) if (pInput->actions & SB_LOOK_DOWN) 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) predict.at24 = FloatToFixed(fmulscale30(120., Sinf(FixedToFloat(predict.at20) * 8.))); diff --git a/source/core/d_net.cpp b/source/core/d_net.cpp index d719a479c..3fb38f18f 100644 --- a/source/core/d_net.cpp +++ b/source/core/d_net.cpp @@ -1037,7 +1037,7 @@ void NetUpdate (void) int svel = 0; int fvel = 0; int64_t q16avel = 0; - int64_t q16horz = 0; + float horz = 0; for (j = 0; j < ticdup; ++j) { @@ -1045,13 +1045,13 @@ void NetUpdate (void) svel += localcmds[modp].ucmd.svel; fvel += localcmds[modp].ucmd.fvel; q16avel += localcmds[modp].ucmd.q16avel; - q16horz += localcmds[modp].ucmd.q16horz; + horz += localcmds[modp].ucmd.horz; } svel /= ticdup; fvel /= ticdup; q16avel /= ticdup; - q16horz /= ticdup; + horz /= ticdup; for (j = 0; j < ticdup; ++j) { @@ -1059,7 +1059,7 @@ void NetUpdate (void) localcmds[modp].ucmd.svel = svel; localcmds[modp].ucmd.fvel = fvel; localcmds[modp].ucmd.q16avel = q16avel; - localcmds[modp].ucmd.q16horz = q16horz; + localcmds[modp].ucmd.horz = horz; } Net_NewMakeTic (); diff --git a/source/core/d_protocol.cpp b/source/core/d_protocol.cpp index 0a7fe8802..adacca02d 100644 --- a/source/core/d_protocol.cpp +++ b/source/core/d_protocol.cpp @@ -160,7 +160,7 @@ int UnpackUserCmd (InputPacket *ucmd, const InputPacket *basis, uint8_t **stream if (flags & UCMDF_BUTTONS) ucmd->actions = ESyncBits::FromInt(ReadLong(stream)); if (flags & UCMDF_PITCH) - ucmd->q16horz = ReadLong(stream); + ucmd->horz = ReadLong(stream); if (flags & UCMDF_YAW) ucmd->q16avel = ReadLong(stream); if (flags & UCMDF_FORWARDMOVE) @@ -193,10 +193,10 @@ int PackUserCmd (const InputPacket *ucmd, const InputPacket *basis, uint8_t **st flags |= UCMDF_BUTTONS; WriteLong(ucmd->actions, stream); } - if (ucmd->q16horz != basis->q16horz) + if (ucmd->horz != basis->horz) { flags |= UCMDF_PITCH; - WriteLong (ucmd->q16horz, stream); + WriteLong (ucmd->horz, stream); } if (ucmd->q16avel != basis->q16avel) { @@ -236,7 +236,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, InputPacket &cmd, Inpu if (arc.BeginObject(key)) { arc("actions", cmd.actions) - ("horz", cmd.q16horz) + ("horz", cmd.horz) ("avel", cmd.q16avel) ("fvel", cmd.fvel) ("svwl", cmd.svel) @@ -250,7 +250,7 @@ int WriteUserCmdMessage (InputPacket *ucmd, const InputPacket *basis, uint8_t ** if (basis == NULL) { if (ucmd->actions != 0 || - ucmd->q16horz != 0 || + ucmd->horz != 0 || ucmd->q16avel != 0 || ucmd->fvel != 0 || ucmd->svel != 0) @@ -261,7 +261,7 @@ int WriteUserCmdMessage (InputPacket *ucmd, const InputPacket *basis, uint8_t ** } else if (ucmd->actions != basis->actions || - ucmd->q16horz != basis->q16horz || + ucmd->horz != basis->horz || ucmd->q16avel != basis->q16avel || ucmd->fvel != basis->fvel || ucmd->svel != basis->svel) diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index d9460e4f9..c674db4de 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -1457,18 +1457,18 @@ void processMovement(InputPacket* currInput, InputPacket* inputBuffer, ControlIn currInput->q16avel += FloatToFixed(hidInput->mouseturnx + (scaleAdjust * hidInput->dyaw)); if (!(inputBuffer->actions & SB_AIMMODE)) - currInput->q16horz -= FloatToFixed(hidInput->mouseturny); + currInput->horz -= hidInput->mouseturny; else currInput->fvel -= xs_CRoundToInt(hidInput->mousemovey * mousevelscale); if (invertmouse) - currInput->q16horz = -currInput->q16horz; + currInput->horz = -currInput->horz; if (invertmousex) currInput->q16avel = -currInput->q16avel; // 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->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->svel = clamp(inputBuffer->svel + currInput->svel, -keymove, keymove); 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 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. double pitch = horiz->aspitch(); - if (q16horz) + if (horz) { *actions &= ~SB_CENTERVIEW; - pitch += FixedToFloat(q16horz); + pitch += horz; } // this is the locked type diff --git a/source/core/gamecontrol.h b/source/core/gamecontrol.h index 56fac6c63..b2dd5eb20 100644 --- a/source/core/gamecontrol.h +++ b/source/core/gamecontrol.h @@ -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 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 playerAddAngle(fixed_t* q16ang, double* helper, double adjustment); void playerSetAngle(fixed_t* q16ang, fixed_t* helper, double adjustment); diff --git a/source/core/packet.h b/source/core/packet.h index 645f019e2..c64410e72 100644 --- a/source/core/packet.h +++ b/source/core/packet.h @@ -73,7 +73,7 @@ struct InputPacket int16_t svel; int16_t fvel; fixed_t q16avel; - fixed_t q16horz; + float horz; ESyncBits actions; diff --git a/source/exhumed/src/exhumed.cpp b/source/exhumed/src/exhumed.cpp index 8cd209610..8490b547b 100644 --- a/source/exhumed/src/exhumed.cpp +++ b/source/exhumed/src/exhumed.cpp @@ -429,7 +429,7 @@ void GameInterface::Ticker() if (oldactions & SB_CENTERVIEW) sPlayerInput[nLocalPlayer].actions |= SB_CENTERVIEW; sPlayerInput[nLocalPlayer].nAngle = localInput.q16avel; - sPlayerInput[nLocalPlayer].pan = localInput.q16horz; + sPlayerInput[nLocalPlayer].pan = localInput.horz; Ra[nLocalPlayer].nTarget = besttarget; diff --git a/source/exhumed/src/input.cpp b/source/exhumed/src/input.cpp index 491f9a5d8..dbf990b3f 100644 --- a/source/exhumed/src/input.cpp +++ b/source/exhumed/src/input.cpp @@ -129,7 +129,7 @@ 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); - 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); diff --git a/source/games/duke/src/inlines.h b/source/games/duke/src/inlines.h index 103a128c7..6ad1b90aa 100644 --- a/source/games/duke/src/inlines.h +++ b/source/games/duke/src/inlines.h @@ -164,9 +164,9 @@ inline fixed_t PlayerInputAngVel(int pl) 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() diff --git a/source/games/duke/src/input.cpp b/source/games/duke/src/input.cpp index 995370800..865182930 100644 --- a/source/games/duke/src/input.cpp +++ b/source/games/duke/src/input.cpp @@ -823,8 +823,8 @@ static void FinalizeInput(int playerNum, InputPacket& input, bool vehicle) { // neutralize all movement when blocked or in automap follow mode loc.fvel = loc.svel = 0; - loc.q16avel = loc.q16horz = 0; - input.q16avel = input.q16horz = 0; + loc.q16avel = loc.horz = 0; + input.q16avel = input.horz = 0; } else { @@ -860,12 +860,12 @@ static void FinalizeInput(int playerNum, InputPacket& input, bool vehicle) if (p->newowner == -1 && !(p->sync.actions & SB_CENTERVIEW)) { - // input.q16horz already added to loc in processMovement() - loc.q16horz = clamp(loc.q16horz, IntToFixed(-MAXHORIZVEL), IntToFixed(MAXHORIZVEL)); + // input.horz already added to loc in processMovement() + loc.horz = clamp(loc.horz, -MAXHORIZVEL, MAXHORIZVEL); } 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); 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); - 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); diff --git a/source/sw/src/input.cpp b/source/sw/src/input.cpp index 94ce42ea0..f674a7c1a 100644 --- a/source/sw/src/input.cpp +++ b/source/sw/src/input.cpp @@ -34,7 +34,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms 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 DoPlayerTurnVehicle(PLAYERp pp, fixed_t q16avel, int z, int floor_dist); 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)) { - DoPlayerHorizon(pp, input.q16horz, scaleAdjust); + DoPlayerHorizon(pp, input.horz, scaleAdjust); } if (TEST(pp->Flags2, PF2_INPUT_CAN_TURN_GENERAL)) diff --git a/source/sw/src/player.cpp b/source/sw/src/player.cpp index bb4f9bcf5..f2c5ad7ba 100644 --- a/source/sw/src/player.cpp +++ b/source/sw/src/player.cpp @@ -1734,14 +1734,14 @@ PlayerAutoLook(PLAYERp pp, double const scaleAdjust) } 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. if (cl_slopetilting) PlayerAutoLook(pp, scaleAdjust); // apply default horizon from backend - sethorizon(&pp->horizon.horiz, q16horz, &pp->input.actions, scaleAdjust); + sethorizon(&pp->horizon.horiz, horz, &pp->input.actions, scaleAdjust); } void @@ -2298,7 +2298,7 @@ DoPlayerMove(PLAYERp pp) } 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)) @@ -2514,7 +2514,7 @@ DoPlayerMoveBoat(PLAYERp pp) } else { - DoPlayerHorizon(pp, pp->input.q16horz, 1); + DoPlayerHorizon(pp, pp->input.horz, 1); } } #endif @@ -3008,7 +3008,7 @@ DoPlayerMoveVehicle(PLAYERp pp) } else { - DoPlayerHorizon(pp, pp->input.q16horz, 1); + DoPlayerHorizon(pp, pp->input.horz, 1); } DoTankTreads(pp); @@ -3045,7 +3045,7 @@ DoPlayerMoveTurret(PLAYERp pp) } else { - DoPlayerHorizon(pp, pp->input.q16horz, 1); + DoPlayerHorizon(pp, pp->input.horz, 1); } } @@ -3624,7 +3624,7 @@ DoPlayerClimb(PLAYERp pp) } else { - DoPlayerHorizon(pp, pp->input.q16horz, 1); + DoPlayerHorizon(pp, pp->input.horz, 1); } 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 (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)) { // Hit a input key or other reason to stop chops