From c1b1182f90c55695cba8ce8f7aeefbf887a737b9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 26 Aug 2020 16:54:54 +0200 Subject: [PATCH] - fix weapon selection in Exhumed. Like Blood it looks like the request isn't processed immediately so it needs to stick around. --- source/exhumed/src/exhumed.cpp | 5 +++-- source/exhumed/src/input.cpp | 13 +++++-------- source/exhumed/src/ps_input.h | 10 ++++------ 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/source/exhumed/src/exhumed.cpp b/source/exhumed/src/exhumed.cpp index a85fe2624..8436e3f26 100644 --- a/source/exhumed/src/exhumed.cpp +++ b/source/exhumed/src/exhumed.cpp @@ -138,7 +138,6 @@ short nEnergyTowers = 0; short nCfgNetPlayers = 0; FILE *vcrfp = NULL; -int lLocalButtons = 0; int lLocalCodes = 0; short bCoordinates = false; @@ -491,7 +490,7 @@ void GameTicker() if (!((int)ogameclock & 3) && moveframes < 4) moveframes++; - GetLocalInput(); + int lLocalButtons = GetLocalInput(); // shouldn't this be placed in localInput? PlayerInterruptKeys(); nPlayerDAng = fix16_sadd(nPlayerDAng, localInput.nAngle); @@ -504,6 +503,8 @@ void GameTicker() sPlayerInput[nLocalPlayer].xVel = lPlayerXVel; sPlayerInput[nLocalPlayer].yVel = lPlayerYVel; + // make weapon selection persist until it gets used up. + if ((lLocalButtons & kButtonWeaponBits) == 0) lLocalButtons |= sPlayerInput[nLocalPlayer].buttons & kButtonWeaponBits; sPlayerInput[nLocalPlayer].buttons = lLocalButtons | lLocalCodes; sPlayerInput[nLocalPlayer].nAngle = nPlayerDAng; sPlayerInput[nLocalPlayer].nTarget = besttarget; diff --git a/source/exhumed/src/input.cpp b/source/exhumed/src/input.cpp index a64b1912c..91afdc49a 100644 --- a/source/exhumed/src/input.cpp +++ b/source/exhumed/src/input.cpp @@ -77,17 +77,15 @@ void ClearSpaceBar(short nPlayer) buttonMap.ClearButton(gamefunc_Open); } -void GetLocalInput() +int GetLocalInput() { - int i = WeaponToSend; - if (WeaponToSend == PlayerList[nLocalPlayer].nCurrentWeapon) - WeaponToSend = 0; - + int lLocalButtons; if (PlayerList[nLocalPlayer].nHealth) { lLocalButtons = (buttonMap.ButtonDown(gamefunc_Crouch) << 4) | (buttonMap.ButtonDown(gamefunc_Fire) << 3) | (buttonMap.ButtonDown(gamefunc_Jump) << 0); - lLocalCodes |= (i << 13); + lLocalButtons |= (WeaponToSend << 13); + WeaponToSend = 0; } else { @@ -95,8 +93,7 @@ void GetLocalInput() } lLocalButtons |= buttonMap.ButtonDown(gamefunc_Open) << 2; - -// TODO ExecRecord(&sPlayerInput[nLocalPlayer], sizeof(PlayerInput)); + return lLocalButtons; } void BackupInput() diff --git a/source/exhumed/src/ps_input.h b/source/exhumed/src/ps_input.h index 2c5b1cd93..4240d5084 100644 --- a/source/exhumed/src/ps_input.h +++ b/source/exhumed/src/ps_input.h @@ -32,6 +32,9 @@ enum { kButtonCheatGodMode = 0x40, kButtonCheatKeys = 0x80, kButtonCheatItems = 0x100, + + kButtonWeaponShift = 13, + kButtonWeaponBits = 7 << kButtonWeaponShift, // upper 3 bits. }; // 32 bytes @@ -39,16 +42,11 @@ struct PlayerInput // TODO consider adjusting this for demo compatibility { int xVel; int yVel; - // short nAngle; fix16_t nAngle; uint16_t buttons; short nTarget; - // uint8_t horizon; fix16_t horizon; int8_t nItem; - int h; - char i; - char field_15[11]; }; void InitInput(); @@ -57,7 +55,7 @@ void UpdateInputs(); void ClearSpaceBar(short nPlayer); -void GetLocalInput(); +int GetLocalInput(); extern PlayerInput sPlayerInput[]; extern PlayerInput localInput;