[iortcw] 45/89: All: Don't pick duplicate random bots until all bot types are added

Simon McVittie smcv at debian.org
Fri Sep 8 10:44:24 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 7c1ec377603a26fcdfd0a55f4a1ad0d56c463370
Author: MAN-AT-ARMS <M4N4T4RMS at gmail.com>
Date:   Wed Jul 19 12:27:48 2017 -0400

    All: Don't pick duplicate random bots until all bot types are added
---
 MP/code/game/g_bot.c | 28 +++++++++++-----------------
 SP/code/game/g_bot.c | 28 +++++++++++-----------------
 2 files changed, 22 insertions(+), 34 deletions(-)

diff --git a/MP/code/game/g_bot.c b/MP/code/game/g_bot.c
index 34b55c4..9eb4367 100644
--- a/MP/code/game/g_bot.c
+++ b/MP/code/game/g_bot.c
@@ -190,11 +190,16 @@ Get random least used bot info on team or whole server if team is -1.
 ===============
 */
 int G_SelectRandomBotInfo( int team ) {
-	int		selection[MAX_BOTS];
-	int		n, num;
-	int		count, bestCount;
+	int	selection[MAX_BOTS];
+	int	n, num;
+	int	count, bestCount;
 	char	*value;
 
+	// don't add duplicate bots to the server if there are less bots than bot types
+	if ( team != -1 && G_CountBotPlayersByName( NULL, -1 ) < g_numBots ) {
+		team = -1;
+	}
+
 	num = 0;
 	bestCount = MAX_CLIENTS;
 	for ( n = 0; n < g_numBots ; n++ ) {
@@ -233,17 +238,8 @@ G_AddRandomBot
 ===============
 */
 void G_AddRandomBot( int team ) {
-	int		n, skill;
-	char	*value, netname[36], *teamstr;
-
-	n = G_SelectRandomBotInfo( team );
-
-	if ( n < 0 ) {
-		// no bot info available
-		return;
-	}
-
-	value = Info_ValueForKey( g_botInfos[n], "name" );
+	char	*teamstr;
+	int	skill;
 
 	skill = trap_Cvar_VariableIntegerValue( "g_spSkill" );
 	if ( team == TEAM_RED ) {
@@ -253,9 +249,7 @@ void G_AddRandomBot( int team ) {
 	} else {
 		teamstr = "free";
 	}
-	Q_strncpyz( netname, value, sizeof( netname ) );
-	Q_CleanStr( netname );
-	trap_SendConsoleCommand( EXEC_INSERT, va( "addbot %s %i %s %i\n", netname, skill, teamstr, 0 ) );
+	trap_SendConsoleCommand( EXEC_INSERT, va( "addbot random %i %s %i\n", skill, teamstr, 0 ) );
 }
 
 /*
diff --git a/SP/code/game/g_bot.c b/SP/code/game/g_bot.c
index f13d571..239ceda 100644
--- a/SP/code/game/g_bot.c
+++ b/SP/code/game/g_bot.c
@@ -191,11 +191,16 @@ Get random least used bot info on team or whole server if team is -1.
 ===============
 */
 int G_SelectRandomBotInfo( int team ) {
-	int		selection[MAX_BOTS];
-	int		n, num;
-	int		count, bestCount;
+	int	selection[MAX_BOTS];
+	int	n, num;
+	int	count, bestCount;
 	char	*value;
 
+	// don't add duplicate bots to the server if there are less bots than bot types
+	if ( team != -1 && G_CountBotPlayersByName( NULL, -1 ) < g_numBots ) {
+		team = -1;
+	}
+
 	num = 0;
 	bestCount = MAX_CLIENTS;
 	for ( n = 0; n < g_numBots ; n++ ) {
@@ -234,17 +239,8 @@ G_AddRandomBot
 ===============
 */
 void G_AddRandomBot( int team ) {
-	int		n, skill;
-	char	*value, netname[36], *teamstr;
-
-	n = G_SelectRandomBotInfo( team );
-
-	if ( n < 0 ) {
-		// no bot info available
-		return;
-	}
-
-	value = Info_ValueForKey( g_botInfos[n], "name" );
+	char	*teamstr;
+	int	skill;
 
 	skill = trap_Cvar_VariableIntegerValue( "g_spSkill" );
 	if ( team == TEAM_RED ) {
@@ -254,9 +250,7 @@ void G_AddRandomBot( int team ) {
 	} else {
 		teamstr = "free";
 	}
-	Q_strncpyz( netname, value, sizeof( netname ) );
-	Q_CleanStr( netname );
-	trap_SendConsoleCommand( EXEC_INSERT, va( "addbot %s %i %s %i\n", netname, skill, teamstr, 0 ) );
+	trap_SendConsoleCommand( EXEC_INSERT, va( "addbot random %i %s %i\n", skill, teamstr, 0 ) );
 }
 
 /*

-- 
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