From f570cb5d21e57ceca100c6a30fd0b5c03224eee4 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Tue, 3 Oct 2023 16:17:00 +1100 Subject: [PATCH] - Change `InputPacket` velocities to an `FVector3`. --- source/core/d_net.cpp | 12 +++---- source/core/d_protocol.cpp | 36 ++++++++++----------- source/core/gameinput.cpp | 30 ++++++++--------- source/core/packet.h | 5 ++- source/games/blood/src/nnexts.cpp | 8 ++--- source/games/blood/src/player.cpp | 16 ++++----- source/games/duke/src/actors_d.cpp | 6 ++-- source/games/duke/src/actors_r.cpp | 4 +-- source/games/duke/src/inlines.h | 10 +++--- source/games/duke/src/player.cpp | 4 +-- source/games/duke/src/player_d.cpp | 4 +-- source/games/duke/src/player_r.cpp | 18 +++++------ source/games/exhumed/src/player.cpp | 6 ++-- source/games/sw/src/player.cpp | 50 ++++++++++++++--------------- 14 files changed, 104 insertions(+), 105 deletions(-) diff --git a/source/core/d_net.cpp b/source/core/d_net.cpp index 6fbd27d90..e26e77bf2 100644 --- a/source/core/d_net.cpp +++ b/source/core/d_net.cpp @@ -1042,9 +1042,9 @@ void NetUpdate (void) for (tic = 0; tic < ticdup; ++tic) { modp = (mod + tic) % LOCALCMDTICS; - svel += localcmds[modp].ucmd.svel; - fvel += localcmds[modp].ucmd.fvel; - uvel += localcmds[modp].ucmd.uvel; + fvel += localcmds[modp].ucmd.vel.X; + svel += localcmds[modp].ucmd.vel.Y; + uvel += localcmds[modp].ucmd.vel.Z; avel += localcmds[modp].ucmd.avel; horz += localcmds[modp].ucmd.horz; roll += localcmds[modp].ucmd.roll; @@ -1060,9 +1060,9 @@ void NetUpdate (void) for (tic = 0; tic < ticdup; ++tic) { modp = (mod + tic) % LOCALCMDTICS; - localcmds[modp].ucmd.svel = svel; - localcmds[modp].ucmd.fvel = fvel; - localcmds[modp].ucmd.uvel = uvel; + localcmds[modp].ucmd.vel.X = fvel; + localcmds[modp].ucmd.vel.Y = svel; + localcmds[modp].ucmd.vel.Z = uvel; localcmds[modp].ucmd.avel = avel; localcmds[modp].ucmd.horz = horz; localcmds[modp].ucmd.roll = roll; diff --git a/source/core/d_protocol.cpp b/source/core/d_protocol.cpp index ba8d64f5d..31de5bb7a 100644 --- a/source/core/d_protocol.cpp +++ b/source/core/d_protocol.cpp @@ -164,11 +164,11 @@ int UnpackUserCmd (InputPacket *ucmd, const InputPacket *basis, uint8_t **stream if (flags & UCMDF_YAW) ucmd->avel = ReadFloat(stream); if (flags & UCMDF_FORWARDMOVE) - ucmd->fvel = ReadFloat(stream); + ucmd->vel.X = ReadFloat(stream); if (flags & UCMDF_SIDEMOVE) - ucmd->svel = ReadFloat(stream); + ucmd->vel.Y = ReadFloat(stream); if (flags & UCMDF_UPMOVE) - ucmd->uvel = ReadFloat(stream); + ucmd->vel.Z = ReadFloat(stream); if (flags & UCMDF_ROLL) ucmd->roll = ReadFloat(stream); } @@ -207,20 +207,20 @@ int PackUserCmd (const InputPacket *ucmd, const InputPacket *basis, uint8_t **st flags |= UCMDF_YAW; WriteFloat (ucmd->avel, stream); } - if (ucmd->fvel != basis->fvel) + if (ucmd->vel.X != basis->vel.X) { flags |= UCMDF_FORWARDMOVE; - WriteFloat (ucmd->fvel, stream); + WriteFloat (ucmd->vel.X, stream); } - if (ucmd->svel != basis->svel) + if (ucmd->vel.Y != basis->vel.Y) { flags |= UCMDF_SIDEMOVE; - WriteFloat (ucmd->svel, stream); + WriteFloat (ucmd->vel.Y, stream); } - if (ucmd->uvel != basis->uvel) + if (ucmd->vel.Z != basis->vel.Z) { flags |= UCMDF_UPMOVE; - WriteFloat (ucmd->uvel, stream); + WriteFloat (ucmd->vel.Z, stream); } if (ucmd->roll != basis->roll) { @@ -252,9 +252,9 @@ FSerializer &Serialize(FSerializer &arc, const char *key, InputPacket &cmd, Inpu arc("actions", cmd.actions) ("horz", cmd.horz) ("avel", cmd.avel) - ("fvel", cmd.fvel) - ("svel", cmd.svel) - ("uvel", cmd.uvel) + ("fvel", cmd.vel.X) + ("svel", cmd.vel.Y) + ("uvel", cmd.vel.Z) ("roll", cmd.roll) .EndObject(); } @@ -268,9 +268,9 @@ int WriteUserCmdMessage (InputPacket *ucmd, const InputPacket *basis, uint8_t ** if (ucmd->actions != 0 || ucmd->horz != 0 || ucmd->avel != 0 || - ucmd->fvel != 0 || - ucmd->svel != 0 || - ucmd->uvel != 0 || + ucmd->vel.X != 0 || + ucmd->vel.Y != 0 || + ucmd->vel.Z != 0 || ucmd->roll != 0) { WriteByte (DEM_USERCMD, stream); @@ -281,9 +281,9 @@ int WriteUserCmdMessage (InputPacket *ucmd, const InputPacket *basis, uint8_t ** if (ucmd->actions != basis->actions || ucmd->horz != basis->horz || ucmd->avel != basis->avel || - ucmd->fvel != basis->fvel || - ucmd->svel != basis->svel || - ucmd->uvel != basis->uvel || + ucmd->vel.X != basis->vel.X || + ucmd->vel.Y != basis->vel.Y || + ucmd->vel.Z != basis->vel.Z || ucmd->roll != basis->roll) { WriteByte (DEM_USERCMD, stream); diff --git a/source/core/gameinput.cpp b/source/core/gameinput.cpp index 5c1545ba3..eea9d7ed3 100644 --- a/source/core/gameinput.cpp +++ b/source/core/gameinput.cpp @@ -137,9 +137,9 @@ void GameInput::processMovement(PlayerAngles* const plrAngles, const float scale } else { - thisInput.svel += mouseInput.X * MOUSE_SCALE * m_side; - thisInput.svel -= joyAxes[JOYAXIS_Yaw] * keymove * scaleAdjust; - thisInput.svel += turning * keymove * scaleAdjust; + thisInput.vel.Y += mouseInput.X * MOUSE_SCALE * m_side; + thisInput.vel.Y -= joyAxes[JOYAXIS_Yaw] * keymove * scaleAdjust; + thisInput.vel.Y += turning * keymove * scaleAdjust; } // process player pitch input. @@ -151,25 +151,25 @@ void GameInput::processMovement(PlayerAngles* const plrAngles, const float scale } else { - thisInput.fvel += mouseInput.Y * MOUSE_SCALE * m_forward; - thisInput.fvel += joyAxes[JOYAXIS_Pitch] * keymove * scaleAdjust; + thisInput.vel.X += mouseInput.Y * MOUSE_SCALE * m_forward; + thisInput.vel.X += joyAxes[JOYAXIS_Pitch] * keymove * scaleAdjust; } // process movement input. - thisInput.fvel += moving * keymove; - thisInput.svel += strafing * keymove * allowstrafe; - thisInput.uvel += soaring; // this isn't scaled by running. + thisInput.vel.X += moving * keymove; + thisInput.vel.Y += strafing * keymove * allowstrafe; + thisInput.vel.Z += soaring; // this isn't scaled by running. // process RR's drunk state. if (isRR() && drink_amt >= 66 && drink_amt <= 87) { - thisInput.svel += drink_amt & 1 ? -thisInput.fvel : thisInput.fvel; + thisInput.vel.Y += drink_amt & 1 ? -thisInput.vel.X : thisInput.vel.X; } // add collected input to game's local input accumulation packet. - inputBuffer.fvel = clamp(inputBuffer.fvel + thisInput.fvel, -(float)keymove, (float)keymove); - inputBuffer.svel = clamp(inputBuffer.svel + thisInput.svel, -(float)keymove, (float)keymove); - inputBuffer.uvel = clamp(inputBuffer.uvel + thisInput.uvel, -1.00f, 1.00f); + inputBuffer.vel.X = clamp(inputBuffer.vel.X + thisInput.vel.X, -(float)keymove, (float)keymove); + inputBuffer.vel.Y = clamp(inputBuffer.vel.Y + thisInput.vel.Y, -(float)keymove, (float)keymove); + inputBuffer.vel.Z = clamp(inputBuffer.vel.Z + thisInput.vel.Z, -1.00f, 1.00f); inputBuffer.avel = clamp(inputBuffer.avel + thisInput.avel, -179.f, 179.f); inputBuffer.horz = clamp(inputBuffer.horz + thisInput.horz, -179.f, 179.f); @@ -202,8 +202,8 @@ void GameInput::processVehicle(PlayerAngles* const plrAngles, const float scaleA { const auto kbdForwards = buttonMap.ButtonDown(gamefunc_Move_Forward) || buttonMap.ButtonDown(gamefunc_Strafe); const auto kbdBackward = buttonMap.ButtonDown(gamefunc_Move_Backward); - thisInput.fvel = kbdForwards - kbdBackward + joyAxes[JOYAXIS_Forward]; - inputBuffer.fvel = clamp(inputBuffer.fvel + thisInput.fvel, -1.f, 1.f); + thisInput.vel.X = kbdForwards - kbdBackward + joyAxes[JOYAXIS_Forward]; + inputBuffer.vel.X = clamp(inputBuffer.vel.X + thisInput.vel.X, -1.f, 1.f); // This sync bit is the brake key. if (buttonMap.ButtonDown(gamefunc_Run)) inputBuffer.actions |= SB_CROUCH; @@ -554,7 +554,7 @@ void PlayerAngles::doRollInput(InputPacket* const input, const DVector2& nVelVec // Scale/attenuate tilting based on player actions. const auto rollAmp = cl_viewtiltscale / (bUnderwater + 1); const auto runScale = 1. / (!(input->actions & SB_RUN) + 1); - const auto strafeScale = !!input->svel + 1; + const auto strafeScale = !!input->vel.Y + 1; if (cl_viewtilting == 1) { diff --git a/source/core/packet.h b/source/core/packet.h index c7f43ef35..bfabd1029 100644 --- a/source/core/packet.h +++ b/source/core/packet.h @@ -3,6 +3,7 @@ #include #include "m_fixed.h" #include "tflags.h" +#include "vectors.h" enum ESyncBits_ : uint32_t { @@ -69,9 +70,7 @@ enum struct InputPacket { - float svel; - float fvel; - float uvel; + FVector3 vel; float avel; float horz; float roll; diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index e49707b08..e4b10f655 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -4358,10 +4358,10 @@ bool condCheckPlayer(DBloodActor* aCond, int cmpOp, bool PUSH) return true; case 10: // check keys pressed switch (arg1) { - case 1: return (pPlayer->cmd.ucmd.fvel > 0); // forward - case 2: return (pPlayer->cmd.ucmd.fvel < 0); // backward - case 3: return (pPlayer->cmd.ucmd.svel < 0); // left - case 4: return (pPlayer->cmd.ucmd.svel > 0); // right + case 1: return (pPlayer->cmd.ucmd.vel.X > 0); // forward + case 2: return (pPlayer->cmd.ucmd.vel.X < 0); // backward + case 3: return (pPlayer->cmd.ucmd.vel.Y < 0); // left + case 4: return (pPlayer->cmd.ucmd.vel.Y > 0); // right case 5: return !!(pPlayer->cmd.ucmd.actions & SB_JUMP); // jump case 6: return !!(pPlayer->cmd.ucmd.actions & SB_CROUCH); // crouch case 7: return !!(pPlayer->cmd.ucmd.actions & SB_FIRE); // normal fire weapon diff --git a/source/games/blood/src/player.cpp b/source/games/blood/src/player.cpp index 7fc9bf04d..761dc3709 100644 --- a/source/games/blood/src/player.cpp +++ b/source/games/blood/src/player.cpp @@ -859,8 +859,8 @@ void playerStart(int nPlayer, int bNewLevel) actor->vel.Zero(); pInput->avel = 0; pInput->actions = 0; - pInput->fvel = 0; - pInput->svel = 0; + pInput->vel.X = 0; + pInput->vel.Y = 0; pInput->horz = 0; pPlayer->flickerEffect = 0; pPlayer->quakeEffect = 0; @@ -1526,7 +1526,7 @@ void ProcessInput(DBloodPlayer* pPlayer) // Allow it to become true behind a CVAR to offer an alternate playing experience if desired. pPlayer->isRunning = !!(pInput->actions & SB_RUN) && !cl_bloodvanillarun; - if ((pInput->actions & SB_BUTTON_MASK) || pInput->fvel || pInput->svel || pInput->avel) + if ((pInput->actions & SB_BUTTON_MASK) || pInput->vel.X || pInput->vel.Y || pInput->avel) pPlayer->restTime = 0; else if (pPlayer->restTime >= 0) pPlayer->restTime += 4; @@ -1573,13 +1573,13 @@ void ProcessInput(DBloodPlayer* pPlayer) return; } - if ((pInput->fvel || pInput->svel) && (pPlayer->posture == 1 || actor->xspr.height < 256)) + if ((pInput->vel.X || pInput->vel.Y) && (pPlayer->posture == 1 || actor->xspr.height < 256)) { const double speed = pPlayer->posture == 1? 1. : 1. - (actor->xspr.height * (1. / 256.) * (actor->xspr.height < 256)); - const double fvAccel = pInput->fvel > 0 ? pPosture->frontAccel : pPosture->backAccel; + const double fvAccel = pInput->vel.X > 0 ? pPosture->frontAccel : pPosture->backAccel; const double svAccel = pPosture->sideAccel; - actor->vel.XY() += DVector2(pInput->fvel * fvAccel, pInput->svel * svAccel).Rotated(actor->spr.Angles.Yaw) * speed; - pPlayer->Angles.StrafeVel += pInput->svel * svAccel * speed; + actor->vel.XY() += DVector2(pInput->vel.X * fvAccel, pInput->vel.Y * svAccel).Rotated(actor->spr.Angles.Yaw) * speed; + pPlayer->Angles.StrafeVel += pInput->vel.Y * svAccel * speed; } pPlayer->Angles.doViewYaw(pInput); @@ -1593,7 +1593,7 @@ void ProcessInput(DBloodPlayer* pPlayer) { const auto kbdDir = !!(pInput->actions & SB_JUMP) - !!(pInput->actions & SB_CROUCH); const double dist = pPosture->normalJumpZ; - actor->vel.Z -= clamp(dist * kbdDir + dist * pInput->uvel, -dist, dist); + actor->vel.Z -= clamp(dist * kbdDir + dist * pInput->vel.Z, -dist, dist); break; } case kPostureCrouch: diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index ead3f7064..11a1a77cb 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -339,8 +339,8 @@ void movetransports_d(void) if (onfloorz == 0 && fabs(act->spr.pos.Z - act2->getOffsetZ()) < 24) { - if ((p->jetpack_on == 0) || (p->jetpack_on && (PlayerInput(pnum, SB_JUMP) || p->cmd.ucmd.uvel > 0)) || - (p->jetpack_on && (PlayerInput(pnum, SB_CROUCH) || p->cmd.ucmd.uvel < 0))) + if ((p->jetpack_on == 0) || (p->jetpack_on && (PlayerInput(pnum, SB_JUMP) || p->cmd.ucmd.vel.Z > 0)) || + (p->jetpack_on && (PlayerInput(pnum, SB_CROUCH) || p->cmd.ucmd.vel.Z < 0))) { act2->spr.pos.XY() += Owner->spr.pos.XY() - act->spr.pos.XY(); act2->backupvec2(); @@ -378,7 +378,7 @@ void movetransports_d(void) } - if (onfloorz && sectlotag == ST_1_ABOVE_WATER && p->on_ground && act2->getOffsetZ() > (sectp->floorz - 16) && (PlayerInput(pnum, SB_CROUCH) || p->cmd.ucmd.uvel < 0 || p->vel.Z > 8)) + if (onfloorz && sectlotag == ST_1_ABOVE_WATER && p->on_ground && act2->getOffsetZ() > (sectp->floorz - 16) && (PlayerInput(pnum, SB_CROUCH) || p->cmd.ucmd.vel.Z < 0 || p->vel.Z > 8)) // if( onfloorz && sectlotag == 1 && ps[p].pos.z > (sectp->floorz-(6<<8)) ) { k = 1; diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 9549a4f0e..707462998 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -309,8 +309,8 @@ void movetransports_r(void) if (onfloorz == 0 && fabs(act->spr.pos.Z - act2->getOffsetZ()) < 24) { - if ((p->jetpack_on == 0) || (p->jetpack_on && (PlayerInput(pnum, SB_JUMP) || p->cmd.ucmd.uvel > 0)) || - (p->jetpack_on && (PlayerInput(pnum, SB_CROUCH) || p->cmd.ucmd.uvel < 0))) + if ((p->jetpack_on == 0) || (p->jetpack_on && (PlayerInput(pnum, SB_JUMP) || p->cmd.ucmd.vel.Z > 0)) || + (p->jetpack_on && (PlayerInput(pnum, SB_CROUCH) || p->cmd.ucmd.vel.Z < 0))) { act2->spr.pos.XY() += Owner->spr.pos.XY() - act->spr.pos.XY(); act2->backupvec2(); diff --git a/source/games/duke/src/inlines.h b/source/games/duke/src/inlines.h index 06e09238d..f1615ed59 100644 --- a/source/games/duke/src/inlines.h +++ b/source/games/duke/src/inlines.h @@ -139,12 +139,12 @@ inline bool PlayerUseItem(int pl, int num) inline float PlayerInputSideVel(int pl) { - return getPlayer(pl)->cmd.ucmd.svel; + return getPlayer(pl)->cmd.ucmd.vel.Y; } inline float PlayerInputForwardVel(int pl) { - return getPlayer(pl)->cmd.ucmd.fvel; + return getPlayer(pl)->cmd.ucmd.vel.X; } inline void clearfriction() @@ -264,9 +264,9 @@ inline int monsterCheatCheck(DDukeActor* self) inline void processinputvel(int snum) { const auto p = getPlayer(snum); - const auto velvect = DVector2(p->cmd.ucmd.fvel, p->cmd.ucmd.svel).Rotated(p->GetActor()->spr.Angles.Yaw) + p->fric; - p->cmd.ucmd.fvel = (float)velvect.X; - p->cmd.ucmd.svel = (float)velvect.Y; + const auto velvect = DVector2(p->cmd.ucmd.vel.X, p->cmd.ucmd.vel.Y).Rotated(p->GetActor()->spr.Angles.Yaw) + p->fric; + p->cmd.ucmd.vel.X = (float)velvect.X; + p->cmd.ucmd.vel.Y = (float)velvect.Y; } diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index e84d66bcf..21cec5204 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -673,7 +673,7 @@ void playerCrouch(int snum) { const auto p = getPlayer(snum); const auto pact = p->GetActor(); - const auto nVelMoveDown = abs(p->cmd.ucmd.uvel * (p->cmd.ucmd.uvel < 0)); + const auto nVelMoveDown = abs(p->cmd.ucmd.vel.Z * (p->cmd.ucmd.vel.Z < 0)); constexpr double vel = 8 + 3; SetGameVarID(g_iReturnVarID, 0, pact, snum); OnEvent(EVENT_CROUCH, snum, pact, -1); @@ -1582,7 +1582,7 @@ void underwater(int snum, ESyncBits actions, double floorz, double ceilingz) const auto pact = p->GetActor(); constexpr double dist = (348. / 256.); const auto kbdDir = ((actions & SB_JUMP) && !p->OnMotorcycle) - ((actions & SB_CROUCH) || p->OnMotorcycle); - const auto velZ = clamp(dist * kbdDir + dist * p->cmd.ucmd.uvel, -dist, dist); + const auto velZ = clamp(dist * kbdDir + dist * p->cmd.ucmd.vel.Z, -dist, dist); p->jumping_counter = 0; p->pycount += 32; diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index c29a1cf01..93c9c1f5e 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -581,7 +581,7 @@ static void operateJetpack(int snum, ESyncBits actions, int psectlotag, double f const auto pact = p->GetActor(); const auto kbdDir = !!(actions & SB_JUMP) - !!(actions & SB_CROUCH); const double dist = shrunk ? 2 : 8; - const double velZ = clamp(dist * kbdDir + dist * p->cmd.ucmd.uvel, -dist, dist); + const double velZ = clamp(dist * kbdDir + dist * p->cmd.ucmd.vel.Z, -dist, dist); p->on_ground = 0; p->jumping_counter = 0; @@ -766,7 +766,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, double floo p->on_warping_sector = 0; - if ((actions & SB_CROUCH) || p->cmd.ucmd.uvel < 0) + if ((actions & SB_CROUCH) || p->cmd.ucmd.vel.Z < 0) { playerCrouch(snum); } diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 2f5fb3870..0524f9f54 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -712,11 +712,11 @@ enum : unsigned static unsigned outVehicleFlags(DDukePlayer* p, ESyncBits& actions) { unsigned flags = 0; - flags += VEH_FORWARD * (p->cmd.ucmd.fvel > 0); - flags += VEH_REVERSE * (p->cmd.ucmd.fvel < 0); + flags += VEH_FORWARD * (p->cmd.ucmd.vel.X > 0); + flags += VEH_REVERSE * (p->cmd.ucmd.vel.X < 0); flags += VEH_TURNLEFT * (p->cmd.ucmd.avel < 0); flags += VEH_TURNRIGHT * (p->cmd.ucmd.avel > 0); - flags += VEH_BRAKING * (!!(actions & SB_CROUCH) || (p->cmd.ucmd.fvel < 0 && p->MotoSpeed > 0)); + flags += VEH_BRAKING * (!!(actions & SB_CROUCH) || (p->cmd.ucmd.vel.X < 0 && p->MotoSpeed > 0)); actions &= ~SB_CROUCH; return flags; } @@ -907,7 +907,7 @@ static void doVehicleThrottling(DDukePlayer* p, DDukeActor* pact, unsigned& flag else if ((flags & VEH_BRAKING) && p->MotoSpeed > 0) { const auto kbdBraking = brakeSpeed * !!(flags & VEH_BRAKING); - const auto hidBraking = brakeSpeed * p->cmd.ucmd.fvel * (p->cmd.ucmd.fvel < 0); + const auto hidBraking = brakeSpeed * p->cmd.ucmd.vel.X * (p->cmd.ucmd.vel.X < 0); p->MotoSpeed -= clamp(kbdBraking - hidBraking, -brakeSpeed, brakeSpeed); if (p->MotoSpeed < 0) p->MotoSpeed = 0; @@ -922,7 +922,7 @@ static void doVehicleThrottling(DDukePlayer* p, DDukeActor* pact, unsigned& flag p->moto_bump_fast = 1; } - p->MotoSpeed += fwdSpeed * p->cmd.ucmd.fvel; + p->MotoSpeed += fwdSpeed * p->cmd.ucmd.vel.X; flags &= ~VEH_FORWARD; if (p->MotoSpeed > 120) @@ -952,7 +952,7 @@ static void doVehicleThrottling(DDukePlayer* p, DDukeActor* pact, unsigned& flag flags &= ~VEH_TURNRIGHT; flags |= VEH_TURNLEFT; } - p->MotoSpeed = revSpeed * p->cmd.ucmd.fvel; + p->MotoSpeed = revSpeed * p->cmd.ucmd.vel.X; flags &= ~VEH_REVERSE; } } @@ -1034,7 +1034,7 @@ static void onMotorcycle(int snum, ESyncBits &actions) } p->moto_on_mud = p->moto_on_oil = 0; - p->cmd.ucmd.fvel = clamp((float)p->MotoSpeed, -15.f, 120.f) * (1.f / 40.f); + p->cmd.ucmd.vel.X = clamp((float)p->MotoSpeed, -15.f, 120.f) * (1.f / 40.f); } //--------------------------------------------------------------------------- @@ -1104,7 +1104,7 @@ static void onBoat(int snum, ESyncBits &actions) if (p->NotOnWater && p->MotoSpeed > 50) p->MotoSpeed *= 0.5; - p->cmd.ucmd.fvel = clamp((float)p->MotoSpeed, -15.f, 120.f) * (1.f / 40.f); + p->cmd.ucmd.vel.X = clamp((float)p->MotoSpeed, -15.f, 120.f) * (1.f / 40.f); } //--------------------------------------------------------------------------- @@ -1282,7 +1282,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, double floo p->on_warping_sector = 0; - if (((actions & SB_CROUCH) || p->cmd.ucmd.uvel < 0) && !p->OnMotorcycle) + if (((actions & SB_CROUCH) || p->cmd.ucmd.vel.Z < 0) && !p->OnMotorcycle) { playerCrouch(snum); } diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index 52c90fbbc..e5bed6c66 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -1102,13 +1102,13 @@ static void updatePlayerVelocity(DExhumedPlayer* const pPlayer) if (pPlayer->nHealth > 0) { const auto pInput = &pPlayer->cmd.ucmd; - const auto inputvect = DVector2(pInput->fvel, pInput->svel).Rotated(pPlayerActor->spr.Angles.Yaw) * 0.375; + const auto inputvect = DVector2(pInput->vel.X, pInput->vel.Y).Rotated(pPlayerActor->spr.Angles.Yaw) * 0.375; for (int i = 0; i < 4; i++) { pPlayerActor->vel.XY() += inputvect; pPlayerActor->vel.XY() *= 0.953125; - pPlayer->Angles.StrafeVel += pInput->svel * 0.375; + pPlayer->Angles.StrafeVel += pInput->vel.Y * 0.375; pPlayer->Angles.StrafeVel *= 0.953125; } } @@ -1231,7 +1231,7 @@ static void updatePlayerAction(DExhumedPlayer* const pPlayer) const auto pInput = &pPlayer->cmd.ucmd; const auto kbdDir = !!(pInput->actions & SB_CROUCH) - !!(pInput->actions & SB_JUMP); const double dist = pPlayer->bUnderwater ? 8 : 14; - const double velZ = clamp(dist * kbdDir - dist * pInput->uvel, -dist, dist); + const double velZ = clamp(dist * kbdDir - dist * pInput->vel.Z, -dist, dist); int nextAction = pPlayerActor->nAction; const auto scaleViewZ = [&](const double target) diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index 07b978736..73406a45b 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -1864,8 +1864,8 @@ void DoPlayerMove(DSWPlayer* pp) pp->ovect = pp->vect; pp->Angles.PrevStrafeVel = pp->Angles.StrafeVel; - pp->vect.X += pp->cmd.ucmd.fvel * INPUT_SCALE; - pp->vect.Y += pp->cmd.ucmd.svel * INPUT_SCALE; + pp->vect.X += pp->cmd.ucmd.vel.X * INPUT_SCALE; + pp->vect.Y += pp->cmd.ucmd.vel.Y * INPUT_SCALE; pp->Angles.StrafeVel += pp->svel * INPUT_SCALE; friction = pp->friction; @@ -2390,9 +2390,9 @@ void DoPlayerMoveVehicle(DSWPlayer* pp) if (!Prediction) { - if (abs(pp->cmd.ucmd.fvel + pp->cmd.ucmd.svel) && !abs(pp->lastcmd.ucmd.fvel + pp->lastcmd.ucmd.svel)) + if (abs(pp->cmd.ucmd.vel.X + pp->cmd.ucmd.vel.Y) && !abs(pp->lastcmd.ucmd.vel.X + pp->lastcmd.ucmd.vel.Y)) PlaySOsound(pp->sop->mid_sector,SO_DRIVE_SOUND); - else if (!abs(pp->cmd.ucmd.fvel + pp->cmd.ucmd.svel) && abs(pp->lastcmd.ucmd.fvel + pp->lastcmd.ucmd.svel)) + else if (!abs(pp->cmd.ucmd.vel.X + pp->cmd.ucmd.vel.Y) && abs(pp->lastcmd.ucmd.vel.X + pp->lastcmd.ucmd.vel.Y)) PlaySOsound(pp->sop->mid_sector,SO_IDLE_SOUND); } @@ -2405,16 +2405,16 @@ void DoPlayerMoveVehicle(DSWPlayer* pp) if (sop->drive_speed) { - pp->vect.X = pp->cmd.ucmd.fvel * sop->drive_speed * (70. / 1048576.); - pp->vect.Y = pp->cmd.ucmd.svel * sop->drive_speed * (70. / 1048576.); + pp->vect.X = pp->cmd.ucmd.vel.X * sop->drive_speed * (70. / 1048576.); + pp->vect.Y = pp->cmd.ucmd.vel.Y * sop->drive_speed * (70. / 1048576.); // does sliding/momentum pp->vect = (pp->vect + (pp->ovect * (sop->drive_slide-1)))/sop->drive_slide; } else { - pp->vect.X += pp->cmd.ucmd.fvel * INPUT_SCALE; - pp->vect.Y += pp->cmd.ucmd.svel * INPUT_SCALE; + pp->vect.X += pp->cmd.ucmd.vel.X * INPUT_SCALE; + pp->vect.Y += pp->cmd.ucmd.vel.Y * INPUT_SCALE; pp->vect *= TANK_FRICTION; pp->vect = (pp->vect + (pp->ovect*1))/2; @@ -3008,7 +3008,7 @@ void DoPlayerFall(DSWPlayer* pp) return; } - if ((pp->cmd.ucmd.actions & SB_CROUCH) || pp->cmd.ucmd.uvel < 0) + if ((pp->cmd.ucmd.actions & SB_CROUCH) || pp->cmd.ucmd.vel.Z < 0) { StackedWaterSplash(pp); DoPlayerBeginCrawl(pp); @@ -3079,8 +3079,8 @@ void DoPlayerClimb(DSWPlayer* pp) if (Prediction) return; - pp->vect.X += pp->cmd.ucmd.fvel * INPUT_SCALE; - pp->vect.Y += pp->cmd.ucmd.svel * INPUT_SCALE; + pp->vect.X += pp->cmd.ucmd.vel.X * INPUT_SCALE; + pp->vect.Y += pp->cmd.ucmd.vel.Y * INPUT_SCALE; pp->vect *= PLAYER_CLIMB_FRICTION; if (abs(pp->vect.X) < 0.05 && abs(pp->vect.Y) < 0.05) pp->vect.X = pp->vect.Y = 0; @@ -3382,7 +3382,7 @@ void DoPlayerCrawl(DSWPlayer* pp) return; } - if ((!(pp->cmd.ucmd.actions & SB_CROUCH) || pp->cmd.ucmd.uvel > 0) && abs(pp->loz - pp->hiz) >= PLAYER_STANDING_ROOM) + if ((!(pp->cmd.ucmd.actions & SB_CROUCH) || pp->cmd.ucmd.vel.Z > 0) && abs(pp->loz - pp->hiz) >= PLAYER_STANDING_ROOM) { // Let off of crawl to get up pp->Flags &= ~PF_CRAWLING; @@ -3485,7 +3485,7 @@ void DoPlayerFly(DSWPlayer* pp) } const auto kbdDir = !!(pp->cmd.ucmd.actions & SB_CROUCH) - !!(pp->cmd.ucmd.actions & SB_JUMP); - const double velZ = clamp(PLAYER_FLY_INC * kbdDir - PLAYER_FLY_INC * pp->cmd.ucmd.uvel, -PLAYER_FLY_INC, PLAYER_FLY_INC); + const double velZ = clamp(PLAYER_FLY_INC * kbdDir - PLAYER_FLY_INC * pp->cmd.ucmd.vel.Z, -PLAYER_FLY_INC, PLAYER_FLY_INC); pp->z_speed = clamp(pp->z_speed + velZ, -PLAYER_FLY_MAX_SPEED, PLAYER_FLY_MAX_SPEED) * FixedToFloat(58000); pp->GetActor()->spr.pos.Z += pp->z_speed; @@ -3684,7 +3684,7 @@ int PlayerCanDive(DSWPlayer* pp) if (Prediction) return false; - const double velZ = clamp(20. * !!(pp->cmd.ucmd.actions & SB_CROUCH) - 20. * pp->cmd.ucmd.uvel, -20., 20.); + const double velZ = clamp(20. * !!(pp->cmd.ucmd.actions & SB_CROUCH) - 20. * pp->cmd.ucmd.vel.Z, -20., 20.); // Crawl - check for diving if (velZ > 0 || pp->jump_speed > 0) @@ -4363,7 +4363,7 @@ void DoPlayerDive(DSWPlayer* pp) } const auto kbdDir = !!(pp->cmd.ucmd.actions & SB_CROUCH) - !!(pp->cmd.ucmd.actions & SB_JUMP); - const double velZ = clamp(PLAYER_DIVE_INC * kbdDir - PLAYER_DIVE_INC * pp->cmd.ucmd.uvel, -PLAYER_DIVE_INC, PLAYER_DIVE_INC); + const double velZ = clamp(PLAYER_DIVE_INC * kbdDir - PLAYER_DIVE_INC * pp->cmd.ucmd.vel.Z, -PLAYER_DIVE_INC, PLAYER_DIVE_INC); pp->z_speed = clamp(pp->z_speed + velZ, -PLAYER_DIVE_MAX_SPEED, PLAYER_DIVE_MAX_SPEED) * FixedToFloat(58000); if (abs(pp->z_speed) < 1./16) @@ -4677,7 +4677,7 @@ void DoPlayerWade(DSWPlayer* pp) } // Crawl Commanded - if (((pp->cmd.ucmd.actions & SB_CROUCH) || pp->cmd.ucmd.uvel < 0) && pp->WadeDepth <= PLAYER_CRAWL_WADE_DEPTH) + if (((pp->cmd.ucmd.actions & SB_CROUCH) || pp->cmd.ucmd.vel.Z < 0) && pp->WadeDepth <= PLAYER_CRAWL_WADE_DEPTH) { DoPlayerBeginCrawl(pp); return; @@ -4957,7 +4957,7 @@ void DoPlayerBeginOperate(DSWPlayer* pp) switch (sop->track) { case SO_VEHICLE: - if (pp->cmd.ucmd.fvel || pp->cmd.ucmd.svel) + if (pp->cmd.ucmd.vel.X || pp->cmd.ucmd.vel.Y) PlaySOsound(pp->sop->mid_sector, SO_DRIVE_SOUND); else PlaySOsound(pp->sop->mid_sector, SO_IDLE_SOUND); @@ -5050,7 +5050,7 @@ void DoPlayerBeginRemoteOperate(DSWPlayer* pp, SECTOR_OBJECT* sop) switch (sop->track) { case SO_VEHICLE: - if (pp->cmd.ucmd.fvel || pp->cmd.ucmd.svel) + if (pp->cmd.ucmd.vel.X || pp->cmd.ucmd.vel.Y) PlaySOsound(pp->sop->mid_sector, SO_DRIVE_SOUND); else PlaySOsound(pp->sop->mid_sector, SO_IDLE_SOUND); @@ -6283,7 +6283,7 @@ void DoPlayerRun(DSWPlayer* pp) } // Crawl Commanded - if ((pp->cmd.ucmd.actions & SB_CROUCH) || pp->cmd.ucmd.uvel < 0) + if ((pp->cmd.ucmd.actions & SB_CROUCH) || pp->cmd.ucmd.vel.Z < 0) { DoPlayerBeginCrawl(pp); return; @@ -6551,7 +6551,7 @@ void ChopsCheck(DSWPlayer* pp) { if (!M_Active() && !(pp->Flags & PF_DEAD) && !pp->sop_riding && numplayers <= 1) { - if (pp->cmd.ucmd.actions & ~SB_RUN || pp->cmd.ucmd.fvel || pp->cmd.ucmd.svel || pp->cmd.ucmd.avel || pp->cmd.ucmd.horz || + if (pp->cmd.ucmd.actions & ~SB_RUN || pp->cmd.ucmd.vel.X || pp->cmd.ucmd.vel.Y || pp->cmd.ucmd.avel || pp->cmd.ucmd.horz || (pp->Flags & (PF_CLIMBING | PF_FALLING | PF_DIVING))) { // Hit a input key or other reason to stop chops @@ -6782,14 +6782,14 @@ void domovethings(void) ChopsCheck(pp); // Get strafe value before it's rotated by the angle. - pp->svel = pp->cmd.ucmd.svel; + pp->svel = pp->cmd.ucmd.vel.Y; // convert fvel/svel into a vector before performing actions. - const auto fvel = pp->cmd.ucmd.fvel + pp->cmd.ucmd.uvel * (pp->DoPlayerAction == DoPlayerClimb); - const auto svel = pp->cmd.ucmd.svel; + const auto fvel = pp->cmd.ucmd.vel.X + pp->cmd.ucmd.vel.Z * (pp->DoPlayerAction == DoPlayerClimb); + const auto svel = pp->cmd.ucmd.vel.Y; const auto velvect = DVector2(fvel, svel).Rotated(pp->GetActor()->spr.Angles.Yaw); - pp->cmd.ucmd.fvel = (float)velvect.X; - pp->cmd.ucmd.svel = (float)velvect.Y; + pp->cmd.ucmd.vel.X = (float)velvect.X; + pp->cmd.ucmd.vel.Y = (float)velvect.Y; if (pp->DoPlayerAction) pp->DoPlayerAction(pp);