mirror of
				https://github.com/KartKrewDev/RingRacers.git
				synced 2025-10-30 08:01:28 +00:00 
			
		
		
		
	Add speed to gametype
Set a specific gamespeed per gametype. KARTSPEED_AUTO for it to be decided by game settings. Wanted this for a while, but also it makes game speed display logic for DRP very straightforward.
This commit is contained in:
		
							parent
							
								
									55d71d7674
								
							
						
					
					
						commit
						af6340741e
					
				
					 6 changed files with 55 additions and 10 deletions
				
			
		| 
						 | 
				
			
			@ -784,6 +784,7 @@ void readgametype(MYFILE *f, char *gtname)
 | 
			
		|||
	INT32 newgtpointlimit = 0;
 | 
			
		||||
	INT32 newgttimelimit = 0;
 | 
			
		||||
	UINT8 newgtinttype = 0;
 | 
			
		||||
	SINT8 newgtspeed = KARTSPEED_AUTO; // KARTSPEED_EASY
 | 
			
		||||
	char gtconst[MAXLINELEN];
 | 
			
		||||
	char gppic[9];
 | 
			
		||||
	char gppicmini[9];
 | 
			
		||||
| 
						 | 
				
			
			@ -850,6 +851,29 @@ void readgametype(MYFILE *f, char *gtname)
 | 
			
		|||
				// Case sensitive
 | 
			
		||||
				newgtinttype = (int)get_number(word2lwr);
 | 
			
		||||
			}
 | 
			
		||||
			else if (fastcmp(word, "GAMESPEED"))
 | 
			
		||||
			{
 | 
			
		||||
				if (fasticmp(word2, "EASY"))
 | 
			
		||||
				{
 | 
			
		||||
					newgtspeed = KARTSPEED_EASY;
 | 
			
		||||
				}
 | 
			
		||||
				else if (fasticmp(word2, "NORMAL"))
 | 
			
		||||
				{
 | 
			
		||||
					newgtspeed = KARTSPEED_NORMAL;
 | 
			
		||||
				}
 | 
			
		||||
				else if (fasticmp(word2, "HARD"))
 | 
			
		||||
				{
 | 
			
		||||
					newgtspeed = KARTSPEED_HARD;
 | 
			
		||||
				}
 | 
			
		||||
				else if (fasticmp(word2, "ANY"))
 | 
			
		||||
				{
 | 
			
		||||
					newgtspeed = KARTSPEED_AUTO;
 | 
			
		||||
				}
 | 
			
		||||
				else
 | 
			
		||||
				{
 | 
			
		||||
					deh_warning("readgametype %s: unknown gamespeed name %s\n", gtname, word2);
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			// Type of level
 | 
			
		||||
			else if (fastcmp(word, "TYPEOFLEVEL"))
 | 
			
		||||
			{
 | 
			
		||||
| 
						 | 
				
			
			@ -942,6 +966,7 @@ void readgametype(MYFILE *f, char *gtname)
 | 
			
		|||
	newgametype->intermission = newgtinttype;
 | 
			
		||||
	newgametype->pointlimit = newgtpointlimit;
 | 
			
		||||
	newgametype->timelimit = newgttimelimit;
 | 
			
		||||
	newgametype->speed = newgtspeed;
 | 
			
		||||
 | 
			
		||||
	gametypes[numgametypes++] = newgametype;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -624,6 +624,7 @@ struct gametype_t
 | 
			
		|||
	UINT32 rules;
 | 
			
		||||
	UINT32 tol;
 | 
			
		||||
	UINT8 intermission;
 | 
			
		||||
	SINT8 speed;
 | 
			
		||||
	INT32 pointlimit;
 | 
			
		||||
	INT32 timelimit;
 | 
			
		||||
	char gppic[9];
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3181,6 +3181,7 @@ static gametype_t defaultgametypes[] =
 | 
			
		|||
		GTR_CIRCUIT|GTR_BOTS|GTR_ENCORE,
 | 
			
		||||
		TOL_RACE,
 | 
			
		||||
		int_time,
 | 
			
		||||
		KARTSPEED_AUTO,
 | 
			
		||||
		0,
 | 
			
		||||
		0,
 | 
			
		||||
		"",
 | 
			
		||||
| 
						 | 
				
			
			@ -3194,6 +3195,7 @@ static gametype_t defaultgametypes[] =
 | 
			
		|||
		GTR_SPHERES|GTR_BUMPERS|GTR_PAPERITEMS|GTR_POWERSTONES|GTR_KARMA|GTR_ITEMARROWS|GTR_PRISONS|GTR_BATTLESTARTS|GTR_POINTLIMIT|GTR_TIMELIMIT|GTR_OVERTIME|GTR_CLOSERPLAYERS,
 | 
			
		||||
		TOL_BATTLE,
 | 
			
		||||
		int_scoreortimeattack,
 | 
			
		||||
		KARTSPEED_EASY,
 | 
			
		||||
		0,
 | 
			
		||||
		3,
 | 
			
		||||
		"TT_RNDB",
 | 
			
		||||
| 
						 | 
				
			
			@ -3207,6 +3209,7 @@ static gametype_t defaultgametypes[] =
 | 
			
		|||
		GTR_CATCHER|GTR_SPECIALSTART|GTR_ROLLINGSTART|GTR_CIRCUIT|GTR_NOPOSITION,
 | 
			
		||||
		TOL_SPECIAL,
 | 
			
		||||
		int_time,
 | 
			
		||||
		KARTSPEED_AUTO,
 | 
			
		||||
		0,
 | 
			
		||||
		0,
 | 
			
		||||
		"TT_RNDSS",
 | 
			
		||||
| 
						 | 
				
			
			@ -3220,6 +3223,7 @@ static gametype_t defaultgametypes[] =
 | 
			
		|||
		GTR_BOSS|GTR_SPHERES|GTR_BUMPERS|GTR_POINTLIMIT|GTR_CLOSERPLAYERS|GTR_NOCUPSELECT|GTR_ENCORE,
 | 
			
		||||
		TOL_VERSUS,
 | 
			
		||||
		int_scoreortimeattack,
 | 
			
		||||
		KARTSPEED_EASY,
 | 
			
		||||
		0,
 | 
			
		||||
		0,
 | 
			
		||||
		"",
 | 
			
		||||
| 
						 | 
				
			
			@ -3233,6 +3237,7 @@ static gametype_t defaultgametypes[] =
 | 
			
		|||
		GTR_CHECKPOINTS|GTR_NOMP|GTR_NOCUPSELECT|GTR_NOPOSITION,
 | 
			
		||||
		TOL_TUTORIAL,
 | 
			
		||||
		int_none,
 | 
			
		||||
		KARTSPEED_EASY,
 | 
			
		||||
		0,
 | 
			
		||||
		0,
 | 
			
		||||
		"",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2516,7 +2516,7 @@ static void HU_DrawRankings(void)
 | 
			
		|||
		V_DrawCenteredString(256, 8, 0, "POINT LIMIT");
 | 
			
		||||
		V_DrawCenteredString(256, 16, hilicol, va("%d", g_pointlimit));
 | 
			
		||||
	}
 | 
			
		||||
	else if (gametyperules & GTR_CIRCUIT)
 | 
			
		||||
	else if (gametypes[gametype]->speed == KARTSPEED_AUTO)
 | 
			
		||||
	{
 | 
			
		||||
		V_DrawCenteredString(256, 8, 0, "GAME SPEED");
 | 
			
		||||
		V_DrawCenteredString(256, 16, hilicol, (cv_4thgear.value) ? va("4th Gear") : kartspeed_cons_t[1+gamespeed].strvalue);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2567,6 +2567,7 @@ static int lib_gAddGametype(lua_State *L)
 | 
			
		|||
	INT32 newgtpointlimit = 0;
 | 
			
		||||
	INT32 newgttimelimit = 0;
 | 
			
		||||
	UINT8 newgtinttype = 0;
 | 
			
		||||
	SINT8 newgtspeed = KARTSPEED_AUTO;
 | 
			
		||||
	INT16 j;
 | 
			
		||||
 | 
			
		||||
	luaL_checktype(L, 1, LUA_TTABLE);
 | 
			
		||||
| 
						 | 
				
			
			@ -2632,6 +2633,14 @@ static int lib_gAddGametype(lua_State *L)
 | 
			
		|||
			if (!lua_isstring(L, 3))
 | 
			
		||||
				TYPEERROR("gppicmini", LUA_TSTRING)
 | 
			
		||||
			gppicmini = lua_tostring(L, 3);
 | 
			
		||||
		} else if (i == 10 || (k && fasticmp(k, "speed"))) {
 | 
			
		||||
			if (!lua_isnumber(L, 3))
 | 
			
		||||
				TYPEERROR("speed", LUA_TNUMBER)
 | 
			
		||||
			newgtspeed = (UINT32)lua_tointeger(L, 3);
 | 
			
		||||
			if (newgtspeed < KARTSPEED_AUTO || newgtspeed > KARTSPEED_HARD)
 | 
			
		||||
			{
 | 
			
		||||
				newgtspeed = KARTSPEED_AUTO;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		lua_pop(L, 1);
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -2672,6 +2681,7 @@ static int lib_gAddGametype(lua_State *L)
 | 
			
		|||
	newgametype->intermission = newgtinttype;
 | 
			
		||||
	newgametype->pointlimit = newgtpointlimit;
 | 
			
		||||
	newgametype->timelimit = newgttimelimit;
 | 
			
		||||
	newgametype->speed = newgtspeed;
 | 
			
		||||
 | 
			
		||||
	if (gppic != NULL)
 | 
			
		||||
	{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7673,7 +7673,8 @@ static void P_InitLevelSettings(void)
 | 
			
		|||
	g_exit.retry = false;
 | 
			
		||||
 | 
			
		||||
	// Gamespeed and frantic items
 | 
			
		||||
	gamespeed = KARTSPEED_EASY;
 | 
			
		||||
	const boolean multi_speed = (gametypes[gametype]->speed == KARTSPEED_AUTO);
 | 
			
		||||
	gamespeed = multi_speed ? KARTSPEED_EASY : gametypes[gametype]->speed;
 | 
			
		||||
	franticitems = false;
 | 
			
		||||
 | 
			
		||||
	if (K_PodiumSequence() == true)
 | 
			
		||||
| 
						 | 
				
			
			@ -7688,7 +7689,7 @@ static void P_InitLevelSettings(void)
 | 
			
		|||
	}
 | 
			
		||||
	else if (grandprixinfo.gp == true)
 | 
			
		||||
	{
 | 
			
		||||
		if (gametyperules & GTR_CIRCUIT)
 | 
			
		||||
		if (multi_speed)
 | 
			
		||||
		{
 | 
			
		||||
			gamespeed = grandprixinfo.gamespeed;
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -7698,18 +7699,21 @@ static void P_InitLevelSettings(void)
 | 
			
		|||
		|| tutorialchallenge ==  TUTORIALSKIP_INPROGRESS
 | 
			
		||||
	)
 | 
			
		||||
	{
 | 
			
		||||
		if ((gametyperules & GTR_CATCHER) && encoremode == false)
 | 
			
		||||
		if (multi_speed)
 | 
			
		||||
		{
 | 
			
		||||
			gamespeed = KARTSPEED_NORMAL;
 | 
			
		||||
		}
 | 
			
		||||
		else if (gametyperules & GTR_CIRCUIT)
 | 
			
		||||
		{
 | 
			
		||||
			gamespeed = KARTSPEED_HARD;
 | 
			
		||||
			if ((gametyperules & GTR_CATCHER) && encoremode == false)
 | 
			
		||||
			{
 | 
			
		||||
				gamespeed = KARTSPEED_NORMAL;
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				gamespeed = KARTSPEED_HARD;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		if (gametyperules & GTR_CIRCUIT)
 | 
			
		||||
		if (multi_speed)
 | 
			
		||||
		{
 | 
			
		||||
			if (cv_kartspeed.value == KARTSPEED_AUTO)
 | 
			
		||||
				gamespeed = ((speedscramble == -1) ? KARTSPEED_NORMAL : (UINT8)speedscramble);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue