mirror of
				https://github.com/KartKrewDev/RingRacers.git
				synced 2025-10-30 08:01:28 +00:00 
			
		
		
		
	Merge branch 'node0Bot' into 'master'
Fix node 0 being occupied by a bot in dedicated servers for clients Closes #385 See merge request kart-krew-dev/ring-racers!77
This commit is contained in:
		
						commit
						b4c597161b
					
				
					 7 changed files with 22 additions and 8 deletions
				
			
		|  | @ -105,6 +105,7 @@ boolean server = true; // true or false but !server == client | ||||||
| #define client (!server) | #define client (!server) | ||||||
| boolean nodownload = false; | boolean nodownload = false; | ||||||
| boolean serverrunning = false; | boolean serverrunning = false; | ||||||
|  | boolean connectedtodedicated = false; | ||||||
| INT32 serverplayer = 0; | INT32 serverplayer = 0; | ||||||
| char motd[254], server_context[8]; // Message of the Day, Unique Context (even without Mumble support)
 | char motd[254], server_context[8]; // Message of the Day, Unique Context (even without Mumble support)
 | ||||||
| 
 | 
 | ||||||
|  | @ -1271,6 +1272,7 @@ static boolean SV_SendServerConfig(INT32 node) | ||||||
| 	netbuffer->u.servercfg.gamestate = (UINT8)gamestate; | 	netbuffer->u.servercfg.gamestate = (UINT8)gamestate; | ||||||
| 	netbuffer->u.servercfg.gametype = (UINT8)gametype; | 	netbuffer->u.servercfg.gametype = (UINT8)gametype; | ||||||
| 	netbuffer->u.servercfg.modifiedgame = (UINT8)modifiedgame; | 	netbuffer->u.servercfg.modifiedgame = (UINT8)modifiedgame; | ||||||
|  | 	netbuffer->u.servercfg.dedicated = (boolean)dedicated; | ||||||
| 
 | 
 | ||||||
| 	netbuffer->u.servercfg.maxplayer = (UINT8)(min((dedicated ? MAXPLAYERS-1 : MAXPLAYERS), cv_maxconnections.value)); | 	netbuffer->u.servercfg.maxplayer = (UINT8)(min((dedicated ? MAXPLAYERS-1 : MAXPLAYERS), cv_maxconnections.value)); | ||||||
| 	netbuffer->u.servercfg.allownewplayer = cv_allownewplayer.value; | 	netbuffer->u.servercfg.allownewplayer = cv_allownewplayer.value; | ||||||
|  | @ -2502,6 +2504,7 @@ static void Command_connect(void) | ||||||
| 	// we don't request a restart unless the filelist differs
 | 	// we don't request a restart unless the filelist differs
 | ||||||
| 
 | 
 | ||||||
| 	server = false; | 	server = false; | ||||||
|  | 	connectedtodedicated = false; | ||||||
| 
 | 
 | ||||||
| 	// Get the server node.
 | 	// Get the server node.
 | ||||||
