Skip to content

Commit

Permalink
- Reset the crouch toggle only when loading a new game, not every tim…
Browse files Browse the repository at this point in the history
…e 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.
  • Loading branch information
mjr4077au committed Sep 24, 2023
1 parent ae192df commit 8d8c30d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 2 additions & 3 deletions source/core/gameinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
8 changes: 7 additions & 1 deletion source/core/gameinput.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ class GameInput
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)
{
Expand All @@ -71,7 +77,7 @@ class GameInput
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
Expand Down
1 change: 1 addition & 0 deletions source/core/mainloop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ void NewGame(MapRecord* map, int skill, bool ns = false)
gi->NewGame(map, skill, ns);
gameaction = ga_level;
ResetStatusBar();
gameInput.resetCrouchToggle();
});
}

Expand Down

0 comments on commit 8d8c30d

Please sign in to comment.