mirror of
https://github.com/ZDoom/Raze.git
synced 2025-01-19 07:01:09 +00:00
- Store scaleAdjust
directly inside the GameInput
object.
This commit is contained in:
parent
bdf566b348
commit
084be1a45c
7 changed files with 32 additions and 25 deletions
|
@ -105,9 +105,9 @@ void GameInput::resetCrouchToggle()
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void GameInterface::doPlayerMovement(const double scaleAdjust)
|
||||
void GameInterface::doPlayerMovement()
|
||||
{
|
||||
gameInput.processMovement(scaleAdjust);
|
||||
gameInput.processMovement();
|
||||
}
|
||||
|
||||
|
||||
|
@ -117,7 +117,7 @@ void GameInterface::doPlayerMovement(const double scaleAdjust)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void GameInput::processMovement(const double scaleAdjust, const int drink_amt, const bool allowstrafe, const double turnscale)
|
||||
void GameInput::processMovement(const double turnscale, const bool allowstrafe, const int drink_amt)
|
||||
{
|
||||
// set up variables.
|
||||
InputPacket thisInput{};
|
||||
|
@ -150,7 +150,7 @@ void GameInput::processMovement(const double scaleAdjust, const int drink_amt, c
|
|||
thisInput.ang.Yaw -= hidspeed * joyAxes[JOYAXIS_Yaw] * scaleAdjust;
|
||||
thisInput.ang.Yaw += turnspeed * turndir * scaleAdjust;
|
||||
thisInput.ang.Yaw *= turnscale;
|
||||
if (turndir) updateTurnHeldAmt(scaleAdjust); else turnheldtime = 0;
|
||||
if (turndir) updateTurnHeldAmt(); else turnheldtime = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -201,7 +201,7 @@ void GameInput::processMovement(const double scaleAdjust, const int drink_amt, c
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void GameInput::processVehicle(const double scaleAdjust, const double baseVel, const double velScale, const unsigned flags)
|
||||
void GameInput::processVehicle(const double baseVel, const double velScale, const unsigned flags)
|
||||
{
|
||||
// open up input packet for this session.
|
||||
InputPacket thisInput{};
|
||||
|
@ -244,7 +244,7 @@ void GameInput::processVehicle(const double scaleAdjust, const double baseVel, c
|
|||
thisInput.ang.Yaw += DAngle::fromDeg(turnVel * kbdDir);
|
||||
thisInput.ang.Yaw *= scaleAdjust;
|
||||
inputBuffer.ang.Yaw += thisInput.ang.Yaw;
|
||||
if (kbdDir) updateTurnHeldAmt(scaleAdjust); else turnheldtime = 0;
|
||||
if (kbdDir) updateTurnHeldAmt(); else turnheldtime = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -364,7 +364,7 @@ void GameInput::processInputBits()
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void GameInput::getInput(const double scaleAdjust, InputPacket* packet)
|
||||
void GameInput::getInput(InputPacket* packet)
|
||||
{
|
||||
I_GetEvent();
|
||||
|
||||
|
@ -376,7 +376,7 @@ void GameInput::getInput(const double scaleAdjust, InputPacket* packet)
|
|||
|
||||
I_GetAxes(joyAxes);
|
||||
processInputBits();
|
||||
gi->doPlayerMovement(!SyncInput() ? scaleAdjust : 1.);
|
||||
gi->doPlayerMovement();
|
||||
mouseInput.Zero();
|
||||
|
||||
if (packet)
|
||||
|
|
|
@ -39,15 +39,16 @@ class GameInput
|
|||
FVector2 mouseInput;
|
||||
|
||||
// Internal variables when generating a packet.
|
||||
int keymove;
|
||||
InputPacket inputBuffer;
|
||||
ESyncBits ActionsToSend;
|
||||
double turnheldtime;
|
||||
double scaleAdjust;
|
||||
int WeaponToSend;
|
||||
int dpad_lock;
|
||||
ESyncBits ActionsToSend;
|
||||
int keymove;
|
||||
|
||||
// Turn speed doubling after x amount of tics.
|
||||
void updateTurnHeldAmt(const double scaleAdjust)
|
||||
void updateTurnHeldAmt()
|
||||
{
|
||||
turnheldtime += getTicrateScale(BUILDTICRATE) * scaleAdjust;
|
||||
}
|
||||
|
@ -83,10 +84,17 @@ public:
|
|||
mouseInput.Y += y;
|
||||
}
|
||||
|
||||
// Receives the current input scale from the engine's main loop.
|
||||
void UpdateInputScale()
|
||||
{
|
||||
const double frac = I_GetInputFrac();
|
||||
scaleAdjust = !SyncInput() ? frac : 1;
|
||||
}
|
||||
|
||||
// Prototypes for large member functions.
|
||||
void processMovement(const double scaleAdjust, const int drink_amt = 0, const bool allowstrafe = true, const double turnscale = 1.);
|
||||
void processVehicle(const double scaleAdjust, const double baseVel, const double velScale, const unsigned flags);
|
||||
void getInput(const double scaleAdjust, InputPacket* packet = nullptr);
|
||||
void processMovement(const double turnscale = 1, const bool allowstrafe = true, const int drink_amt = 0);
|
||||
void processVehicle(const double baseVel, const double velScale, const unsigned flags);
|
||||
void getInput(InputPacket* packet = nullptr);
|
||||
void resetCrouchToggle();
|
||||
};
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ struct GameInterface
|
|||
virtual void RemoveQAVInterpProps(const int res_id) { }
|
||||
virtual bool WantEscape() { return false; }
|
||||
virtual void StartSoundEngine() = 0;
|
||||
virtual void doPlayerMovement(const double scaleAdjust);
|
||||
virtual void doPlayerMovement();
|
||||
virtual unsigned getCrouchState() = 0;
|
||||
|
||||
virtual FString statFPS()
|
||||
|
|
|
@ -99,7 +99,6 @@ CVAR(Bool, cl_resumesavegame, true, CVAR_ARCHIVE)
|
|||
|
||||
static uint64_t stabilityticduration = 0;
|
||||
static uint64_t stabilitystarttime = 0;
|
||||
static double inputScale;
|
||||
|
||||
DCorePlayer* PlayerArray[MAXPLAYERS];
|
||||
|
||||
|
@ -145,7 +144,7 @@ void G_BuildTiccmd(ticcmd_t* cmd)
|
|||
savegamefile = "";
|
||||
}
|
||||
cmd->ucmd = {};
|
||||
gameInput.getInput(inputScale, &cmd->ucmd);
|
||||
gameInput.getInput(&cmd->ucmd);
|
||||
cmd->consistency = consistency[myconnectindex][(maketic / ticdup) % BACKUPTICS];
|
||||
}
|
||||
|
||||
|
@ -620,7 +619,7 @@ void TryRunTics (void)
|
|||
}
|
||||
if (!SyncInput())
|
||||
{
|
||||
gameInput.getInput(inputScale);
|
||||
gameInput.getInput();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -752,7 +751,7 @@ void MainLoop ()
|
|||
I_SetFrameTime();
|
||||
|
||||
// update the scale factor for unsynchronised input here.
|
||||
inputScale = I_GetInputFrac();
|
||||
gameInput.UpdateInputScale();
|
||||
|
||||
TryRunTics (); // will run at least one tic
|
||||
// Update display, next frame, with current state.
|
||||
|
|
|
@ -37,7 +37,7 @@ struct GameInterface : public ::GameInterface
|
|||
void SerializeGameState(FSerializer& arc) override;
|
||||
void ExitFromMenu() override;
|
||||
void DrawPlayerSprite(const DVector2& origin, bool onteam) override;
|
||||
void doPlayerMovement(const double scaleAdjust) override;
|
||||
void doPlayerMovement() override;
|
||||
unsigned getCrouchState() override;
|
||||
void UpdateSounds() override;
|
||||
void Startup() override;
|
||||
|
|
|
@ -507,7 +507,7 @@ unsigned GameInterface::getCrouchState()
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void GameInterface::doPlayerMovement(const double scaleAdjust)
|
||||
void GameInterface::doPlayerMovement()
|
||||
{
|
||||
const auto p = getPlayer(myconnectindex);
|
||||
|
||||
|
@ -529,11 +529,11 @@ void GameInterface::doPlayerMovement(const double scaleAdjust)
|
|||
baseVel = VEHICLETURN * velScale;
|
||||
}
|
||||
|
||||
gameInput.processVehicle(scaleAdjust, baseVel, velScale, vehFlags);
|
||||
gameInput.processVehicle(baseVel, velScale, vehFlags);
|
||||
}
|
||||
else
|
||||
{
|
||||
gameInput.processMovement(scaleAdjust, p->drink_amt, true, (p->psectlotag != ST_2_UNDERWATER) ? 1. : 0.875);
|
||||
gameInput.processMovement((p->psectlotag != ST_2_UNDERWATER) ? 1 : 0.875, true, p->drink_amt);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1901,10 +1901,10 @@ struct GameInterface : public ::GameInterface
|
|||
int GetCurrentSkill() override;
|
||||
void StartSoundEngine() override;
|
||||
unsigned getCrouchState() override;
|
||||
void doPlayerMovement(const double scaleAdjust) override
|
||||
void doPlayerMovement() override
|
||||
{
|
||||
const auto pp = getPlayer(myconnectindex);
|
||||
gameInput.processMovement(scaleAdjust, 0, !pp->sop, pp->sop_control ? (3. / 1.40625) : 1.);
|
||||
gameInput.processMovement(!pp->sop_control ? 1 : (3. / 1.40625), !pp->sop);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue