diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index 2df95f938..b819d71b7 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -233,5 +233,6 @@ void nonsharedkeys(void); void apply_seasick(player_struct* p, double scalefactor); void calcviewpitch(player_struct* p, double factor); void sethorizon(int snum, int sb_snum, double factor, bool frominput = false); +bool movementBlocked(int snum); END_DUKE_NS diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index 23a2dbf65..4e36fb43b 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -950,6 +950,38 @@ void playerAimDown(int snum, ESyncBits sb_snum) } } +//--------------------------------------------------------------------------- +// +// split out so that the weapon check can be done right. +// +//--------------------------------------------------------------------------- + +bool movementBlocked(int snum) +{ + auto p = &ps[snum]; + + auto blockingweapon = [=]() + { + if (isRR()) return false; + if (isWW2GI()) return aplWeaponWorksLike[p->curr_weapon][snum] == TRIPBOMB_WEAPON; + else return p->curr_weapon == TRIPBOMB_WEAPON; + }; + + auto weapondelay = [=]() + { + if (isWW2GI()) return aplWeaponFireDelay[p->curr_weapon][snum]; + else return 4; + }; + + return (p->fist_incs || + p->transporter_hold > 2 || + p->hard_landing || + p->access_incs > 0 || + p->knee_incs > 0 || + (blockingweapon() && p->kickback_pic > 1 && p->kickback_pic < weapondelay())); +} + + //--------------------------------------------------------------------------- // // diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index af8d5aa16..8d8f4feae 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -2789,13 +2789,7 @@ void processinput_d(int snum) //Do the quick lefts and rights - if (p->fist_incs || - p->transporter_hold > 2 || - p->hard_landing || - p->access_incs > 0 || - p->knee_incs > 0 || - (((!isWW2GI() && p->curr_weapon == TRIPBOMB_WEAPON) || (isWW2GI() && aplWeaponWorksLike[p->curr_weapon][snum] == TRIPBOMB_WEAPON)) && - p->kickback_pic > 1 && p->kickback_pic < 4)) + if (movementBlocked(snum)) { doubvel = 0; p->posxv = 0; diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index e3e0817f5..a137d3872 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -3698,11 +3698,7 @@ void processinput_r(int snum) //Do the quick lefts and rights - if (p->fist_incs || - p->transporter_hold > 2 || - p->hard_landing || - p->access_incs > 0 || - p->knee_incs > 0) + if (movementBlocked(snum)) { doubvel = 0; p->posxv = 0; diff --git a/source/games/duke/src/prediction.cpp b/source/games/duke/src/prediction.cpp index 523b981e1..e18b7dad7 100644 --- a/source/games/duke/src/prediction.cpp +++ b/source/games/duke/src/prediction.cpp @@ -394,14 +394,7 @@ void fakedomovethings(void) } - if ( p->fist_incs || - p->transporter_hold > 2 || - myhardlanding || - p->access_incs > 0 || - p->knee_incs > 0 || - (p->curr_weapon == TRIPBOMB_WEAPON && - p->kickback_pic > 1 && - p->kickback_pic < 4 ) ) + if (movementBlocked(snum) || myhardlanding) { doubvel = 0; myxvel = 0; diff --git a/source/games/duke/src/zz_player.cpp b/source/games/duke/src/zz_player.cpp index 7bdfdb2d1..8b5fb28c6 100644 --- a/source/games/duke/src/zz_player.cpp +++ b/source/games/duke/src/zz_player.cpp @@ -63,23 +63,20 @@ enum inputlock_t // //--------------------------------------------------------------------------- -static int P_CheckLockedMovement(int const playerNum) +static int P_CheckLockedMovement(int snum) { - auto const pPlayer = &ps[playerNum]; + auto p = &ps[snum]; - if (sprite[pPlayer->i].extra <= 0 || (pPlayer->dead_flag && !ud.god) || pPlayer->fist_incs || pPlayer->transporter_hold > 2 || pPlayer->hard_landing || pPlayer->access_incs > 0 - || pPlayer->knee_incs > 0 - || (PWEAPON(playerNum, pPlayer->curr_weapon, WorksLike) == TRIPBOMB_WEAPON && pPlayer->kickback_pic > 1 - && pPlayer->kickback_pic < PWEAPON(playerNum, pPlayer->curr_weapon, FireDelay))) + if (sprite[p->i].extra <= 0 || (p->dead_flag && !ud.god) || movementBlocked(snum)) return IL_NOTHING; - if (pPlayer->on_crane >= 0) + if (p->on_crane >= 0) return IL_NOMOVE | IL_NOANGLE; - if (pPlayer->newowner != -1) + if (p->newowner != -1) return IL_NOANGLE | IL_NOHORIZ; - if (pPlayer->return_to_center > 0) + if (p->return_to_center > 0) return IL_NOHORIZ; return 0;