- fix weapon selection in Exhumed.

Like Blood it looks like the request isn't processed immediately so it needs to stick around.
This commit is contained in:
Christoph Oelckers 2020-08-26 16:54:54 +02:00
parent d0655a1068
commit c1b1182f90
3 changed files with 12 additions and 16 deletions

View file

@ -138,7 +138,6 @@ short nEnergyTowers = 0;
short nCfgNetPlayers = 0; short nCfgNetPlayers = 0;
FILE *vcrfp = NULL; FILE *vcrfp = NULL;
int lLocalButtons = 0;
int lLocalCodes = 0; int lLocalCodes = 0;
short bCoordinates = false; short bCoordinates = false;
@ -491,7 +490,7 @@ void GameTicker()
if (!((int)ogameclock & 3) && moveframes < 4) if (!((int)ogameclock & 3) && moveframes < 4)
moveframes++; moveframes++;
GetLocalInput(); int lLocalButtons = GetLocalInput(); // shouldn't this be placed in localInput?
PlayerInterruptKeys(); PlayerInterruptKeys();
nPlayerDAng = fix16_sadd(nPlayerDAng, localInput.nAngle); nPlayerDAng = fix16_sadd(nPlayerDAng, localInput.nAngle);
@ -504,6 +503,8 @@ void GameTicker()
sPlayerInput[nLocalPlayer].xVel = lPlayerXVel; sPlayerInput[nLocalPlayer].xVel = lPlayerXVel;
sPlayerInput[nLocalPlayer].yVel = lPlayerYVel; 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].buttons = lLocalButtons | lLocalCodes;
sPlayerInput[nLocalPlayer].nAngle = nPlayerDAng; sPlayerInput[nLocalPlayer].nAngle = nPlayerDAng;
sPlayerInput[nLocalPlayer].nTarget = besttarget; sPlayerInput[nLocalPlayer].nTarget = besttarget;

View file

@ -77,17 +77,15 @@ void ClearSpaceBar(short nPlayer)
buttonMap.ClearButton(gamefunc_Open); buttonMap.ClearButton(gamefunc_Open);
} }
void GetLocalInput() int GetLocalInput()
{ {
int i = WeaponToSend; int lLocalButtons;
if (WeaponToSend == PlayerList[nLocalPlayer].nCurrentWeapon)
WeaponToSend = 0;
if (PlayerList[nLocalPlayer].nHealth) if (PlayerList[nLocalPlayer].nHealth)
{ {
lLocalButtons = (buttonMap.ButtonDown(gamefunc_Crouch) << 4) | (buttonMap.ButtonDown(gamefunc_Fire) << 3) lLocalButtons = (buttonMap.ButtonDown(gamefunc_Crouch) << 4) | (buttonMap.ButtonDown(gamefunc_Fire) << 3)
| (buttonMap.ButtonDown(gamefunc_Jump) << 0); | (buttonMap.ButtonDown(gamefunc_Jump) << 0);
lLocalCodes |= (i << 13); lLocalButtons |= (WeaponToSend << 13);
WeaponToSend = 0;
} }
else else
{ {
@ -95,8 +93,7 @@ void GetLocalInput()
} }
lLocalButtons |= buttonMap.ButtonDown(gamefunc_Open) << 2; lLocalButtons |= buttonMap.ButtonDown(gamefunc_Open) << 2;
return lLocalButtons;
// TODO ExecRecord(&sPlayerInput[nLocalPlayer], sizeof(PlayerInput));
} }
void BackupInput() void BackupInput()

View file

@ -32,6 +32,9 @@ enum {
kButtonCheatGodMode = 0x40, kButtonCheatGodMode = 0x40,
kButtonCheatKeys = 0x80, kButtonCheatKeys = 0x80,
kButtonCheatItems = 0x100, kButtonCheatItems = 0x100,
kButtonWeaponShift = 13,
kButtonWeaponBits = 7 << kButtonWeaponShift, // upper 3 bits.
}; };
// 32 bytes // 32 bytes
@ -39,16 +42,11 @@ struct PlayerInput // TODO consider adjusting this for demo compatibility
{ {
int xVel; int xVel;
int yVel; int yVel;
// short nAngle;
fix16_t nAngle; fix16_t nAngle;
uint16_t buttons; uint16_t buttons;
short nTarget; short nTarget;
// uint8_t horizon;
fix16_t horizon; fix16_t horizon;
int8_t nItem; int8_t nItem;
int h;
char i;
char field_15[11];
}; };
void InitInput(); void InitInput();
@ -57,7 +55,7 @@ void UpdateInputs();
void ClearSpaceBar(short nPlayer); void ClearSpaceBar(short nPlayer);
void GetLocalInput(); int GetLocalInput();
extern PlayerInput sPlayerInput[]; extern PlayerInput sPlayerInput[];
extern PlayerInput localInput; extern PlayerInput localInput;