From 3fc79940f2b0a843efd47fe47cb6864b2f943fad Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 26 Aug 2020 16:48:33 +0200 Subject: [PATCH] - merged the bit fields in Blood's packet structure. Whatever this was for it made that thing extremely unwieldy. With these merged the resulting structure doesn't look much different from Duke's anymore. --- source/blood/src/actor.cpp | 2 +- source/blood/src/blood.cpp | 21 ++++--- source/blood/src/controls.cpp | 48 ++++++++-------- source/blood/src/controls.h | 48 ++++------------ source/blood/src/nnexts.cpp | 16 +++--- source/blood/src/player.cpp | 96 ++++++++++++++++---------------- source/blood/src/player.h | 10 +--- source/blood/src/prediction.cpp | 33 ++++++----- source/blood/src/weapon.cpp | 98 ++++++++++++++++----------------- 9 files changed, 165 insertions(+), 207 deletions(-) diff --git a/source/blood/src/actor.cpp b/source/blood/src/actor.cpp index cd0d9e8e6..f71f763ae 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.buttonFlags.jump) { + if (!pPlayer->cantJump && pPlayer->input.syncFlags.jump) { zvel[nSprite] = -0x6aaaa; pPlayer->cantJump = 1; } diff --git a/source/blood/src/blood.cpp b/source/blood/src/blood.cpp index 160076986..f1901c765 100644 --- a/source/blood/src/blood.cpp +++ b/source/blood/src/blood.cpp @@ -525,11 +525,10 @@ void ProcessFrame(void) char buffer[128]; for (int i = connecthead; i >= 0; i = connectpoint2[i]) { - gPlayer[i].input.buttonFlags = gFifoInput[gNetFifoTail&255][i].buttonFlags; - gPlayer[i].input.keyFlags.word |= gFifoInput[gNetFifoTail&255][i].keyFlags.word; - gPlayer[i].input.useFlags.byte |= gFifoInput[gNetFifoTail&255][i].useFlags.byte; - if (gFifoInput[gNetFifoTail&255][i].newWeapon) - gPlayer[i].input.newWeapon = gFifoInput[gNetFifoTail&255][i].newWeapon; + gPlayer[i].input.syncFlags.value &= ~flag_buttonmask; + gPlayer[i].input.syncFlags.value |= gFifoInput[gNetFifoTail & 255][i].syncFlags.value; + if (gFifoInput[gNetFifoTail&255][i].syncFlags.newWeapon) + gPlayer[i].newWeapon = gFifoInput[gNetFifoTail&255][i].syncFlags.newWeapon; gPlayer[i].input.forward = gFifoInput[gNetFifoTail&255][i].forward; gPlayer[i].input.q16turn = gFifoInput[gNetFifoTail&255][i].q16turn; gPlayer[i].input.strafe = gFifoInput[gNetFifoTail&255][i].strafe; @@ -539,9 +538,9 @@ void ProcessFrame(void) for (int i = connecthead; i >= 0; i = connectpoint2[i]) { - if (gPlayer[i].input.keyFlags.quit) + if (gPlayer[i].input.syncFlags.quit) { - gPlayer[i].input.keyFlags.quit = 0; + gPlayer[i].input.syncFlags.quit = 0; netBroadcastPlayerLogoff(i); if (i == myconnectindex) { @@ -553,15 +552,15 @@ void ProcessFrame(void) return; } } - if (gPlayer[i].input.keyFlags.restart) + if (gPlayer[i].input.syncFlags.restart) { - gPlayer[i].input.keyFlags.restart = 0; + gPlayer[i].input.syncFlags.restart = 0; levelRestart(); return; } - if (gPlayer[i].input.keyFlags.pause) + if (gPlayer[i].input.syncFlags.pause) { - gPlayer[i].input.keyFlags.pause = 0; + gPlayer[i].input.syncFlags.pause = 0; if (paused && gGameOptions.nGameType > 0 && numplayers > 1) { sprintf(buffer,"%s paused the game",gProfile[i].name); diff --git a/source/blood/src/controls.cpp b/source/blood/src/controls.cpp index 5459d0204..31cb1b893 100644 --- a/source/blood/src/controls.cpp +++ b/source/blood/src/controls.cpp @@ -45,8 +45,7 @@ bool bSilentAim = false; int iTurnCount = 0; static int WeaponToSend; -static KEYFLAGS BitsToSend; -static USEFLAGS UsesToSend; +static SYNCFLAGS BitsToSend; void ctrlInit(void) { @@ -128,7 +127,7 @@ void ctrlGetInput(void) if (paused != prevPauseState) { - gInput.keyFlags.pause = 1; + gInput.syncFlags.pause = 1; } if (paused) @@ -137,7 +136,7 @@ void ctrlGetInput(void) GINPUT input = {}; bool mouseaim = in_mousemode || buttonMap.ButtonDown(gamefunc_Mouse_Aiming); - if (!mouseaim) gInput.keyFlags.lookCenter = 1; + if (!mouseaim) gInput.syncFlags.lookCenter = 1; if (numplayers == 1) { @@ -148,15 +147,13 @@ void ctrlGetInput(void) CONTROL_GetInput(&info); if (gQuitRequest) - gInput.keyFlags.quit = 1; + gInput.syncFlags.quit = 1; - gInput.keyFlags.word |= BitsToSend.word; - gInput.useFlags.byte |= UsesToSend.byte; + gInput.syncFlags.value |= BitsToSend.value; if (WeaponToSend != 0) - gInput.newWeapon = WeaponToSend; + gInput.syncFlags.newWeapon = WeaponToSend; - BitsToSend.word = 0; - UsesToSend.byte = 0; + BitsToSend.value = 0; WeaponToSend = 0; if (buttonMap.ButtonDown(gamefunc_Shrink_Screen)) @@ -188,32 +185,32 @@ void ctrlGetInput(void) } if (buttonMap.ButtonDown(gamefunc_Jump)) - gInput.buttonFlags.jump = 1; + gInput.syncFlags.jump = 1; if (buttonMap.ButtonDown(gamefunc_Crouch)) - gInput.buttonFlags.crouch = 1; + gInput.syncFlags.crouch = 1; if (buttonMap.ButtonDown(gamefunc_Fire)) - gInput.buttonFlags.shoot = 1; + gInput.syncFlags.shoot = 1; if (buttonMap.ButtonDown(gamefunc_Alt_Fire)) - gInput.buttonFlags.shoot2 = 1; + gInput.syncFlags.shoot2 = 1; if (buttonMap.ButtonDown(gamefunc_Open)) { buttonMap.ClearButton(gamefunc_Open); - gInput.keyFlags.action = 1; + gInput.syncFlags.action = 1; } - gInput.buttonFlags.lookUp |= buttonMap.ButtonDown(gamefunc_Look_Up); - gInput.buttonFlags.lookDown |= buttonMap.ButtonDown(gamefunc_Look_Down); + gInput.syncFlags.lookUp |= buttonMap.ButtonDown(gamefunc_Look_Up); + gInput.syncFlags.lookDown |= buttonMap.ButtonDown(gamefunc_Look_Down); if (buttonMap.ButtonDown(gamefunc_Look_Up) || buttonMap.ButtonDown(gamefunc_Look_Down)) - gInput.keyFlags.lookCenter = 1; + gInput.syncFlags.lookCenter = 1; else { - gInput.buttonFlags.lookUp |= buttonMap.ButtonDown(gamefunc_Aim_Up); - gInput.buttonFlags.lookDown |= buttonMap.ButtonDown(gamefunc_Aim_Down); + gInput.syncFlags.lookUp |= buttonMap.ButtonDown(gamefunc_Aim_Up); + gInput.syncFlags.lookDown |= buttonMap.ButtonDown(gamefunc_Aim_Down); } int const run = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run)); @@ -369,14 +366,14 @@ void registerinputcommands() C_RegisterFunction("pause", nullptr, [](CCmdFuncPtr)->int { BitsToSend.pause = 1; sendPause = true; return CCMD_OK; }); C_RegisterFunction("proximitybombs", nullptr, [](CCmdFuncPtr)->int { WeaponToSend = 11; return CCMD_OK; }); C_RegisterFunction("remotebombs", nullptr, [](CCmdFuncPtr)->int { WeaponToSend = 12; return CCMD_OK; }); - C_RegisterFunction("jumpboots", nullptr, [](CCmdFuncPtr)->int { UsesToSend.useJumpBoots = 1; return CCMD_OK; }); - C_RegisterFunction("medkit", nullptr, [](CCmdFuncPtr)->int { UsesToSend.useMedKit = 1; return CCMD_OK; }); + C_RegisterFunction("jumpboots", nullptr, [](CCmdFuncPtr)->int { BitsToSend.useJumpBoots = 1; return CCMD_OK; }); + C_RegisterFunction("medkit", nullptr, [](CCmdFuncPtr)->int { BitsToSend.useMedKit = 1; return CCMD_OK; }); 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("invprev", nullptr, [](CCmdFuncPtr)->int { BitsToSend.prevItem = 1; return CCMD_OK; }); C_RegisterFunction("invnext", nullptr, [](CCmdFuncPtr)->int { BitsToSend.nextItem = 1; return CCMD_OK; }); - C_RegisterFunction("crystalball", nullptr, [](CCmdFuncPtr)->int { UsesToSend.useCrystalBall = 1; return CCMD_OK; }); - C_RegisterFunction("beastvision", nullptr, [](CCmdFuncPtr)->int { UsesToSend.useBeastVision = 1; return CCMD_OK; }); + C_RegisterFunction("crystalball", nullptr, [](CCmdFuncPtr)->int { BitsToSend.useCrystalBall = 1; return CCMD_OK; }); + C_RegisterFunction("beastvision", nullptr, [](CCmdFuncPtr)->int { BitsToSend.useBeastVision = 1; return CCMD_OK; }); C_RegisterFunction("turnaround", nullptr, [](CCmdFuncPtr)->int { BitsToSend.spin180 = 1; return CCMD_OK; }); C_RegisterFunction("invuse", nullptr, [](CCmdFuncPtr)->int { BitsToSend.useItem = 1; return CCMD_OK; }); } @@ -385,8 +382,7 @@ void registerinputcommands() void GameInterface::clearlocalinputstate() { WeaponToSend = 0; - BitsToSend.word = 0; - UsesToSend.byte = 0; + BitsToSend.value = 0; } diff --git a/source/blood/src/controls.h b/source/blood/src/controls.h index b8f7faa64..a2f238210 100644 --- a/source/blood/src/controls.h +++ b/source/blood/src/controls.h @@ -26,25 +26,24 @@ BEGIN_BLD_NS #pragma pack(push, 1) -union BUTTONFLAGS +enum { - int8_t byte; + flag_buttonmask = 127, + flag_buttonmask_norun = 126 +}; + +union SYNCFLAGS +{ + uint32_t value; struct { + unsigned int run : 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; - }; -}; - -union KEYFLAGS -{ - int16_t word; - struct - { unsigned int action : 1; unsigned int jab : 1; unsigned int prevItem : 1; @@ -60,44 +59,19 @@ union KEYFLAGS unsigned int pause : 1; unsigned int quit : 1; unsigned int restart : 1; - }; -}; - -union USEFLAGS -{ - uint8_t byte; - struct - { unsigned int useBeastVision : 1; unsigned int useCrystalBall : 1; unsigned int useJumpBoots : 1; unsigned int useMedKit : 1; - }; -}; - -union SYNCFLAGS -{ - uint8_t byte; - struct - { - unsigned int buttonChange : 1; - unsigned int keyChange : 1; - unsigned int useChange : 1; - unsigned int weaponChange : 1; - unsigned int mlookChange : 1; - unsigned int run : 1; + unsigned int newWeapon : 4; }; }; struct GINPUT { SYNCFLAGS syncFlags; int16_t forward; - fix16_t q16turn; int16_t strafe; - BUTTONFLAGS buttonFlags; - KEYFLAGS keyFlags; - USEFLAGS useFlags; - uint8_t newWeapon; + fix16_t q16turn; fix16_t q16mlook; }; diff --git a/source/blood/src/nnexts.cpp b/source/blood/src/nnexts.cpp index a87899cec..facace1a5 100644 --- a/source/blood/src/nnexts.cpp +++ b/source/blood/src/nnexts.cpp @@ -1350,7 +1350,7 @@ void trPlayerCtrlStopScene(PLAYER* pPlayer) { // restore weapon if (pPlayer->pXSprite->health > 0) { int oldWeapon = (pXSource && pXSource->dropMsg != 0) ? pXSource->dropMsg : 1; - pPlayer->input.newWeapon = pPlayer->curWeapon = oldWeapon; + pPlayer->newWeapon = pPlayer->curWeapon = oldWeapon; WeaponRaise(pPlayer); } } @@ -1590,7 +1590,7 @@ void trPlayerCtrlGiveStuff(XSPRITE* pXSource, PLAYER* pPlayer, TRPLAYERCTRL* pCt XSPRITE* pXScene = &xsprite[sprite[pCtrl->qavScene.index].extra]; pXScene->dropMsg = weapon; } else if (pPlayer->curWeapon != weapon) { - pPlayer->input.newWeapon = weapon; + pPlayer->newWeapon = weapon; WeaponRaise(pPlayer); } } @@ -1990,7 +1990,7 @@ void usePropertiesChanger(XSPRITE* pXSource, short objType, int objIndex) { xsprite[pSpr->extra].medium = kMediumNormal; if (pPlayer) { - pPlayer->posture = (!pPlayer->input.buttonFlags.crouch) ? kPostureStand : kPostureCrouch; + pPlayer->posture = (!pPlayer->input.syncFlags.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.buttonFlags.crouch) ? kPostureStand : kPostureCrouch; + pPlayer->posture = (!pPlayer->input.syncFlags.crouch) ? kPostureStand : kPostureCrouch; pPlayer->nWaterPal = 0; } @@ -2889,10 +2889,10 @@ bool condCheckPlayer(XSPRITE* pXCond, int cmpOp, bool PUSH) { case 2: return (pPlayer->input.forward < 0); // backward case 3: return (pPlayer->input.strafe > 0); // left case 4: return (pPlayer->input.strafe < 0); // right - case 5: return (pPlayer->input.buttonFlags.jump); // jump - case 6: return (pPlayer->input.buttonFlags.crouch); // crouch - case 7: return (pPlayer->input.buttonFlags.shoot); // normal fire weapon - case 8: return (pPlayer->input.buttonFlags.shoot2); // alt fire weapon + 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 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 d09214ead..f832476e9 100644 --- a/source/blood/src/player.cpp +++ b/source/blood/src/player.cpp @@ -318,7 +318,7 @@ char powerupActivate(PLAYER *pPlayer, int nPowerUp) pPlayer->damageControl[1]++; break; case kItemTwoGuns: - pPlayer->input.newWeapon = pPlayer->curWeapon; + pPlayer->newWeapon = pPlayer->curWeapon; WeaponRaise(pPlayer); break; } @@ -369,7 +369,7 @@ void powerupDeactivate(PLAYER *pPlayer, int nPowerUp) pPlayer->damageControl[1]--; break; case kItemTwoGuns: - pPlayer->input.newWeapon = pPlayer->curWeapon; + pPlayer->newWeapon = pPlayer->curWeapon; WeaponRaise(pPlayer); break; } @@ -749,12 +749,10 @@ void playerStart(int nPlayer, int bNewLevel) pPlayer->nextWeapon = 0; xvel[pSprite->index] = yvel[pSprite->index] = zvel[pSprite->index] = 0; pInput->q16turn = 0; - pInput->keyFlags.word = 0; + pInput->syncFlags.value = 0; pInput->forward = 0; pInput->strafe = 0; pInput->q16mlook = 0; - pInput->buttonFlags.byte = 0; - pInput->useFlags.byte = 0; pPlayer->flickerEffect = 0; pPlayer->quakeEffect = 0; pPlayer->tiltEffect = 0; @@ -822,7 +820,7 @@ void playerReset(PLAYER *pPlayer) pPlayer->hasWeapon[1] = 1; pPlayer->curWeapon = 0; pPlayer->qavCallback = -1; - pPlayer->input.newWeapon = 1; + pPlayer->newWeapon = 1; for (int i = 0; i < 14; i++) { pPlayer->weaponOrder[0][i] = dword_136400[i]; @@ -1311,7 +1309,7 @@ void ProcessInput(PLAYER *pPlayer) } pPlayer->isRunning = pInput->syncFlags.run; - if (pInput->buttonFlags.byte || pInput->forward || pInput->strafe || pInput->q16turn) + if ((pInput->syncFlags.value & flag_buttonmask_norun) || pInput->forward || pInput->strafe || pInput->q16turn) pPlayer->restTime = 0; else if (pPlayer->restTime >= 0) pPlayer->restTime += 4; @@ -1333,8 +1331,8 @@ void ProcessInput(PLAYER *pPlayer) pPlayer->q16horiz = mulscale16(0x8000-(Cos(ClipHigh(pPlayer->deathTime*8, 1024))>>15), fix16_from_int(120)); } if (pPlayer->curWeapon) - pInput->newWeapon = pPlayer->curWeapon; - if (pInput->keyFlags.action) + pInput->syncFlags.newWeapon = pPlayer->curWeapon; + if (pInput->syncFlags.action) { if (bSeqStat) { @@ -1350,12 +1348,12 @@ void ProcessInput(PLAYER *pPlayer) playerReset(pPlayer); if (gGameOptions.nGameType == 0 && numplayers == 1) { - pInput->keyFlags.restart = 1; + pInput->syncFlags.restart = 1; } else playerStart(pPlayer->nPlayer); } - pInput->keyFlags.action = 0; + pInput->syncFlags.action = 0; } return; } @@ -1412,11 +1410,11 @@ void ProcessInput(PLAYER *pPlayer) } if (pInput->q16turn) pPlayer->q16ang = (pPlayer->q16ang+pInput->q16turn)&0x7ffffff; - if (pInput->keyFlags.spin180) + if (pInput->syncFlags.spin180) { if (!pPlayer->spin) pPlayer->spin = -1024; - pInput->keyFlags.spin180 = 0; + pInput->syncFlags.spin180 = 0; } if (pPlayer->spin < 0) { @@ -1434,22 +1432,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->buttonFlags.jump) + if (!pInput->syncFlags.jump) pPlayer->cantJump = 0; switch (pPlayer->posture) { case 1: - if (pInput->buttonFlags.jump) + if (pInput->syncFlags.jump) zvel[nSprite] -= pPosture->normalJumpZ;//0x5b05; - if (pInput->buttonFlags.crouch) + if (pInput->syncFlags.crouch) zvel[nSprite] += pPosture->normalJumpZ;//0x5b05; break; case 2: - if (!pInput->buttonFlags.crouch) + if (!pInput->syncFlags.crouch) pPlayer->posture = 0; break; default: - if (!pPlayer->cantJump && pInput->buttonFlags.jump && pXSprite->height == 0) { + if (!pPlayer->cantJump && pInput->syncFlags.jump && pXSprite->height == 0) { #ifdef NOONE_EXTENSIONS if ((packItemActive(pPlayer, 4) && pPosture->pwupJumpZ != 0) || pPosture->normalJumpZ != 0) #endif @@ -1460,11 +1458,11 @@ void ProcessInput(PLAYER *pPlayer) pPlayer->cantJump = 1; } - if (pInput->buttonFlags.crouch) + if (pInput->syncFlags.crouch) pPlayer->posture = 2; break; } - if (pInput->keyFlags.action) + if (pInput->syncFlags.action) { int a2, a3; int hit = ActionScan(pPlayer, &a2, &a3); @@ -1537,24 +1535,24 @@ void ProcessInput(PLAYER *pPlayer) zvel[pSprite2->index] = zvel[nSprite]; pPlayer->hand = 0; } - pInput->keyFlags.action = 0; + pInput->syncFlags.action = 0; } if (bVanilla) { - if (pInput->keyFlags.lookCenter && !pInput->buttonFlags.lookUp && !pInput->buttonFlags.lookDown) + if (pInput->syncFlags.lookCenter && !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->keyFlags.lookCenter = 0; + pInput->syncFlags.lookCenter = 0; } else { - if (pInput->buttonFlags.lookUp) + if (pInput->syncFlags.lookUp) pPlayer->q16look = fix16_min(pPlayer->q16look+fix16_from_int(4), fix16_from_int(60)); - if (pInput->buttonFlags.lookDown) + if (pInput->syncFlags.lookDown) pPlayer->q16look = fix16_max(pPlayer->q16look-fix16_from_int(4), fix16_from_int(-60)); } pPlayer->q16look = fix16_clamp(pPlayer->q16look+pInput->q16mlook, fix16_from_int(-60), fix16_from_int(60)); @@ -1571,33 +1569,33 @@ void ProcessInput(PLAYER *pPlayer) int downAngle = -347; double lookStepUp = 4.0*upAngle/60.0; double lookStepDown = -4.0*downAngle/60.0; - if (pInput->keyFlags.lookCenter && !pInput->buttonFlags.lookUp && !pInput->buttonFlags.lookDown) + if (pInput->syncFlags.lookCenter && !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->keyFlags.lookCenter = 0; + pInput->syncFlags.lookCenter = 0; } else { - if (pInput->buttonFlags.lookUp) + if (pInput->syncFlags.lookUp) pPlayer->q16look = fix16_min(pPlayer->q16look+fix16_from_dbl(lookStepUp), fix16_from_int(upAngle)); - if (pInput->buttonFlags.lookDown) + if (pInput->syncFlags.lookDown) pPlayer->q16look = fix16_max(pPlayer->q16look-fix16_from_dbl(lookStepDown), fix16_from_int(downAngle)); } if (pPlayer == gMe && numplayers == 1) { - if (pInput->buttonFlags.lookUp) + if (pInput->syncFlags.lookUp) { gViewLookAdjust += float(lookStepUp); } - if (pInput->buttonFlags.lookDown) + if (pInput->syncFlags.lookDown) { gViewLookAdjust -= float(lookStepDown); } - gViewLookRecenter = pInput->keyFlags.lookCenter && !pInput->buttonFlags.lookUp && !pInput->buttonFlags.lookDown; + gViewLookRecenter = pInput->syncFlags.lookCenter && !pInput->syncFlags.lookUp && !pInput->syncFlags.lookDown; } pPlayer->q16look = fix16_clamp(pPlayer->q16look+(pInput->q16mlook<<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)); @@ -1629,49 +1627,49 @@ void ProcessInput(PLAYER *pPlayer) pPlayer->q16slopehoriz = 0; } pPlayer->slope = (-fix16_to_int(pPlayer->q16horiz))<<7; - if (pInput->keyFlags.prevItem) + if (pInput->syncFlags.prevItem) { - pInput->keyFlags.prevItem = 0; + pInput->syncFlags.prevItem = 0; packPrevItem(pPlayer); } - if (pInput->keyFlags.nextItem) + if (pInput->syncFlags.nextItem) { - pInput->keyFlags.nextItem = 0; + pInput->syncFlags.nextItem = 0; packNextItem(pPlayer); } - if (pInput->keyFlags.useItem) + if (pInput->syncFlags.useItem) { - pInput->keyFlags.useItem = 0; + pInput->syncFlags.useItem = 0; if (pPlayer->packSlots[pPlayer->packItemId].curAmount > 0) packUseItem(pPlayer, pPlayer->packItemId); } - if (pInput->useFlags.useBeastVision) + if (pInput->syncFlags.useBeastVision) { - pInput->useFlags.useBeastVision = 0; + pInput->syncFlags.useBeastVision = 0; if (pPlayer->packSlots[3].curAmount > 0) packUseItem(pPlayer, 3); } - if (pInput->useFlags.useCrystalBall) + if (pInput->syncFlags.useCrystalBall) { - pInput->useFlags.useCrystalBall = 0; + pInput->syncFlags.useCrystalBall = 0; if (pPlayer->packSlots[2].curAmount > 0) packUseItem(pPlayer, 2); } - if (pInput->useFlags.useJumpBoots) + if (pInput->syncFlags.useJumpBoots) { - pInput->useFlags.useJumpBoots = 0; + pInput->syncFlags.useJumpBoots = 0; if (pPlayer->packSlots[4].curAmount > 0) packUseItem(pPlayer, 4); } - if (pInput->useFlags.useMedKit) + if (pInput->syncFlags.useMedKit) { - pInput->useFlags.useMedKit = 0; + pInput->syncFlags.useMedKit = 0; if (pPlayer->packSlots[0].curAmount > 0) packUseItem(pPlayer, 0); } - if (pInput->keyFlags.holsterWeapon) + if (pInput->syncFlags.holsterWeapon) { - pInput->keyFlags.holsterWeapon = 0; + pInput->syncFlags.holsterWeapon = 0; if (pPlayer->curWeapon) { WeaponLower(pPlayer); @@ -2178,7 +2176,7 @@ void PlayerSurvive(int, int nXSprite) sprintf(buffer, "%s lives again!", gProfile[pPlayer->nPlayer].name); viewSetMessage(buffer); } - pPlayer->input.newWeapon = 1; + pPlayer->newWeapon = 1; } } } diff --git a/source/blood/src/player.h b/source/blood/src/player.h index 61e1bf7b2..aafab87b8 100644 --- a/source/blood/src/player.h +++ b/source/blood/src/player.h @@ -87,15 +87,7 @@ struct PLAYER XSPRITE* pXSprite; DUDEINFO* pDudeInfo; GINPUT input; - //short input; // INPUT - //char moveFunc; // forward - //short at11; // turn - //char hearDist; // strafe - //int bobV; // buttonFlags - //unsigned int bobH; // keyFlags - //char swayV; // useFlags; - //char swayH; // newWeapon - //char at21; // mlook + uint8_t newWeapon; int used1; // something related to game checksum int weaponQav; int qavCallback; diff --git a/source/blood/src/prediction.cpp b/source/blood/src/prediction.cpp index e55f10faf..577ed651c 100644 --- a/source/blood/src/prediction.cpp +++ b/source/blood/src/prediction.cpp @@ -66,7 +66,7 @@ void viewInitializePrediction(void) predict.at6f = gMe->cantJump; predict.at70 = gMe->isRunning; predict.at72 = gMe->isUnderwater; - predict.at71 = gMe->input.buttonFlags.jump; + predict.at71 = gMe->input.syncFlags.jump; predict.at50 = gMe->pSprite->x; predict.at54 = gMe->pSprite->y; predict.at58 = gMe->pSprite->z; @@ -78,7 +78,7 @@ void viewInitializePrediction(void) predict.at6a = gMe->pXSprite->height; predict.at48 = gMe->posture; predict.at4c = gMe->spin; - predict.at6e = gMe->input.keyFlags.lookCenter; + predict.at6e = gMe->input.syncFlags.lookCenter; memcpy(&predict.at75,&gSpriteHit[gMe->pSprite->extra],sizeof(SPRITEHIT)); predict.at0 = gMe->bobPhase; predict.at4 = gMe->bobAmp; @@ -136,8 +136,7 @@ static void fakeProcessInput(PLAYER *pPlayer, GINPUT *pInput) } predict.at70 = pInput->syncFlags.run; - predict.at70 = 0; - predict.at71 = pInput->buttonFlags.jump; + predict.at71 = pInput->syncFlags.jump; if (predict.at48 == 1) { int x = Cos(fix16_to_int(predict.at30)); @@ -191,7 +190,7 @@ static void fakeProcessInput(PLAYER *pPlayer, GINPUT *pInput) } if (pInput->q16turn) predict.at30 = (predict.at30+pInput->q16turn)&0x7ffffff; - if (pInput->keyFlags.spin180) + if (pInput->syncFlags.spin180) if (!predict.at4c) predict.at4c = -1024; if (predict.at4c < 0) @@ -216,11 +215,11 @@ static void fakeProcessInput(PLAYER *pPlayer, GINPUT *pInput) case 1: if (predict.at71) predict.at64 -= pPosture->normalJumpZ;//0x5b05; - if (pInput->buttonFlags.crouch) + if (pInput->syncFlags.crouch) predict.at64 += pPosture->normalJumpZ;//0x5b05; break; case 2: - if (!pInput->buttonFlags.crouch) + if (!pInput->syncFlags.crouch) predict.at48 = 0; break; default: @@ -229,12 +228,12 @@ static void fakeProcessInput(PLAYER *pPlayer, GINPUT *pInput) else predict.at64 = pPosture->normalJumpZ;//-0xbaaaa; predict.at6f = 1; } - if (pInput->buttonFlags.crouch) + if (pInput->syncFlags.crouch) predict.at48 = 2; break; } #if 0 - if (predict.at6e && !pInput->buttonFlags.lookUp && !pInput->buttonFlags.lookDown) + if (predict.at6e && !pInput->syncFlags.lookUp && !pInput->syncFlags.lookDown) { if (predict.at20 < 0) predict.at20 = fix16_min(predict.at20+fix16_from_int(4), fix16_from_int(0)); @@ -245,9 +244,9 @@ static void fakeProcessInput(PLAYER *pPlayer, GINPUT *pInput) } else { - if (pInput->buttonFlags.lookUp) + if (pInput->syncFlags.lookUp) predict.at20 = fix16_min(predict.at20+fix16_from_int(4), fix16_from_int(60)); - if (pInput->buttonFlags.lookDown) + if (pInput->syncFlags.lookDown) predict.at20 = fix16_max(predict.at20-fix16_from_int(4), fix16_from_int(-60)); } predict.at20 = fix16_clamp(predict.at20+pInput->q16mlook, fix16_from_int(-60), fix16_from_int(60)); @@ -263,7 +262,7 @@ static void fakeProcessInput(PLAYER *pPlayer, GINPUT *pInput) int downAngle = -347; double lookStepUp = 4.0*upAngle/60.0; double lookStepDown = -4.0*downAngle/60.0; - if (predict.at6e && !pInput->buttonFlags.lookUp && !pInput->buttonFlags.lookDown) + if (predict.at6e && !pInput->syncFlags.lookUp && !pInput->syncFlags.lookDown) { if (predict.at20 < 0) predict.at20 = fix16_min(predict.at20+fix16_from_dbl(lookStepDown), fix16_from_int(0)); @@ -274,22 +273,22 @@ static void fakeProcessInput(PLAYER *pPlayer, GINPUT *pInput) } else { - if (pInput->buttonFlags.lookUp) + if (pInput->syncFlags.lookUp) predict.at20 = fix16_min(predict.at20+fix16_from_dbl(lookStepUp), fix16_from_int(upAngle)); - if (pInput->buttonFlags.lookDown) + if (pInput->syncFlags.lookDown) predict.at20 = fix16_max(predict.at20-fix16_from_dbl(lookStepDown), fix16_from_int(downAngle)); } if (numplayers > 1 && gPrediction) { - if (pInput->buttonFlags.lookUp) + if (pInput->syncFlags.lookUp) { gViewLookAdjust += float(lookStepUp); } - if (pInput->buttonFlags.lookDown) + if (pInput->syncFlags.lookDown) { gViewLookAdjust -= float(lookStepDown); } - gViewLookRecenter = predict.at6e && !pInput->buttonFlags.lookUp && !pInput->buttonFlags.lookDown; + gViewLookRecenter = predict.at6e && !pInput->syncFlags.lookUp && !pInput->syncFlags.lookDown; } predict.at20 = fix16_clamp(predict.at20+(pInput->q16mlook<<3), fix16_from_int(downAngle), fix16_from_int(upAngle)); predict.at24 = fix16_from_float(100.f*tanf(fix16_to_float(predict.at20)*fPI/1024.f)); diff --git a/source/blood/src/weapon.cpp b/source/blood/src/weapon.cpp index ee5748c8a..76cd93f5a 100644 --- a/source/blood/src/weapon.cpp +++ b/source/blood/src/weapon.cpp @@ -469,8 +469,8 @@ void WeaponRaise(PLAYER *pPlayer) { dassert(pPlayer != NULL); int prevWeapon = pPlayer->curWeapon; - pPlayer->curWeapon = pPlayer->input.newWeapon; - pPlayer->input.newWeapon = 0; + pPlayer->curWeapon = pPlayer->newWeapon; + pPlayer->newWeapon = 0; pPlayer->weaponAmmo = weaponModes[pPlayer->curWeapon].at4; switch (pPlayer->curWeapon) { @@ -641,21 +641,21 @@ void WeaponLower(PLAYER *pPlayer) case 4: pPlayer->weaponState = 1; StartQAV(pPlayer, 11, -1, 0); - pPlayer->input.newWeapon = 0; + pPlayer->newWeapon = 0; WeaponLower(pPlayer); break; case 3: - if (pPlayer->input.newWeapon == 6) + if (pPlayer->newWeapon == 6) { pPlayer->weaponState = 2; StartQAV(pPlayer, 11, -1, 0); return; } - else if (pPlayer->input.newWeapon == 7) + else if (pPlayer->newWeapon == 7) { pPlayer->weaponState = 1; StartQAV(pPlayer, 11, -1, 0); - pPlayer->input.newWeapon = 0; + pPlayer->newWeapon = 0; WeaponLower(pPlayer); } else @@ -676,7 +676,7 @@ void WeaponLower(PLAYER *pPlayer) WeaponRaise(pPlayer); break; case 3: - if (pPlayer->input.newWeapon == 7) + if (pPlayer->newWeapon == 7) { pPlayer->weaponState = 2; StartQAV(pPlayer, 17, -1, 0); @@ -1767,17 +1767,17 @@ char sub_4F0E0(PLAYER *pPlayer) switch (pPlayer->weaponState) { case 5: - if (!pPlayer->input.buttonFlags.shoot2) + if (!pPlayer->input.syncFlags.shoot2) pPlayer->weaponState = 6; return 1; case 6: - if (pPlayer->input.buttonFlags.shoot2) + if (pPlayer->input.syncFlags.shoot2) { pPlayer->weaponState = 3; pPlayer->fuseTime = pPlayer->weaponTimer; StartQAV(pPlayer, 13, nClientDropCan, 0); } - else if (pPlayer->input.buttonFlags.shoot) + else if (pPlayer->input.syncFlags.shoot) { 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.buttonFlags.shoot) + if (!pPlayer->input.syncFlags.shoot) { if (!pPlayer->fuseTime) pPlayer->fuseTime = pPlayer->weaponTimer; @@ -1805,17 +1805,17 @@ char sub_4F200(PLAYER *pPlayer) switch (pPlayer->weaponState) { case 4: - if (!pPlayer->input.buttonFlags.shoot2) + if (!pPlayer->input.syncFlags.shoot2) pPlayer->weaponState = 5; return 1; case 5: - if (pPlayer->input.buttonFlags.shoot2) + if (pPlayer->input.syncFlags.shoot2) { pPlayer->weaponState = 1; pPlayer->fuseTime = pPlayer->weaponTimer; StartQAV(pPlayer, 22, nClientDropBundle, 0); } - else if (pPlayer->input.buttonFlags.shoot) + else if (pPlayer->input.syncFlags.shoot) { 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.buttonFlags.shoot) + if (!pPlayer->input.syncFlags.shoot) { 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.buttonFlags.shoot) + if (!pPlayer->input.syncFlags.shoot) { 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.buttonFlags.shoot) + if (!pPlayer->input.syncFlags.shoot) { 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.buttonFlags.shoot2) + if (!pPlayer->input.syncFlags.shoot2) { 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.buttonFlags.shoot) + if (!pPlayer->input.syncFlags.shoot) { 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.buttonFlags.shoot; - char bShoot2 = pPlayer->input.buttonFlags.shoot2; + char bShoot = pPlayer->input.syncFlags.shoot; + char bShoot2 = pPlayer->input.syncFlags.shoot2; if (pPlayer->qavLoop && pPlayer->pXSprite->health > 0) { if (bShoot && CheckAmmo(pPlayer, pPlayer->weaponAmmo, 1)) @@ -2023,12 +2023,12 @@ void WeaponProcess(PLAYER *pPlayer) { { sfxKill3DSound(pPlayer->pSprite, -1, 441); pPlayer->weaponState = 0; - pPlayer->input.newWeapon = pPlayer->nextWeapon; + pPlayer->newWeapon = pPlayer->nextWeapon; pPlayer->nextWeapon = 0; } - if (pPlayer->input.keyFlags.nextWeapon) + if (pPlayer->input.syncFlags.nextWeapon) { - pPlayer->input.keyFlags.nextWeapon = 0; + pPlayer->input.syncFlags.nextWeapon = 0; pPlayer->weaponState = 0; pPlayer->nextWeapon = 0; int t; @@ -2040,11 +2040,11 @@ void WeaponProcess(PLAYER *pPlayer) { pPlayer->nextWeapon = weapon; return; } - pPlayer->input.newWeapon = weapon; + pPlayer->newWeapon = weapon; } - if (pPlayer->input.keyFlags.prevWeapon) + if (pPlayer->input.syncFlags.prevWeapon) { - pPlayer->input.keyFlags.prevWeapon = 0; + pPlayer->input.syncFlags.prevWeapon = 0; pPlayer->weaponState = 0; pPlayer->nextWeapon = 0; int t; @@ -2056,7 +2056,7 @@ void WeaponProcess(PLAYER *pPlayer) { pPlayer->nextWeapon = weapon; return; } - pPlayer->input.newWeapon = weapon; + pPlayer->newWeapon = weapon; } if (pPlayer->weaponState == -1) { @@ -2070,54 +2070,54 @@ void WeaponProcess(PLAYER *pPlayer) { pPlayer->nextWeapon = weapon; return; } - pPlayer->input.newWeapon = weapon; + pPlayer->newWeapon = weapon; } - if (pPlayer->input.newWeapon) + if (pPlayer->newWeapon) { - if (pPlayer->input.newWeapon == 6) + if (pPlayer->newWeapon == 6) { if (pPlayer->curWeapon == 6) { if (sub_4B2C8(pPlayer, 10, 1)) - pPlayer->input.newWeapon = 11; + pPlayer->newWeapon = 11; else if (sub_4B2C8(pPlayer, 11, 1)) - pPlayer->input.newWeapon = 12; + pPlayer->newWeapon = 12; } else if (pPlayer->curWeapon == 11) { if (sub_4B2C8(pPlayer, 11, 1)) - pPlayer->input.newWeapon = 12; + pPlayer->newWeapon = 12; else if (sub_4B2C8(pPlayer, 5, 1) && pPlayer->isUnderwater == 0) - pPlayer->input.newWeapon = 6; + pPlayer->newWeapon = 6; } else if (pPlayer->curWeapon == 12) { if (sub_4B2C8(pPlayer, 5, 1) && pPlayer->isUnderwater == 0) - pPlayer->input.newWeapon = 6; + pPlayer->newWeapon = 6; else if (sub_4B2C8(pPlayer, 10, 1)) - pPlayer->input.newWeapon = 11; + pPlayer->newWeapon = 11; } else { if (sub_4B2C8(pPlayer, 5, 1) && pPlayer->isUnderwater == 0) - pPlayer->input.newWeapon = 6; + pPlayer->newWeapon = 6; else if (sub_4B2C8(pPlayer, 10, 1)) - pPlayer->input.newWeapon = 11; + pPlayer->newWeapon = 11; else if (sub_4B2C8(pPlayer, 11, 1)) - pPlayer->input.newWeapon = 12; + pPlayer->newWeapon = 12; } } - if (pPlayer->pXSprite->health == 0 || pPlayer->hasWeapon[pPlayer->input.newWeapon] == 0) + if (pPlayer->pXSprite->health == 0 || pPlayer->hasWeapon[pPlayer->newWeapon] == 0) { - pPlayer->input.newWeapon = 0; + pPlayer->newWeapon = 0; return; } - if (pPlayer->isUnderwater && BannedUnderwater(pPlayer->input.newWeapon) && !sub_4B1A4(pPlayer)) + if (pPlayer->isUnderwater && BannedUnderwater(pPlayer->newWeapon) && !sub_4B1A4(pPlayer)) { - pPlayer->input.newWeapon = 0; + pPlayer->newWeapon = 0; return; } - int nWeapon = pPlayer->input.newWeapon; + int nWeapon = pPlayer->newWeapon; int v4c = weaponModes[nWeapon].at0; if (!pPlayer->curWeapon) { @@ -2126,7 +2126,7 @@ void WeaponProcess(PLAYER *pPlayer) { { if (CheckAmmo(pPlayer, nAmmoType, 1) || nAmmoType == 11) WeaponRaise(pPlayer); - pPlayer->input.newWeapon = 0; + pPlayer->newWeapon = 0; } else { @@ -2144,14 +2144,14 @@ void WeaponProcess(PLAYER *pPlayer) { pPlayer->nextWeapon = weapon; return; } - pPlayer->input.newWeapon = weapon; + pPlayer->newWeapon = weapon; } } return; } if (nWeapon == pPlayer->curWeapon && v4c <= 1) { - pPlayer->input.newWeapon = 0; + pPlayer->newWeapon = 0; return; } int i = 0; @@ -2167,7 +2167,7 @@ void WeaponProcess(PLAYER *pPlayer) { return; } } - pPlayer->input.newWeapon = 0; + pPlayer->newWeapon = 0; return; } if (pPlayer->curWeapon && !CheckAmmo(pPlayer, pPlayer->weaponAmmo, 1) && pPlayer->weaponAmmo != 11)