mirror of
https://github.com/ZDoom/Raze.git
synced 2025-04-07 16:31:26 +00:00
- Make scaleAdjust
a float since it's what's needed anyway.
This commit is contained in:
parent
69c65dfe7e
commit
3ef431a428
7 changed files with 23 additions and 26 deletions
|
@ -1415,7 +1415,7 @@ void GameInterface::FreeLevelData()
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void GameInterface::doPlayerMovement(const double scaleAdjust)
|
||||
void GameInterface::doPlayerMovement(const float scaleAdjust)
|
||||
{
|
||||
gameInput.processMovement(scaleAdjust);
|
||||
}
|
||||
|
|
|
@ -106,42 +106,39 @@ void processCrouchToggle(bool& toggle, ESyncBits& actions, const bool crouchable
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void GameInput::processMovement(const double scaleAdjust, const int drink_amt, const bool allowstrafe, const double turnscale)
|
||||
void GameInput::processMovement(const float scaleAdjust, const int drink_amt, const bool allowstrafe, const double turnscale)
|
||||
{
|
||||
// open up input packet for this session.
|
||||
InputPacket thisInput{};
|
||||
|
||||
// set up variables.
|
||||
const int keymove = 1 << int(!!(inputBuffer.actions & SB_RUN));
|
||||
const float hidspeed = float(getTicrateScale(YAW_TURNSPEEDS[2]) * turnscale);
|
||||
const float scaleAdjustf = float(scaleAdjust);
|
||||
|
||||
// determine player input.
|
||||
const auto keymove = 1 << int(!!(inputBuffer.actions & SB_RUN));
|
||||
const auto hidspeed = float(getTicrateScale(YAW_TURNSPEEDS[2]) * turnscale);
|
||||
const auto turning = buttonMap.ButtonDown(gamefunc_Turn_Right) - buttonMap.ButtonDown(gamefunc_Turn_Left);
|
||||
const auto moving = buttonMap.ButtonDown(gamefunc_Move_Forward) - buttonMap.ButtonDown(gamefunc_Move_Backward) + joyAxes[JOYAXIS_Forward] * scaleAdjustf;
|
||||
const auto strafing = buttonMap.ButtonDown(gamefunc_Strafe_Right) - buttonMap.ButtonDown(gamefunc_Strafe_Left) - joyAxes[JOYAXIS_Side] * scaleAdjustf;
|
||||
const auto moving = buttonMap.ButtonDown(gamefunc_Move_Forward) - buttonMap.ButtonDown(gamefunc_Move_Backward) + joyAxes[JOYAXIS_Forward] * scaleAdjust;
|
||||
const auto strafing = buttonMap.ButtonDown(gamefunc_Strafe_Right) - buttonMap.ButtonDown(gamefunc_Strafe_Left) - joyAxes[JOYAXIS_Side] * scaleAdjust;
|
||||
|
||||
// process player angle input.
|
||||
if (!(buttonMap.ButtonDown(gamefunc_Strafe) && allowstrafe))
|
||||
{
|
||||
const float turndir = clamp(turning + strafing * !allowstrafe, -1.f, 1.f);
|
||||
const float turnspeed = float(getTicrateScale(YAW_TURNSPEEDS[keymove]) * turnscale * (isTurboTurnTime() ? 1. : YAW_PREAMBLESCALE));
|
||||
thisInput.avel += mouseInput.X * m_yaw - (joyAxes[JOYAXIS_Yaw] * hidspeed - turndir * turnspeed) * scaleAdjustf;
|
||||
thisInput.avel += mouseInput.X * m_yaw - (joyAxes[JOYAXIS_Yaw] * hidspeed - turndir * turnspeed) * scaleAdjust;
|
||||
if (turndir) updateTurnHeldAmt(scaleAdjust); else turnheldtime = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
thisInput.svel += mouseInput.X * m_side - (joyAxes[JOYAXIS_Yaw] - turning) * keymove * scaleAdjustf;
|
||||
thisInput.svel += mouseInput.X * m_side - (joyAxes[JOYAXIS_Yaw] - turning) * keymove * scaleAdjust;
|
||||
}
|
||||
|
||||
// process player pitch input.
|
||||
if (!(inputBuffer.actions & SB_AIMMODE))
|
||||
{
|
||||
thisInput.horz -= mouseInput.Y * m_pitch + joyAxes[JOYAXIS_Pitch] * hidspeed * scaleAdjustf;
|
||||
thisInput.horz -= mouseInput.Y * m_pitch + joyAxes[JOYAXIS_Pitch] * hidspeed * scaleAdjust;
|
||||
}
|
||||
else
|
||||
{
|
||||
thisInput.fvel += mouseInput.Y * m_forward + joyAxes[JOYAXIS_Pitch] * keymove * scaleAdjustf;
|
||||
thisInput.fvel += mouseInput.Y * m_forward + joyAxes[JOYAXIS_Pitch] * keymove * scaleAdjust;
|
||||
}
|
||||
|
||||
// process movement input.
|
||||
|
@ -174,7 +171,7 @@ void GameInput::processMovement(const double scaleAdjust, const int drink_amt, c
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void GameInput::processVehicle(const double scaleAdjust, const float baseVel, const float velScale, const bool canMove, const bool canTurn, const bool attenuate)
|
||||
void GameInput::processVehicle(const float scaleAdjust, const float baseVel, const float velScale, const bool canMove, const bool canTurn, const bool attenuate)
|
||||
{
|
||||
// open up input packet for this session.
|
||||
InputPacket thisInput{};
|
||||
|
@ -204,8 +201,8 @@ void GameInput::processVehicle(const double scaleAdjust, const float baseVel, co
|
|||
const auto turnVel = (!attenuate && (isTurboTurnTime() || hidLeft || hidRight)) ? (baseVel) : (baseVel * velScale);
|
||||
|
||||
thisInput.avel += turnVel * -joyAxes[JOYAXIS_Yaw] + turnVel * kbdDir;
|
||||
thisInput.avel += sqrtf(abs(turnVel * mouseInput.X * m_yaw / (float)scaleAdjust) * (7.f / 20.f)) * Sgn(turnVel) * Sgn(mouseInput.X);
|
||||
thisInput.avel *= (float)scaleAdjust;
|
||||
thisInput.avel += sqrtf(abs(turnVel * mouseInput.X * m_yaw / scaleAdjust) * (7.f / 20.f)) * Sgn(turnVel) * Sgn(mouseInput.X);
|
||||
thisInput.avel *= scaleAdjust;
|
||||
if (kbdDir) updateTurnHeldAmt(scaleAdjust); else turnheldtime = 0;
|
||||
}
|
||||
else
|
||||
|
@ -357,7 +354,7 @@ void GameInput::getInput(const double scaleAdjust, InputPacket* packet)
|
|||
|
||||
prepareHidInput();
|
||||
processInputBits();
|
||||
gi->doPlayerMovement(!SyncInput() ? scaleAdjust : 1.);
|
||||
gi->doPlayerMovement(!SyncInput() ? (float)scaleAdjust : 1.f);
|
||||
resetHidInput();
|
||||
|
||||
if (packet)
|
||||
|
|
|
@ -32,7 +32,7 @@ class GameInput
|
|||
ESyncBits ActionsToSend;
|
||||
|
||||
// Turn speed doubling after x amount of tics.
|
||||
void updateTurnHeldAmt(const double scaleAdjust)
|
||||
void updateTurnHeldAmt(const float scaleAdjust)
|
||||
{
|
||||
turnheldtime += getTicrateScale(BUILDTICRATE) * scaleAdjust;
|
||||
}
|
||||
|
@ -75,8 +75,8 @@ public:
|
|||
}
|
||||
|
||||
// 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 float baseVel, const float velScale, const bool canMove, const bool canTurn, const bool attenuate);
|
||||
void processMovement(const float scaleAdjust, const int drink_amt = 0, const bool allowstrafe = true, const double turnscale = 1.);
|
||||
void processVehicle(const float scaleAdjust, const float baseVel, const float velScale, const bool canMove, const bool canTurn, const bool attenuate);
|
||||
void getInput(const double scaleAdjust, InputPacket* packet = nullptr);
|
||||
};
|
||||
|
||||
|
@ -89,8 +89,8 @@ struct PlayerAngles
|
|||
DAngle YawSpin;
|
||||
|
||||
friend FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerAngles& w, PlayerAngles* def);
|
||||
friend void GameInput::processMovement(const double scaleAdjust, const int drink_amt, const bool allowstrafe, const double turnscale);
|
||||
friend void GameInput::processVehicle(const double scaleAdjust, const float baseVel, const float velScale, const bool canMove, const bool canTurn, const bool attenuate);
|
||||
friend void GameInput::processMovement(const float scaleAdjust, const int drink_amt, const bool allowstrafe, const double turnscale);
|
||||
friend void GameInput::processVehicle(const float scaleAdjust, const float baseVel, const float velScale, const bool canMove, const bool canTurn, const bool attenuate);
|
||||
|
||||
// Prototypes.
|
||||
void doPitchKeys(InputPacket* const input);
|
||||
|
|
|
@ -119,7 +119,7 @@ struct GameInterface
|
|||
virtual bool WantEscape() { return false; }
|
||||
virtual void StartSoundEngine() = 0;
|
||||
virtual void reapplyInputBits(InputPacket* const input) = 0;
|
||||
virtual void doPlayerMovement(const double scaleAdjust);
|
||||
virtual void doPlayerMovement(const float scaleAdjust);
|
||||
|
||||
virtual FString statFPS()
|
||||
{
|
||||
|
|
|
@ -40,7 +40,7 @@ struct GameInterface : public ::GameInterface
|
|||
void ExitFromMenu() override;
|
||||
void DrawPlayerSprite(const DVector2& origin, bool onteam) override;
|
||||
void reapplyInputBits(InputPacket* const input) override { input->actions |= ps[myconnectindex].sync.actions & SB_CENTERVIEW; }
|
||||
void doPlayerMovement(const double scaleAdjust) override;
|
||||
void doPlayerMovement(const float scaleAdjust) override;
|
||||
void UpdateSounds() override;
|
||||
void Startup() override;
|
||||
void DrawBackground() override;
|
||||
|
|
|
@ -501,7 +501,7 @@ void hud_input(int plnum)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void GameInterface::doPlayerMovement(const double scaleAdjust)
|
||||
void GameInterface::doPlayerMovement(const float scaleAdjust)
|
||||
{
|
||||
auto const p = &ps[myconnectindex];
|
||||
|
||||
|
|
|
@ -1889,7 +1889,7 @@ struct GameInterface : public ::GameInterface
|
|||
int GetCurrentSkill() override;
|
||||
void StartSoundEngine() override;
|
||||
void reapplyInputBits(InputPacket* const input) override { input->actions |= Player[myconnectindex].input.actions & SB_CENTERVIEW; }
|
||||
void doPlayerMovement(const double scaleAdjust) override
|
||||
void doPlayerMovement(const float scaleAdjust) override
|
||||
{
|
||||
gameInput.processMovement(scaleAdjust, 0, !Player[myconnectindex].sop, Player[myconnectindex].sop_control ? 3. / 1.40625 : 1.);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue