From 8bef451ed927fe6dc14b1344b68310dea9f58ffb Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Wed, 18 Mar 2020 10:56:21 +1100 Subject: [PATCH] Manually merge EDuke32 SVN commit 8619. --- source/rr/src/player.cpp | 125 +++++++++++++++++++++++---------------- 1 file changed, 74 insertions(+), 51 deletions(-) diff --git a/source/rr/src/player.cpp b/source/rr/src/player.cpp index b9403156d..622a985e5 100644 --- a/source/rr/src/player.cpp +++ b/source/rr/src/player.cpp @@ -3167,15 +3167,32 @@ enddisplayweapon: int32_t g_myAimStat = 0, g_oldAimStat = 0; int32_t mouseyaxismode = -1; +enum inputlock_t +{ + IL_NOANGLE = 0x1, + IL_NOHORIZ = 0x2, + IL_NOMOVE = 0x4, + + IL_NOTHING = IL_NOANGLE|IL_NOHORIZ|IL_NOMOVE, +}; + static int P_CheckLockedMovement(int const playerNum) { auto const pPlayer = g_player[playerNum].ps; - if (pPlayer->on_crane >= 0) return 2; + if (pPlayer->on_crane >= 0) + return IL_NOMOVE|IL_NOANGLE; - return (pPlayer->dead_flag || 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 (pPlayer->newowner != -1) + return IL_NOANGLE|IL_NOHORIZ; + + if (pPlayer->dead_flag || 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))) + return IL_NOTHING; + + return 0; } void P_GetInput(int const playerNum) @@ -3448,7 +3465,7 @@ void P_GetInput(int const playerNum) int const movementLocked = P_CheckLockedMovement(playerNum); - if ((ud.scrollmode && ud.overhead_on) || movementLocked == 1) + if ((ud.scrollmode && ud.overhead_on) || (movementLocked & IL_NOTHING) == IL_NOTHING) { if (ud.scrollmode && ud.overhead_on) { @@ -3456,26 +3473,28 @@ void P_GetInput(int const playerNum) ud.folavel = fix16_to_int(input.q16avel); } - localInput.fvel = 0; - localInput.svel = 0; - - localInput.q16avel = 0; - localInput.q16horz = 0; + localInput.fvel = localInput.svel = 0; + localInput.q16avel = localInput.q16horz = 0; } else { - if (movementLocked != 2) + if (!(movementLocked & IL_NOMOVE)) + { + localInput.fvel = clamp(localInput.fvel + input.fvel, -MAXVEL, MAXVEL); + localInput.svel = clamp(localInput.svel + input.svel, -MAXSVEL, MAXSVEL); + } + + if (!(movementLocked & IL_NOANGLE)) { localInput.q16avel = fix16_sadd(localInput.q16avel, input.q16avel); - localInput.fvel = clamp(localInput.fvel + input.fvel, -MAXVEL, MAXVEL); - localInput.svel = clamp(localInput.svel + input.svel, -MAXSVEL, MAXSVEL); - - pPlayer->q16ang = fix16_sadd(pPlayer->q16ang, input.q16avel); - pPlayer->q16ang &= 0x7FFFFFF; + pPlayer->q16ang = fix16_sadd(pPlayer->q16ang, input.q16avel) & 0x7FFFFFF; + } + + if (!(movementLocked & IL_NOHORIZ)) + { + localInput.q16horz = fix16_clamp(fix16_sadd(localInput.q16horz, input.q16horz), F16(-MAXHORIZVEL), F16(MAXHORIZVEL)); + pPlayer->q16horiz = fix16_clamp(fix16_sadd(pPlayer->q16horiz, input.q16horz), F16(HORIZ_MIN), F16(HORIZ_MAX)); } - - localInput.q16horz = fix16_clamp(fix16_sadd(localInput.q16horz, input.q16horz), F16(-MAXHORIZVEL), F16(MAXHORIZVEL)); - pPlayer->q16horiz = fix16_clamp(fix16_add(pPlayer->q16horiz, input.q16horz), F16(HORIZ_MIN), F16(HORIZ_MAX)); } // A horiz diff of 128 equal 45 degrees, so we convert horiz to 1024 angle units @@ -3776,7 +3795,7 @@ void P_GetInputMotorcycle(int playerNum) int const movementLocked = P_CheckLockedMovement(playerNum); - if ((ud.scrollmode && ud.overhead_on) || movementLocked == 1) + if ((ud.scrollmode && ud.overhead_on) || (movementLocked & IL_NOTHING) == IL_NOTHING) { if (ud.scrollmode && ud.overhead_on) { @@ -3784,26 +3803,28 @@ void P_GetInputMotorcycle(int playerNum) ud.folavel = fix16_to_int(input.q16avel); } - localInput.fvel = 0; - localInput.svel = 0; - - localInput.q16avel = 0; - localInput.q16horz = 0; + localInput.fvel = localInput.svel = 0; + localInput.q16avel = localInput.q16horz = 0; } else { - if (movementLocked != 2) + if (!(movementLocked & IL_NOMOVE)) + { + localInput.fvel = clamp(localInput.fvel + input.fvel, -15, 120); + localInput.svel = clamp(localInput.svel + input.svel, -MAXSVEL, MAXSVEL); + } + + if (!(movementLocked & IL_NOANGLE)) { localInput.q16avel = fix16_sadd(localInput.q16avel, input.q16avel); - localInput.fvel = clamp(localInput.fvel + input.fvel, -15, 120); - localInput.svel = clamp(localInput.svel + input.svel, -MAXSVEL, MAXSVEL); - - pPlayer->q16ang = fix16_sadd(pPlayer->q16ang, input.q16avel); - pPlayer->q16ang &= 0x7FFFFFF; + pPlayer->q16ang = fix16_sadd(pPlayer->q16ang, input.q16avel) & 0x7FFFFFF; + } + + if (!(movementLocked & IL_NOHORIZ)) + { + localInput.q16horz = fix16_clamp(fix16_sadd(localInput.q16horz, input.q16horz), F16(-MAXHORIZVEL), F16(MAXHORIZVEL)); + pPlayer->q16horiz = fix16_clamp(fix16_sadd(pPlayer->q16horiz, input.q16horz), F16(HORIZ_MIN), F16(HORIZ_MAX)); } - - localInput.q16horz = fix16_clamp(fix16_sadd(localInput.q16horz, input.q16horz), F16(-MAXHORIZVEL), F16(MAXHORIZVEL)); - pPlayer->q16horiz = fix16_clamp(fix16_add(pPlayer->q16horiz, input.q16horz), F16(HORIZ_MIN), F16(HORIZ_MAX)); } // A horiz diff of 128 equal 45 degrees, so we convert horiz to 1024 angle units @@ -4083,7 +4104,7 @@ void P_GetInputBoat(int playerNum) int const movementLocked = P_CheckLockedMovement(playerNum); - if ((ud.scrollmode && ud.overhead_on) || movementLocked == 1) + if ((ud.scrollmode && ud.overhead_on) || (movementLocked & IL_NOTHING) == IL_NOTHING) { if (ud.scrollmode && ud.overhead_on) { @@ -4091,26 +4112,28 @@ void P_GetInputBoat(int playerNum) ud.folavel = fix16_to_int(input.q16avel); } - localInput.fvel = 0; - localInput.svel = 0; - - localInput.q16avel = 0; - localInput.q16horz = 0; + localInput.fvel = localInput.svel = 0; + localInput.q16avel = localInput.q16horz = 0; } else { - if (movementLocked != 2) + if (!(movementLocked & IL_NOMOVE)) + { + localInput.fvel = clamp(localInput.fvel + input.fvel, -15, 120); + localInput.svel = clamp(localInput.svel + input.svel, -MAXSVEL, MAXSVEL); + } + + if (!(movementLocked & IL_NOANGLE)) { localInput.q16avel = fix16_sadd(localInput.q16avel, input.q16avel); - localInput.fvel = clamp(localInput.fvel + input.fvel, -15, 120); - localInput.svel = clamp(localInput.svel + input.svel, -MAXSVEL, MAXSVEL); - - pPlayer->q16ang = fix16_sadd(pPlayer->q16ang, input.q16avel); - pPlayer->q16ang &= 0x7FFFFFF; + pPlayer->q16ang = fix16_sadd(pPlayer->q16ang, input.q16avel) & 0x7FFFFFF; + } + + if (!(movementLocked & IL_NOHORIZ)) + { + localInput.q16horz = fix16_clamp(fix16_sadd(localInput.q16horz, input.q16horz), F16(-MAXHORIZVEL), F16(MAXHORIZVEL)); + pPlayer->q16horiz = fix16_clamp(fix16_sadd(pPlayer->q16horiz, input.q16horz), F16(HORIZ_MIN), F16(HORIZ_MAX)); } - - localInput.q16horz = fix16_clamp(fix16_sadd(localInput.q16horz, input.q16horz), F16(-MAXHORIZVEL), F16(MAXHORIZVEL)); - pPlayer->q16horiz = fix16_clamp(fix16_add(pPlayer->q16horiz, input.q16horz), F16(HORIZ_MIN), F16(HORIZ_MAX)); } // A horiz diff of 128 equal 45 degrees, @@ -8364,7 +8387,7 @@ check_enemy_sprite: } } - if (P_CheckLockedMovement(playerNum)) + if (P_CheckLockedMovement(playerNum) & IL_NOMOVE) { velocityModifier = 0; pPlayer->vel.x = 0; @@ -9418,7 +9441,7 @@ void P_DHProcessInput(int playerNum) } } - if (P_CheckLockedMovement(playerNum)) + if (P_CheckLockedMovement(playerNum) & IL_NOMOVE) { velocityModifier = 0; pPlayer->vel.x = 0;