mirror of
https://github.com/ZDoom/Raze.git
synced 2025-05-31 01:11:15 +00:00
- Take better advantage of InputPacket::vel
's FVector3
status.
* Change it to a DVector3 as that's what the game is expecting. Too many narrowings against DAngle objects needed. * Utilise object methods where possible. * Do all math against the object where possible, not its members.
This commit is contained in:
parent
828e46a8da
commit
f88d435335
9 changed files with 42 additions and 59 deletions
|
@ -1032,9 +1032,7 @@ void NetUpdate (void)
|
|||
int mod = maketic - ticdup;
|
||||
int modp, tic;
|
||||
|
||||
float svel = 0;
|
||||
float fvel = 0;
|
||||
float uvel = 0;
|
||||
DVector3 vel{};
|
||||
float avel = 0;
|
||||
float horz = 0;
|
||||
float roll = 0;
|
||||
|
@ -1042,17 +1040,13 @@ void NetUpdate (void)
|
|||
for (tic = 0; tic < ticdup; ++tic)
|
||||
{
|
||||
modp = (mod + tic) % LOCALCMDTICS;
|
||||
fvel += localcmds[modp].ucmd.vel.X;
|
||||
svel += localcmds[modp].ucmd.vel.Y;
|
||||
uvel += localcmds[modp].ucmd.vel.Z;
|
||||
vel += localcmds[modp].ucmd.vel;
|
||||
avel += localcmds[modp].ucmd.avel;
|
||||
horz += localcmds[modp].ucmd.horz;
|
||||
roll += localcmds[modp].ucmd.roll;
|
||||
}
|
||||
|
||||
svel /= ticdup;
|
||||
fvel /= ticdup;
|
||||
uvel /= ticdup;
|
||||
vel /= ticdup;
|
||||
avel /= ticdup;
|
||||
horz /= ticdup;
|
||||
roll /= ticdup;
|
||||
|
@ -1060,9 +1054,7 @@ void NetUpdate (void)
|
|||
for (tic = 0; tic < ticdup; ++tic)
|
||||
{
|
||||
modp = (mod + tic) % LOCALCMDTICS;
|
||||
localcmds[modp].ucmd.vel.X = fvel;
|
||||
localcmds[modp].ucmd.vel.Y = svel;
|
||||
localcmds[modp].ucmd.vel.Z = uvel;
|
||||
localcmds[modp].ucmd.vel = vel;
|
||||
localcmds[modp].ucmd.avel = avel;
|
||||
localcmds[modp].ucmd.horz = horz;
|
||||
localcmds[modp].ucmd.roll = roll;
|
||||
|
|
|
@ -210,17 +210,17 @@ int PackUserCmd (const InputPacket *ucmd, const InputPacket *basis, uint8_t **st
|
|||
if (ucmd->vel.X != basis->vel.X)
|
||||
{
|
||||
flags |= UCMDF_FORWARDMOVE;
|
||||
WriteFloat (ucmd->vel.X, stream);
|
||||
WriteFloat ((float)ucmd->vel.X, stream);
|
||||
}
|
||||
if (ucmd->vel.Y != basis->vel.Y)
|
||||
{
|
||||
flags |= UCMDF_SIDEMOVE;
|
||||
WriteFloat (ucmd->vel.Y, stream);
|
||||
WriteFloat ((float)ucmd->vel.Y, stream);
|
||||
}
|
||||
if (ucmd->vel.Z != basis->vel.Z)
|
||||
{
|
||||
flags |= UCMDF_UPMOVE;
|
||||
WriteFloat (ucmd->vel.Z, stream);
|
||||
WriteFloat ((float)ucmd->vel.Z, stream);
|
||||
}
|
||||
if (ucmd->roll != basis->roll)
|
||||
{
|
||||
|
@ -252,9 +252,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, InputPacket &cmd, Inpu
|
|||
arc("actions", cmd.actions)
|
||||
("horz", cmd.horz)
|
||||
("avel", cmd.avel)
|
||||
("fvel", cmd.vel.X)
|
||||
("svel", cmd.vel.Y)
|
||||
("uvel", cmd.vel.Z)
|
||||
("vel", cmd.vel)
|
||||
("roll", cmd.roll)
|
||||
.EndObject();
|
||||
}
|
||||
|
@ -268,9 +266,7 @@ int WriteUserCmdMessage (InputPacket *ucmd, const InputPacket *basis, uint8_t **
|
|||
if (ucmd->actions != 0 ||
|
||||
ucmd->horz != 0 ||
|
||||
ucmd->avel != 0 ||
|
||||
ucmd->vel.X != 0 ||
|
||||
ucmd->vel.Y != 0 ||
|
||||
ucmd->vel.Z != 0 ||
|
||||
!ucmd->vel.isZero() ||
|
||||
ucmd->roll != 0)
|
||||
{
|
||||
WriteByte (DEM_USERCMD, stream);
|
||||
|
@ -281,9 +277,7 @@ int WriteUserCmdMessage (InputPacket *ucmd, const InputPacket *basis, uint8_t **
|
|||
if (ucmd->actions != basis->actions ||
|
||||
ucmd->horz != basis->horz ||
|
||||
ucmd->avel != basis->avel ||
|
||||
ucmd->vel.X != basis->vel.X ||
|
||||
ucmd->vel.Y != basis->vel.Y ||
|
||||
ucmd->vel.Z != basis->vel.Z ||
|
||||
ucmd->vel != basis->vel ||
|
||||
ucmd->roll != basis->roll)
|
||||
{
|
||||
WriteByte (DEM_USERCMD, stream);
|
||||
|
|
|
@ -167,9 +167,8 @@ void GameInput::processMovement(PlayerAngles* const plrAngles, const float scale
|
|||
}
|
||||
|
||||
// add collected input to game's local input accumulation packet.
|
||||
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);
|
||||
const DVector3 maxVel{ (double)keymove, (double)keymove, 1. };
|
||||
inputBuffer.vel = clamp(inputBuffer.vel + thisInput.vel, -maxVel, maxVel);
|
||||
inputBuffer.avel = clamp(inputBuffer.avel + thisInput.avel, -179.f, 179.f);
|
||||
inputBuffer.horz = clamp(inputBuffer.horz + thisInput.horz, -179.f, 179.f);
|
||||
|
||||
|
@ -203,7 +202,7 @@ 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.vel.X = kbdForwards - kbdBackward + joyAxes[JOYAXIS_Forward];
|
||||
inputBuffer.vel.X = clamp(inputBuffer.vel.X + thisInput.vel.X, -1.f, 1.f);
|
||||
inputBuffer.vel.X = clamp(inputBuffer.vel.X + thisInput.vel.X, -1., 1.);
|
||||
|
||||
// This sync bit is the brake key.
|
||||
if (buttonMap.ButtonDown(gamefunc_Run)) inputBuffer.actions |= SB_CROUCH;
|
||||
|
|
|
@ -70,7 +70,7 @@ enum
|
|||
|
||||
struct InputPacket
|
||||
{
|
||||
FVector3 vel;
|
||||
DVector3 vel;
|
||||
float avel;
|
||||
float horz;
|
||||
float roll;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue