From 87d09228faea5a16bb1a5a9674f57184882514e0 Mon Sep 17 00:00:00 2001
From: ZTsukei <ztsukei@gmail.com>
Date: Mon, 27 Feb 2017 23:54:02 -0500
Subject: [PATCH] Roulette timer stops manually again - as more players join
 the game, the player in first will have to wait longer to stop the roulette
 manually. Players further back will also wait slightly longer, while the
 person in last will always only take 1 second to stop the roulette. Fixed
 drifting so it stops when you're too slow.

---
 src/doomdef.h | 10 +++++-----
 src/k_kart.c  | 24 +++++++++++++-----------
 src/p_map.c   |  2 +-
 src/p_mobj.c  |  2 +-
 4 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/src/doomdef.h b/src/doomdef.h
index 50213a4d5..2f91afad0 100644
--- a/src/doomdef.h
+++ b/src/doomdef.h
@@ -143,16 +143,16 @@ extern FILE *logstream;
 #define DEVELOP // Disable this for release builds to remove excessive cheat commands and enable MD5 checking and stuff, all in one go. :3
 #ifdef DEVELOP
 #define VERSION    102 // Game version
-#define SUBVERSION 3 // more precise version number
+#define SUBVERSION 4 // more precise version number
 #define VERSIONSTRING "Development EXE"
-#define VERSIONSTRINGW "v1.2.03"
+#define VERSIONSTRINGW "v1.2.04"
 // most interface strings are ignored in development mode.
 // we use comprevision and compbranch instead.
 #else
 #define VERSION    102 // Game version
-#define SUBVERSION 3  // more precise version number
-#define VERSIONSTRING "DevEXE v1.2.03"
-#define VERSIONSTRINGW L"v1.2.03"
+#define SUBVERSION 4  // more precise version number
+#define VERSIONSTRING "DevEXE v1.2.04"
+#define VERSIONSTRINGW L"v1.2.04"
 // Hey! If you change this, add 1 to the MODVERSION below!
 // Otherwise we can't force updates!
 #endif
diff --git a/src/k_kart.c b/src/k_kart.c
index a606f8737..64e4cd39d 100644
--- a/src/k_kart.c
+++ b/src/k_kart.c
@@ -788,12 +788,6 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd)
 	if ((player->kartstuff[k_itemroulette] % 3) == 1 && P_IsLocalPlayer(player))
 		S_StartSound(NULL,sfx_mkitm1 + ((player->kartstuff[k_itemroulette] / 3) % 8));
 
-	// If the roulette finishes or the player presses BT_ATTACK, stop the roulette and calculate the item.
-	// I'm returning via the exact opposite, however, to forgo having another bracket embed. Same result either way, I think.
-	// Finally, if you get past this check, now you can actually start calculating what item you get.
-	if (!(player->kartstuff[k_itemroulette] > (TICRATE*3)-1)) // || ((cmd->buttons & BT_ATTACK) && player->kartstuff[k_itemroulette] > ((TICRATE*2)/3)-1)))
-		return;
-
 	// Initializes existing values
 	basechance = chance = prevchance = 0;
 	numchoices = pingame = pexiting = 0;
@@ -813,6 +807,15 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd)
 			pexiting++;
 	}
 
+	INT32 roulettestop = (TICRATE*1) + (3*(pingame - player->kartstuff[k_position]));
+
+	// If the roulette finishes or the player presses BT_ATTACK, stop the roulette and calculate the item.
+	// I'm returning via the exact opposite, however, to forgo having another bracket embed. Same result either way, I think.
+	// Finally, if you get past this check, now you can actually start calculating what item you get.
+	if (!(player->kartstuff[k_itemroulette] >= (TICRATE*3) 
+		|| ((cmd->buttons & BT_ATTACK) && player->kartstuff[k_itemroulette] >= roulettestop)))
+		return;
+
 	if (cmd->buttons & BT_ATTACK)
 		player->pflags |= PF_ATTACKDOWN;
 
