From b9e0f493b2ae0e88d72436dc771d7dc1b9289413 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 28 Aug 2020 22:51:05 +0200 Subject: [PATCH] - transitioned the 5 primary action keys: Open, Jump, Crouch and Fire/AltFire. --- source/blood/src/actor.cpp | 2 +- source/blood/src/blood.cpp | 10 ++- source/blood/src/controls.cpp | 18 ---- source/blood/src/nnexts.cpp | 12 +-- source/blood/src/player.cpp | 45 +++++----- source/blood/src/weapon.cpp | 28 +++--- source/core/inputstate.cpp | 33 +++---- source/core/packet.h | 38 ++++---- source/exhumed/src/exhumed.cpp | 43 +-------- source/exhumed/src/input.cpp | 19 +--- source/exhumed/src/player.cpp | 15 ++-- source/games/duke/src/actors.cpp | 2 +- source/games/duke/src/actors_d.cpp | 10 +-- source/games/duke/src/actors_r.cpp | 6 +- source/games/duke/src/gameexec.cpp | 4 +- source/games/duke/src/gameloop.cpp | 2 +- source/games/duke/src/input.cpp | 23 ++--- source/games/duke/src/player_d.cpp | 80 ++++++++--------- source/games/duke/src/player_r.cpp | 102 +++++++++++----------- source/games/duke/src/player_w.cpp | 12 +-- source/games/duke/src/sectors_d.cpp | 6 +- source/games/duke/src/sectors_r.cpp | 6 +- source/sw/src/input.cpp | 11 +-- source/sw/src/panel.cpp | 131 +++++++++++++--------------- source/sw/src/player.cpp | 104 +++++++++++----------- source/sw/src/predict.cpp | 6 +- source/sw/src/sector.cpp | 20 ++--- 27 files changed, 352 insertions(+), 436 deletions(-) diff --git a/source/blood/src/actor.cpp b/source/blood/src/actor.cpp index f71f763ae..2fefb8676 100644 --- a/source/blood/src/actor.cpp +++ b/source/blood/src/actor.cpp @@ -4749,7 +4749,7 @@ void MoveDude(spritetype *pSprite) if (pPlayer) { pPlayer->posture = 0; pPlayer->bubbleTime = 0; - if (!pPlayer->cantJump && pPlayer->input.syncFlags.jump) { + if (!pPlayer->cantJump && (pPlayer->input.actions & SB_JUMP)) { zvel[nSprite] = -0x6aaaa; pPlayer->cantJump = 1; } diff --git a/source/blood/src/blood.cpp b/source/blood/src/blood.cpp index aec358c6b..e637998c0 100644 --- a/source/blood/src/blood.cpp +++ b/source/blood/src/blood.cpp @@ -73,6 +73,7 @@ char gUserMapFilename[BMAX_PATH]; short BloodVersion = 0x115; +bool gameRestart; int gNetPlayers; int gQuitRequest; @@ -529,7 +530,7 @@ void ProcessFrame(void) auto oldflags = inp.syncFlags.value; inp = gFifoInput[gNetFifoTail & 255][i]; - inp.actions |= oldactions & SB_INTERFACE_MASK; // should be everything non-button and non-weapon + inp.actions |= oldactions & ~(SB_BUTTON_MASK|SB_RUN|SB_WEAPONMASK_BITS); // should be everything non-button and non-weapon inp.syncFlags.value |= oldflags & ~flag_buttonmask; int newweap = inp.getNewWeapon(); @@ -562,6 +563,13 @@ void ProcessFrame(void) } } #endif + // This is single player only. + if (gameRestart) + { + gameRestart = false; + levelRestart(); + return; + } viewClearInterpolations(); { if (paused || gEndGameMgr.at0 || (gGameOptions.nGameType == 0 && M_Active())) diff --git a/source/blood/src/controls.cpp b/source/blood/src/controls.cpp index 253fa90cc..3eeddedbf 100644 --- a/source/blood/src/controls.cpp +++ b/source/blood/src/controls.cpp @@ -169,24 +169,6 @@ void ctrlGetInput(void) cl_showweapon = (cl_showweapon + 1) & 3; } - if (buttonMap.ButtonDown(gamefunc_Jump)) - gInput.syncFlags.jump = 1; - - if (buttonMap.ButtonDown(gamefunc_Crouch)) - gInput.syncFlags.crouch = 1; - - if (buttonMap.ButtonDown(gamefunc_Fire)) - gInput.syncFlags.shoot = 1; - - if (buttonMap.ButtonDown(gamefunc_Alt_Fire)) - gInput.syncFlags.shoot2 = 1; - - if (buttonMap.ButtonDown(gamefunc_Open)) - { - buttonMap.ClearButton(gamefunc_Open); - gInput.syncFlags.action = 1; - } - gInput.syncFlags.lookUp |= buttonMap.ButtonDown(gamefunc_Look_Up); gInput.syncFlags.lookDown |= buttonMap.ButtonDown(gamefunc_Look_Down); diff --git a/source/blood/src/nnexts.cpp b/source/blood/src/nnexts.cpp index fe4ad0265..5993f5af7 100644 --- a/source/blood/src/nnexts.cpp +++ b/source/blood/src/nnexts.cpp @@ -1990,7 +1990,7 @@ void usePropertiesChanger(XSPRITE* pXSource, short objType, int objIndex) { xsprite[pSpr->extra].medium = kMediumNormal; if (pPlayer) { - pPlayer->posture = (!pPlayer->input.syncFlags.crouch) ? kPostureStand : kPostureCrouch; + pPlayer->posture = (!(pPlayer->input.actions & SB_CROUCH)) ? kPostureStand : kPostureCrouch; pPlayer->nWaterPal = 0; } @@ -2087,7 +2087,7 @@ void useTeleportTarget(XSPRITE* pXSource, spritetype* pSprite) { xsprite[pSprite->extra].medium = kMediumNormal; if (pPlayer) { - pPlayer->posture = (!pPlayer->input.syncFlags.crouch) ? kPostureStand : kPostureCrouch; + pPlayer->posture = (!(pPlayer->input.actions & SB_CROUCH)) ? kPostureStand : kPostureCrouch; pPlayer->nWaterPal = 0; } @@ -2889,10 +2889,10 @@ bool condCheckPlayer(XSPRITE* pXCond, int cmpOp, bool PUSH) { case 2: return (pPlayer->input.fvel < 0); // backward case 3: return (pPlayer->input.svel > 0); // left case 4: return (pPlayer->input.svel < 0); // right - case 5: return (pPlayer->input.syncFlags.jump); // jump - case 6: return (pPlayer->input.syncFlags.crouch); // crouch - case 7: return (pPlayer->input.syncFlags.shoot); // normal fire weapon - case 8: return (pPlayer->input.syncFlags.shoot2); // alt fire weapon + case 5: return !!(pPlayer->input.actions & SB_JUMP); // jump + case 6: return !!(pPlayer->input.actions & SB_CROUCH); // crouch + case 7: return !!(pPlayer->input.actions & SB_FIRE); // normal fire weapon + case 8: return !!(pPlayer->input.actions & SB_ALTFIRE); // alt fire weapon default: condError(pXCond, "Player conditions:\nSpecify a correct key!"); break; diff --git a/source/blood/src/player.cpp b/source/blood/src/player.cpp index 7600c4ab0..fc950d0c7 100644 --- a/source/blood/src/player.cpp +++ b/source/blood/src/player.cpp @@ -51,6 +51,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_BLD_NS +extern bool gameRestart; + PROFILE gProfile[kMaxPlayers]; PLAYER gPlayer[kMaxPlayers]; @@ -762,6 +764,7 @@ void playerStart(int nPlayer, int bNewLevel) pPlayer->nextWeapon = 0; xvel[pSprite->index] = yvel[pSprite->index] = zvel[pSprite->index] = 0; pInput->q16avel = 0; + pInput->actions = 0; pInput->syncFlags.value = 0; pInput->fvel = 0; pInput->svel = 0; @@ -1330,7 +1333,7 @@ void ProcessInput(PLAYER *pPlayer) } pPlayer->isRunning = pInput->syncFlags.run; - if ((pInput->syncFlags.value & flag_buttonmask_norun) || pInput->fvel || pInput->svel || pInput->q16avel) + if ((pInput->syncFlags.value & flag_buttonmask_norun) || (pInput->actions & SB_BUTTON_MASK) || pInput->fvel || pInput->svel || pInput->q16avel) pPlayer->restTime = 0; else if (pPlayer->restTime >= 0) pPlayer->restTime += 4; @@ -1353,7 +1356,7 @@ void ProcessInput(PLAYER *pPlayer) } if (pPlayer->curWeapon) pInput->setNewWeapon(pPlayer->curWeapon); - if (pInput->syncFlags.action) + if (pInput->actions & SB_OPEN) { if (bSeqStat) { @@ -1369,12 +1372,12 @@ void ProcessInput(PLAYER *pPlayer) playerReset(pPlayer); if (gGameOptions.nGameType == 0 && numplayers == 1) { - pInput->syncFlags.restart = 1; + gameRestart = 1; } else playerStart(pPlayer->nPlayer); } - pInput->syncFlags.action = 0; + pInput->actions &= ~SB_OPEN; } return; } @@ -1431,11 +1434,11 @@ void ProcessInput(PLAYER *pPlayer) } if (pInput->q16avel) pPlayer->q16ang = (pPlayer->q16ang+pInput->q16avel)&0x7ffffff; - if (pInput->syncFlags.spin180) + if (pInput->actions & SB_TURNAROUND) { if (!pPlayer->spin) pPlayer->spin = -1024; - pInput->syncFlags.spin180 = 0; + pInput->actions &= ~SB_TURNAROUND; } if (pPlayer->spin < 0) { @@ -1453,22 +1456,22 @@ void ProcessInput(PLAYER *pPlayer) gViewAngleAdjust += float(pSprite->ang - pPlayer->angold); pPlayer->q16ang = (pPlayer->q16ang+fix16_from_int(pSprite->ang-pPlayer->angold))&0x7ffffff; pPlayer->angold = pSprite->ang = fix16_to_int(pPlayer->q16ang); - if (!pInput->syncFlags.jump) + if (!(pInput->actions & SB_JUMP)) pPlayer->cantJump = 0; switch (pPlayer->posture) { case 1: - if (pInput->syncFlags.jump) + if (pInput->actions & SB_JUMP) zvel[nSprite] -= pPosture->normalJumpZ;//0x5b05; - if (pInput->syncFlags.crouch) + if (pInput->actions & SB_CROUCH) zvel[nSprite] += pPosture->normalJumpZ;//0x5b05; break; case 2: - if (!pInput->syncFlags.crouch) + if (!(pInput->actions & SB_CROUCH)) pPlayer->posture = 0; break; default: - if (!pPlayer->cantJump && pInput->syncFlags.jump && pXSprite->height == 0) { + if (!pPlayer->cantJump && (pInput->actions & SB_JUMP) && pXSprite->height == 0) { #ifdef NOONE_EXTENSIONS if ((packItemActive(pPlayer, 4) && pPosture->pwupJumpZ != 0) || pPosture->normalJumpZ != 0) #endif @@ -1479,11 +1482,11 @@ void ProcessInput(PLAYER *pPlayer) pPlayer->cantJump = 1; } - if (pInput->syncFlags.crouch) + if (pInput->actions & SB_CROUCH) pPlayer->posture = 2; break; } - if (pInput->syncFlags.action) + if (pInput->actions & SB_OPEN) { int a2, a3; int hit = ActionScan(pPlayer, &a2, &a3); @@ -1556,18 +1559,18 @@ void ProcessInput(PLAYER *pPlayer) zvel[pSprite2->index] = zvel[nSprite]; pPlayer->hand = 0; } - pInput->syncFlags.action = 0; + pInput->actions &= ~SB_OPEN; } if (bVanilla) { - if (pInput->syncFlags.lookCenter && !pInput->syncFlags.lookUp && !pInput->syncFlags.lookDown) + if ((pInput->actions & SB_CENTERVIEW) && !pInput->syncFlags.lookUp && !pInput->syncFlags.lookDown) { if (pPlayer->q16look < 0) pPlayer->q16look = fix16_min(pPlayer->q16look+fix16_from_int(4), fix16_from_int(0)); if (pPlayer->q16look > 0) pPlayer->q16look = fix16_max(pPlayer->q16look-fix16_from_int(4), fix16_from_int(0)); if (!pPlayer->q16look) - pInput->syncFlags.lookCenter = 0; + pInput->actions &= ~SB_CENTERVIEW; } else { @@ -1590,14 +1593,14 @@ void ProcessInput(PLAYER *pPlayer) int downAngle = -347; double lookStepUp = 4.0*upAngle/60.0; double lookStepDown = -4.0*downAngle/60.0; - if (pInput->syncFlags.lookCenter && !pInput->syncFlags.lookUp && !pInput->syncFlags.lookDown) + if ((pInput->actions & SB_CENTERVIEW) && !pInput->syncFlags.lookUp && !pInput->syncFlags.lookDown) { if (pPlayer->q16look < 0) pPlayer->q16look = fix16_min(pPlayer->q16look+fix16_from_dbl(lookStepDown), fix16_from_int(0)); if (pPlayer->q16look > 0) pPlayer->q16look = fix16_max(pPlayer->q16look-fix16_from_dbl(lookStepUp), fix16_from_int(0)); if (!pPlayer->q16look) - pInput->syncFlags.lookCenter = 0; + pInput->actions &= ~SB_CENTERVIEW; } else { @@ -1616,7 +1619,7 @@ void ProcessInput(PLAYER *pPlayer) { gViewLookAdjust -= float(lookStepDown); } - gViewLookRecenter = pInput->syncFlags.lookCenter && !pInput->syncFlags.lookUp && !pInput->syncFlags.lookDown; + gViewLookRecenter = (pInput->actions & SB_CENTERVIEW) && !pInput->syncFlags.lookUp && !pInput->syncFlags.lookDown; } pPlayer->q16look = fix16_clamp(pPlayer->q16look+(pInput->q16horz<<3), fix16_from_int(downAngle), fix16_from_int(upAngle)); pPlayer->q16horiz = fix16_from_float(100.f*tanf(fix16_to_float(pPlayer->q16look)*fPI/1024.f)); @@ -1688,9 +1691,9 @@ void ProcessInput(PLAYER *pPlayer) if (pPlayer->packSlots[0].curAmount > 0) packUseItem(pPlayer, 0); } - if (pInput->syncFlags.holsterWeapon) + if (pInput->actions & SB_HOLSTER) { - pInput->syncFlags.holsterWeapon = 0; + pInput->actions &= ~SB_HOLSTER; if (pPlayer->curWeapon) { WeaponLower(pPlayer); diff --git a/source/blood/src/weapon.cpp b/source/blood/src/weapon.cpp index 581486447..6583ca9f1 100644 --- a/source/blood/src/weapon.cpp +++ b/source/blood/src/weapon.cpp @@ -1767,17 +1767,17 @@ char sub_4F0E0(PLAYER *pPlayer) switch (pPlayer->weaponState) { case 5: - if (!pPlayer->input.syncFlags.shoot2) + if (!(pPlayer->input.actions & SB_ALTFIRE)) pPlayer->weaponState = 6; return 1; case 6: - if (pPlayer->input.syncFlags.shoot2) + if (pPlayer->input.actions & SB_ALTFIRE) { pPlayer->weaponState = 3; pPlayer->fuseTime = pPlayer->weaponTimer; StartQAV(pPlayer, 13, nClientDropCan, 0); } - else if (pPlayer->input.syncFlags.shoot) + else if (pPlayer->input.actions & SB_FIRE) { pPlayer->weaponState = 7; pPlayer->fuseTime = 0; @@ -1787,7 +1787,7 @@ char sub_4F0E0(PLAYER *pPlayer) case 7: { pPlayer->throwPower = ClipHigh(divscale16(gFrameClock-pPlayer->throwTime,240), 65536); - if (!pPlayer->input.syncFlags.shoot) + if (!(pPlayer->input.actions & SB_FIRE)) { if (!pPlayer->fuseTime) pPlayer->fuseTime = pPlayer->weaponTimer; @@ -1805,17 +1805,17 @@ char sub_4F200(PLAYER *pPlayer) switch (pPlayer->weaponState) { case 4: - if (!pPlayer->input.syncFlags.shoot2) + if (!(pPlayer->input.actions & SB_ALTFIRE)) pPlayer->weaponState = 5; return 1; case 5: - if (pPlayer->input.syncFlags.shoot2) + if (pPlayer->input.actions & SB_ALTFIRE) { pPlayer->weaponState = 1; pPlayer->fuseTime = pPlayer->weaponTimer; StartQAV(pPlayer, 22, nClientDropBundle, 0); } - else if (pPlayer->input.syncFlags.shoot) + else if (pPlayer->input.actions & SB_FIRE) { pPlayer->weaponState = 6; pPlayer->fuseTime = 0; @@ -1825,7 +1825,7 @@ char sub_4F200(PLAYER *pPlayer) case 6: { pPlayer->throwPower = ClipHigh(divscale16(gFrameClock-pPlayer->throwTime,240), 65536); - if (!pPlayer->input.syncFlags.shoot) + if (!(pPlayer->input.actions & SB_FIRE)) { if (!pPlayer->fuseTime) pPlayer->fuseTime = pPlayer->weaponTimer; @@ -1845,7 +1845,7 @@ char sub_4F320(PLAYER *pPlayer) case 9: pPlayer->throwPower = ClipHigh(divscale16(gFrameClock-pPlayer->throwTime,240), 65536); pPlayer->weaponTimer = 0; - if (!pPlayer->input.syncFlags.shoot) + if (!(pPlayer->input.actions & SB_FIRE)) { pPlayer->weaponState = 8; StartQAV(pPlayer, 29, nClientThrowProx, 0); @@ -1861,7 +1861,7 @@ char sub_4F3A0(PLAYER *pPlayer) { case 13: pPlayer->throwPower = ClipHigh(divscale16(gFrameClock-pPlayer->throwTime,240), 65536); - if (!pPlayer->input.syncFlags.shoot) + if (!(pPlayer->input.actions & SB_FIRE)) { pPlayer->weaponState = 11; StartQAV(pPlayer, 39, nClientThrowRemote, 0); @@ -1880,7 +1880,7 @@ char sub_4F414(PLAYER *pPlayer) StartQAV(pPlayer, 114, nClientFireLifeLeech, 1); return 1; case 6: - if (!pPlayer->input.syncFlags.shoot2) + if (!(pPlayer->input.actions & SB_ALTFIRE)) { pPlayer->weaponState = 2; StartQAV(pPlayer, 118, -1, 0); @@ -1907,7 +1907,7 @@ char sub_4F484(PLAYER *pPlayer) StartQAV(pPlayer, 77, nClientFireTesla, 1); return 1; case 5: - if (!pPlayer->input.syncFlags.shoot) + if (!(pPlayer->input.actions & SB_FIRE)) { pPlayer->weaponState = 2; if (sub_4B2C8(pPlayer, 7, 10) && powerupCheck(pPlayer, kPwUpTwoGuns)) @@ -1968,8 +1968,8 @@ void WeaponProcess(PLAYER *pPlayer) { WeaponPlay(pPlayer); UpdateAimVector(pPlayer); pPlayer->weaponTimer -= 4; - char bShoot = pPlayer->input.syncFlags.shoot; - char bShoot2 = pPlayer->input.syncFlags.shoot2; + bool bShoot = pPlayer->input.actions & SB_FIRE; + bool bShoot2 = pPlayer->input.actions & SB_ALTFIRE; if (pPlayer->qavLoop && pPlayer->pXSprite->health > 0) { if (bShoot && CheckAmmo(pPlayer, pPlayer->weaponAmmo, 1)) diff --git a/source/core/inputstate.cpp b/source/core/inputstate.cpp index 0529da3dc..47af110d7 100644 --- a/source/core/inputstate.cpp +++ b/source/core/inputstate.cpp @@ -343,25 +343,28 @@ void ApplyGlobalInput(InputPacket& input, ControlInfo *info) input.actions |= ActionsToSend; ActionsToSend = 0; + if (buttonMap.ButtonDown(gamefunc_Jump)) + input.actions |= SB_JUMP; + + if (buttonMap.ButtonDown(gamefunc_Crouch)) + input.actions |= SB_CROUCH; + + if (buttonMap.ButtonDown(gamefunc_Fire)) + input.actions |= SB_FIRE; + + if (buttonMap.ButtonDown(gamefunc_Alt_Fire)) + input.actions |= SB_ALTFIRE; + + if (buttonMap.ButtonDown(gamefunc_Open)) + { + if (g_gameType & GAMEFLAG_BLOOD) buttonMap.ClearButton(gamefunc_Open); + input.actions |= SB_OPEN; + } + } #if 0 -void registerinputcommands() -{ - C_RegisterFunction("centerview", nullptr, [](CCmdFuncPtr)->int { BitsToSend.lookCenter = 1; return CCMD_OK; }); - C_RegisterFunction("holsterweapon", nullptr, [](CCmdFuncPtr)->int { BitsToSend.holsterWeapon = 1; return CCMD_OK; }); - C_RegisterFunction("turnaround", nullptr, [](CCmdFuncPtr)->int { BitsToSend.spin180 = 1; return CCMD_OK; }); -} - -//--------------------------------------------------------------------------- -// -// CCMD based input. The basics are from Randi's ZDuke but this uses dynamic -// registration to only have the commands active when this game module runs. -// -//--------------------------------------------------------------------------- C_RegisterFunction("backoff", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_ESCAPE; return CCMD_OK; }); -} - #endif diff --git a/source/core/packet.h b/source/core/packet.h index 53d9de8ba..50cf00b1d 100644 --- a/source/core/packet.h +++ b/source/core/packet.h @@ -21,12 +21,19 @@ enum ESyncBits_ : uint32_t SB_CENTERVIEW = 1 << 14, SB_TURNAROUND = 1 << 15, SB_HOLSTER = 1 << 16, + SB_OPEN = 1 << 17, + + SB_RUN = 1 << 27, + SB_JUMP = 1 << 28, + SB_CROUCH = 1 << 29, + SB_FIRE = 1 << 30, + SB_ALTFIRE = 1u << 31, SB_WEAPONMASK_BITS = (15u * SB_FIRST_WEAPON_BIT), // Weapons take up 4 bits SB_ITEMUSE_BITS = (127u * SB_ITEM_BIT_1), - SB_BUTTON_MASK = 0, // all input from buttons (i.e. active while held) - SB_INTERFACE_MASK = (SB_INVPREV|SB_INVNEXT|SB_INVUSE|SB_CENTERVIEW|SB_TURNAROUND|SB_HOLSTER), // all input from CCMDs + SB_BUTTON_MASK = SB_ALTFIRE|SB_FIRE|SB_CROUCH|SB_JUMP, // all input from buttons (i.e. active while held) + SB_INTERFACE_MASK = (SB_INVPREV|SB_INVNEXT|SB_INVUSE|SB_CENTERVIEW|SB_TURNAROUND|SB_HOLSTER|SB_OPEN), // all input from CCMDs SB_INTERFACE_BITS = (SB_WEAPONMASK_BITS | SB_ITEMUSE_BITS | SB_INTERFACE_MASK), SB_ALL = ~0u }; @@ -60,9 +67,6 @@ enum enum EDukeSyncBits_ : uint32_t { - SKB_JUMP = 1 << 0, - SKB_CROUCH = 1 << 1, - SKB_FIRE = 1 << 2, SKB_AIM_UP = 1 << 3, SKB_AIM_DOWN = 1 << 4, SKB_RUN = 1 << 5, @@ -72,11 +76,10 @@ enum EDukeSyncBits_ : uint32_t SKB_LOOK_DOWN = 1 << 14, SKB_QUICK_KICK = 1 << 22, SKB_AIMMODE = 1 << 23, - SKB_OPEN = 1 << 29, SKB_ESCAPE = 1u << 31, SKB_INTERFACE_BITS = (SKB_QUICK_KICK | \ - SKB_OPEN | SKB_ESCAPE), + SKB_ESCAPE), SKB_NONE = 0, SKB_ALL = ~0u @@ -93,15 +96,14 @@ union SYNCFLAGS struct { unsigned int run : 1; - unsigned int jump : 1; - unsigned int crouch : 1; - unsigned int shoot : 1; - unsigned int shoot2 : 1; + unsigned int _jump : 1; + unsigned int _crouch : 1; + unsigned int _shoot : 1; + unsigned int _shoot2 : 1; unsigned int lookUp : 1; unsigned int lookDown : 1; - unsigned int action : 1; unsigned int jab : 1; unsigned int lookLeft : 1; unsigned int lookRight : 1; @@ -123,12 +125,8 @@ union SYNCFLAGS #define SK_FLY 15 #define SK_RUN 16 -#define SK_SHOOT 17 -#define SK_OPERATE 18 -#define SK_JUMP 19 -#define SK_CRAWL 20 -#define SK_SNAP_UP 21 -#define SK_SNAP_DOWN 22 +#define SK_AIM_UP 21 +#define SK_AIM_DOWN 22 #define SK_SPACE_BAR 31 @@ -136,10 +134,6 @@ union SYNCFLAGS // Exhumed enum { - kButtonJump = 0x1, - kButtonOpen = 0x4, - kButtonFire = 0x8, - kButtonCrouch = 0x10, kButtonCheatGuns = 0x20, kButtonCheatGodMode = 0x40, kButtonCheatKeys = 0x80, diff --git a/source/exhumed/src/exhumed.cpp b/source/exhumed/src/exhumed.cpp index 8221d88af..e5e33e103 100644 --- a/source/exhumed/src/exhumed.cpp +++ b/source/exhumed/src/exhumed.cpp @@ -501,7 +501,6 @@ void GameTicker() { lastTic = currentTic; - int lLocalButtons = GetLocalInput(); // shouldn't this be placed in localInput? PlayerInterruptKeys(false); nPlayerDAng = fix16_sadd(nPlayerDAng, localInput.q16avel); @@ -601,7 +600,7 @@ void GameTicker() sPlayerInput[nLocalPlayer].xVel = lPlayerXVel; sPlayerInput[nLocalPlayer].yVel = lPlayerYVel; // make weapon selection persist until it gets used up. - sPlayerInput[nLocalPlayer].buttons = lLocalButtons | lLocalCodes; + sPlayerInput[nLocalPlayer].buttons = lLocalCodes; int weap = sPlayerInput[nLocalPlayer].getNewWeapon(); sPlayerInput[nLocalPlayer].actions = localInput.actions; if (weap2 <= 0 || weap2 > 7) sPlayerInput[nLocalPlayer].SetNewWeapon(weap); @@ -635,52 +634,12 @@ void InitTimer() htimer = 1; } -static const char* actions[] = -{ - "Move_Forward", - "Move_Backward", - "Turn_Left", - "Turn_Right", - "Strafe", - "Fire", - "Open", - "Run", - "Alt_Fire", // Duke3D", Blood - "Jump", - "Crouch", - "Look_Up", - "Look_Down", - "Look_Left", - "Look_Right", - "Strafe_Left", - "Strafe_Right", - "Aim_Up", - "Aim_Down", - "SendMessage", - "Shrink_Screen", - "Enlarge_Screen", - "Show_Opponents_Weapon", - "See_Coop_View", - "Mouse_Aiming", - "Dpad_Select", - "Dpad_Aiming", - "Last_Weapon", - "Alt_Weapon", - "Third_Person_View", - "Toggle_Crouch", // This is the last one used by EDuke32. -}; - - - - void GameInterface::app_init() { int i; //int esi = 1; //int edi = esi; - buttonMap.SetButtons(actions, NUM_ACTIONS); - help_disabled = true; // Create the global level table. Parts of the engine need it, even though the game itself does not. for (int i = 0; i <= 32; i++) diff --git a/source/exhumed/src/input.cpp b/source/exhumed/src/input.cpp index 55e923bbf..f1e5e6799 100644 --- a/source/exhumed/src/input.cpp +++ b/source/exhumed/src/input.cpp @@ -74,26 +74,10 @@ void InitInput() void ClearSpaceBar(short nPlayer) { - sPlayerInput[nPlayer].buttons &= 0x0FB; + sPlayerInput[nPlayer].actions &= SB_OPEN; buttonMap.ClearButton(gamefunc_Open); } -int GetLocalInput() -{ - int lLocalButtons; - if (PlayerList[nLocalPlayer].nHealth) - { - lLocalButtons = (buttonMap.ButtonDown(gamefunc_Crouch) << 4) | (buttonMap.ButtonDown(gamefunc_Fire) << 3) - | (buttonMap.ButtonDown(gamefunc_Jump) << 0); - } - else - { - lLocalButtons = 0; - } - - lLocalButtons |= buttonMap.ButtonDown(gamefunc_Open) << 2; - return lLocalButtons; -} void BackupInput() { @@ -189,6 +173,7 @@ void PlayerInterruptKeys(bool after) if (!after) { ApplyGlobalInput(localInput, &info); + if (PlayerList[nLocalPlayer].nHealth == 0) localInput.actions &= ~(SB_FIRE | SB_JUMP | SB_CROUCH); } diff --git a/source/exhumed/src/player.cpp b/source/exhumed/src/player.cpp index 1d8eb9725..264f1e609 100644 --- a/source/exhumed/src/player.cpp +++ b/source/exhumed/src/player.cpp @@ -1279,6 +1279,7 @@ loc_1AB8E: int var_5C = SectFlag[nViewSect] & kSectUnderwater; uint16_t buttons = sPlayerInput[nPlayer].buttons; + auto actions = sPlayerInput[nPlayer].actions; if (buttons & kButtonCheatGodMode) // LOBODEITY cheat { @@ -2535,7 +2536,7 @@ do_default_b: if (!PlayerList[nPlayer].bIsMummified) { - if (buttons & kButtonOpen) + if (actions & SB_OPEN) { ClearSpaceBar(nPlayer); @@ -2551,7 +2552,7 @@ do_default_b: } // was int var_38 = buttons & 0x8 - if (buttons & kButtonFire) + if (actions & SB_FIRE) { FireWeapon(nPlayer); } @@ -2568,7 +2569,7 @@ do_default_b: } // Jumping - if (buttons & kButtonJump) + if (actions & SB_JUMP) { if (bUnderwater) { @@ -2586,7 +2587,7 @@ do_default_b: // goto loc_1BE70: } - else if (buttons & kButtonCrouch) + else if (actions & SB_CROUCH) { if (bUnderwater) { @@ -2647,7 +2648,7 @@ loc_1BD2E: } } // loc_1BE30 - if (buttons & kButtonFire) // was var_38 + if (actions & SB_FIRE) // was var_38 { if (bUnderwater) { @@ -2679,7 +2680,7 @@ loc_1BD2E: } else // player is mummified { - if (buttons & kButtonFire) + if (actions & SB_FIRE) { FireWeapon(nPlayer); } @@ -2708,7 +2709,7 @@ loc_1BD2E: else // else, player's health is less than 0 { // loc_1C0E9 - if (buttons & kButtonOpen) + if (actions & SB_OPEN) { ClearSpaceBar(nPlayer); diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 84bae3b4e..c59123564 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -1522,7 +1522,7 @@ bool queball(int i, int pocket, int queball, int stripeball) // if(s->pal == 12) { j = getincangle(ps[p].getang(), getangle(s->x - ps[p].posx, s->y - ps[p].posy)); - if (j > -64 && j < 64 && PlayerInput(p, SKB_OPEN)) + if (j > -64 && j < 64 && PlayerInput(p, SB_OPEN)) if (ps[p].toggle_key_flag == 1) { int a = headspritestat[STAT_ACTOR]; diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index b992c6049..981670e95 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -2126,13 +2126,13 @@ void movetransports_d(void) else if (!(sectlotag == 1 && ps[p].on_ground == 1)) break; if (onfloorz == 0 && abs(sprite[i].z - ps[p].posz) < 6144) - if ((ps[p].jetpack_on == 0) || (ps[p].jetpack_on && (PlayerInput(p, SKB_JUMP))) || - (ps[p].jetpack_on && (PlayerInput(p, SKB_CROUCH) ^ !!ps[p].crouch_toggle))) + if ((ps[p].jetpack_on == 0) || (ps[p].jetpack_on && (PlayerInput(p, SB_JUMP))) || + (ps[p].jetpack_on && (PlayerInput(p, SB_CROUCH) ^ !!ps[p].crouch_toggle))) { ps[p].oposx = ps[p].posx += sprite[sprite[i].owner].x - sprite[i].x; ps[p].oposy = ps[p].posy += sprite[sprite[i].owner].y - sprite[i].y; - if (ps[p].jetpack_on && (PlayerInput(p, SKB_JUMP) || ps[p].jetpack_on < 11)) + if (ps[p].jetpack_on && (PlayerInput(p, SB_JUMP) || ps[p].jetpack_on < 11)) ps[p].posz = sprite[sprite[i].owner].z - 6144; else ps[p].posz = sprite[sprite[i].owner].z + 6144; ps[p].oposz = ps[p].posz; @@ -2149,7 +2149,7 @@ void movetransports_d(void) k = 0; - if (onfloorz && sectlotag == ST_1_ABOVE_WATER && ps[p].on_ground && ps[p].posz > (sector[sect].floorz - (16 << 8)) && (PlayerInput(p, SKB_CROUCH) || ps[p].poszv > 2048)) + if (onfloorz && sectlotag == ST_1_ABOVE_WATER && ps[p].on_ground && ps[p].posz > (sector[sect].floorz - (16 << 8)) && (PlayerInput(p, SB_CROUCH) || ps[p].poszv > 2048)) // if( onfloorz && sectlotag == 1 && ps[p].posz > (sector[sect].floorz-(6<<8)) ) { k = 1; @@ -2478,7 +2478,7 @@ static void greenslime(int i) s->ang = ps[p].getang(); - if ((PlayerInput(p, SKB_FIRE) || (ps[p].quick_kick > 0)) && sprite[ps[p].i].extra > 0) + if ((PlayerInput(p, SB_FIRE) || (ps[p].quick_kick > 0)) && sprite[ps[p].i].extra > 0) if (ps[p].quick_kick > 0 || (ps[p].curr_weapon != HANDREMOTE_WEAPON && ps[p].curr_weapon != HANDBOMB_WEAPON && ps[p].curr_weapon != TRIPBOMB_WEAPON && ps[p].ammo_amount[ps[p].curr_weapon] >= 0)) { for (x = 0; x < 8; x++) diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 3ad0c5974..e0d416a66 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -1755,13 +1755,13 @@ void movetransports_r(void) else break; if (onfloorz == 0 && abs(sprite[i].z - ps[p].posz) < 6144) - if ((ps[p].jetpack_on == 0) || (ps[p].jetpack_on && PlayerInput(p, SKB_JUMP)) || - (ps[p].jetpack_on && PlayerInput(p, SKB_CROUCH))) + if ((ps[p].jetpack_on == 0) || (ps[p].jetpack_on && PlayerInput(p, SB_JUMP)) || + (ps[p].jetpack_on && PlayerInput(p, SB_CROUCH))) { ps[p].oposx = ps[p].posx += sprite[OW].x - sprite[i].x; ps[p].oposy = ps[p].posy += sprite[OW].y - sprite[i].y; - if (ps[p].jetpack_on && (PlayerInput(p, SKB_JUMP) || ps[p].jetpack_on < 11)) + if (ps[p].jetpack_on && (PlayerInput(p, SB_JUMP) || ps[p].jetpack_on < 11)) ps[p].posz = sprite[OW].z - 6144; else ps[p].posz = sprite[OW].z + 6144; ps[p].oposz = ps[p].posz; diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 52e9dfde3..5f25f5711 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -1163,7 +1163,7 @@ int ParseState::parse(void) s = g_sp->xvel; // sigh... this was yet another place where number literals were used as bit masks for every single value, making the code totally unreadable. - if( (l& pducking) && ps[g_p].on_ground && (PlayerInput(g_p, SKB_CROUCH) ^ !!(ps[g_p].crouch_toggle) )) + if( (l& pducking) && ps[g_p].on_ground && (PlayerInput(g_p, SB_CROUCH) ^ !!(ps[g_p].crouch_toggle) )) j = 1; else if( (l& pfalling) && ps[g_p].jumping_counter == 0 && !ps[g_p].on_ground && ps[g_p].poszv > 2048 ) j = 1; @@ -1244,7 +1244,7 @@ int ParseState::parse(void) parseifelse( (( hittype[g_i].floorz - hittype[g_i].ceilingz ) >> 8 ) < *insptr); break; case concmd_ifhitspace: - parseifelse(PlayerInput(g_p, SKB_OPEN)); + parseifelse(PlayerInput(g_p, SB_OPEN)); break; case concmd_ifoutside: parseifelse(sector[g_sp->sectnum].ceilingstat & 1); diff --git a/source/games/duke/src/gameloop.cpp b/source/games/duke/src/gameloop.cpp index 6f46fce67..585430861 100644 --- a/source/games/duke/src/gameloop.cpp +++ b/source/games/duke/src/gameloop.cpp @@ -178,7 +178,7 @@ void mploadsave() int domovethings() { - int i, j; + int i; // mplpadsave(); diff --git a/source/games/duke/src/input.cpp b/source/games/duke/src/input.cpp index b59cddc1f..6517b78cb 100644 --- a/source/games/duke/src/input.cpp +++ b/source/games/duke/src/input.cpp @@ -607,33 +607,34 @@ enum static void processInputBits(player_struct *p, ControlInfo &info) { bool onVehicle = p->OnMotorcycle || p->OnBoat; - if (buttonMap.ButtonDown(gamefunc_Fire)) loc.sbits |= SKB_FIRE; - if (buttonMap.ButtonDown(gamefunc_Open)) loc.sbits |= SKB_OPEN; if (!onVehicle) { - if (buttonMap.ButtonDown(gamefunc_Jump)) loc.sbits |= SKB_JUMP; - if (buttonMap.ButtonDown(gamefunc_Crouch) || buttonMap.ButtonDown(gamefunc_Toggle_Crouch) || p->crouch_toggle) + if (buttonMap.ButtonDown(gamefunc_Toggle_Crouch) || p->crouch_toggle) { - loc.sbits |= SKB_CROUCH; - if (isRR()) loc.sbits &= ~SKB_JUMP; + loc.actions |= SB_CROUCH; } if (buttonMap.ButtonDown(gamefunc_Aim_Up) || (buttonMap.ButtonDown(gamefunc_Dpad_Aiming) && info.dz > 0)) loc.sbits |= SKB_AIM_UP; if ((buttonMap.ButtonDown(gamefunc_Aim_Down) || (buttonMap.ButtonDown(gamefunc_Dpad_Aiming) && info.dz < 0))) loc.sbits |= SKB_AIM_DOWN; if (G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run))) loc.sbits |= SKB_RUN; - if (buttonMap.ButtonDown(gamefunc_Look_Left) || (isRR() && p->drink_amt > 88)) loc.sbits |= SKB_LOOK_LEFT; + if (buttonMap.ButtonDown(gamefunc_Look_Left)) loc.sbits |= SKB_LOOK_LEFT; if (buttonMap.ButtonDown(gamefunc_Look_Right)) loc.sbits |= SKB_LOOK_RIGHT; if (buttonMap.ButtonDown(gamefunc_Look_Up)) loc.sbits |= SKB_LOOK_UP; - if (buttonMap.ButtonDown(gamefunc_Look_Down) || (isRR() && p->drink_amt > 99)) loc.sbits |= SKB_LOOK_DOWN; + if (buttonMap.ButtonDown(gamefunc_Look_Down)) loc.sbits |= SKB_LOOK_DOWN; if (buttonMap.ButtonDown(gamefunc_Quick_Kick)) loc.sbits |= SKB_QUICK_KICK; if (in_mousemode || buttonMap.ButtonDown(gamefunc_Mouse_Aiming)) loc.sbits |= SKB_AIMMODE; + if ((isRR() && p->drink_amt > 88)) loc.sbits |= SKB_LOOK_LEFT; + if ((isRR() && p->drink_amt > 99)) loc.sbits |= SKB_LOOK_DOWN; + } ApplyGlobalInput(loc, &info); + if (isRR() && (loc.actions & SB_CROUCH)) loc.actions &= ~SB_JUMP; + if (onVehicle) { // mask out all actions not compatible with vehicles. - loc.actions &= ~(SB_WEAPONMASK_BITS | SB_TURNAROUND | SB_CENTERVIEW | SB_HOLSTER); + loc.actions &= ~(SB_WEAPONMASK_BITS | SB_TURNAROUND | SB_CENTERVIEW | SB_HOLSTER | SB_JUMP | SB_CROUCH); } if (buttonMap.ButtonDown(gamefunc_Dpad_Aiming)) @@ -978,11 +979,11 @@ static void processVehicleInput(player_struct *p, ControlInfo& info, InputPacket if (p->OnBoat || !p->moto_underwater) { if (buttonMap.ButtonDown(gamefunc_Move_Forward) || buttonMap.ButtonDown(gamefunc_Strafe)) - loc.sbits |= SKB_JUMP; + loc.actions |= SB_JUMP; if (buttonMap.ButtonDown(gamefunc_Move_Backward)) loc.sbits |= SKB_AIM_UP; if (buttonMap.ButtonDown(gamefunc_Run)) - loc.sbits |= SKB_CROUCH; + loc.actions |= SB_CROUCH; } if (turnl) diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 2186a93f2..f64d2661b 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -41,7 +41,7 @@ source as it is released. BEGIN_DUKE_NS void fireweapon_ww(int snum); -void operateweapon_ww(int snum, EDukeSyncBits sb_snum, int psect); +void operateweapon_ww(int snum, ESyncBits actions, EDukeSyncBits sb_snum, int psect); //--------------------------------------------------------------------------- // @@ -1498,7 +1498,7 @@ int doincrements_d(struct player_struct* p) } S_PlayActorSound(DUKE_CRACK_FIRST, p->i); } - else if (p->knuckle_incs == 22 || PlayerInput(snum, SKB_FIRE)) + else if (p->knuckle_incs == 22 || PlayerInput(snum, SB_FIRE)) p->knuckle_incs = 0; return 1; @@ -1552,7 +1552,7 @@ void checkweapons_d(struct player_struct* p) // //--------------------------------------------------------------------------- -static void operateJetpack(int snum, EDukeSyncBits sb_snum, int psectlotag, int fz, int cz, int shrunk) +static void operateJetpack(int snum, ESyncBits actions, int psectlotag, int fz, int cz, int shrunk) { int j; auto p = &ps[snum]; @@ -1582,7 +1582,7 @@ static void operateJetpack(int snum, EDukeSyncBits sb_snum, int psectlotag, int if (shrunk) j = 512; else j = 2048; - if (sb_snum & SKB_JUMP) //A (soar high) + if (actions & SB_JUMP) //A (soar high) { // jump SetGameVarID(g_iReturnVarID, 0, pi, snum); @@ -1594,7 +1594,7 @@ static void operateJetpack(int snum, EDukeSyncBits sb_snum, int psectlotag, int } } - if (sb_snum & SKB_CROUCH) //Z (soar low) + if (actions & SB_CROUCH) //Z (soar low) { // crouch SetGameVarID(g_iReturnVarID, 0, pi, snum); @@ -1626,7 +1626,7 @@ static void operateJetpack(int snum, EDukeSyncBits sb_snum, int psectlotag, int // //--------------------------------------------------------------------------- -static void movement(int snum, EDukeSyncBits sb_snum, int psect, int fz, int cz, int shrunk, int truefdist, int psectlotag) +static void movement(int snum, ESyncBits actions, int psect, int fz, int cz, int shrunk, int truefdist, int psectlotag) { int j; auto p = &ps[snum]; @@ -1675,7 +1675,7 @@ static void movement(int snum, EDukeSyncBits sb_snum, int psect, int fz, int cz, { // not jumping or crouching - if ((sb_snum & (SKB_JUMP|SKB_CROUCH)) == 0 && p->on_ground && (sector[psect].floorstat & 2) && p->posz >= (fz - (i << 8) - (16 << 8))) + if ((actions & (SB_JUMP|SB_CROUCH)) == 0 && p->on_ground && (sector[psect].floorstat & 2) && p->posz >= (fz - (i << 8) - (16 << 8))) p->posz = fz - (i << 8); else { @@ -1751,27 +1751,27 @@ static void movement(int snum, EDukeSyncBits sb_snum, int psect, int fz, int cz, p->on_warping_sector = 0; - if (sb_snum & SKB_CROUCH) + if (actions & SB_CROUCH) { playerCrouch(snum); } // jumping - if ((sb_snum & SKB_JUMP) == 0 && p->jumping_toggle == 1) + if ((actions & SB_JUMP) == 0 && p->jumping_toggle == 1) p->jumping_toggle = 0; - else if ((sb_snum & SKB_JUMP)) + else if ((actions & SB_JUMP)) { playerJump(snum, fz, cz); } - if (p->jumping_counter && (sb_snum & SKB_JUMP) == 0) + if (p->jumping_counter && (actions & SB_JUMP) == 0) p->jumping_toggle = 0; } if (p->jumping_counter) { - if ((sb_snum & SKB_JUMP) == 0 && p->jumping_toggle == 1) + if ((actions & SB_JUMP) == 0 && p->jumping_toggle == 1) p->jumping_toggle = 0; if (p->jumping_counter < (1024 + 256)) @@ -1813,7 +1813,7 @@ static void movement(int snum, EDukeSyncBits sb_snum, int psect, int fz, int cz, // //--------------------------------------------------------------------------- -static void underwater(int snum, EDukeSyncBits sb_snum, int psect, int fz, int cz) +static void underwater(int snum, ESyncBits actions, int psect, int fz, int cz) { int j; auto p = &ps[snum]; @@ -1830,14 +1830,14 @@ static void underwater(int snum, EDukeSyncBits sb_snum, int psect, int fz, int c if (!S_CheckActorSoundPlaying(pi, DUKE_UNDERWATER)) S_PlayActorSound(DUKE_UNDERWATER, pi); - if (sb_snum & SKB_JUMP) + if (actions & SB_JUMP) { // jump if (p->poszv > 0) p->poszv = 0; p->poszv -= 348; if (p->poszv < -(256 * 6)) p->poszv = -(256 * 6); } - else if (sb_snum & SKB_CROUCH) + else if (actions & SB_CROUCH) { // crouch if (p->poszv < 0) p->poszv = 0; @@ -2062,7 +2062,7 @@ static void fireweapon(int snum) // //--------------------------------------------------------------------------- -static void operateweapon(int snum, EDukeSyncBits sb_snum, int psect) +static void operateweapon(int snum, ESyncBits actions, EDukeSyncBits sb_snum, int psect) { auto p = &ps[snum]; int pi = p->i; @@ -2073,7 +2073,7 @@ static void operateweapon(int snum, EDukeSyncBits sb_snum, int psect) switch (p->curr_weapon) { case HANDBOMB_WEAPON: // grenade in NAM - if (p->kickback_pic == 6 && (sb_snum & SKB_FIRE)) + if (p->kickback_pic == 6 && (actions & SB_FIRE)) { p->rapid_fire_hold = 1; break; @@ -2083,7 +2083,7 @@ static void operateweapon(int snum, EDukeSyncBits sb_snum, int psect) { p->ammo_amount[HANDBOMB_WEAPON]--; - if (p->on_ground && (sb_snum & SKB_CROUCH)) + if (p->on_ground && (actions & SB_CROUCH)) { k = 15; i = ((p->gethorizsum() - 100) * 20); @@ -2122,7 +2122,7 @@ static void operateweapon(int snum, EDukeSyncBits sb_snum, int psect) p->hbomb_on = 1; } - else if (p->kickback_pic < 12 && (sb_snum & SKB_FIRE)) + else if (p->kickback_pic < 12 && (actions & SB_FIRE)) p->hbomb_hold_delay++; else if (p->kickback_pic > 19) { @@ -2282,7 +2282,7 @@ static void operateweapon(int snum, EDukeSyncBits sb_snum, int psect) p->visibility = 0; checkavailweapon(p); - if ((sb_snum & SKB_FIRE) == 0) + if ((actions & SB_FIRE) == 0) { p->okickback_pic = p->kickback_pic = 0; break; @@ -2291,7 +2291,7 @@ static void operateweapon(int snum, EDukeSyncBits sb_snum, int psect) } else if (p->kickback_pic > 10) { - if (sb_snum & SKB_FIRE) p->okickback_pic = p->kickback_pic = 1; + if (actions & SB_FIRE) p->okickback_pic = p->kickback_pic = 1; else p->okickback_pic = p->kickback_pic = 0; } @@ -2429,7 +2429,7 @@ static void operateweapon(int snum, EDukeSyncBits sb_snum, int psect) } else { - if (sb_snum & SKB_FIRE) + if (actions & SB_FIRE) { p->okickback_pic = p->kickback_pic = 1; S_PlayActorSound(CAT_FIRE, pi); @@ -2455,7 +2455,7 @@ static void operateweapon(int snum, EDukeSyncBits sb_snum, int psect) } else if (p->kickback_pic == 16) { - if ((sb_snum & SKB_FIRE) != 0) + if ((actions & SB_FIRE) != 0) { p->okickback_pic = p->kickback_pic = 1; S_PlayActorSound(FLAMETHROWER_INTRO, pi); @@ -2487,7 +2487,7 @@ static void operateweapon(int snum, EDukeSyncBits sb_snum, int psect) if (p->kickback_pic == 7) fi.shoot(pi, KNEE); else if (p->kickback_pic == 14) { - if (sb_snum & SKB_FIRE) + if (actions & SB_FIRE) p->okickback_pic = p->kickback_pic = 1 + (krand() & 3); else p->okickback_pic = p->kickback_pic = 0; } @@ -2547,7 +2547,7 @@ static void processweapon(int snum, ESyncBits actions, EDukeSyncBits sb_snum, in p->ammo_amount[p->curr_weapon] % aplWeaponClip[p->curr_weapon][snum]; // p->kickback_pic = aplWeaponFireDelay[p->curr_weapon][snum]+1; // animate, but don't shoot... p->kickback_pic = aplWeaponTotalTime[p->curr_weapon][snum] + 1; // animate, but don't shoot... - sb_snum &= ~SKB_FIRE; // not firing... + actions &= ~SB_FIRE; // not firing... } return; } @@ -2560,7 +2560,7 @@ static void processweapon(int snum, ESyncBits actions, EDukeSyncBits sb_snum, in // throw away the remaining clip p->ammo_amount[PISTOL_WEAPON] -= p->ammo_amount[PISTOL_WEAPON] % 20; p->kickback_pic = 3; // animate, but don't shoot... - sb_snum &= ~SKB_FIRE; // not firing... + actions &= ~SB_FIRE; // not firing... } return; } @@ -2575,13 +2575,13 @@ static void processweapon(int snum, ESyncBits actions, EDukeSyncBits sb_snum, in if (p->rapid_fire_hold == 1) { - if (sb_snum & SKB_FIRE) return; + if (actions & SB_FIRE) return; p->rapid_fire_hold = 0; } if (shrunk || p->tipincs || p->access_incs) - sb_snum &= ~SKB_FIRE; - else if (shrunk == 0 && (sb_snum & SKB_FIRE) && p->kickback_pic == 0 && p->fist_incs == 0 && + actions &= ~SB_FIRE; + else if (shrunk == 0 && (actions & SB_FIRE) && p->kickback_pic == 0 && p->fist_incs == 0 && p->last_weapon == -1 && (p->weapon_pos == 0 || p->holster_weapon == 1)) { if (!isWW2GI()) fireweapon(snum); @@ -2589,8 +2589,8 @@ static void processweapon(int snum, ESyncBits actions, EDukeSyncBits sb_snum, in } else if (p->kickback_pic) { - if (!isWW2GI()) operateweapon(snum, sb_snum, psect); - else operateweapon_ww(snum, sb_snum, psect); + if (!isWW2GI()) operateweapon(snum, actions, sb_snum, psect); + else operateweapon_ww(snum, actions, sb_snum, psect); } } //--------------------------------------------------------------------------- @@ -2764,16 +2764,16 @@ void processinput_d(int snum) if (psectlotag == ST_2_UNDERWATER) { - underwater(snum, sb_snum, psect, fz, cz); + underwater(snum, actions, psect, fz, cz); } else if (p->jetpack_on) { - operateJetpack(snum, sb_snum, psectlotag, fz, cz, shrunk); + operateJetpack(snum, actions, psectlotag, fz, cz, shrunk); } else if (psectlotag != ST_2_UNDERWATER) { - movement(snum, sb_snum, psect, fz, cz, shrunk, truefdist, psectlotag); + movement(snum, actions, psect, fz, cz, shrunk, truefdist, psectlotag); } p->psectlotag = psectlotag; @@ -2882,8 +2882,8 @@ void processinput_d(int snum) bool check; - if (!isWW2GI()) check = ((p->curr_weapon == KNEE_WEAPON && p->kickback_pic > 10 && p->on_ground) || (p->on_ground && (sb_snum & SKB_CROUCH))); - else check = ((aplWeaponWorksLike[p->curr_weapon][snum] == KNEE_WEAPON && p->kickback_pic > 10 && p->on_ground) || (p->on_ground && (sb_snum & SKB_CROUCH))); + if (!isWW2GI()) check = ((p->curr_weapon == KNEE_WEAPON && p->kickback_pic > 10 && p->on_ground) || (p->on_ground && (actions & SB_CROUCH))); + else check = ((aplWeaponWorksLike[p->curr_weapon][snum] == KNEE_WEAPON && p->kickback_pic > 10 && p->on_ground) || (p->on_ground && (actions & SB_CROUCH))); if (check) { p->posxv = mulscale(p->posxv, dukefriction - 0x2000, 16); @@ -3071,22 +3071,22 @@ HORIZONLY: processweapon(snum, actions, sb_snum, psect); } -void processmove_d(int snum, EDukeSyncBits sb_snum, int psect, int fz, int cz, int shrunk, int truefdist) +void processmove_d(int snum, ESyncBits actions, int psect, int fz, int cz, int shrunk, int truefdist) { int psectlotag = sector[psect].lotag; auto p = &ps[snum]; if (psectlotag == 2) { - underwater(snum, sb_snum, psect, fz, cz); + underwater(snum, actions, psect, fz, cz); } else if (p->jetpack_on) { - operateJetpack(snum, sb_snum, psectlotag, fz, cz, shrunk); + operateJetpack(snum, actions, psectlotag, fz, cz, shrunk); } else if (psectlotag != 2) { - movement(snum, sb_snum, psect, fz, cz, shrunk, truefdist, psectlotag); + movement(snum, actions, psect, fz, cz, shrunk, truefdist, psectlotag); } } END_DUKE_NS diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 9aba0c134..5f4d9ca76 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -1411,7 +1411,7 @@ int doincrements_r(struct player_struct* p) else S_PlayActorSound(DUKE_CRACK2, p->i); } } - else if (p->knuckle_incs == 22 || PlayerInput(snum, SKB_FIRE)) + else if (p->knuckle_incs == 22 || PlayerInput(snum, SB_FIRE)) p->knuckle_incs = 0; return 1; @@ -1513,7 +1513,7 @@ void checkweapons_r(struct player_struct* p) // //--------------------------------------------------------------------------- -static void onMotorcycle(int snum, EDukeSyncBits &sb_snum) +static void onMotorcycle(int snum, ESyncBits &actions, EDukeSyncBits &sb_snum) { auto p = &ps[snum]; auto pi = p->i; @@ -1523,18 +1523,18 @@ static void onMotorcycle(int snum, EDukeSyncBits &sb_snum) short var84; if (p->MotoSpeed < 0) p->MotoSpeed = 0; - if (sb_snum & SKB_CROUCH) + if (actions & SB_CROUCH) { var64 = 1; - sb_snum &= ~SKB_CROUCH; + actions &= ~SB_CROUCH; } else var64 = 0; - if (sb_snum & SKB_JUMP) + if (actions & SB_JUMP) { var68 = 1; - sb_snum &= ~SKB_JUMP; + actions &= ~SB_JUMP; if (p->on_ground) { if (p->MotoSpeed == 0 && var64) @@ -1806,7 +1806,7 @@ static void onMotorcycle(int snum, EDukeSyncBits &sb_snum) // //--------------------------------------------------------------------------- -static void onBoat(int snum, EDukeSyncBits& sb_snum) +static void onBoat(int snum, ESyncBits &actions, EDukeSyncBits& sb_snum) { auto p = &ps[snum]; auto pi = p->i; @@ -1829,19 +1829,19 @@ static void onBoat(int snum, EDukeSyncBits& sb_snum) } if (p->MotoSpeed < 0) p->MotoSpeed = 0; - if ((sb_snum & SKB_CROUCH) && (sb_snum & SKB_JUMP)) + if ((actions & SB_CROUCH) && (actions & SB_JUMP)) { vara8 = 1; varac = 0; varb0 = 0; - sb_snum &= ~(SKB_JUMP|SKB_CROUCH); + actions &= ~(SB_JUMP|SB_CROUCH); } else vara8 = 0; - if (sb_snum & SKB_JUMP) + if (actions & SB_JUMP) { varac = 1; - sb_snum &= ~SKB_JUMP; + actions &= ~SB_JUMP; if (p->MotoSpeed == 0 && !S_CheckActorSoundPlaying(pi, 89)) { if (S_CheckActorSoundPlaying(pi, 87)) @@ -1872,10 +1872,10 @@ static void onBoat(int snum, EDukeSyncBits& sb_snum) S_PlayActorSound(87, pi); } - if (sb_snum & SKB_CROUCH) + if (actions & SB_CROUCH) { varb0 = 1; - sb_snum &= ~SKB_CROUCH; + actions &= ~SB_CROUCH; } else varb0 = 0; @@ -2090,7 +2090,7 @@ static void onBoat(int snum, EDukeSyncBits& sb_snum) // //--------------------------------------------------------------------------- -static void movement(int snum, EDukeSyncBits sb_snum, int psect, int fz, int cz, int shrunk, int truefdist, int psectlotag) +static void movement(int snum, ESyncBits actions, EDukeSyncBits sb_snum, int psect, int fz, int cz, int shrunk, int truefdist, int psectlotag) { auto p = &ps[snum]; auto pi = p->i; @@ -2148,7 +2148,7 @@ static void movement(int snum, EDukeSyncBits sb_snum, int psect, int fz, int cz, if (p->posz < (fz - (i << 8))) //falling { - if ((sb_snum & (SKB_JUMP|SKB_CROUCH)) == 0 && p->on_ground && (sector[psect].floorstat & 2) && p->posz >= (fz - (i << 8) - (16 << 8))) + if ((actions & (SB_JUMP|SB_CROUCH)) == 0 && p->on_ground && (sector[psect].floorstat & 2) && p->posz >= (fz - (i << 8) - (16 << 8))) p->posz = fz - (i << 8); else { @@ -2262,15 +2262,15 @@ static void movement(int snum, EDukeSyncBits sb_snum, int psect, int fz, int cz, p->on_warping_sector = 0; - if ((sb_snum & SKB_CROUCH) && !p->OnMotorcycle) + if ((actions & SB_CROUCH) && !p->OnMotorcycle) { playerCrouch(snum); } - if ((sb_snum & SKB_JUMP) == 0 && !p->OnMotorcycle && p->jumping_toggle == 1) + if ((actions & SB_JUMP) == 0 && !p->OnMotorcycle && p->jumping_toggle == 1) p->jumping_toggle = 0; - else if ((sb_snum & SKB_JUMP) && !p->OnMotorcycle && p->jumping_toggle == 0) + else if ((actions & SB_JUMP) && !p->OnMotorcycle && p->jumping_toggle == 0) { playerJump(snum, fz, cz); } @@ -2278,7 +2278,7 @@ static void movement(int snum, EDukeSyncBits sb_snum, int psect, int fz, int cz, if (p->jumping_counter) { - if ((sb_snum & SKB_JUMP) == 0 && !p->OnMotorcycle && p->jumping_toggle == 1) + if ((actions & SB_JUMP) == 0 && !p->OnMotorcycle && p->jumping_toggle == 1) p->jumping_toggle = 0; if (p->jumping_counter < 768) @@ -2320,7 +2320,7 @@ static void movement(int snum, EDukeSyncBits sb_snum, int psect, int fz, int cz, // //--------------------------------------------------------------------------- -static void underwater(int snum, EDukeSyncBits sb_snum, int psect, int fz, int cz) +static void underwater(int snum, ESyncBits actions, EDukeSyncBits sb_snum, int psect, int fz, int cz) { int j; auto p = &ps[snum]; @@ -2336,13 +2336,13 @@ static void underwater(int snum, EDukeSyncBits sb_snum, int psect, int fz, int c if (!S_CheckActorSoundPlaying(pi, DUKE_UNDERWATER)) S_PlayActorSound(DUKE_UNDERWATER, pi); - if ((sb_snum & SKB_JUMP) && !p->OnMotorcycle) + if ((actions & SB_JUMP) && !p->OnMotorcycle) { if (p->poszv > 0) p->poszv = 0; p->poszv -= 348; if (p->poszv < -(256 * 6)) p->poszv = -(256 * 6); } - else if ((sb_snum & SKB_CROUCH) || p->OnMotorcycle) + else if ((actions & SB_CROUCH) || p->OnMotorcycle) { if (p->poszv < 0) p->poszv = 0; p->poszv += 348; @@ -2744,7 +2744,7 @@ static void fireweapon(int snum) // //--------------------------------------------------------------------------- -static void operateweapon(int snum, EDukeSyncBits sb_snum, int psect) +static void operateweapon(int snum, ESyncBits actions, EDukeSyncBits sb_snum, int psect) { auto p = &ps[snum]; int pi = p->i; @@ -2758,7 +2758,7 @@ static void operateweapon(int snum, EDukeSyncBits sb_snum, int psect) if (p->kickback_pic == 1) S_PlaySound(401); - if (p->kickback_pic == 6 && (sb_snum & SKB_FIRE)) + if (p->kickback_pic == 6 && (actions & SB_FIRE)) p->rapid_fire_hold = 1; p->kickback_pic++; if (p->kickback_pic > 19) @@ -2795,7 +2795,7 @@ static void operateweapon(int snum, EDukeSyncBits sb_snum, int psect) p->ammo_amount[DYNAMITE_WEAPON]--; if (p->ammo_amount[CROSSBOW_WEAPON]) p->ammo_amount[CROSSBOW_WEAPON]--; - if (p->on_ground && (sb_snum & SKB_CROUCH) && !p->OnMotorcycle) + if (p->on_ground && (actions & SB_CROUCH) && !p->OnMotorcycle) { k = 15; i = ((p->gethorizsum() - 100) * 20); @@ -2828,7 +2828,7 @@ static void operateweapon(int snum, EDukeSyncBits sb_snum, int psect) p->hbomb_on = 1; } - else if (p->kickback_pic < 12 && (sb_snum & SKB_FIRE)) + else if (p->kickback_pic < 12 && (actions & SB_FIRE)) p->hbomb_hold_delay++; if (p->kickback_pic == 40) @@ -2911,7 +2911,7 @@ static void operateweapon(int snum, EDukeSyncBits sb_snum, int psect) if (p->kickback_pic == 6) if (p->shotgun_state[0] == 0) if (p->ammo_amount[SHOTGUN_WEAPON] > 1) - if (sb_snum & SKB_FIRE) + if (actions & SB_FIRE) p->shotgun_state[1] = 1; if (p->kickback_pic == 4) @@ -3055,7 +3055,7 @@ static void operateweapon(int snum, EDukeSyncBits sb_snum, int psect) } checkavailweapon(p); - if ((sb_snum & SKB_FIRE) == 0) + if ((actions & SB_FIRE) == 0) { p->kickback_pic = 0; break; @@ -3064,7 +3064,7 @@ static void operateweapon(int snum, EDukeSyncBits sb_snum, int psect) } else if (p->kickback_pic > 10) { - if (sb_snum & SKB_FIRE) p->kickback_pic = 1; + if (actions & SB_FIRE) p->kickback_pic = 1; else p->kickback_pic = 0; } @@ -3119,7 +3119,7 @@ static void operateweapon(int snum, EDukeSyncBits sb_snum, int psect) } if (p->kickback_pic > 4) p->kickback_pic = 1; - if (!(sb_snum & SKB_FIRE)) + if (!(actions & SB_FIRE)) p->kickback_pic = 0; break; @@ -3149,7 +3149,7 @@ static void operateweapon(int snum, EDukeSyncBits sb_snum, int psect) } if (p->kickback_pic > 4) p->kickback_pic = 1; - if (!(sb_snum & SKB_FIRE)) + if (!(actions & SB_FIRE)) p->kickback_pic = 0; break; case BOAT_WEAPON: @@ -3205,7 +3205,7 @@ static void operateweapon(int snum, EDukeSyncBits sb_snum, int psect) { p->ammo_amount[POWDERKEG_WEAPON]--; p->gotweapon.Clear(POWDERKEG_WEAPON); - if (p->on_ground && (sb_snum & SKB_CROUCH) && !p->OnMotorcycle) + if (p->on_ground && (actions & SB_CROUCH) && !p->OnMotorcycle) { k = 15; i = ((p->gethorizsum() - 100) * 20); @@ -3336,14 +3336,14 @@ static void operateweapon(int snum, EDukeSyncBits sb_snum, int psect) // //--------------------------------------------------------------------------- -static void processweapon(int snum, EDukeSyncBits sb_snum, int psect) +static void processweapon(int snum, ESyncBits actions, EDukeSyncBits sb_snum, int psect) { auto p = &ps[snum]; int pi = p->i; auto s = &sprite[pi]; int shrunk = (s->yrepeat < 8); - if (sb_snum & SKB_FIRE) + if (actions & SB_FIRE) { int a = 0; } @@ -3374,20 +3374,20 @@ static void processweapon(int snum, EDukeSyncBits sb_snum, int psect) if (p->rapid_fire_hold == 1) { - if (sb_snum & SKB_FIRE) return; + if (actions & SB_FIRE) return; p->rapid_fire_hold = 0; } if (shrunk || p->tipincs || p->access_incs) - sb_snum &= ~SKB_FIRE; - else if (shrunk == 0 && (sb_snum & SKB_FIRE) && p->kickback_pic == 0 && p->fist_incs == 0 && + actions &= ~SB_FIRE; + else if (shrunk == 0 && (actions & SB_FIRE) && p->kickback_pic == 0 && p->fist_incs == 0 && p->last_weapon == -1 && (p->weapon_pos == 0 || p->holster_weapon == 1)) { fireweapon(snum); } else if (p->kickback_pic) { - operateweapon(snum, sb_snum, psect); + operateweapon(snum, actions, sb_snum, psect); } } @@ -3423,11 +3423,11 @@ void processinput_r(int snum) psect = p->cursectnum; if (p->OnMotorcycle && s->extra > 0) { - onMotorcycle(snum, sb_snum); + onMotorcycle(snum, actions, sb_snum); } else if (p->OnBoat && s->extra > 0) { - onBoat(snum, sb_snum); + onBoat(snum, actions, sb_snum); } if (psect == -1) { @@ -3510,7 +3510,7 @@ void processinput_r(int snum) if (!p->stairs) { p->stairs = 10; - if ((sb_snum & SKB_JUMP) && !p->OnMotorcycle) + if ((actions & SB_JUMP) && !p->OnMotorcycle) { hz = 0; cz = p->truecz; @@ -3560,7 +3560,7 @@ void processinput_r(int snum) if (!p->stairs) { p->stairs = 10; - if ((sb_snum & SKB_CROUCH) && !p->OnMotorcycle) + if ((actions & SB_CROUCH) && !p->OnMotorcycle) { cz = sprite[j].z; hz = 0; @@ -3572,7 +3572,7 @@ void processinput_r(int snum) } else if (sprite[j].picnum == TOILET || sprite[j].picnum == RRTILE2121) { - if ((sb_snum & SKB_CROUCH) && !p->OnMotorcycle) + if ((actions & SB_CROUCH) && !p->OnMotorcycle) //if (Sound[436].num == 0) { S_PlayActorSound(436, p->i); @@ -3634,7 +3634,7 @@ void processinput_r(int snum) fi.doincrements(p); - if (p->curr_weapon == THROWINGDYNAMITE_WEAPON) processweapon(snum, sb_snum, psect); + if (p->curr_weapon == THROWINGDYNAMITE_WEAPON) processweapon(snum, actions, sb_snum, psect); return; } @@ -3680,11 +3680,11 @@ void processinput_r(int snum) if (psectlotag == ST_2_UNDERWATER) { - underwater(snum, sb_snum, psect, fz, cz); + underwater(snum, actions, sb_snum, psect, fz, cz); } else { - movement(snum, sb_snum, psect, fz, cz, shrunk, truefdist, psectlotag); + movement(snum, actions, sb_snum, psect, fz, cz, shrunk, truefdist, psectlotag); } p->psectlotag = psectlotag; @@ -3780,7 +3780,7 @@ void processinput_r(int snum) p->posxv += ((sb_fvel * doubvel) << 6); p->posyv += ((sb_svel * doubvel) << 6); - if (!isRRRA() && ((p->curr_weapon == KNEE_WEAPON && p->kickback_pic > 10 && p->on_ground) || (p->on_ground && (sb_snum & SKB_CROUCH)))) + if (!isRRRA() && ((p->curr_weapon == KNEE_WEAPON && p->kickback_pic > 10 && p->on_ground) || (p->on_ground && (actions & SB_CROUCH)))) { p->posxv = mulscale(p->posxv, dukefriction - 0x2000, 16); p->posyv = mulscale(p->posyv, dukefriction - 0x2000, 16); @@ -4096,7 +4096,7 @@ HORIZONLY: else p->weapon_pos--; } - processweapon(snum, sb_snum, psect); + processweapon(snum, actions, sb_snum, psect); } //--------------------------------------------------------------------------- @@ -4105,17 +4105,17 @@ HORIZONLY: // //--------------------------------------------------------------------------- -void processmove_r(int snum, EDukeSyncBits sb_snum, int psect, int fz, int cz, int shrunk, int truefdist) +void processmove_r(int snum, ESyncBits actions, EDukeSyncBits sb_snum, int psect, int fz, int cz, int shrunk, int truefdist) { int psectlotag = sector[psect].lotag; auto p = &ps[snum]; if (psectlotag == ST_2_UNDERWATER) { - underwater(snum, sb_snum, psect, fz, cz); + underwater(snum, actions, sb_snum, psect, fz, cz); } else { - movement(snum, sb_snum, psect, fz, cz, shrunk, truefdist, psectlotag); + movement(snum, actions, sb_snum, psect, fz, cz, shrunk, truefdist, psectlotag); } } diff --git a/source/games/duke/src/player_w.cpp b/source/games/duke/src/player_w.cpp index 29466ea0b..9521c1ece 100644 --- a/source/games/duke/src/player_w.cpp +++ b/source/games/duke/src/player_w.cpp @@ -306,7 +306,7 @@ void fireweapon_ww(int snum) // //--------------------------------------------------------------------------- -void operateweapon_ww(int snum, EDukeSyncBits sb_snum, int psect) +void operateweapon_ww(int snum, ESyncBits actions, EDukeSyncBits sb_snum, int psect) { auto p = &ps[snum]; int pi = p->i; @@ -318,7 +318,7 @@ void operateweapon_ww(int snum, EDukeSyncBits sb_snum, int psect) { if (aplWeaponHoldDelay[p->curr_weapon][snum] // there is a hold delay && (p->kickback_pic == aplWeaponFireDelay[p->curr_weapon][snum]) // and we are 'at' hold - && (sb_snum & SKB_FIRE) // and 'fire' button is still down + && (actions & SB_FIRE) // and 'fire' button is still down ) // just hold here... { @@ -330,7 +330,7 @@ void operateweapon_ww(int snum, EDukeSyncBits sb_snum, int psect) { p->ammo_amount[p->curr_weapon]--; - if (p->on_ground && (sb_snum & SKB_CROUCH)) + if (p->on_ground && (actions & SB_CROUCH)) { k = 15; i = ((p->gethorizsum() - 100) * 20); @@ -374,7 +374,7 @@ void operateweapon_ww(int snum, EDukeSyncBits sb_snum, int psect) } else if (p->kickback_pic < aplWeaponHoldDelay[p->curr_weapon][snum] && - (sb_snum & SKB_CROUCH)) + (actions & SB_CROUCH)) { p->hbomb_hold_delay++; } @@ -461,7 +461,7 @@ void operateweapon_ww(int snum, EDukeSyncBits sb_snum, int psect) if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_AUTOMATIC) { // an 'automatic' - if ((sb_snum & SKB_FIRE) == 0) + if ((actions & SB_FIRE) == 0) { p->kickback_pic = aplWeaponTotalTime[p->curr_weapon][snum]; } @@ -518,7 +518,7 @@ void operateweapon_ww(int snum, EDukeSyncBits sb_snum, int psect) { if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_AUTOMATIC) { // an 'automatic' - if (sb_snum & SKB_FIRE) + if (actions & SB_FIRE) { // we are an AUTOMATIC. Fire again... if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_RANDOMRESTART) diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index 9906218cd..d03d3fda7 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -1520,7 +1520,7 @@ void checksectors_d(int snum) if (chatmodeon || sprite[p->i].extra <= 0) return; - if (ud.cashman && PlayerInput(snum, SKB_OPEN)) + if (ud.cashman && PlayerInput(snum, SB_OPEN)) fi.lotsofmoney(&sprite[p->i], 2); if (p->newowner >= 0) @@ -1532,7 +1532,7 @@ void checksectors_d(int snum) } } - if (!(PlayerInput(snum, SKB_OPEN)) && !PlayerInput(snum, SKB_ESCAPE)) + if (!(PlayerInput(snum, SB_OPEN)) && !PlayerInput(snum, SKB_ESCAPE)) p->toggle_key_flag = 0; else if (!p->toggle_key_flag) @@ -1740,7 +1740,7 @@ void checksectors_d(int snum) } } - if (!PlayerInput(snum, SKB_OPEN)) return; + if (!PlayerInput(snum, SB_OPEN)) return; else if (p->newowner >= 0) { i = -1; goto CLEARCAMERAS; } if (neartagwall == -1 && neartagsector == -1 && neartagsprite == -1) diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index 7803b606d..7430e9bfa 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -2484,11 +2484,11 @@ void checksectors_r(int snum) if (chatmodeon || sprite[p->i].extra <= 0) return; - if (ud.cashman && PlayerInput(snum, SKB_OPEN)) + if (ud.cashman && PlayerInput(snum, SB_OPEN)) fi.lotsofmoney(&sprite[p->i], 2); - if (!(PlayerInput(snum, SKB_OPEN)) && !PlayerInput(snum, SKB_ESCAPE)) + if (!(PlayerInput(snum, SB_OPEN)) && !PlayerInput(snum, SKB_ESCAPE)) p->toggle_key_flag = 0; else if (!p->toggle_key_flag) @@ -2709,7 +2709,7 @@ void checksectors_r(int snum) } } - if (!PlayerInput(snum, SKB_OPEN)) return; + if (!PlayerInput(snum, SB_OPEN)) return; if (neartagwall == -1 && neartagsector == -1 && neartagsprite == -1) if (abs(hits(p->i)) < 512) diff --git a/source/sw/src/input.cpp b/source/sw/src/input.cpp index 5941e0f85..60746b28d 100644 --- a/source/sw/src/input.cpp +++ b/source/sw/src/input.cpp @@ -323,12 +323,10 @@ getinput(InputPacket *loc, SWBOOL tied) #endif } - SET_LOC_KEY(loc->bits, SK_RUN, buttonMap.ButtonDown(gamefunc_Run)); - SET_LOC_KEY(loc->bits, SK_SHOOT, buttonMap.ButtonDown(gamefunc_Fire)); // actually snap - SET_LOC_KEY(loc->bits, SK_SNAP_UP, buttonMap.ButtonDown(gamefunc_Aim_Up)); - SET_LOC_KEY(loc->bits, SK_SNAP_DOWN, buttonMap.ButtonDown(gamefunc_Aim_Down)); + SET_LOC_KEY(loc->bits, SK_AIM_UP, buttonMap.ButtonDown(gamefunc_Aim_Up)); + SET_LOC_KEY(loc->bits, SK_AIM_DOWN, buttonMap.ButtonDown(gamefunc_Aim_Down)); // actually just look SET_LOC_KEY(loc->bits, SK_LOOK_UP, buttonMap.ButtonDown(gamefunc_Look_Up)); @@ -410,11 +408,6 @@ getinput(InputPacket *loc, SWBOOL tied) loc->setNewWeapon(which_weapon); } - - SET_LOC_KEY(loc->bits, SK_OPERATE, buttonMap.ButtonDown(gamefunc_Open)); - SET_LOC_KEY(loc->bits, SK_JUMP, buttonMap.ButtonDown(gamefunc_Jump)); - SET_LOC_KEY(loc->bits, SK_CRAWL, buttonMap.ButtonDown(gamefunc_Crouch)); - // need BUTTON SET_LOC_KEY(loc->bits, SK_CRAWL_LOCK, buttonMap.ButtonDown(gamefunc_Toggle_Crouch)); diff --git a/source/sw/src/panel.cpp b/source/sw/src/panel.cpp index eb85154a1..4cc12b940 100644 --- a/source/sw/src/panel.cpp +++ b/source/sw/src/panel.cpp @@ -465,9 +465,9 @@ int WeaponOperate(PLAYERp pp) if (!TEST(pp->sop->flags, SOBJ_HAS_WEAPON)) break; - if (TEST_SYNC_KEY(pp, SK_SHOOT)) + if (pp->input.actions & SB_FIRE) { - if (FLAG_KEY_PRESSED(pp, SK_SHOOT)) + if (pp->KeyPressBits & SB_FIRE) { if (!pp->FirePause) { @@ -693,7 +693,7 @@ WeaponOK(PLAYERp pp) return TRUE; } - FLAG_KEY_RELEASE(pp, SK_SHOOT); + pp->KeyPressBits &= ~SB_FIRE; FindWeaponNum = WPN_SHOTGUN; // Start at the top @@ -984,8 +984,7 @@ InitWeaponSword(PLAYERp pp) PlayerSound(DIGI_ILIKESWORD, v3df_follow|v3df_dontpan,pp); } - FLAG_KEY_RELEASE(psp->PlayerP, SK_SHOOT); - FLAG_KEY_RESET(psp->PlayerP, SK_SHOOT); + psp->PlayerP->KeyPressBits |= SB_FIRE; } @@ -1065,9 +1064,9 @@ pSwordSlideDown(PANEL_SPRITEp psp) if (psp->x < -40) { // if still holding down the fire key - continue swinging - if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT)) + if (psp->PlayerP->input.actions & SB_FIRE) { - if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT)) + if (psp->PlayerP->KeyPressBits & SB_FIRE) { DoPlayerChooseYell(psp->PlayerP); // continue to next state to swing right @@ -1150,9 +1149,9 @@ pSwordSlideDownR(PANEL_SPRITEp psp) if (psp->x > 350) { // if still holding down the fire key - continue swinging - if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT)) + if (psp->PlayerP->input.actions & SB_FIRE) { - if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT)) + if (psp->PlayerP->KeyPressBits & SB_FIRE) { DoPlayerChooseYell(psp->PlayerP); // back to action state @@ -1227,9 +1226,9 @@ pSwordRest(PANEL_SPRITEp psp) force = !!TEST(psp->flags, PANF_UNHIDE_SHOOT); - if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT) || force) + if ((psp->PlayerP->input.actions & SB_FIRE) || force) { - if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT) || force) + if ((psp->PlayerP->KeyPressBits & SB_FIRE) || force) { RESET(psp->flags, PANF_UNHIDE_SHOOT); @@ -1361,9 +1360,9 @@ PANEL_STATE ps_RetractStar[] = void pStarRestTest(PANEL_SPRITEp psp) { - if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT)) + if (psp->PlayerP->input.actions & SB_FIRE) { - if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT)) + if (psp->PlayerP->KeyPressBits & SB_FIRE) { if (!WeaponOK(psp->PlayerP)) return; @@ -1439,8 +1438,7 @@ InitWeaponStar(PLAYERp pp) PlayerSound(DIGI_ILIKESHURIKEN, v3df_follow|v3df_dontpan,pp); } - FLAG_KEY_RELEASE(psp->PlayerP, SK_SHOOT); - FLAG_KEY_RESET(psp->PlayerP, SK_SHOOT); + psp->PlayerP->KeyPressBits |= SB_FIRE; } void @@ -1518,9 +1516,9 @@ pStarRest(PANEL_SPRITEp psp) pStarBobSetup(psp); pWeaponBob(psp, PLAYER_MOVING(psp->PlayerP)); - if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT) || force) + if ((psp->PlayerP->input.actions & SB_FIRE) || force) { - if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT) || force) + if ((psp->PlayerP->KeyPressBits & SB_FIRE) || force) { RESET(psp->flags, PANF_UNHIDE_SHOOT); @@ -2156,8 +2154,7 @@ InitWeaponUzi(PLAYERp pp) PlaySound(DIGI_UZI_UP, pp, v3df_follow); - FLAG_KEY_RELEASE(psp->PlayerP, SK_SHOOT); - FLAG_KEY_RESET(psp->PlayerP, SK_SHOOT); + psp->PlayerP->KeyPressBits |= SB_FIRE; } PANEL_SPRITEp @@ -2358,7 +2355,7 @@ pUziRest(PANEL_SPRITEp psp) SetVisNorm(); - shooting = TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT) && FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT); + shooting = (psp->PlayerP->input.actions & SB_FIRE) && (psp->PlayerP->KeyPressBits & SB_FIRE); shooting |= force; pUziBobSetup(psp); @@ -2383,7 +2380,7 @@ pUziAction(PANEL_SPRITEp psp) char shooting; static SWBOOL alternate = FALSE; - shooting = TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT) && FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT); + shooting = (psp->PlayerP->input.actions & SB_FIRE) && (psp->PlayerP->KeyPressBits & SB_FIRE); if (shooting) { @@ -2803,8 +2800,7 @@ InitWeaponShotgun(PLAYERp pp) PlaySound(DIGI_SHOTGUN_UP, pp, v3df_follow); - FLAG_KEY_RELEASE(psp->PlayerP, SK_SHOOT); - FLAG_KEY_RESET(psp->PlayerP, SK_SHOOT); + psp->PlayerP->KeyPressBits |= SB_FIRE; } void @@ -3056,9 +3052,9 @@ pShotgunRest(PANEL_SPRITEp psp) pWeaponBob(psp, PLAYER_MOVING(psp->PlayerP)); - if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT) || force) + if ((psp->PlayerP->input.actions & SB_FIRE) || force) { - if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT) || force) + if ((psp->PlayerP->KeyPressBits & SB_FIRE) || force) { RESET(psp->flags, PANF_UNHIDE_SHOOT); @@ -3100,9 +3096,9 @@ pShotgunRestTest(PANEL_SPRITEp psp) pShotgunBobSetup(psp); pWeaponBob(psp, PLAYER_MOVING(psp->PlayerP)); - if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT) || force) + if ((psp->PlayerP->input.actions & SB_FIRE) || force) { - if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT) || force) + if ((psp->PlayerP->KeyPressBits & SB_FIRE) || force) { RESET(psp->flags, PANF_UNHIDE_SHOOT); @@ -3315,8 +3311,7 @@ InitWeaponRail(PLAYERp pp) PlaySound(DIGI_RAILREADY, pp, v3df_follow | v3df_dontpan, CHAN_ITEM); // this one needs to be on a dedicated channel to allow switching it off without too many checks. Set3DSoundOwner(psp->PlayerP->PlayerSprite); - FLAG_KEY_RELEASE(psp->PlayerP, SK_SHOOT); - FLAG_KEY_RESET(psp->PlayerP, SK_SHOOT); + psp->PlayerP->KeyPressBits |= SB_FIRE; } void @@ -3460,9 +3455,9 @@ pRailRest(PANEL_SPRITEp psp) pRailBobSetup(psp); pWeaponBob(psp, PLAYER_MOVING(psp->PlayerP)); - if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT) || force) + if ((psp->PlayerP->input.actions & SB_FIRE) || force) { - if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT) || force) + if ((psp->PlayerP->KeyPressBits & SB_FIRE) || force) { RESET(psp->flags, PANF_UNHIDE_SHOOT); @@ -3493,9 +3488,9 @@ pRailRestTest(PANEL_SPRITEp psp) pRailBobSetup(psp); pWeaponBob(psp, PLAYER_MOVING(psp->PlayerP)); - if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT) || force) + if ((psp->PlayerP->input.actions & SB_FIRE) || force) { - if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT) || force) + if ((psp->PlayerP->KeyPressBits & SB_FIRE) || force) { RESET(psp->flags, PANF_UNHIDE_SHOOT); @@ -3773,8 +3768,7 @@ InitWeaponHothead(PLAYERp pp) psp->ang = 768; psp->vel = 512; - FLAG_KEY_RELEASE(psp->PlayerP, SK_SHOOT); - FLAG_KEY_RESET(psp->PlayerP, SK_SHOOT); + psp->PlayerP->KeyPressBits |= SB_FIRE; pHotHeadOverlays(psp, pp->WpnFlameType); psp->over[0].xoff = HOTHEAD_FINGER_XOFF; psp->over[0].yoff = HOTHEAD_FINGER_YOFF; @@ -3785,9 +3779,9 @@ InitWeaponHothead(PLAYERp pp) void pHotheadRestTest(PANEL_SPRITEp psp) { - if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT)) + if (psp->PlayerP->input.actions & SB_FIRE) { - if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT)) + if (psp->PlayerP->KeyPressBits & SB_FIRE) { //if (!TEST(psp->PlayerP->Flags,PF_DIVING)) { @@ -3883,9 +3877,9 @@ pHotheadRest(PANEL_SPRITEp psp) pHotheadBobSetup(psp); pWeaponBob(psp, PLAYER_MOVING(psp->PlayerP)); - if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT) || force) + if ((psp->PlayerP->input.actions & SB_FIRE) || force) { - if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT) || force) + if ((psp->PlayerP->KeyPressBits & SB_FIRE) || force) { RESET(psp->flags, PANF_UNHIDE_SHOOT); @@ -3917,7 +3911,7 @@ pHotheadAction(PANEL_SPRITEp psp) { char shooting; - shooting = TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT) && FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT); + shooting = (psp->PlayerP->input.actions & SB_FIRE) && (psp->PlayerP->KeyPressBits & SB_FIRE); if (shooting) { @@ -4216,8 +4210,7 @@ InitWeaponMicro(PLAYERp pp) PlaySound(DIGI_ROCKET_UP, pp, v3df_follow); - FLAG_KEY_RELEASE(psp->PlayerP, SK_SHOOT); - FLAG_KEY_RESET(psp->PlayerP, SK_SHOOT); + psp->PlayerP->KeyPressBits |= SB_FIRE; } @@ -4467,9 +4460,9 @@ pMicroRest(PANEL_SPRITEp psp) } } - if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT) || force) + if ((psp->PlayerP->input.actions & SB_FIRE) || force) { - if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT) || force) + if ((psp->PlayerP->KeyPressBits & SB_FIRE) || force) { RESET(psp->flags, PANF_UNHIDE_SHOOT); @@ -4729,8 +4722,7 @@ InitWeaponHeart(PLAYERp pp) psp->RestState = ps_HeartRest; pSetState(psp, psp->PresentState); - FLAG_KEY_RELEASE(psp->PlayerP, SK_SHOOT); - FLAG_KEY_RESET(psp->PlayerP, SK_SHOOT); + psp->PlayerP->KeyPressBits |= SB_FIRE; } void @@ -4798,11 +4790,11 @@ pHeartRest(PANEL_SPRITEp psp) pHeartBobSetup(psp); pWeaponBob(psp, PLAYER_MOVING(psp->PlayerP)); - if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT) || force) + if ((psp->PlayerP->input.actions & SB_FIRE) || force) { - if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT) || force) + if ((psp->PlayerP->KeyPressBits & SB_FIRE) || force) { - FLAG_KEY_RELEASE(psp->PlayerP, SK_SHOOT); + psp->PlayerP->KeyPressBits &= ~SB_FIRE; RESET(psp->flags, PANF_UNHIDE_SHOOT); if (!WeaponOK(psp->PlayerP)) @@ -4814,7 +4806,7 @@ pHeartRest(PANEL_SPRITEp psp) } else { - FLAG_KEY_RESET(psp->PlayerP, SK_SHOOT); + psp->PlayerP->KeyPressBits |= SB_FIRE; WeaponOK(psp->PlayerP); } } @@ -5232,8 +5224,7 @@ InitWeaponGrenade(PLAYERp pp) PlaySound(DIGI_GRENADE_UP, pp, v3df_follow); - FLAG_KEY_RELEASE(psp->PlayerP, SK_SHOOT); - FLAG_KEY_RESET(psp->PlayerP, SK_SHOOT); + psp->PlayerP->KeyPressBits |= SB_FIRE; } void @@ -5380,9 +5371,9 @@ pGrenadeRest(PANEL_SPRITEp psp) pGrenadeBobSetup(psp); pWeaponBob(psp, PLAYER_MOVING(psp->PlayerP)); - if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT) || force) + if ((psp->PlayerP->input.actions & SB_FIRE) || force) { - if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT) || force) + if ((psp->PlayerP->KeyPressBits & SB_FIRE) || force) { RESET(psp->flags, PANF_UNHIDE_SHOOT); @@ -5530,8 +5521,7 @@ InitWeaponMine(PLAYERp pp) PlaySound(DIGI_PULL, pp, v3df_follow|v3df_dontpan); - FLAG_KEY_RELEASE(psp->PlayerP, SK_SHOOT); - FLAG_KEY_RESET(psp->PlayerP, SK_SHOOT); + psp->PlayerP->KeyPressBits |= SB_FIRE; } void @@ -5630,9 +5620,9 @@ pMineRest(PANEL_SPRITEp psp) pMineBobSetup(psp); pWeaponBob(psp, PLAYER_MOVING(psp->PlayerP)); - if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT) || force) + if ((psp->PlayerP->input.actions & SB_FIRE) || force) { - if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT) || force) + if ((psp->PlayerP->KeyPressBits & SB_FIRE) || force) { RESET(psp->flags, PANF_UNHIDE_SHOOT); @@ -6197,8 +6187,7 @@ InitWeaponFist(PLAYERp pp) else if (rnd_num > 700) PlaySound(DIGI_PLAYERYELL2, pp, v3df_follow|v3df_dontpan); - FLAG_KEY_RELEASE(psp->PlayerP, SK_SHOOT); - FLAG_KEY_RESET(psp->PlayerP, SK_SHOOT); + psp->PlayerP->KeyPressBits |= SB_FIRE; } @@ -6298,9 +6287,9 @@ pFistSlideDown(PANEL_SPRITEp psp) if (psp->y > 440) { // if still holding down the fire key - continue swinging - if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT)) + if (psp->PlayerP->input.actions & SB_FIRE) { - if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT)) + if (psp->PlayerP->KeyPressBits & SB_FIRE) { DoPlayerChooseYell(psp->PlayerP); @@ -6417,9 +6406,9 @@ pFistSlideDownR(PANEL_SPRITEp psp) if (psp->y > 440) { // if still holding down the fire key - continue swinging - if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT)) + if (psp->PlayerP->input.actions & SB_FIRE) { - if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT)) + if (psp->PlayerP->KeyPressBits & SB_FIRE) { DoPlayerChooseYell(psp->PlayerP); @@ -6520,11 +6509,11 @@ pFistRest(PANEL_SPRITEp psp) // Reset move to default psp->PlayerP->WpnKungFuMove = 0; - //if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT) || force || TEST_SYNC_KEY(psp->PlayerP, SK_OPERATE)) - if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT) || force) + //if ((psp->PlayerP->input.actions & SB_FIRE) || force || TEST_SYNC_KEY(psp->PlayerP, SK_OPERATE)) + if ((psp->PlayerP->input.actions & SB_FIRE) || force) { - //if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT) || force || FLAG_KEY_PRESSED(psp->PlayerP, SK_OPERATE)) - if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT) || force) + //if ((psp->PlayerP->KeyPressBits & SB_FIRE) || force || FLAG_KEY_PRESSED(psp->PlayerP, SK_OPERATE)) + if ((psp->PlayerP->KeyPressBits & SB_FIRE) || force) { RESET(psp->flags, PANF_UNHIDE_SHOOT); @@ -6585,7 +6574,7 @@ pFistBlock(PANEL_SPRITEp psp) pFistBobSetup(psp); pWeaponBob(psp, PLAYER_MOVING(psp->PlayerP)); - if (!TEST_SYNC_KEY(psp->PlayerP, SK_OPERATE)) + if (!(psp->PlayerP->input.actions & SB_OPEN)) { pStatePlusOne(psp); } @@ -6641,9 +6630,9 @@ pWeaponUnHideKeys(PANEL_SPRITEp psp, PANEL_STATEp state) psp->PlayerP->KeyPressBits |= SB_HOLSTER; } - if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT)) + if (psp->PlayerP->input.actions & SB_FIRE) { - if (FLAG_KEY_PRESSED(psp->PlayerP, SK_SHOOT)) + if (psp->PlayerP->KeyPressBits & SB_FIRE) { SET(psp->flags, PANF_UNHIDE_SHOOT); pSetState(psp, state); diff --git a/source/sw/src/player.cpp b/source/sw/src/player.cpp index 51b389f3f..724fc9505 100644 --- a/source/sw/src/player.cpp +++ b/source/sw/src/player.cpp @@ -1957,13 +1957,13 @@ DoPlayerHorizon(PLAYERp pp, fix16_t *pq16horiz, fix16_t q16aimvel) } // this is the locked type - if (TEST_SYNC_KEY(pp, SK_SNAP_UP) || TEST_SYNC_KEY(pp, SK_SNAP_DOWN)) + if (TEST_SYNC_KEY(pp, SK_AIM_UP) || TEST_SYNC_KEY(pp, SK_AIM_DOWN)) { // set looking because player is manually looking SET(pp->Flags, PF_LOCK_HORIZ | PF_LOOKING); // adjust *pq16horiz negative - if (TEST_SYNC_KEY(pp, SK_SNAP_DOWN)) + if (TEST_SYNC_KEY(pp, SK_AIM_DOWN)) { if (PedanticMode) pp->q16horizbase -= fix16_from_int((HORIZ_SPEED/2)); @@ -1972,7 +1972,7 @@ DoPlayerHorizon(PLAYERp pp, fix16_t *pq16horiz, fix16_t q16aimvel) } // adjust *pq16horiz positive - if (TEST_SYNC_KEY(pp, SK_SNAP_UP)) + if (TEST_SYNC_KEY(pp, SK_AIM_UP)) { if (PedanticMode) pp->q16horizbase += fix16_from_int((HORIZ_SPEED/2)); @@ -3485,16 +3485,16 @@ DoPlayerJump(PLAYERp pp) short i; // reset flag key for double jumps - if (!TEST_SYNC_KEY(pp, SK_JUMP)) + if (!(pp->input.actions & SB_JUMP)) { - FLAG_KEY_RESET(pp, SK_JUMP); + pp->KeyPressBits |= SB_JUMP; } // instead of multiplying by synctics, use a loop for greater accuracy for (i = 0; i < synctics; i++) { // PlayerGravity += synctics; // See how increase gravity as we go? - if (TEST_SYNC_KEY(pp, SK_JUMP)) + if (pp->input.actions & SB_JUMP) { if (pp->JumpDuration > 0) { @@ -3650,9 +3650,9 @@ DoPlayerFall(PLAYERp pp) int depth; // reset flag key for double jumps - if (!TEST_SYNC_KEY(pp, SK_JUMP)) + if (!(pp->input.actions & SB_JUMP)) { - FLAG_KEY_RESET(pp, SK_JUMP); + pp->KeyPressBits |= SB_JUMP; } if (pp->cursectnum >= 0 && SectorIsUnderwaterArea(pp->cursectnum)) @@ -3727,7 +3727,7 @@ DoPlayerFall(PLAYERp pp) StopPlayerSound(pp, DIGI_FALLSCREAM); // i any kind of crawl key get rid of recoil - if (DoPlayerTestCrawl(pp) || TEST_SYNC_KEY(pp, SK_CRAWL)) + if (DoPlayerTestCrawl(pp) || (pp->input.actions & SB_CROUCH)) { pp->posz = pp->loz - PLAYER_CRAWL_HEIGHT; } @@ -3767,7 +3767,7 @@ DoPlayerFall(PLAYERp pp) return; } - if (TEST_SYNC_KEY(pp, SK_CRAWL)) + if (pp->input.actions & SB_CROUCH) { StackedWaterSplash(pp); DoPlayerBeginCrawl(pp); @@ -3856,7 +3856,7 @@ DoPlayerClimb(PLAYERp pp) // need to rewrite this for FAF stuff // Jump off of the ladder - if (TEST_SYNC_KEY(pp, SK_JUMP)) + if (pp->input.actions & SB_JUMP) { RESET(pp->Flags, PF_CLIMBING|PF_WEAPON_DOWN); RESET(sp->cstat, CSTAT_SPRITE_YCENTER); @@ -4188,7 +4188,7 @@ DoPlayerCrawl(PLAYERp pp) } // Jump to get up - if (TEST_SYNC_KEY(pp, SK_JUMP)) + if (pp->input.actions & SB_JUMP) { if (labs(pp->loz - pp->hiz) >= PLAYER_STANDING_ROOM) { @@ -4204,7 +4204,7 @@ DoPlayerCrawl(PLAYERp pp) else { // Let off of crawl to get up - if (!TEST_SYNC_KEY(pp, SK_CRAWL)) + if (!(pp->input.actions & SB_CROUCH)) { if (labs(pp->loz - pp->hiz) >= PLAYER_STANDING_ROOM) { @@ -4331,7 +4331,7 @@ DoPlayerFly(PLAYERp pp) return; } - if (TEST_SYNC_KEY(pp, SK_CRAWL)) + if (pp->input.actions & SB_CROUCH) { pp->z_speed += PLAYER_FLY_INC; @@ -4339,7 +4339,7 @@ DoPlayerFly(PLAYERp pp) pp->z_speed = PLAYER_FLY_MAX_SPEED; } - if (TEST_SYNC_KEY(pp, SK_JUMP)) + if (pp->input.actions & SB_JUMP) { pp->z_speed -= PLAYER_FLY_INC; @@ -4550,7 +4550,7 @@ PlayerCanDive(PLAYERp pp) return FALSE; // Crawl - check for diving - if (TEST_SYNC_KEY(pp, SK_CRAWL) || pp->jump_speed > 0) + if ((pp->input.actions & SB_CROUCH) || pp->jump_speed > 0) { if (PlayerInDiveArea(pp)) { @@ -5183,7 +5183,7 @@ DoPlayerDive(PLAYERp pp) } } - if (TEST_SYNC_KEY(pp, SK_CRAWL)) + if (pp->input.actions & SB_CROUCH) { pp->z_speed += PLAYER_DIVE_INC; @@ -5191,7 +5191,7 @@ DoPlayerDive(PLAYERp pp) pp->z_speed = PLAYER_DIVE_MAX_SPEED; } - if (TEST_SYNC_KEY(pp, SK_JUMP)) + if (pp->input.actions & SB_JUMP) { pp->z_speed -= PLAYER_DIVE_INC; @@ -5456,13 +5456,13 @@ DoPlayerWade(PLAYERp pp) if (DebugOperate) { - if (TEST_SYNC_KEY(pp, SK_OPERATE)) + if (pp->input.actions & SB_OPEN) { - if (FLAG_KEY_PRESSED(pp, SK_OPERATE)) + if (pp->KeyPressBits & SB_OPEN) { if (TEST(sector[pp->cursectnum].extra, SECTFX_OPERATIONAL)) { - FLAG_KEY_RELEASE(pp, SK_OPERATE); + pp->KeyPressBits &= ~SB_OPEN; DoPlayerBeginOperate(pp); pp->bob_amt = 0; pp->bob_ndx = 0; @@ -5472,7 +5472,7 @@ DoPlayerWade(PLAYERp pp) } else { - FLAG_KEY_RESET(pp, SK_OPERATE); + pp->KeyPressBits |= SB_OPEN; } } @@ -5484,17 +5484,17 @@ DoPlayerWade(PLAYERp pp) } // Crawl Commanded - if (TEST_SYNC_KEY(pp, SK_CRAWL) && pp->WadeDepth <= PLAYER_CRAWL_WADE_DEPTH) + if ((pp->input.actions & SB_CROUCH) && pp->WadeDepth <= PLAYER_CRAWL_WADE_DEPTH) { DoPlayerBeginCrawl(pp); return; } - if (TEST_SYNC_KEY(pp, SK_JUMP)) + if (pp->input.actions & SB_JUMP) { - if (FLAG_KEY_PRESSED(pp, SK_JUMP)) + if (pp->KeyPressBits & SB_JUMP) { - FLAG_KEY_RELEASE(pp, SK_JUMP); + pp->KeyPressBits &= ~SB_JUMP; //DoPlayerHeight(pp); //DoPlayerHeight(pp); //DoPlayerHeight(pp); @@ -5507,7 +5507,7 @@ DoPlayerWade(PLAYERp pp) } else { - FLAG_KEY_RESET(pp, SK_JUMP); + pp->KeyPressBits |= SB_JUMP; } if (PlayerFlyKey()) @@ -5980,18 +5980,18 @@ DoPlayerOperateTurret(PLAYERp pp) { short save_sectnum; - if (TEST_SYNC_KEY(pp, SK_OPERATE)) + if (pp->input.actions & SB_OPEN) { - if (FLAG_KEY_PRESSED(pp, SK_OPERATE)) + if (pp->KeyPressBits & SB_OPEN) { - FLAG_KEY_RELEASE(pp, SK_OPERATE); + pp->KeyPressBits &= ~SB_OPEN; DoPlayerStopOperate(pp); return; } } else { - FLAG_KEY_RESET(pp, SK_OPERATE); + pp->KeyPressBits |= SB_OPEN; } if (pp->sop->max_damage != -9999 && pp->sop->max_damage <= 0) @@ -6020,18 +6020,18 @@ DoPlayerOperateBoat(PLAYERp pp) { short save_sectnum; - if (TEST_SYNC_KEY(pp, SK_OPERATE)) + if (pp->input.actions & SB_OPEN) { - if (FLAG_KEY_PRESSED(pp, SK_OPERATE)) + if (pp->KeyPressBits & SB_OPEN) { - FLAG_KEY_RELEASE(pp, SK_OPERATE); + pp->KeyPressBits &= ~SB_OPEN; DoPlayerStopOperate(pp); return; } } else { - FLAG_KEY_RESET(pp, SK_OPERATE); + pp->KeyPressBits |= SB_OPEN; } if (pp->sop->max_damage != -9999 && pp->sop->max_damage <= 0) @@ -6060,18 +6060,18 @@ DoPlayerOperateTank(PLAYERp pp) short save_sectnum; //ASSERT(!TEST_SYNC_KEY(pp, SK_OPERATE)); - if (TEST_SYNC_KEY(pp, SK_OPERATE)) + if (pp->input.actions & SB_OPEN) { - if (FLAG_KEY_PRESSED(pp, SK_OPERATE)) + if (pp->KeyPressBits & SB_OPEN) { - FLAG_KEY_RELEASE(pp, SK_OPERATE); + pp->KeyPressBits &= ~SB_OPEN; DoPlayerStopOperate(pp); return; } } else { - FLAG_KEY_RESET(pp, SK_OPERATE); + pp->KeyPressBits |= SB_OPEN; } if (pp->sop->max_damage != -9999 && pp->sop->max_damage <= 0) @@ -6574,9 +6574,9 @@ void DoPlayerDeathHurl(PLAYERp pp) { if (numplayers > 1) { - if (TEST_SYNC_KEY(pp, SK_SHOOT)) + if (pp->input.actions & SB_FIRE) { - if (FLAG_KEY_PRESSED(pp, SK_SHOOT)) + if (pp->KeyPressBits & SB_FIRE) { @@ -6637,7 +6637,7 @@ void DoPlayerDeathCheckKeys(PLAYERp pp) SPRITEp sp = pp->SpriteP; USERp u = User[pp->PlayerSprite]; - //if (TEST_SYNC_KEY(pp, SK_OPERATE)) + //if (pp->input.actions & SB_OPEN) if (TEST_SYNC_KEY(pp, SK_SPACE_BAR)) { // Spawn a dead LoWang body for non-head deaths @@ -7139,18 +7139,18 @@ DoPlayerRun(PLAYERp pp) } // Crawl Commanded - if (TEST_SYNC_KEY(pp, SK_CRAWL)) + if (pp->input.actions & SB_CROUCH) { DoPlayerBeginCrawl(pp); return; } // Jump - if (TEST_SYNC_KEY(pp, SK_JUMP)) + if (pp->input.actions & SB_JUMP) { - if (FLAG_KEY_PRESSED(pp, SK_JUMP)) + if (pp->KeyPressBits & SB_JUMP) { - FLAG_KEY_RELEASE(pp, SK_JUMP); + pp->KeyPressBits &= ~SB_JUMP; // make sure you stand at full heights for jumps/double jumps //DoPlayerHeight(pp); //DoPlayerHeight(pp); @@ -7164,7 +7164,7 @@ DoPlayerRun(PLAYERp pp) } else { - FLAG_KEY_RESET(pp, SK_JUMP); + pp->KeyPressBits |= SB_JUMP; } // Crawl lock @@ -7193,13 +7193,13 @@ DoPlayerRun(PLAYERp pp) { if (!TEST(pp->Flags, PF_DEAD) && !Prediction) { - if (TEST_SYNC_KEY(pp, SK_OPERATE)) + if (pp->input.actions & SB_OPEN) { - if (FLAG_KEY_PRESSED(pp, SK_OPERATE) && pp->cursectnum >= 0) + if ((pp->KeyPressBits & SB_OPEN) && pp->cursectnum >= 0) { if (TEST(sector[pp->cursectnum].extra, SECTFX_OPERATIONAL)) { - FLAG_KEY_RELEASE(pp, SK_OPERATE); + pp->KeyPressBits &= ~SB_OPEN; DoPlayerBeginOperate(pp); return; } @@ -7211,7 +7211,7 @@ DoPlayerRun(PLAYERp pp) if (sp && SP_TAG5(sp) == TRIGGER_TYPE_REMOTE_SO) { pp->remote_sprite = sp; - FLAG_KEY_RELEASE(pp, SK_OPERATE); + pp->KeyPressBits &= ~SB_OPEN; ASSERT(pp->remote_sprite); DoPlayerBeginRemoteOperate(pp, &SectorObject[SP_TAG7(pp->remote_sprite)]); return; @@ -7221,7 +7221,7 @@ DoPlayerRun(PLAYERp pp) } else { - FLAG_KEY_RESET(pp, SK_OPERATE); + pp->KeyPressBits |= SB_OPEN; } } } diff --git a/source/sw/src/predict.cpp b/source/sw/src/predict.cpp index a7892620b..56094b50a 100644 --- a/source/sw/src/predict.cpp +++ b/source/sw/src/predict.cpp @@ -83,15 +83,13 @@ DoPrediction(PLAYERp ppp) // get rid of input bits so it doesn't go into other code branches that would // get it out of sync - ppp->input.actions &= ~(SB_WEAPONMASK_BITS|SB_ITEMUSE_BITS|SB_HOLSTER|SB_CENTERVIEW); - ppp->KeyPressBits |= (SB_WEAPONMASK_BITS|SB_ITEMUSE_BITS|SB_INVNEXT|SB_INVPREV|SB_INVUSE|SB_HOLSTER|SB_CENTERVIEW); + ppp->input.actions &= ~(SB_WEAPONMASK_BITS|SB_ITEMUSE_BITS|SB_INVNEXT|SB_INVPREV|SB_INVUSE|SB_HOLSTER|SB_CENTERVIEW|SB_FIRE|SB_OPEN);; + ppp->KeyPressBits |= (SB_WEAPONMASK_BITS|SB_ITEMUSE_BITS|SB_INVNEXT|SB_INVPREV|SB_INVUSE|SB_HOLSTER|SB_CENTERVIEW|SB_FIRE|SB_OPEN); RESET(ppp->input.bits, - BIT(SK_SHOOT)|BIT(SK_OPERATE)| BIT(SK_AUTO_AIM) ); SET(ppp->KeyPressFlags, - BIT(SK_SHOOT)|BIT(SK_OPERATE)| BIT(SK_AUTO_AIM) ); diff --git a/source/sw/src/sector.cpp b/source/sw/src/sector.cpp index 7d5c4092f..58a2cb98c 100644 --- a/source/sw/src/sector.cpp +++ b/source/sw/src/sector.cpp @@ -2585,9 +2585,9 @@ PlayerOperateEnv(PLAYERp pp) // Switch & door activations // - if (TEST_SYNC_KEY(pp, SK_OPERATE)) + if (pp->input.actions & SB_OPEN) { - if (FLAG_KEY_PRESSED(pp, SK_OPERATE)) + if (pp->KeyPressBits & SB_OPEN) { // if space bar pressed short nt_ndx; @@ -2595,7 +2595,7 @@ PlayerOperateEnv(PLAYERp pp) if (DoPlayerGrabStar(pp)) { - FLAG_KEY_RELEASE(pp, SK_OPERATE); + pp->KeyPressBits &= ~SB_OPEN; } else { @@ -2613,7 +2613,7 @@ PlayerOperateEnv(PLAYERp pp) { if (OperateSprite(nti[nt_ndx].spritenum, TRUE)) { - FLAG_KEY_RELEASE(pp, SK_OPERATE); + pp->KeyPressBits &= ~SB_OPEN; found = TRUE; } } @@ -2642,7 +2642,7 @@ PlayerOperateEnv(PLAYERp pp) { if (OperateSprite(nti[nt_ndx].spritenum, TRUE)) { - FLAG_KEY_RELEASE(pp, SK_OPERATE); + pp->KeyPressBits &= ~SB_OPEN; break; } } @@ -2663,7 +2663,7 @@ PlayerOperateEnv(PLAYERp pp) if (OperateSector(neartagsector, TRUE)) { // Release the key - FLAG_KEY_RELEASE(pp, SK_OPERATE); + pp->KeyPressBits &= ~SB_OPEN; } } @@ -2671,7 +2671,7 @@ PlayerOperateEnv(PLAYERp pp) { if (OperateWall(neartagwall, TRUE)) { - FLAG_KEY_RELEASE(pp, SK_OPERATE); + pp->KeyPressBits &= ~SB_OPEN; } } } @@ -2690,11 +2690,11 @@ PlayerOperateEnv(PLAYERp pp) break; case TAG_SPRING_BOARD: DoSpringBoard(pp/*, pp->cursectnum*/); - FLAG_KEY_RELEASE(pp, SK_OPERATE); + pp->KeyPressBits &= ~SB_OPEN; break; case TAG_DOOR_ROTATE: if (OperateSector(pp->cursectnum, TRUE)) - FLAG_KEY_RELEASE(pp, SK_OPERATE); + pp->KeyPressBits &= ~SB_OPEN; break; } } @@ -2702,7 +2702,7 @@ PlayerOperateEnv(PLAYERp pp) else { // Reset the key when syncbit key is not in use - FLAG_KEY_RESET(pp, SK_OPERATE); + pp->KeyPressBits |= SB_OPEN; } // ////////////////////////////