[ioquake3] 14/50: Fix not adding random bot when all bot info are in use on team
Simon McVittie
smcv at debian.org
Sun Jul 23 21:55:23 UTC 2017
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to branch debian/master
in repository ioquake3.
commit 7c601da6510252b17fdb1909f15d94f6a912142d
Author: Zack Middleton <zack at cloemail.com>
Date: Thu Jun 29 15:59:09 2017 -0500
Fix not adding random bot when all bot info are in use on team
If there are two bot infos in scripts/bots.txt then each team can
only add two random bots via bot_minplayers or addbot random.
Pick random bot info from least used bot infos instead of only ones
that are used by zero players. That way a random bot can always be
added to the game.
This rarely affected Quake 3 since there is 32 bot infos. It could
easily affect new games though.
---
code/game/g_bot.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/code/game/g_bot.c b/code/game/g_bot.c
index 2c363eb..fc6a321 100644
--- a/code/game/g_bot.c
+++ b/code/game/g_bot.c
@@ -263,22 +263,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 ) {
@@ -308,7 +317,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;
}
@@ -636,7 +645,7 @@ static void G_AddBot( const char *name, float 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/ioquake3.git
More information about the Pkg-games-commits
mailing list