@@ -1887,10 +1890,10 @@ void K_KartDrift(player_t *player, ticcmd_t *cmd, boolean onground)
 	}
 
 	// Drifting: left or right?
-	if (player->kartstuff[k_turndir] == 1 && player->speed > 10 && player->kartstuff[k_jmp] == 1
+	if (player->kartstuff[k_turndir] == 1 && player->speed > (10<<16) && player->kartstuff[k_jmp] == 1
 		&& player->kartstuff[k_drift] < 3 && player->kartstuff[k_drift] > -1) // && player->kartstuff[k_drift] != 1)
 		player->kartstuff[k_drift] = 1;
-	else if (player->kartstuff[k_turndir] == -1 && player->speed > 10 && player->kartstuff[k_jmp] == 1
+	else if (player->kartstuff[k_turndir] == -1 && player->speed > (10<<16) && player->kartstuff[k_jmp] == 1
 		&& player->kartstuff[k_drift] > -3 && player->kartstuff[k_drift] < 1) // && player->kartstuff[k_drift] != -1)
 		player->kartstuff[k_drift] = -1;
 	else if (player->kartstuff[k_jmp] == 0) // || player->kartstuff[k_turndir] == 0)
@@ -1965,7 +1968,7 @@ void K_KartDrift(player_t *player, ticcmd_t *cmd, boolean onground)
 
 	// Stop drifting
 	if (player->kartstuff[k_spinouttimer] > 0 // banana peel
-	|| player->speed < 10) // you're too slow!
+		|| player->speed < (10<<16)) // you're too slow!
 	{
 		player->kartstuff[k_drift] = 0;
 		player->kartstuff[k_driftcharge] = 0;
@@ -2512,8 +2515,7 @@ void K_MoveKartPlayer(player_t *player, ticcmd_t *cmd, boolean onground)
 
 		// Mushroom Boost
 		if (((player->kartstuff[k_mushroomtimer] > 0 && player->kartstuff[k_boosting] == 0)
-			|| (player->kartstuff[k_mushroomtimer] > 0 && ATTACK_IS_DOWN 
-			&& player->kartstuff[k_goldshroomtimer] > 1 && NO_BOO)) && onground)
+			|| (player->kartstuff[k_mushroomtimer] > 0 && ATTACK_IS_DOWN && NO_BOO)) && onground)
 		{
 			cmd->forwardmove = 1;
 			if (player->kartstuff[k_drift] >= 1)
diff --git a/src/p_map.c b/src/p_map.c
index 8b11ba0dd..1cb7eedcb 100644
--- a/src/p_map.c
+++ b/src/p_map.c
@@ -365,7 +365,7 @@ static void P_DoTailsCarry(player_t *sonic, player_t *tails)
 			|| (gametype == GT_MATCH)
 			|| (G_GametypeHasTeams() && tails->ctfteam != sonic->ctfteam))
 			sonic->pflags &= ~PF_CARRIED; */
-		if (tails->spectator || sonic->spectator)
+		if (tails->spectator || sonic->spectator || gametype == GT_RACE) // SRB2kart
 			sonic->pflags &= ~PF_CARRIED;
 		else
 		{
diff --git a/src/p_mobj.c b/src/p_mobj.c
index 6708ddf32..d236cd7ed 100644
--- a/src/p_mobj.c
+++ b/src/p_mobj.c
@@ -1958,7 +1958,7 @@ void P_XYMovement(mobj_t *mo)
 #endif
 
 	//{ SRB2kart stuff
-	if (mo->type == MT_GREENITEM || mo->type == MT_REDITEMDUD || (mo->type == MT_REDITEM && !mo->tracer))
+	if (mo->type == MT_GREENITEM || mo->type == MT_REDITEMDUD || mo->type == MT_REDITEM) //(mo->type == MT_REDITEM && !mo->tracer))
 		return;
 
 	if (mo->player && mo->player->kartstuff[k_spinouttimer] && mo->player->speed <= mo->player->normalspeed/4)
-- 
GitLab