Skip to content

Commit

Permalink
- Exhumed: Remove ClearSpaceBar() and just directly clear the input…
Browse files Browse the repository at this point in the history
… bit.

* Also fix issue where `SB_OPEN` bit never seemed to be cleared properly.
* Also just directly test/use the player's input actions to minimise stack variables during this cleanup process.
  • Loading branch information
mjr4077au committed Mar 24, 2023
1 parent 7293a1f commit ed2c557
Showing 1 changed file with 11 additions and 25 deletions.
36 changes: 11 additions & 25 deletions source/games/exhumed/src/player.cpp
Expand Up @@ -819,18 +819,6 @@ bool CheckMovingBlocks(int nPlayer, Collision& nMove, DVector3& spr_pos, sectort
//
//---------------------------------------------------------------------------

static void ClearSpaceBar(int nPlayer)
{
PlayerList[nPlayer].input.actions &= SB_OPEN;
buttonMap.ClearButton(gamefunc_Open);
}

//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------

static void doPlayerCurrentItem(Player* const pPlayer)
{
UseItem(pPlayer->nPlayer, pPlayer->nCurrentItem);
Expand Down Expand Up @@ -1218,8 +1206,6 @@ void AIPlayer::Tick(RunListEvent* ev)

int var_5C = pViewSect->Flag & kSectUnderwater;

auto actions = pPlayer->input.actions;

// loc_1AEF5:
if (pPlayer->nHealth > 0)
{
Expand Down Expand Up @@ -1373,9 +1359,9 @@ void AIPlayer::Tick(RunListEvent* ev)

if (!pPlayer->bIsMummified)
{
if (actions & SB_OPEN)
if (pPlayer->input.actions & SB_OPEN)
{
ClearSpaceBar(nPlayer);
pPlayer->input.actions &= ~SB_OPEN;

int tag;
if (near.hitWall != nullptr && (tag = near.hitWall->lotag) > 0)
Expand All @@ -1390,7 +1376,7 @@ void AIPlayer::Tick(RunListEvent* ev)
}

// was int var_38 = buttons & 0x8
if (actions & SB_FIRE)
if (pPlayer->input.actions & SB_FIRE)
{
FireWeapon(nPlayer);
}
Expand All @@ -1407,7 +1393,7 @@ void AIPlayer::Tick(RunListEvent* ev)
}

// Jumping
if (actions & SB_JUMP)
if (pPlayer->input.actions & SB_JUMP)
{
if (bUnderwater)
{
Expand All @@ -1425,7 +1411,7 @@ void AIPlayer::Tick(RunListEvent* ev)

// goto loc_1BE70:
}
else if (actions & SB_CROUCH)
else if (pPlayer->input.actions & SB_CROUCH)
{
if (bUnderwater)
{
Expand Down Expand Up @@ -1485,7 +1471,7 @@ void AIPlayer::Tick(RunListEvent* ev)
}
}
// loc_1BE30
if (actions & SB_FIRE) // was var_38
if (pPlayer->input.actions & SB_FIRE) // was var_38
{
if (bUnderwater)
{
Expand Down Expand Up @@ -1517,7 +1503,7 @@ void AIPlayer::Tick(RunListEvent* ev)
}
else // player is mummified
{
if (actions & SB_FIRE)
if (pPlayer->input.actions & SB_FIRE)
{
FireWeapon(nPlayer);
}
Expand Down Expand Up @@ -1550,12 +1536,12 @@ void AIPlayer::Tick(RunListEvent* ev)

pPlayer->Angles.doPitchKeys(&pPlayer->input);

if (actions & (SB_AIM_UP | SB_AIM_DOWN) || pPlayer->input.horz)
if (pPlayer->input.actions & (SB_AIM_UP | SB_AIM_DOWN) || pPlayer->input.horz)
{
pPlayer->nDestVertPan = pPlayer->pActor->spr.Angles.Pitch;
pPlayer->bPlayerPan = pPlayer->bLockPan = true;
}
else if (actions & (SB_LOOK_UP | SB_LOOK_DOWN | SB_CENTERVIEW))
else if (pPlayer->input.actions & (SB_LOOK_UP | SB_LOOK_DOWN | SB_CENTERVIEW))
{
pPlayer->nDestVertPan = pPlayer->pActor->spr.Angles.Pitch;
pPlayer->bPlayerPan = pPlayer->bLockPan = false;
Expand All @@ -1579,9 +1565,9 @@ void AIPlayer::Tick(RunListEvent* ev)
setForcedSyncInput(nPlayer);

// loc_1C0E9
if (actions & SB_OPEN)
if (pPlayer->input.actions & SB_OPEN)
{
ClearSpaceBar(nPlayer);
pPlayer->input.actions &= ~SB_OPEN;

if (nAction >= 16)
{
Expand Down

0 comments on commit ed2c557

Please sign in to comment.