This is an automated email from the git hooks/post-receive script. smcv pushed a commit to tag 1.51b in repository iortcw.
commit 03d2032770b0445684039863d9b1f835dbeb158d Author: MAN-AT-ARMS <[email protected]> Date: Wed Jul 19 12:15:23 2017 -0400 All: Fix not adding random bot when all bot info are in use on team --- MP/code/game/g_bot.c | 17 +++++++++++++---- SP/code/game/g_bot.c | 17 +++++++++++++---- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/MP/code/game/g_bot.c b/MP/code/game/g_bot.c index e594e86..f97a53c 100644 --- a/MP/code/game/g_bot.c +++ b/MP/code/game/g_bot.c @@ -184,22 +184,31 @@ int G_CountBotPlayersByName( const char *name, int team ) { =============== G_SelectRandomBotInfo -Get random unused bot info on team or whole server if team is -1. +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; char *value; num = 0; + bestCount = MAX_CLIENTS; for ( n = 0; n < g_numBots ; n++ ) { value = Info_ValueForKey( g_botInfos[n], "funname" ); if ( !value[0] ) { value = Info_ValueForKey( g_botInfos[n], "name" ); } // - if ( G_CountBotPlayersByName( value, team ) == 0 ) { + count = G_CountBotPlayersByName( value, team ); + + if ( count < bestCount ) { + bestCount = count; + num = 0; + } + + if ( count == bestCount ) { selection[num++] = n; if ( num == MAX_BOTS ) { @@ -228,7 +237,7 @@ void G_AddRandomBot( int team ) { n = G_SelectRandomBotInfo( team ); if ( n < 0 ) { - // all bot types are in use on team + // no bot info available return; } @@ -555,7 +564,7 @@ static void G_AddBot( const char *name, int skill, const char *team, int delay ) botinfoNum = G_SelectRandomBotInfo( teamNum ); if ( botinfoNum < 0 ) { - G_Printf( S_COLOR_YELLOW "WARNING: Cannot add random bot: all bot types in use on team '%s'.\n", team ); + G_Printf( S_COLOR_RED "Error: Cannot add random bot, no bot info available.\n" ); trap_BotFreeClient( clientNum ); return; } diff --git a/SP/code/game/g_bot.c b/SP/code/game/g_bot.c index f2343e9..370f3bb 100644 --- a/SP/code/game/g_bot.c +++ b/SP/code/game/g_bot.c @@ -185,22 +185,31 @@ int G_CountBotPlayersByName( const char *name, int team ) { =============== G_SelectRandomBotInfo -Get random unused bot info on team or whole server if team is -1. +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; char *value; num = 0; + bestCount = MAX_CLIENTS; for ( n = 0; n < g_numBots ; n++ ) { value = Info_ValueForKey( g_botInfos[n], "funname" ); if ( !value[0] ) { value = Info_ValueForKey( g_botInfos[n], "name" ); } // - if ( G_CountBotPlayersByName( value, team ) == 0 ) { + count = G_CountBotPlayersByName( value, team ); + + if ( count < bestCount ) { + bestCount = count; + num = 0; + } + + if ( count == bestCount ) { selection[num++] = n; if ( num == MAX_BOTS ) { @@ -229,7 +238,7 @@ void G_AddRandomBot( int team ) { n = G_SelectRandomBotInfo( team ); if ( n < 0 ) { - // all bot types are in use on team + // no bot info available return; } @@ -556,7 +565,7 @@ static void G_AddBot( const char *name, int skill, const char *team, int delay ) botinfoNum = G_SelectRandomBotInfo( teamNum ); if ( botinfoNum < 0 ) { - G_Printf( S_COLOR_YELLOW "WARNING: Cannot add random bot: all bot types in use on team '%s'.\n", team ); + G_Printf( S_COLOR_RED "Error: Cannot add random bot, no bot info available.\n" ); trap_BotFreeClient( clientNum ); return; } -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/iortcw.git _______________________________________________ Pkg-games-commits mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits

