- Reset the crouch toggle only when loading a new game, not every time we clear out the input.

* We need to preserve the crouch toggle when loading saves.
* Deliberately not resetting during level transitions as each level in an episode is interconnecting.
This commit is contained in:
Mitchell Richters 2023-09-24 17:50:06 +10:00
parent ae192df7b7
commit 8d8c30d10e
3 changed files with 10 additions and 4 deletions

View file

@ -82,13 +82,12 @@ bool scaletozero(DAngle& angle, const double scale, const double push)
//---------------------------------------------------------------------------
//
// Clears entire game input state.
// Clears crouch toggle state for new games.
//
//---------------------------------------------------------------------------
void GameInput::Clear()
void GameInput::resetCrouchToggle()
{
memset(this, 0, sizeof(*this));
crouch_toggle = false;
}

View file

@ -60,6 +60,12 @@ public:
ActionsToSend |= action;
}
// Clear all values within this object.
void Clear()
{
memset(this, 0, sizeof(*this));
}
// Receives mouse input from OS for processing.
void MouseAddToPos(float x, float y)
{
@ -71,7 +77,7 @@ public:
void processMovement(PlayerAngles* const plrAngles, const float scaleAdjust, const int drink_amt = 0, const bool allowstrafe = true, const float turnscale = 1.f);
void processVehicle(PlayerAngles* const plrAngles, 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);
void Clear();
void resetCrouchToggle();
};
struct PlayerAngles

View file

@ -156,6 +156,7 @@ void NewGame(MapRecord* map, int skill, bool ns = false)
gi->NewGame(map, skill, ns);
gameaction = ga_level;
ResetStatusBar();
gameInput.resetCrouchToggle();
});
}