diff --git a/source/blood/src/controls.cpp b/source/blood/src/controls.cpp index 3eeddedbf..e994a2238 100644 --- a/source/blood/src/controls.cpp +++ b/source/blood/src/controls.cpp @@ -180,12 +180,9 @@ void ctrlGetInput(void) gInput.syncFlags.lookDown |= buttonMap.ButtonDown(gamefunc_Aim_Down); } - int const run = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run)); - int const run2 = false; // What??? buttonMap.ButtonDown(gamefunc_Run); + int const run = !!(gInput.actions & SB_RUN); int const keyMove = (1 + run) << 10; - gInput.syncFlags.run |= run; - if (gInput.fvel < keyMove && gInput.fvel > -keyMove) { if (buttonMap.ButtonDown(gamefunc_Move_Forward)) @@ -244,7 +241,7 @@ void ctrlGetInput(void) if (turnRight) input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(ClipHigh(12 * turnHeldTime, gTurnSpeed)>>2))); - if ((run2 || run) && turnHeldTime > 24) + if (run && turnHeldTime > 24) input.q16avel <<= 1; if (buttonMap.ButtonDown(gamefunc_Strafe)) diff --git a/source/blood/src/player.cpp b/source/blood/src/player.cpp index fc950d0c7..8193e745c 100644 --- a/source/blood/src/player.cpp +++ b/source/blood/src/player.cpp @@ -1332,7 +1332,7 @@ void ProcessInput(PLAYER *pPlayer) gViewLookAdjust = 0.f; } - pPlayer->isRunning = pInput->syncFlags.run; + pPlayer->isRunning = !!(pInput->actions & SB_RUN); 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) diff --git a/source/core/inputstate.cpp b/source/core/inputstate.cpp index 47af110d7..34bb06189 100644 --- a/source/core/inputstate.cpp +++ b/source/core/inputstate.cpp @@ -360,6 +360,8 @@ void ApplyGlobalInput(InputPacket& input, ControlInfo *info) if (g_gameType & GAMEFLAG_BLOOD) buttonMap.ClearButton(gamefunc_Open); input.actions |= SB_OPEN; } + if (G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run))) + input.actions |= SB_RUN; } diff --git a/source/core/packet.h b/source/core/packet.h index 50cf00b1d..a3ce5ae74 100644 --- a/source/core/packet.h +++ b/source/core/packet.h @@ -69,7 +69,6 @@ enum EDukeSyncBits_ : uint32_t { SKB_AIM_UP = 1 << 3, SKB_AIM_DOWN = 1 << 4, - SKB_RUN = 1 << 5, SKB_LOOK_LEFT = 1 << 6, SKB_LOOK_RIGHT = 1 << 7, SKB_LOOK_UP = 1 << 13, @@ -95,7 +94,7 @@ union SYNCFLAGS uint32_t value; struct { - unsigned int run : 1; + unsigned int _run : 1; unsigned int _jump : 1; unsigned int _crouch : 1; unsigned int _shoot : 1; @@ -124,7 +123,6 @@ union SYNCFLAGS #define SK_CRAWL_LOCK 14 #define SK_FLY 15 -#define SK_RUN 16 #define SK_AIM_UP 21 #define SK_AIM_DOWN 22 diff --git a/source/exhumed/src/input.cpp b/source/exhumed/src/input.cpp index f1e5e6799..0c04a6db9 100644 --- a/source/exhumed/src/input.cpp +++ b/source/exhumed/src/input.cpp @@ -178,7 +178,7 @@ void PlayerInterruptKeys(bool after) // JBF: Run key behaviour is selectable - int const playerRunning = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run)); + int const playerRunning = !!(localInput.actions & SB_RUN); int const turnAmount = playerRunning ? 12 : 8; int const keyMove = playerRunning ? 12 : 6; diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index 3e396f62f..5621a1127 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -112,10 +112,10 @@ void playerJump(int snum, int fz, int cz); void applylook(int snum, double factor, fixed_t adjustment); void checklook(int snum, int sb_snum); void playerCenterView(int snum); -void playerLookUp(int snum, EDukeSyncBits sb_snum); -void playerLookDown(int snum, EDukeSyncBits sb_snum); -void playerAimUp(int snum, EDukeSyncBits sb_snum); -void playerAimDown(int snum, EDukeSyncBits sb_snum); +void playerLookUp(int snum, ESyncBits sb_snum); +void playerLookDown(int snum, ESyncBits sb_snum); +void playerAimUp(int snum, ESyncBits sb_snum); +void playerAimDown(int snum, ESyncBits sb_snum); bool view(struct player_struct* pp, int* vx, int* vy, int* vz, short* vsectnum, int ang, int horiz); void tracers(int x1, int y1, int z1, int x2, int y2, int z2, int n); int hits(int i); diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 5f25f5711..c10701986 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -1171,15 +1171,15 @@ int ParseState::parse(void) j = 1; else if( (l& pstanding) && s >= 0 && s < 8) j = 1; - else if( (l& pwalking) && s >= 8 && !(PlayerInput(g_p, SKB_RUN)) ) + else if( (l& pwalking) && s >= 8 && !(PlayerInput(g_p, SB_RUN)) ) j = 1; - else if( (l& prunning) && s >= 8 && PlayerInput(g_p, SKB_RUN) ) + else if( (l& prunning) && s >= 8 && PlayerInput(g_p, SB_RUN) ) j = 1; else if( (l& phigher) && ps[g_p].posz < (g_sp->z-(48<<8)) ) j = 1; - else if( (l& pwalkingback) && s <= -8 && !(PlayerInput(g_p, SKB_RUN)) ) + else if( (l& pwalkingback) && s <= -8 && !(PlayerInput(g_p, SB_RUN)) ) j = 1; - else if( (l& prunningback) && s <= -8 && (PlayerInput(g_p, SKB_RUN)) ) + else if( (l& prunningback) && s <= -8 && (PlayerInput(g_p, SB_RUN)) ) j = 1; else if( (l& pkicking) && ( ps[g_p].quick_kick > 0 || ( ps[g_p].curr_weapon == KNEE_WEAPON && ps[g_p].kickback_pic > 0 ) ) ) j = 1; diff --git a/source/games/duke/src/input.cpp b/source/games/duke/src/input.cpp index 6517b78cb..760b98d42 100644 --- a/source/games/duke/src/input.cpp +++ b/source/games/duke/src/input.cpp @@ -616,7 +616,6 @@ static void processInputBits(player_struct *p, ControlInfo &info) } 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)) 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; @@ -634,7 +633,7 @@ static void processInputBits(player_struct *p, ControlInfo &info) if (onVehicle) { // mask out all actions not compatible with vehicles. - loc.actions &= ~(SB_WEAPONMASK_BITS | SB_TURNAROUND | SB_CENTERVIEW | SB_HOLSTER | SB_JUMP | SB_CROUCH); + loc.actions &= ~(SB_WEAPONMASK_BITS | SB_TURNAROUND | SB_CENTERVIEW | SB_HOLSTER | SB_JUMP | SB_CROUCH | SB_RUN); } if (buttonMap.ButtonDown(gamefunc_Dpad_Aiming)) @@ -688,7 +687,7 @@ static void processMovement(player_struct *p, InputPacket &input, ControlInfo &i bool mouseaim = in_mousemode || buttonMap.ButtonDown(gamefunc_Mouse_Aiming); // JBF: Run key behaviour is selectable - int running = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run)); + int running = !!(loc.actions & SB_RUN); int turnamount = NORMALTURN << running; int keymove = NORMALKEYMOVE << running; @@ -982,7 +981,7 @@ static void processVehicleInput(player_struct *p, ControlInfo& info, InputPacket loc.actions |= SB_JUMP; if (buttonMap.ButtonDown(gamefunc_Move_Backward)) loc.sbits |= SKB_AIM_UP; - if (buttonMap.ButtonDown(gamefunc_Run)) + if (loc.buttons & SB_RUN) loc.actions |= SB_CROUCH; } @@ -1126,9 +1125,9 @@ void GetInput() } else { + processInputBits(p, info); processMovement(p, input, info, scaleAdjust); checkCrouchToggle(p); - processInputBits(p, info); FinalizeInput(myconnectindex, input, false); } diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index 41ce74954..ca67ca056 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -1050,7 +1050,7 @@ void playerCenterView(int snum) } } -void playerLookUp(int snum, EDukeSyncBits sb_snum) +void playerLookUp(int snum, ESyncBits actions) { auto p = &ps[snum]; SetGameVarID(g_iReturnVarID, 0, p->i, snum); @@ -1058,11 +1058,11 @@ void playerLookUp(int snum, EDukeSyncBits sb_snum) if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0) { p->return_to_center = 9; - p->pitchAdjust += (sb_snum & SKB_RUN) ? 12 : 24; + p->pitchAdjust += (actions & SB_RUN) ? 12 : 24; } } -void playerLookDown(int snum, EDukeSyncBits sb_snum) +void playerLookDown(int snum, ESyncBits actions) { auto p = &ps[snum]; SetGameVarID(g_iReturnVarID, 0, p->i, snum); @@ -1070,29 +1070,29 @@ void playerLookDown(int snum, EDukeSyncBits sb_snum) if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0) { p->return_to_center = 9; - p->pitchAdjust -= (sb_snum & SKB_RUN) ? 12 : 24; + p->pitchAdjust -= (actions & SB_RUN) ? 12 : 24; } } -void playerAimUp(int snum, EDukeSyncBits sb_snum) +void playerAimUp(int snum, ESyncBits actions) { auto p = &ps[snum]; SetGameVarID(g_iReturnVarID, 0, p->i, snum); OnEvent(EVENT_AIMUP, p->i, snum, -1); if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0) { - p->pitchAdjust += (sb_snum & SKB_RUN) ? 6 : 12; + p->pitchAdjust += (actions & SB_RUN) ? 6 : 12; } } -void playerAimDown(int snum, EDukeSyncBits sb_snum) +void playerAimDown(int snum, ESyncBits actions) { auto p = &ps[snum]; SetGameVarID(g_iReturnVarID, 0, p->i, snum); OnEvent(EVENT_AIMDOWN, p->i, snum, -1); if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0) { - p->pitchAdjust -= (sb_snum & SKB_RUN) ? 6 : 12; + p->pitchAdjust -= (actions & SB_RUN) ? 6 : 12; } } diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index f64d2661b..536b9c26c 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -3009,19 +3009,19 @@ HORIZONLY: } else if (sb_snum & SKB_LOOK_UP) { - playerLookUp(snum, sb_snum); + playerLookUp(snum, actions); } else if (sb_snum & SKB_LOOK_DOWN) { - playerLookDown(snum, sb_snum); + playerLookDown(snum, actions); } else if (sb_snum & SKB_AIM_UP) { - playerAimUp(snum, sb_snum); + playerAimUp(snum, actions); } else if (sb_snum & SKB_AIM_DOWN) { // aim_down - playerAimDown(snum, sb_snum); + playerAimDown(snum, actions); } if (cl_syncinput) diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 5f4d9ca76..6c00df7ee 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -4035,19 +4035,19 @@ HORIZONLY: } else if (sb_snum & SKB_LOOK_UP) { - playerLookUp(snum, sb_snum); + playerLookUp(snum, actions); } else if (sb_snum & SKB_LOOK_DOWN) { - playerLookDown(snum, sb_snum); + playerLookDown(snum, actions); } else if ((sb_snum & SKB_AIM_UP) && !p->OnMotorcycle) { - playerAimUp(snum, sb_snum); + playerAimUp(snum, actions); } else if ((sb_snum & SKB_AIM_DOWN) && !p->OnMotorcycle) { - playerAimDown(snum, sb_snum); + playerAimDown(snum, actions); } if (p->recoil && p->kickback_pic == 0) { diff --git a/source/sw/src/input.cpp b/source/sw/src/input.cpp index 60746b28d..53074c42e 100644 --- a/source/sw/src/input.cpp +++ b/source/sw/src/input.cpp @@ -149,7 +149,6 @@ getinput(InputPacket *loc, SWBOOL tied) SET_LOC_KEY(loc->bits, SK_SPACE_BAR, buttonMap.ButtonDown(gamefunc_Open)); - int const running = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run)); int32_t turnamount; int32_t keymove; @@ -165,7 +164,7 @@ getinput(InputPacket *loc, SWBOOL tied) ApplyGlobalInput(*loc, &info); - if (running) + if (loc->actions & SB_RUN) { if (pp->sop_control) turnamount = RUNTURN * 3; diff --git a/source/sw/src/player.cpp b/source/sw/src/player.cpp index 724fc9505..225b46da2 100644 --- a/source/sw/src/player.cpp +++ b/source/sw/src/player.cpp @@ -2073,7 +2073,7 @@ DoPlayerBob(PLAYERp pp) dist = 0; // if running make a longer stride - if (G_CheckAutorun(TEST_SYNC_KEY(pp, SK_RUN))) + if (pp->input.actions & SB_RUN) { //amt = 10; amt = 12; @@ -2464,31 +2464,12 @@ MoveScrollMode2D(PLAYERp pp) if (M_Active()) return; -#if 0 - // Recenter view if told - if (buttonMap.ButtonDown(gamefunc_Center_View)) - { - Follow_posx = pp->posx; - Follow_posy = pp->posy; - } -#endif - if (buttonMap.ButtonDown(gamefunc_Strafe)) mfsvel -= scrl_input.dyaw / 4; mfsvel -= scrl_input.dx / 4; mfvel = -scrl_input.dz /4; -#if 0 - int const running = !!BUTTON(gamefunc_Run) ^ !!TEST(pp->Flags, PF_LOCK_RUN); - if (running) - { - keymove = NORMALKEYMOVE << 1; - } - else -#endif - { - keymove = NORMALKEYMOVE; - } + keymove = NORMALKEYMOVE; if (buttonMap.ButtonDown(gamefunc_Turn_Left)) {