[iortcw] 03/89: All: Stop caching sv_maxclients in bot code

Simon McVittie smcv at debian.org
Fri Sep 8 10:43:58 UTC 2017


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to tag 1.51b
in repository iortcw.

commit f53f9fd13aa7648731ba8a54d1a6a41a1979ce3a
Author: MAN-AT-ARMS <M4N4T4RMS at gmail.com>
Date:   Mon Jun 12 15:31:40 2017 -0400

    All: Stop caching sv_maxclients in bot code
---
 MP/code/game/ai_chat.c | 42 ++++++------------------------------------
 MP/code/game/ai_cmd.c  | 23 +++++------------------
 MP/code/game/ai_dmq3.c | 10 +++-------
 MP/code/game/ai_main.c |  5 +----
 MP/code/game/ai_team.c | 14 ++------------
 SP/code/game/ai_chat.c | 42 ++++++------------------------------------
 SP/code/game/ai_cmd.c  | 23 +++++------------------
 SP/code/game/ai_dmq3.c | 10 +++-------
 SP/code/game/ai_main.c |  5 +----
 SP/code/game/ai_team.c | 14 ++------------
 10 files changed, 34 insertions(+), 154 deletions(-)

diff --git a/MP/code/game/ai_chat.c b/MP/code/game/ai_chat.c
index 7c71d3f..3eac6fb 100644
--- a/MP/code/game/ai_chat.c
+++ b/MP/code/game/ai_chat.c
@@ -67,14 +67,9 @@ BotNumActivePlayers
 int BotNumActivePlayers( void ) {
 	int i, num;
 	char buf[MAX_INFO_STRING];
-	static int maxclients;
-
-	if ( !maxclients ) {
-		maxclients = trap_Cvar_VariableIntegerValue( "sv_maxclients" );
-	}
 
 	num = 0;
-	for ( i = 0; i < maxclients && i < MAX_CLIENTS; i++ ) {
+	for ( i = 0; i < level.maxclients; i++ ) {
 		trap_GetConfigstring( CS_PLAYERS + i, buf, sizeof( buf ) );
 		//if no config string or no name
 		if ( !strlen( buf ) || !strlen( Info_ValueForKey( buf, "n" ) ) ) {
@@ -98,15 +93,10 @@ BotIsFirstInRankings
 int BotIsFirstInRankings( bot_state_t *bs ) {
 	int i, score;
 	char buf[MAX_INFO_STRING];
-	static int maxclients;
 	playerState_t ps;
 
-	if ( !maxclients ) {
-		maxclients = trap_Cvar_VariableIntegerValue( "sv_maxclients" );
-	}
-
 	score = bs->cur_ps.persistant[PERS_SCORE];
-	for ( i = 0; i < maxclients && i < MAX_CLIENTS; i++ ) {
+	for ( i = 0; i < level.maxclients; i++ ) {
 		trap_GetConfigstring( CS_PLAYERS + i, buf, sizeof( buf ) );
 		//if no config string or no name
 		if ( !strlen( buf ) || !strlen( Info_ValueForKey( buf, "n" ) ) ) {
@@ -133,15 +123,10 @@ BotIsLastInRankings
 int BotIsLastInRankings( bot_state_t *bs ) {
 	int i, score;
 	char buf[MAX_INFO_STRING];
-	static int maxclients;
 	playerState_t ps;
 
-	if ( !maxclients ) {
-		maxclients = trap_Cvar_VariableIntegerValue( "sv_maxclients" );
-	}
-
 	score = bs->cur_ps.persistant[PERS_SCORE];
-	for ( i = 0; i < maxclients && i < MAX_CLIENTS; i++ ) {
+	for ( i = 0; i < level.maxclients; i++ ) {
 		trap_GetConfigstring( CS_PLAYERS + i, buf, sizeof( buf ) );
 		//if no config string or no name
 		if ( !strlen( buf ) || !strlen( Info_ValueForKey( buf, "n" ) ) ) {
@@ -169,16 +154,11 @@ char *BotFirstClientInRankings( void ) {
 	int i, bestscore, bestclient;
 	char buf[MAX_INFO_STRING];
 	static char name[32];
-	static int maxclients;
 	playerState_t ps;
 
-	if ( !maxclients ) {
-		maxclients = trap_Cvar_VariableIntegerValue( "sv_maxclients" );
-	}
-
 	bestscore = -999999;
 	bestclient = 0;
-	for ( i = 0; i < maxclients && i < MAX_CLIENTS; i++ ) {
+	for ( i = 0; i < level.maxclients; i++ ) {
 		trap_GetConfigstring( CS_PLAYERS + i, buf, sizeof( buf ) );
 		//if no config string or no name
 		if ( !strlen( buf ) || !strlen( Info_ValueForKey( buf, "n" ) ) ) {
@@ -208,16 +188,11 @@ char *BotLastClientInRankings( void ) {
 	int i, worstscore, bestclient;
 	char buf[MAX_INFO_STRING];
 	static char name[32];
-	static int maxclients;
 	playerState_t ps;
 
-	if ( !maxclients ) {
-		maxclients = trap_Cvar_VariableIntegerValue( "sv_maxclients" );
-	}
-
 	worstscore = 999999;
 	bestclient = 0;
-	for ( i = 0; i < maxclients && i < MAX_CLIENTS; i++ ) {
+	for ( i = 0; i < level.maxclients; i++ ) {
 		trap_GetConfigstring( CS_PLAYERS + i, buf, sizeof( buf ) );
 		//if no config string or no name
 		if ( !strlen( buf ) || !strlen( Info_ValueForKey( buf, "n" ) ) ) {
@@ -247,16 +222,11 @@ char *BotRandomOpponentName( bot_state_t *bs ) {
 	int i, count;
 	char buf[MAX_INFO_STRING];
 	int opponents[MAX_CLIENTS], numopponents;
-	static int maxclients;
 	static char name[32];
 
-	if ( !maxclients ) {
-		maxclients = trap_Cvar_VariableIntegerValue( "sv_maxclients" );
-	}
-
 	numopponents = 0;
 	opponents[0] = 0;
-	for ( i = 0; i < maxclients && i < MAX_CLIENTS; i++ ) {
+	for ( i = 0; i < level.maxclients; i++ ) {
 		if ( i == bs->client ) {
 			continue;
 		}
diff --git a/MP/code/game/ai_cmd.c b/MP/code/game/ai_cmd.c
index b85f099..14da135 100644
--- a/MP/code/game/ai_cmd.c
+++ b/MP/code/game/ai_cmd.c
@@ -223,18 +223,14 @@ FindClientByName
 int FindClientByName( char *name ) {
 	int i;
 	char buf[MAX_INFO_STRING];
-	static int maxclients;
 
-	if ( !maxclients ) {
-		maxclients = trap_Cvar_VariableIntegerValue( "sv_maxclients" );
-	}
-	for ( i = 0; i < maxclients && i < MAX_CLIENTS; i++ ) {
+	for ( i = 0; i < level.maxclients; i++ ) {
 		ClientName( i, buf, sizeof( buf ) );
 		if ( !Q_stricmp( buf, name ) ) {
 			return i;
 		}
 	}
-	for ( i = 0; i < maxclients && i < MAX_CLIENTS; i++ ) {
+	for ( i = 0; i < level.maxclients; i++ ) {
 		ClientName( i, buf, sizeof( buf ) );
 		if ( stristr( buf, name ) ) {
 			return i;
@@ -251,12 +247,8 @@ FindEnemyByName
 int FindEnemyByName( bot_state_t *bs, char *name ) {
 	int i;
 	char buf[MAX_INFO_STRING];
-	static int maxclients;
 
-	if ( !maxclients ) {
-		maxclients = trap_Cvar_VariableIntegerValue( "sv_maxclients" );
-	}
-	for ( i = 0; i < maxclients && i < MAX_CLIENTS; i++ ) {
+	for ( i = 0; i < level.maxclients; i++ ) {
 		if ( BotSameTeam( bs, i ) ) {
 			continue;
 		}
@@ -265,7 +257,7 @@ int FindEnemyByName( bot_state_t *bs, char *name ) {
 			return i;
 		}
 	}
-	for ( i = 0; i < maxclients && i < MAX_CLIENTS; i++ ) {
+	for ( i = 0; i < level.maxclients; i++ ) {
 		if ( BotSameTeam( bs, i ) ) {
 			continue;
 		}
@@ -285,14 +277,9 @@ NumPlayersOnSameTeam
 int NumPlayersOnSameTeam( bot_state_t *bs ) {
 	int i, num;
 	char buf[MAX_INFO_STRING];
-	static int maxclients;
-
-	if ( !maxclients ) {
-		maxclients = trap_Cvar_VariableIntegerValue( "sv_maxclients" );
-	}
 
 	num = 0;
-	for ( i = 0; i < maxclients && i < MAX_CLIENTS; i++ ) {
+	for ( i = 0; i < level.maxclients; i++ ) {
 		trap_GetConfigstring( CS_PLAYERS + i, buf, MAX_INFO_STRING );
 		if ( strlen( buf ) ) {
 			if ( BotSameTeam( bs, i + 1 ) ) {
diff --git a/MP/code/game/ai_dmq3.c b/MP/code/game/ai_dmq3.c
index a87adf0..55990da 100644
--- a/MP/code/game/ai_dmq3.c
+++ b/MP/code/game/ai_dmq3.c
@@ -304,12 +304,8 @@ ClientFromName
 int ClientFromName( char *name ) {
 	int i;
 	char buf[MAX_INFO_STRING];
-	static int maxclients;
 
-	if ( !maxclients ) {
-		maxclients = trap_Cvar_VariableIntegerValue( "sv_maxclients" );
-	}
-	for ( i = 0; i < maxclients && i < MAX_CLIENTS; i++ ) {
+	for ( i = 0; i < level.maxclients; i++ ) {
 		trap_GetConfigstring( CS_PLAYERS + i, buf, sizeof( buf ) );
 		Q_CleanStr( buf );
 		if ( !Q_stricmp( Info_ValueForKey( buf, "n" ), name ) ) {
@@ -1443,7 +1439,7 @@ int BotFindEnemy( bot_state_t *bs, int curenemy ) {
 		curdist = 0;
 	}
 	//
-	for ( i = 0; i < MAX_CLIENTS; i++ ) {
+	for ( i = 0; i < level.maxclients; i++ ) {
 
 		if ( i == bs->client ) {
 			continue;
@@ -1955,7 +1951,7 @@ void BotMapScripts( bot_state_t *bs ) {
 		}
 		shootbutton = qfalse;
 		//if an enemy is below this bounding box then shoot the button
-		for ( i = 0; i < MAX_CLIENTS; i++ ) {
+		for ( i = 0; i < level.maxclients; i++ ) {
 
 			if ( i == bs->client ) {
 				continue;
diff --git a/MP/code/game/ai_main.c b/MP/code/game/ai_main.c
index 3e17a5a..eef1af4 100644
--- a/MP/code/game/ai_main.c
+++ b/MP/code/game/ai_main.c
@@ -1051,10 +1051,7 @@ int BotInitLibrary( void ) {
 	char buf[144];
 
 	//set the maxclients and maxentities library variables before calling BotSetupLibrary
-	trap_Cvar_VariableStringBuffer( "sv_maxclients", buf, sizeof( buf ) );
-	if ( !strlen( buf ) ) {
-		strcpy( buf, "8" );
-	}
+	Com_sprintf( buf, sizeof( buf ), "%d", level.maxclients );
 	trap_BotLibVarSet( "maxclients", buf );
 	Com_sprintf( buf, sizeof( buf ), "%d", MAX_GENTITIES );
 	trap_BotLibVarSet( "maxentities", buf );
diff --git a/MP/code/game/ai_team.c b/MP/code/game/ai_team.c
index e691ced..51b32f3 100644
--- a/MP/code/game/ai_team.c
+++ b/MP/code/game/ai_team.c
@@ -77,14 +77,9 @@ BotNumTeamMates
 int BotNumTeamMates( bot_state_t *bs ) {
 	int i, numplayers;
 	char buf[MAX_INFO_STRING];
-	static int maxclients;
-
-	if ( !maxclients ) {
-		maxclients = trap_Cvar_VariableIntegerValue( "sv_maxclients" );
-	}
 
 	numplayers = 0;
-	for ( i = 0; i < maxclients && i < MAX_CLIENTS; i++ ) {
+	for ( i = 0; i < level.maxclients; i++ ) {
 		trap_GetConfigstring( CS_PLAYERS + i, buf, sizeof( buf ) );
 		//if no config string or no name
 		if ( !strlen( buf ) || !strlen( Info_ValueForKey( buf, "n" ) ) ) {
@@ -128,7 +123,6 @@ int BotSortTeamMatesByBaseTravelTime( bot_state_t *bs, int *teammates, int maxte
 
 	int i, j, k, numteammates, traveltime;
 	char buf[MAX_INFO_STRING];
-	static int maxclients;
 	int traveltimes[MAX_CLIENTS];
 	bot_goal_t *goal;
 
@@ -136,12 +130,8 @@ int BotSortTeamMatesByBaseTravelTime( bot_state_t *bs, int *teammates, int maxte
 		goal = &ctf_redflag;
 	} else { goal = &ctf_blueflag;}
 
-	if ( !maxclients ) {
-		maxclients = trap_Cvar_VariableIntegerValue( "sv_maxclients" );
-	}
-
 	numteammates = 0;
-	for ( i = 0; i < maxclients && i < MAX_CLIENTS; i++ ) {
+	for ( i = 0; i < level.maxclients; i++ ) {
 		trap_GetConfigstring( CS_PLAYERS + i, buf, sizeof( buf ) );
 		//if no config string or no name
 		if ( !strlen( buf ) || !strlen( Info_ValueForKey( buf, "n" ) ) ) {
diff --git a/SP/code/game/ai_chat.c b/SP/code/game/ai_chat.c
index d484159..0942694 100644
--- a/SP/code/game/ai_chat.c
+++ b/SP/code/game/ai_chat.c
@@ -67,14 +67,9 @@ BotNumActivePlayers
 int BotNumActivePlayers( void ) {
 	int i, num;
 	char buf[MAX_INFO_STRING];
-	static int maxclients;
-
-	if ( !maxclients ) {
-		maxclients = trap_Cvar_VariableIntegerValue( "sv_maxclients" );
-	}
 
 	num = 0;
-	for ( i = 0; i < maxclients && i < MAX_CLIENTS; i++ ) {
+	for ( i = 0; i < level.maxclients; i++ ) {
 		trap_GetConfigstring( CS_PLAYERS + i, buf, sizeof( buf ) );
 		//if no config string or no name
 		if ( !strlen( buf ) || !strlen( Info_ValueForKey( buf, "n" ) ) ) {
@@ -98,15 +93,10 @@ BotIsFirstInRankings
 int BotIsFirstInRankings( bot_state_t *bs ) {
 	int i, score;
 	char buf[MAX_INFO_STRING];
-	static int maxclients;
 	playerState_t ps;
 
-	if ( !maxclients ) {
-		maxclients = trap_Cvar_VariableIntegerValue( "sv_maxclients" );
-	}
-
 	score = bs->cur_ps.persistant[PERS_SCORE];
-	for ( i = 0; i < maxclients && i < MAX_CLIENTS; i++ ) {
+	for ( i = 0; i < level.maxclients; i++ ) {
 		trap_GetConfigstring( CS_PLAYERS + i, buf, sizeof( buf ) );
 		//if no config string or no name
 		if ( !strlen( buf ) || !strlen( Info_ValueForKey( buf, "n" ) ) ) {
@@ -133,15 +123,10 @@ BotIsLastInRankings
 int BotIsLastInRankings( bot_state_t *bs ) {
 	int i, score;
 	char buf[MAX_INFO_STRING];
-	static int maxclients;
 	playerState_t ps;
 
-	if ( !maxclients ) {
-		maxclients = trap_Cvar_VariableIntegerValue( "sv_maxclients" );
-	}
-
 	score = bs->cur_ps.persistant[PERS_SCORE];
-	for ( i = 0; i < maxclients && i < MAX_CLIENTS; i++ ) {
+	for ( i = 0; i < level.maxclients; i++ ) {
 		trap_GetConfigstring( CS_PLAYERS + i, buf, sizeof( buf ) );
 		//if no config string or no name
 		if ( !strlen( buf ) || !strlen( Info_ValueForKey( buf, "n" ) ) ) {
@@ -169,16 +154,11 @@ char *BotFirstClientInRankings( void ) {
 	int i, bestscore, bestclient;
 	char buf[MAX_INFO_STRING];
 	static char name[32];
-	static int maxclients;
 	playerState_t ps;
 
-	if ( !maxclients ) {
-		maxclients = trap_Cvar_VariableIntegerValue( "sv_maxclients" );
-	}
-
 	bestscore = -999999;
 	bestclient = 0;
-	for ( i = 0; i < maxclients && i < MAX_CLIENTS; i++ ) {
+	for ( i = 0; i < level.maxclients; i++ ) {
 		trap_GetConfigstring( CS_PLAYERS + i, buf, sizeof( buf ) );
 		//if no config string or no name
 		if ( !strlen( buf ) || !strlen( Info_ValueForKey( buf, "n" ) ) ) {
@@ -208,16 +188,11 @@ char *BotLastClientInRankings( void ) {
 	int i, worstscore, bestclient;
 	char buf[MAX_INFO_STRING];
 	static char name[32];
-	static int maxclients;
 	playerState_t ps;
 
-	if ( !maxclients ) {
-		maxclients = trap_Cvar_VariableIntegerValue( "sv_maxclients" );
-	}
-
 	worstscore = 999999;
 	bestclient = 0;
-	for ( i = 0; i < maxclients && i < MAX_CLIENTS; i++ ) {
+	for ( i = 0; i < level.maxclients; i++ ) {
 		trap_GetConfigstring( CS_PLAYERS + i, buf, sizeof( buf ) );
 		//if no config string or no name
 		if ( !strlen( buf ) || !strlen( Info_ValueForKey( buf, "n" ) ) ) {
@@ -247,16 +222,11 @@ char *BotRandomOpponentName( bot_state_t *bs ) {
 	int i, count;
 	char buf[MAX_INFO_STRING];
 	int opponents[MAX_CLIENTS], numopponents;
-	static int maxclients;
 	static char name[32];
 
-	if ( !maxclients ) {
-		maxclients = trap_Cvar_VariableIntegerValue( "sv_maxclients" );
-	}
-
 	numopponents = 0;
 	opponents[0] = 0;
-	for ( i = 0; i < maxclients && i < MAX_CLIENTS; i++ ) {
+	for ( i = 0; i < level.maxclients; i++ ) {
 		if ( i == bs->client ) {
 			continue;
 		}
diff --git a/SP/code/game/ai_cmd.c b/SP/code/game/ai_cmd.c
index 119e60e..1856788 100644
--- a/SP/code/game/ai_cmd.c
+++ b/SP/code/game/ai_cmd.c
@@ -223,18 +223,14 @@ FindClientByName
 int FindClientByName( char *name ) {
 	int i;
 	char buf[MAX_INFO_STRING];
-	static int maxclients;
 
-	if ( !maxclients ) {
-		maxclients = trap_Cvar_VariableIntegerValue( "sv_maxclients" );
-	}
-	for ( i = 0; i < maxclients && i < MAX_CLIENTS; i++ ) {
+	for ( i = 0; i < level.maxclients; i++ ) {
 		ClientName( i, buf, sizeof( buf ) );
 		if ( !Q_stricmp( buf, name ) ) {
 			return i;
 		}
 	}
-	for ( i = 0; i < maxclients && i < MAX_CLIENTS; i++ ) {
+	for ( i = 0; i < level.maxclients; i++ ) {
 		ClientName( i, buf, sizeof( buf ) );
 		if ( stristr( buf, name ) ) {
 			return i;
@@ -251,12 +247,8 @@ FindEnemyByName
 int FindEnemyByName( bot_state_t *bs, char *name ) {
 	int i;
 	char buf[MAX_INFO_STRING];
-	static int maxclients;
 
-	if ( !maxclients ) {
-		maxclients = trap_Cvar_VariableIntegerValue( "sv_maxclients" );
-	}
-	for ( i = 0; i < maxclients && i < MAX_CLIENTS; i++ ) {
+	for ( i = 0; i < level.maxclients; i++ ) {
 		if ( BotSameTeam( bs, i ) ) {
 			continue;
 		}
@@ -265,7 +257,7 @@ int FindEnemyByName( bot_state_t *bs, char *name ) {
 			return i;
 		}
 	}
-	for ( i = 0; i < maxclients && i < MAX_CLIENTS; i++ ) {
+	for ( i = 0; i < level.maxclients; i++ ) {
 		if ( BotSameTeam( bs, i ) ) {
 			continue;
 		}
@@ -285,14 +277,9 @@ NumPlayersOnSameTeam
 int NumPlayersOnSameTeam( bot_state_t *bs ) {
 	int i, num;
 	char buf[MAX_INFO_STRING];
-	static int maxclients;
-
-	if ( !maxclients ) {
-		maxclients = trap_Cvar_VariableIntegerValue( "sv_maxclients" );
-	}
 
 	num = 0;
-	for ( i = 0; i < maxclients && i < MAX_CLIENTS; i++ ) {
+	for ( i = 0; i < level.maxclients; i++ ) {
 		trap_GetConfigstring( CS_PLAYERS + i, buf, MAX_INFO_STRING );
 		if ( strlen( buf ) ) {
 			if ( BotSameTeam( bs, i + 1 ) ) {
diff --git a/SP/code/game/ai_dmq3.c b/SP/code/game/ai_dmq3.c
index bef4664..4cb38d6 100644
--- a/SP/code/game/ai_dmq3.c
+++ b/SP/code/game/ai_dmq3.c
@@ -305,12 +305,8 @@ ClientFromName
 int ClientFromName( char *name ) {
 	int i;
 	char buf[MAX_INFO_STRING];
-	static int maxclients;
 
-	if ( !maxclients ) {
-		maxclients = trap_Cvar_VariableIntegerValue( "sv_maxclients" );
-	}
-	for ( i = 0; i < maxclients && i < MAX_CLIENTS; i++ ) {
+	for ( i = 0; i < level.maxclients; i++ ) {
 		trap_GetConfigstring( CS_PLAYERS + i, buf, sizeof( buf ) );
 		Q_CleanStr( buf );
 		if ( !Q_stricmp( Info_ValueForKey( buf, "n" ), name ) ) {
@@ -1441,7 +1437,7 @@ int BotFindEnemy( bot_state_t *bs, int curenemy ) {
 		curdist = 0;
 	}
 	//
-	for ( i = 0; i < MAX_CLIENTS; i++ ) {
+	for ( i = 0; i < level.maxclients; i++ ) {
 
 		if ( i == bs->client ) {
 			continue;
@@ -1948,7 +1944,7 @@ void BotMapScripts( bot_state_t *bs ) {
 		}
 		shootbutton = qfalse;
 		//if an enemy is below this bounding box then shoot the button
-		for ( i = 0; i < MAX_CLIENTS; i++ ) {
+		for ( i = 0; i < level.maxclients; i++ ) {
 
 			if ( i == bs->client ) {
 				continue;
diff --git a/SP/code/game/ai_main.c b/SP/code/game/ai_main.c
index 0299bdd..02e9364 100644
--- a/SP/code/game/ai_main.c
+++ b/SP/code/game/ai_main.c
@@ -1052,10 +1052,7 @@ int BotInitLibrary( void ) {
 	char buf[144];
 
 	//set the maxclients and maxentities library variables before calling BotSetupLibrary
-	trap_Cvar_VariableStringBuffer( "sv_maxclients", buf, sizeof( buf ) );
-	if ( !strlen( buf ) ) {
-		strcpy( buf, "8" );
-	}
+	Com_sprintf( buf, sizeof( buf ), "%d", level.maxclients );
 	trap_BotLibVarSet( "maxclients", buf );
 	Com_sprintf( buf, sizeof( buf ), "%d", MAX_GENTITIES );
 	trap_BotLibVarSet( "maxentities", buf );
diff --git a/SP/code/game/ai_team.c b/SP/code/game/ai_team.c
index 86ae5f6..adeb31a 100644
--- a/SP/code/game/ai_team.c
+++ b/SP/code/game/ai_team.c
@@ -77,14 +77,9 @@ BotNumTeamMates
 int BotNumTeamMates( bot_state_t *bs ) {
 	int i, numplayers;
 	char buf[MAX_INFO_STRING];
-	static int maxclients;
-
-	if ( !maxclients ) {
-		maxclients = trap_Cvar_VariableIntegerValue( "sv_maxclients" );
-	}
 
 	numplayers = 0;
-	for ( i = 0; i < maxclients && i < MAX_CLIENTS; i++ ) {
+	for ( i = 0; i < level.maxclients; i++ ) {
 		trap_GetConfigstring( CS_PLAYERS + i, buf, sizeof( buf ) );
 		//if no config string or no name
 		if ( !strlen( buf ) || !strlen( Info_ValueForKey( buf, "n" ) ) ) {
@@ -128,7 +123,6 @@ int BotSortTeamMatesByBaseTravelTime( bot_state_t *bs, int *teammates, int maxte
 
 	int i, j, k, numteammates, traveltime;
 	char buf[MAX_INFO_STRING];
-	static int maxclients;
 	int traveltimes[MAX_CLIENTS];
 	bot_goal_t *goal;
 
@@ -136,12 +130,8 @@ int BotSortTeamMatesByBaseTravelTime( bot_state_t *bs, int *teammates, int maxte
 		goal = &ctf_redflag;
 	} else { goal = &ctf_blueflag;}
 
-	if ( !maxclients ) {
-		maxclients = trap_Cvar_VariableIntegerValue( "sv_maxclients" );
-	}
-
 	numteammates = 0;
-	for ( i = 0; i < maxclients && i < MAX_CLIENTS; i++ ) {
+	for ( i = 0; i < level.maxclients; i++ ) {
 		trap_GetConfigstring( CS_PLAYERS + i, buf, sizeof( buf ) );
 		//if no config string or no name
 		if ( !strlen( buf ) || !strlen( Info_ValueForKey( buf, "n" ) ) ) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/iortcw.git



More information about the Pkg-games-commits mailing list