- Remove concept of InputOptions, its messy and unnecessary.

This commit is contained in:
Mitchell Richters 2023-03-18 21:16:50 +11:00
parent 366423a09b
commit 1147030bca
5 changed files with 10 additions and 16 deletions

View file

@ -113,11 +113,9 @@ void resetTurnHeldAmt()
//
//---------------------------------------------------------------------------
void processMovement(HIDInput* const hidInput, InputPacket* const inputBuffer, InputPacket* const currInput, const double scaleAdjust, const InputOptions& inputOpts)
void processMovement(HIDInput* const hidInput, InputPacket* const inputBuffer, InputPacket* const currInput, const double scaleAdjust, const int drink_amt, const bool allowstrafe, const double turnscale)
{
// set up variables.
const bool allowstrafe = isDukeEngine() ? true : inputOpts.first;
const double turnscale = inputOpts.second;
const int keymove = 1 << int(!!(inputBuffer->actions & SB_RUN));
const float hidspeed = float(getTicrateScale(YAW_TURNSPEEDS[2]) * turnscale);
const float scaleAdjustf = float(scaleAdjust);
@ -151,8 +149,8 @@ void processMovement(HIDInput* const hidInput, InputPacket* const inputBuffer, I
currInput->svel += strafing * keymove * allowstrafe;
// process RR's drunk state.
if (isRR() && inputOpts.first)
currInput->svel += inputOpts.first & 1 ? -currInput->fvel : currInput->fvel;
if (isRR() && drink_amt >= 66 && drink_amt <= 87)
currInput->svel += drink_amt & 1 ? -currInput->fvel : currInput->fvel;
// add collected input to game's local input accumulation packet.
inputBuffer->fvel = clamp(inputBuffer->fvel + currInput->fvel, -(float)keymove, (float)keymove);
@ -181,12 +179,11 @@ void getInput(const double scaleAdjust, PlayerAngles* const plrAngles, InputPack
return;
}
const auto inputOpts = gi->GetInputOptions();
InputPacket input{};
HIDInput hidInput{};
getHidInput(&hidInput);
ApplyGlobalInput(&hidInput, &inputBuffer);
gi->GetInput(&hidInput, &inputBuffer, &input, !SyncInput() ? scaleAdjust : 1., inputOpts);
gi->GetInput(&hidInput, &inputBuffer, &input, !SyncInput() ? scaleAdjust : 1.);
// Directly update the camera angles if we're unsynchronised.
if (!SyncInput())

View file

@ -19,8 +19,7 @@ class DCoreActor;
struct MapRecord;
struct PlayerAngles;
using InputOptions = std::pair<int, double>;
void processMovement(HIDInput* const hidInput, InputPacket* const inputBuffer, InputPacket* const currInput, const double scaleAdjust, const InputOptions& inputOpts);
void processMovement(HIDInput* const hidInput, InputPacket* const inputBuffer, InputPacket* const currInput, const double scaleAdjust, const int drink_amt = 0, const bool allowstrafe = true, const double turnscale = 1.);
struct GameStats
{
@ -91,8 +90,7 @@ struct GameInterface
virtual void DrawPlayerSprite(const DVector2& origin, bool onteam) {}
virtual void SetAmbience(bool on) {}
virtual void ExitFromMenu() { throw CExitEvent(0); }
virtual void GetInput(HIDInput* const hidInput, InputPacket* const inputBuffer, InputPacket* const currInput, const double scaleAdjust, const InputOptions& inputOpts) { processMovement(hidInput, inputBuffer, currInput, scaleAdjust, inputOpts); }
virtual InputOptions GetInputOptions() { return std::make_pair(true, 1.); }
virtual void GetInput(HIDInput* const hidInput, InputPacket* const inputBuffer, InputPacket* const currInput, const double scaleAdjust) { processMovement(hidInput, inputBuffer, currInput, scaleAdjust); }
virtual void UpdateSounds() {}
virtual void ErrorCleanup() {}
virtual void Startup() {}

View file

@ -39,8 +39,7 @@ struct GameInterface : public ::GameInterface
void SerializeGameState(FSerializer& arc) override;
void ExitFromMenu() override;
void DrawPlayerSprite(const DVector2& origin, bool onteam) override;
void GetInput(HIDInput* const hidInput, InputPacket* const inputBuffer, InputPacket* const currInput, const double scaleAdjust, const InputOptions& inputOpts) override;
InputOptions GetInputOptions() override { return std::make_pair(ps[myconnectindex].drink_amt >= 66 && ps[myconnectindex].drink_amt <= 87, 1.); }
void GetInput(HIDInput* const hidInput, InputPacket* const inputBuffer, InputPacket* const currInput, const double scaleAdjust) override;
void UpdateSounds() override;
void Startup() override;
void DrawBackground() override;

View file

@ -745,7 +745,7 @@ static void processVehicleInput(player_struct *p, HIDInput* const hidInput, Inpu
//
//---------------------------------------------------------------------------
void GameInterface::GetInput(HIDInput* const hidInput, InputPacket* const inputBuffer, InputPacket* const currInput, const double scaleAdjust, const InputOptions& inputOpts)
void GameInterface::GetInput(HIDInput* const hidInput, InputPacket* const inputBuffer, InputPacket* const currInput, const double scaleAdjust)
{
auto const p = &ps[myconnectindex];
@ -755,7 +755,7 @@ void GameInterface::GetInput(HIDInput* const hidInput, InputPacket* const inputB
}
else
{
processMovement(hidInput, inputBuffer, currInput, scaleAdjust, inputOpts);
processMovement(hidInput, inputBuffer, currInput, scaleAdjust, p->drink_amt);
}
}

View file

@ -1866,7 +1866,7 @@ struct GameInterface : public ::GameInterface
void SetAmbience(bool on) override { if (on) StartAmbientSound(); else StopAmbientSound(); }
void UpdateSounds() override;
void ErrorCleanup() override;
InputOptions GetInputOptions() override { return std::make_pair(!Player[myconnectindex].sop, Player[myconnectindex].sop_control ? 3. / 1.40625 : 1.); }
void GetInput(HIDInput* const hidInput, InputPacket* const inputBuffer, InputPacket* const currInput, const double scaleAdjust) override { processMovement(hidInput, inputBuffer, currInput, scaleAdjust, 0, Player[myconnectindex].sop, Player[myconnectindex].sop_control ? 3. / 1.40625 : 1.); }
void DrawBackground(void) override;
void Ticker(void) override;
void Render() override;