From 672bcc349c0ee07b0edf7844e53cfdf00e3fcb22 Mon Sep 17 00:00:00 2001
From: toasterbabe <rollerorbital@gmail.com>
Date: Wed, 26 Jul 2017 16:10:08 +0100
Subject: [PATCH] * Hide the number of lives you can steal if game-overed. It's
 not directly relevant unless you're game overed. * Fix an issue where
 everyone being game overed except for one person, and then kicking that one
 person, meant the game over trigger was never met. * Fix an issue where the
 spectator text could be overridden with a count of the number of remaining
 players to complete the level. * Fixed a few glitches with spinning.
 (Unrelated to the branch, but exposed through new_coop testing.)

---
 src/p_mobj.c   | 20 ++++++++++----------
 src/p_user.c   | 41 ++++++++++++++++++-----------------------
 src/st_stuff.c |  4 +++-
 3 files changed, 31 insertions(+), 34 deletions(-)

diff --git a/src/p_mobj.c b/src/p_mobj.c
index ccf5e36688..122d3bfd5d 100644
--- a/src/p_mobj.c
+++ b/src/p_mobj.c
@@ -3041,6 +3041,15 @@ static void P_PlayerZMovement(mobj_t *mo)
 
 				if (mo->health && !mo->player->spectator && !P_CheckDeathPitCollide(mo))
 				{
+					if ((mo->player->charability2 == CA2_SPINDASH) && !(mo->player->pflags & PF_THOKKED) && (mo->player->cmd.buttons & BT_USE) && (FixedHypot(mo->momx, mo->momy) > (5*mo->scale)))
+					{
+						mo->player->pflags |= PF_SPINNING;
+						P_SetPlayerMobjState(mo, S_PLAY_ROLL);
+						S_StartSound(mo, sfx_spin);
+					}
+					else
+						mo->player->pflags &= ~PF_SPINNING;
+
 					if (mo->player->pflags & PF_GLIDING) // ground gliding
 					{
 						mo->player->skidtime = TICRATE;
@@ -3053,7 +3062,7 @@ static void P_PlayerZMovement(mobj_t *mo)
 						S_StartSound(mo, sfx_s3k8b);
 						mo->player->pflags |= PF_FULLSTASIS;
 					}
-					else if (mo->player->pflags & PF_JUMPED || (mo->player->pflags & (PF_SPINNING|PF_USEDOWN)) != (PF_SPINNING|PF_USEDOWN)
+					else if (mo->player->pflags & PF_JUMPED || !(mo->player->pflags & PF_SPINNING)
 					|| mo->player->powers[pw_tailsfly] || mo->state-states == S_PLAY_FLY_TIRED)
 					{
 						if (mo->player->cmomx || mo->player->cmomy)
@@ -3084,15 +3093,6 @@ static void P_PlayerZMovement(mobj_t *mo)
 						}
 					}
 
-					if ((mo->player->charability2 == CA2_SPINDASH) && !(mo->player->pflags & PF_THOKKED) && (mo->player->cmd.buttons & BT_USE) && (FixedHypot(mo->momx, mo->momy) > (5*mo->scale)))
-					{
-						mo->player->pflags |= PF_SPINNING;
-						P_SetPlayerMobjState(mo, S_PLAY_ROLL);
-						S_StartSound(mo, sfx_spin);
-					}
-					else
-						mo->player->pflags &= ~PF_SPINNING;
-
 					if (!(mo->player->pflags & PF_GLIDING))
 						mo->player->pflags &= ~(PF_JUMPED|PF_NOJUMPDAMAGE);
 
diff --git a/src/p_user.c b/src/p_user.c
index adaa78ed48..28646d0caa 100644
--- a/src/p_user.c
+++ b/src/p_user.c
@@ -4837,7 +4837,7 @@ static void P_3dMovement(player_t *player)
 	angle_t dangle; // replaces old quadrants bits
 	fixed_t normalspd = FixedMul(player->normalspeed, player->mo->scale);
 	boolean analogmove = false;
-	boolean spin = (player->pflags & PF_SPINNING && (player->rmomx || player->rmomy) && !(player->pflags & PF_STARTDASH));
+	boolean spin = ((onground = P_IsObjectOnGround(player->mo)) && player->pflags & PF_SPINNING && (player->rmomx || player->rmomy) && !(player->pflags & PF_STARTDASH));
 	fixed_t oldMagnitude, newMagnitude;
 #ifdef ESLOPE
 	vector3_t totalthrust;
@@ -4927,9 +4927,6 @@ static void P_3dMovement(player_t *player)
 	if (player->pflags & PF_SLIDING)
 		cmd->forwardmove = 0;
 
-	// Do not let the player control movement if not onground.
-	onground = P_IsObjectOnGround(player->mo);
-
 	player->aiming = cmd->aiming<<FRACBITS;
 
 	// Set the player speeds.
@@ -4990,10 +4987,7 @@ static void P_3dMovement(player_t *player)
 	if (spin) // Prevent gaining speed whilst rolling!
 	{
 		const fixed_t ns = FixedDiv(549*ORIG_FRICTION,500*FRACUNIT); // P_XYFriction
-		if (onground)
-			topspeed = FixedMul(oldMagnitude, ns);
-		else
-			topspeed = oldMagnitude;
+		topspeed = FixedMul(oldMagnitude, ns);
 	}
 
 	// Better maneuverability while flying
@@ -5037,15 +5031,14 @@ static void P_3dMovement(player_t *player)
 		// allow very small movement while in air for gameplay
 		if (!onground)
 			movepushforward >>= 2; // proper air movement
-
 		// Allow a bit of movement while spinning
-		if (player->pflags & PF_SPINNING)
+		else if (player->pflags & PF_SPINNING)
 		{
 			if ((mforward && cmd->forwardmove > 0) || (mbackward && cmd->forwardmove < 0)
 			|| (player->pflags & PF_STARTDASH))
 				movepushforward = 0;
 			else
-				movepushforward = FixedDiv(movepushforward, 16*FRACUNIT);
+				movepushforward >>= 4;
 		}
 
 		movepushforward = FixedMul(movepushforward, player->mo->scale);
@@ -5077,17 +5070,14 @@ static void P_3dMovement(player_t *player)
 			// allow very small movement while in air for gameplay
 			if (!onground)
 				movepushforward >>= 2; // proper air movement
-
 			// Allow a bit of movement while spinning
-			if (player->pflags & PF_SPINNING)
+			else if (player->pflags & PF_SPINNING)
 			{
-				// Stupid little movement prohibitor hack
-				// that REALLY shouldn't belong in analog code.
 				if ((mforward && cmd->forwardmove > 0) || (mbackward && cmd->forwardmove < 0)
 				|| (player->pflags & PF_STARTDASH))
 					movepushforward = 0;
 				else
-					movepushforward = FixedDiv(movepushforward, 16*FRACUNIT);
+					movepushforward >>= 4;
 			}
 
 			movepushsideangle = controldirection;
@@ -8198,6 +8188,10 @@ boolean P_GetLives(player_t *player)
 static void P_ConsiderAllGone(void)
 {
 	INT32 i, lastdeadplayer = -1, deadtimercheck = INT32_MAX;
+
+	if (countdown2)
+		return;
+
 	for (i = 0; i < MAXPLAYERS; i++)
 	{
 		if (!playeringame[i])
@@ -8206,15 +8200,16 @@ static void P_ConsiderAllGone(void)
 		if (players[i].playerstate != PST_DEAD && !players[i].spectator && players[i].mo && players[i].mo->health)
 			break;
 
-		if (players[i].lives > 0)
+		if (players[i].spectator)
+		{
+			if (lastdeadplayer == -1)
+				lastdeadplayer = i;
+		}
+		else if (players[i].lives > 0)
 		{
-			if (players[i].spectator && lastdeadplayer == -1)
-				;
-			else if (players[i].deadtimer < deadtimercheck)
-				deadtimercheck = players[i].deadtimer;
-			else
-				continue;
 			lastdeadplayer = i;
+			if (players[i].deadtimer < deadtimercheck)
+				deadtimercheck = players[i].deadtimer;
 		}
 	}
 
diff --git a/src/st_stuff.c b/src/st_stuff.c
index 06877bbb3a..c85e5d28e5 100644
--- a/src/st_stuff.c
+++ b/src/st_stuff.c
@@ -761,6 +761,7 @@ static void ST_drawLives(void)
 						va("%d",sum));
 					return;
 				}
+#if 0 // render the number of lives you COULD steal
 			case 2:
 				{
 					INT32 i, sum = 0;
@@ -781,6 +782,7 @@ static void ST_drawLives(void)
 						V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANSHALF|v_splitflag, va("/%d",sum));
 				}
 				// intentional fallthrough
+#endif
 			default:
 				// don't return so the SP one can be drawn below
 				break;
@@ -1997,7 +1999,7 @@ static void ST_overlayDrawer(void)
 
 	if (!hu_showscores && (netgame || multiplayer) && displayplayer == consoleplayer)
 	{
-		if (stplyr->exiting && cv_playersforexit.value && gametype == GT_COOP)
+		if (!stplyr->spectator && stplyr->exiting && cv_playersforexit.value && gametype == GT_COOP)
 		{
 			INT32 i, total = 0, exiting = 0;
 
-- 
GitLab