| 	if (netgame) | 	if (netgame) | ||||||
|  | @ -2761,6 +2764,7 @@ void CL_Reset(void) | ||||||
| 	multiplayer = false; | 	multiplayer = false; | ||||||
| 	servernode = 0; | 	servernode = 0; | ||||||
| 	server = true; | 	server = true; | ||||||
|  | 	connectedtodedicated = false; | ||||||
| 	doomcom->numnodes = 1; | 	doomcom->numnodes = 1; | ||||||
| 	doomcom->numslots = 1; | 	doomcom->numslots = 1; | ||||||
| 	SV_StopServer(); | 	SV_StopServer(); | ||||||
|  | @ -4274,6 +4278,11 @@ boolean Playing(void) | ||||||
| 	return (server && serverrunning) || (client && cl_mode == CL_CONNECTED); | 	return (server && serverrunning) || (client && cl_mode == CL_CONNECTED); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | boolean InADedicatedServer(void) | ||||||
|  | { | ||||||
|  | 	return Playing() && (dedicated || connectedtodedicated); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| boolean SV_SpawnServer(void) | boolean SV_SpawnServer(void) | ||||||
| { | { | ||||||
| #ifdef TESTERS | #ifdef TESTERS | ||||||
|  | @ -4376,6 +4385,7 @@ void SV_StartSinglePlayerServer(INT32 dogametype, boolean donetgame) | ||||||
| { | { | ||||||
| 	INT32 lastgametype = gametype; | 	INT32 lastgametype = gametype; | ||||||
| 	server = true; | 	server = true; | ||||||
|  | 	connectedtodedicated = false; | ||||||
| 	multiplayer = (modeattacking == ATTACKING_NONE); | 	multiplayer = (modeattacking == ATTACKING_NONE); | ||||||
| 	joinedIP[0] = '\0';	// Make sure to empty this so that we don't save garbage when we start our own game. (because yes we use this for netgames too....)
 | 	joinedIP[0] = '\0';	// Make sure to empty this so that we don't save garbage when we start our own game. (because yes we use this for netgames too....)
 | ||||||
| 
 | 
 | ||||||
|  | @ -5002,6 +5012,7 @@ static void HandlePacketFromAwayNode(SINT8 node) | ||||||
| 				G_SetGametype(netbuffer->u.servercfg.gametype); | 				G_SetGametype(netbuffer->u.servercfg.gametype); | ||||||
| 
 | 
 | ||||||
| 				modifiedgame = netbuffer->u.servercfg.modifiedgame; | 				modifiedgame = netbuffer->u.servercfg.modifiedgame; | ||||||
|  | 				connectedtodedicated = netbuffer->u.servercfg.dedicated; | ||||||
| 
 | 
 | ||||||
| 				memcpy(server_context, netbuffer->u.servercfg.server_context, 8); | 				memcpy(server_context, netbuffer->u.servercfg.server_context, 8); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -231,6 +231,7 @@ struct serverconfig_pak | ||||||
| 
 | 
 | ||||||
| 	UINT8 gametype; | 	UINT8 gametype; | ||||||
| 	UINT8 modifiedgame; | 	UINT8 modifiedgame; | ||||||
|  | 	boolean dedicated; | ||||||
| 
 | 
 | ||||||
| 	char server_context[8]; // Unique context id, generated at server startup.
 | 	char server_context[8]; // Unique context id, generated at server startup.
 | ||||||
| 
 | 
 | ||||||
|  | @ -465,7 +466,7 @@ struct doomdata_t | ||||||
| 		client3cmd_pak client3pak;          //         264 bytes(?)
 | 		client3cmd_pak client3pak;          //         264 bytes(?)
 | ||||||
| 		client4cmd_pak client4pak;          //         324 bytes(?)
 | 		client4cmd_pak client4pak;          //         324 bytes(?)
 | ||||||
| 		servertics_pak serverpak;           //      132495 bytes (more around 360, no?)
 | 		servertics_pak serverpak;           //      132495 bytes (more around 360, no?)
 | ||||||
| 		serverconfig_pak servercfg;         //         773 bytes
 | 		serverconfig_pak servercfg;         //         777 bytes
 | ||||||
| 		UINT8 textcmd[MAXTEXTCMD+2];        //       66049 bytes (wut??? 64k??? More like 258 bytes...)
 | 		UINT8 textcmd[MAXTEXTCMD+2];        //       66049 bytes (wut??? 64k??? More like 258 bytes...)
 | ||||||
| 		char filetxpak[sizeof (filetx_pak)];//         139 bytes
 | 		char filetxpak[sizeof (filetx_pak)];//         139 bytes
 | ||||||
| 		char fileack[sizeof (fileack_pak)]; | 		char fileack[sizeof (fileack_pak)]; | ||||||
|  | @ -558,6 +559,7 @@ extern boolean server; | ||||||
| extern boolean serverrunning; | extern boolean serverrunning; | ||||||
| #define client (!server) | #define client (!server) | ||||||
| extern boolean dedicated; // For dedicated server
 | extern boolean dedicated; // For dedicated server
 | ||||||
|  | extern boolean connectedtodedicated; // Client that is connected to a dedicated server.
 | ||||||
| extern UINT16 software_MAXPACKETLENGTH; | extern UINT16 software_MAXPACKETLENGTH; | ||||||
| extern boolean acceptnewnode; | extern boolean acceptnewnode; | ||||||
| extern SINT8 servernode; | extern SINT8 servernode; | ||||||
|  | @ -670,6 +672,7 @@ void CL_UpdateServerList(void); | ||||||
| void CL_TimeoutServerList(void); | void CL_TimeoutServerList(void); | ||||||
| // Is there a game running
 | // Is there a game running
 | ||||||
| boolean Playing(void); | boolean Playing(void); | ||||||
|  | boolean InADedicatedServer(void); | ||||||
| 
 | 
 | ||||||
| // Advance client-to-client pubkey verification flow
 | // Advance client-to-client pubkey verification flow
 | ||||||
| void UpdateChallenges(void); | void UpdateChallenges(void); | ||||||
|  |  | ||||||
|  | @ -864,6 +864,7 @@ void D_SRB2Loop(void) | ||||||
| 
 | 
 | ||||||
| 	if (dedicated) | 	if (dedicated) | ||||||
| 		server = true; | 		server = true; | ||||||
|  | 	connectedtodedicated = dedicated; | ||||||
| 
 | 
 | ||||||
| 	// Pushing of + parameters is now done back in D_SRB2Main, not here.
 | 	// Pushing of + parameters is now done back in D_SRB2Main, not here.
 | ||||||
| 
 | 
 | ||||||
|  | @ -1597,6 +1598,7 @@ void D_SRB2Main(void) | ||||||
| 
 | 
 | ||||||
| 	// for dedicated server
 | 	// for dedicated server
 | ||||||
| 	dedicated = M_CheckParm("-dedicated") != 0; | 	dedicated = M_CheckParm("-dedicated") != 0; | ||||||
|  | 	connectedtodedicated = dedicated; | ||||||
| 	if (dedicated) | 	if (dedicated) | ||||||
| 	{ | 	{ | ||||||
| 		usedTourney = true; | 		usedTourney = true; | ||||||
|  |  | ||||||
|  | @ -1229,6 +1229,7 @@ boolean I_InitTcpNetwork(void) | ||||||
| 	if (M_CheckParm("-server") || dedicated) | 	if (M_CheckParm("-server") || dedicated) | ||||||
| 	{ | 	{ | ||||||
| 		server = true; | 		server = true; | ||||||
|  | 		connectedtodedicated = dedicated; | ||||||
| 
 | 
 | ||||||
| 		// If a number of clients (i.e. nodes) is specified, the server will wait for the clients
 | 		// If a number of clients (i.e. nodes) is specified, the server will wait for the clients
 | ||||||
| 		// to connect before starting.
 | 		// to connect before starting.
 | ||||||
|  |  | ||||||
|  | @ -227,7 +227,7 @@ void K_UpdateMatchRaceBots(void) | ||||||
| { | { | ||||||
| 	const UINT16 defaultbotskin = R_BotDefaultSkin(); | 	const UINT16 defaultbotskin = R_BotDefaultSkin(); | ||||||
| 	UINT8 difficulty; | 	UINT8 difficulty; | ||||||
| 	UINT8 pmax = (dedicated ? MAXPLAYERS-1 : MAXPLAYERS); | 	UINT8 pmax = (InADedicatedServer() ? MAXPLAYERS-1 : MAXPLAYERS); | ||||||
| 	UINT8 numplayers = 0; | 	UINT8 numplayers = 0; | ||||||
| 	UINT8 numbots = 0; | 	UINT8 numbots = 0; | ||||||
| 	UINT8 numwaiting = 0; | 	UINT8 numwaiting = 0; | ||||||
|  | @ -343,12 +343,7 @@ void K_UpdateMatchRaceBots(void) | ||||||
| 	if (numbots < wantedbots) | 	if (numbots < wantedbots) | ||||||
| 	{ | 	{ | ||||||
| 		// We require MORE bots!
 | 		// We require MORE bots!
 | ||||||
| 		UINT8 newplayernum = 0; | 		UINT8 newplayernum = InADedicatedServer() ? 1 : 0; | ||||||
| 
 |  | ||||||
| 		if (dedicated) |  | ||||||
| 		{ |  | ||||||
| 			newplayernum = 1; |  | ||||||
| 		} |  | ||||||
| 
 | 
 | ||||||
| 		// Rearrange usable bot skins list to prevent gaps for randomised selection
 | 		// Rearrange usable bot skins list to prevent gaps for randomised selection
 | ||||||
| 		if (tutorialchallenge == TUTORIALSKIP_INPROGRESS) | 		if (tutorialchallenge == TUTORIALSKIP_INPROGRESS) | ||||||
|  |  | ||||||
|  | @ -358,6 +358,7 @@ boolean I_InitNetwork(void) | ||||||
| 	if (M_CheckParm("-server") || dedicated) | 	if (M_CheckParm("-server") || dedicated) | ||||||
| 	{ | 	{ | ||||||
| 		server = true; | 		server = true; | ||||||
|  | 		connectedtodedicated = dedicated; | ||||||
| 
 | 
 | ||||||
| 		// If a number of clients (i.e. nodes) is specified, the server will wait for the clients
 | 		// If a number of clients (i.e. nodes) is specified, the server will wait for the clients
 | ||||||
| 		// to connect before starting.
 | 		// to connect before starting.
 | ||||||
|  |  | ||||||
|  | @ -260,6 +260,7 @@ static inline VOID OpenTextConsole(void) | ||||||
| 	HANDLE ci, co; | 	HANDLE ci, co; | ||||||
| 	const BOOL tco = M_CheckParm("-console") != 0; | 	const BOOL tco = M_CheckParm("-console") != 0; | ||||||
| 	dedicated = M_CheckParm("-dedicated") != 0; | 	dedicated = M_CheckParm("-dedicated") != 0; | ||||||
|  | 	connectedtodedicated = dedicated; | ||||||
| 	if (!(dedicated || tco)) | 	if (!(dedicated || tco)) | ||||||
| 		return; | 		return; | ||||||
| 	FreeConsole(); | 	FreeConsole(); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Eidolon
						Eidolon