q3rally/engine/code/game/g_bot.c

1075 lines
23 KiB
C
Raw Normal View History

2011-02-18 14:31:32 +00:00
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
2021-03-24 20:13:01 +00:00
Copyright (C) 2002-2021 Q3Rally Team (Per Thormann - q3rally@gmail.com)
2011-02-18 14:31:32 +00:00
This file is part of q3rally source code.
q3rally source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
q3rally source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with q3rally; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
// g_bot.c
#include "g_local.h"
static int g_numBots;
static char *g_botInfos[MAX_BOTS];
int g_numArenas;
static char *g_arenaInfos[MAX_ARENAS];
#define BOT_BEGIN_DELAY_BASE 2000
#define BOT_BEGIN_DELAY_INCREMENT 1500
#define BOT_SPAWN_QUEUE_DEPTH 16
typedef struct {
int clientNum;
int spawnTime;
} botSpawnQueue_t;
static botSpawnQueue_t botSpawnQueue[BOT_SPAWN_QUEUE_DEPTH];
vmCvar_t bot_minplayers;
extern gentity_t *podium1;
extern gentity_t *podium2;
extern gentity_t *podium3;
float trap_Cvar_VariableValue( const char *var_name ) {
char buf[128];
trap_Cvar_VariableStringBuffer(var_name, buf, sizeof(buf));
return atof(buf);
}
/*
===============
G_ParseInfos
===============
*/
int G_ParseInfos( char *buf, int max, char *infos[] ) {
char *token;
int count;
char key[MAX_TOKEN_CHARS];
char info[MAX_INFO_STRING];
count = 0;
while ( 1 ) {
token = COM_Parse( &buf );
if ( !token[0] ) {
break;
}
if ( strcmp( token, "{" ) ) {
Com_Printf( "Missing { in info file\n" );
break;
}
if ( count == max ) {
Com_Printf( "Max infos exceeded\n" );
break;
}
info[0] = '\0';
while ( 1 ) {
token = COM_ParseExt( &buf, qtrue );
if ( !token[0] ) {
Com_Printf( "Unexpected end of info file\n" );
break;
}
if ( !strcmp( token, "}" ) ) {
break;
}
Q_strncpyz( key, token, sizeof( key ) );
token = COM_ParseExt( &buf, qfalse );
if ( !token[0] ) {
strcpy( token, "<NULL>" );
}
Info_SetValueForKey( info, key, token );
}
//NOTE: extra space for arena number
infos[count] = G_Alloc(strlen(info) + strlen("\\num\\") + strlen(va("%d", MAX_ARENAS)) + 1);
if (infos[count]) {
strcpy(infos[count], info);
count++;
}
}
return count;
}
/*
===============
G_LoadArenasFromFile
===============
*/
static void G_LoadArenasFromFile( char *filename ) {
int len;
fileHandle_t f;
char buf[MAX_ARENAS_TEXT];
len = trap_FS_FOpenFile( filename, &f, FS_READ );
if ( !f ) {
trap_Print( va( S_COLOR_RED "file not found: %s\n", filename ) );
2011-02-18 14:31:32 +00:00
return;
}
if ( len >= MAX_ARENAS_TEXT ) {
trap_FS_FCloseFile( f );
trap_Print( va( S_COLOR_RED "file too large: %s is %i, max allowed is %i\n", filename, len, MAX_ARENAS_TEXT ) );
2011-02-18 14:31:32 +00:00
return;
}
trap_FS_Read( buf, len, f );
buf[len] = 0;
trap_FS_FCloseFile( f );
g_numArenas += G_ParseInfos( buf, MAX_ARENAS - g_numArenas, &g_arenaInfos[g_numArenas] );
}
/*
===============
G_LoadArenas
===============
*/
static void G_LoadArenas( void ) {
int numdirs;
vmCvar_t arenasFile;
char filename[128];
char dirlist[1024];
char* dirptr;
int i, n;
int dirlen;
g_numArenas = 0;
trap_Cvar_Register( &arenasFile, "g_arenasFile", "", CVAR_INIT|CVAR_ROM );
if( *arenasFile.string ) {
G_LoadArenasFromFile(arenasFile.string);
}
else {
// STONELANCE
// G_LoadArenasFromFile("scripts/arenas.txt");
G_LoadArenasFromFile("scripts/q3r_arenas.txt");
// END
}
// get all arenas from .arena files
numdirs = trap_FS_GetFileList("scripts", ".arena", dirlist, 1024 );
dirptr = dirlist;
for (i = 0; i < numdirs; i++, dirptr += dirlen+1) {
dirlen = strlen(dirptr);
strcpy(filename, "scripts/");
strcat(filename, dirptr);
G_LoadArenasFromFile(filename);
}
trap_Print( va( "%i arenas parsed\n", g_numArenas ) );
2011-02-18 14:31:32 +00:00
for( n = 0; n < g_numArenas; n++ ) {
Info_SetValueForKey( g_arenaInfos[n], "num", va( "%i", n ) );
}
}
/*
===============
G_GetArenaInfoByNumber
===============
*/
const char *G_GetArenaInfoByMap( const char *map ) {
int n;
for( n = 0; n < g_numArenas; n++ ) {
if( Q_stricmp( Info_ValueForKey( g_arenaInfos[n], "map" ), map ) == 0 ) {
return g_arenaInfos[n];
}
}
return NULL;
}
/*
=================
PlayerIntroSound
=================
*/
static void PlayerIntroSound( const char *modelAndSkin ) {
char model[MAX_QPATH];
char *skin;
Q_strncpyz( model, modelAndSkin, sizeof(model) );
skin = strrchr( model, '/' );
2011-02-18 14:31:32 +00:00
if ( skin ) {
*skin++ = '\0';
}
else {
skin = model;
}
if( Q_stricmp( skin, "default" ) == 0 ) {
skin = model;
}
trap_SendConsoleCommand( EXEC_APPEND, va( "play sound/player/announce/%s.wav\n", skin ) );
}
/*
===============
G_CountBotPlayersByName
Check connected and connecting (delay join) bots.
Returns number of bots with name on specified team or whole server if team is -1.
2011-02-18 14:31:32 +00:00
===============
*/
int G_CountBotPlayersByName( const char *name, int team ) {
int i, num;
2011-02-18 14:31:32 +00:00
gclient_t *cl;
num = 0;
for ( i=0 ; i< g_maxclients.integer ; i++ ) {
cl = level.clients + i;
if ( cl->pers.connected == CON_DISCONNECTED ) {
continue;
}
if ( !(g_entities[i].r.svFlags & SVF_BOT) ) {
continue;
}
if ( team >= 0 && cl->sess.sessionTeam != team ) {
continue;
2011-02-18 14:31:32 +00:00
}
if ( name && Q_stricmp( name, cl->pers.netname ) ) {
continue;
2011-02-18 14:31:32 +00:00
}
num++;
}
return num;
}
/*
===============
G_SelectRandomBotInfo
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;
// 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;
2011-02-18 14:31:32 +00:00
}
num = 0;
bestCount = MAX_CLIENTS;
2011-02-18 14:31:32 +00:00
for ( n = 0; n < g_numBots ; n++ ) {
value = Info_ValueForKey( g_botInfos[n], "funname" );
if ( !value[0] ) {
value = Info_ValueForKey( g_botInfos[n], "name" );
}
2011-02-18 14:31:32 +00:00
//
count = G_CountBotPlayersByName( value, team );
if ( count < bestCount ) {
bestCount = count;
num = 0;
2011-02-18 14:31:32 +00:00
}
if ( count == bestCount ) {
selection[num++] = n;
if ( num == MAX_BOTS ) {
break;
2011-02-18 14:31:32 +00:00
}
}
}
if ( num > 0 ) {
num = random() * ( num - 1 );
return selection[num];
}
return -1;
}
/*
===============
G_AddRandomBot
===============
*/
void G_AddRandomBot( int team ) {
char *teamstr;
float skill;
skill = trap_Cvar_VariableValue( "g_spSkill" );
if (team == TEAM_RED) teamstr = "red";
else if (team == TEAM_BLUE) teamstr = "blue";
else teamstr = "free";
trap_SendConsoleCommand( EXEC_INSERT, va("addbot random %f %s %i\n", skill, teamstr, 0) );
2011-02-18 14:31:32 +00:00
}
/*
===============
G_RemoveRandomBot
===============
*/
int G_RemoveRandomBot( int team ) {
int i;
gclient_t *cl;
for ( i=0 ; i< g_maxclients.integer ; i++ ) {
cl = level.clients + i;
if ( cl->pers.connected != CON_CONNECTED ) {
continue;
}
ioquake3 resync to revision 2398 from 2369. This is the last ioquake3 revision before ioquake3 changed from subversion to git at the beginning of 2013. #5808 - Include and use .glsl in source (rend2) #5812 - Use refdef's coordinates when drawing to screen shadow fbo, and separate depth texture and screen texture coordinates in glsl shaders. Include Rend2 renderer in MacOSX bundle Include OpenGL1 and Rend2 renderers in MacOSX UB Include Rend2 renderer in NSIS installer. Include OpenGL1 and Rend2 renderers in Loki Setup Installer. Have NSIS uninstaller delete rend2. Split light sample into direct and ambient parts when using deluxemaps or per-vertex light vectors. Fixes #5813. Fix writting voip data in demos (broke in r2102). Fix server ignoring client move commands if voip data is included. Allow changing cl_voip without restarting. Fix assert failing in CL_ParseVoip() while flipping cl_voip off and on. Only declare var_SampleToView in lightall shader when it is actually used. Fix a couple files not ending with a newline. Fix clients being able to reset their player state and respawn using donedl. Fix passing arg9 (qvm only), arg10, and arg11 to vmMain for native libs and non-i386 compiled or interpated qvms. (Currently they aren't use in vmMain in game, cgame, or ui.) Fix passing args[11] to args[15] from vm to engine on ppc64 and sparc64. Some of the args are used by game bot prediction syscalls. May have been causing bugs. Note: This was fixed for x86_64 in r2163. Fix reconnect command to work after leaving server. (#5794) Fix dedicated server crashing when using MSG_ReadDelta*, though it only happens if someone modifies the engine. (#5449) Makefile fixes for OpenBSD by Jonathan Gray. (#5728) Save all arguments from connect for reconnect command. Remove unnecessary localhost check from reconnect command. Support r_srgb even without hardware support. Also tweak default autoexposure/tonemap settings to look good on both r_srgb 0 and 1. Changed the MacOS-X build system to make UB's containing i386 and x86_64 arches and made make-macosx.sh not build UB's but only standard binaries Fix spectator client being switched from follow to free after map_restart if following a client with a higher client number. Fix client unlinking issue caused by ent->s.number being set to followed client's ps->clientNum after map_restart. Reported by Ensiform. Changes from Ensiform: - In G_AddBot, try to allocate clientNum before doing anything else. - In G_AddBot, don't set SVF_BOT and inuse. It's done in ClientConnect, plus inuse causes ClientDisconnect to be run for no reason. - In G_AddBot, only set skill in bot useinfo once. - Avoid using cl->ps.clientNum to check if cl is a bot. Fix bot skill format so it doesn't always have a space at the beginning of it. More fixes to the macosx buildsystem. This removes the SDL Framework and makes use of a SDL library that is position independant. This also brings back PPC builds into the UB and also as a standa alone build choice. Have make-macosx.sh require the user to specify which architecture she/he wants to build for and suggest building UB's if the user is unaware of what architectures are Lets list all the valid options.
2017-07-09 21:21:12 +00:00
if ( !(g_entities[i].r.svFlags & SVF_BOT) ) {
2011-02-18 14:31:32 +00:00
continue;
}
if ( team >= 0 && cl->sess.sessionTeam != team ) {
continue;
}
ioquake3 resync to revision 2398 from 2369. This is the last ioquake3 revision before ioquake3 changed from subversion to git at the beginning of 2013. #5808 - Include and use .glsl in source (rend2) #5812 - Use refdef's coordinates when drawing to screen shadow fbo, and separate depth texture and screen texture coordinates in glsl shaders. Include Rend2 renderer in MacOSX bundle Include OpenGL1 and Rend2 renderers in MacOSX UB Include Rend2 renderer in NSIS installer. Include OpenGL1 and Rend2 renderers in Loki Setup Installer. Have NSIS uninstaller delete rend2. Split light sample into direct and ambient parts when using deluxemaps or per-vertex light vectors. Fixes #5813. Fix writting voip data in demos (broke in r2102). Fix server ignoring client move commands if voip data is included. Allow changing cl_voip without restarting. Fix assert failing in CL_ParseVoip() while flipping cl_voip off and on. Only declare var_SampleToView in lightall shader when it is actually used. Fix a couple files not ending with a newline. Fix clients being able to reset their player state and respawn using donedl. Fix passing arg9 (qvm only), arg10, and arg11 to vmMain for native libs and non-i386 compiled or interpated qvms. (Currently they aren't use in vmMain in game, cgame, or ui.) Fix passing args[11] to args[15] from vm to engine on ppc64 and sparc64. Some of the args are used by game bot prediction syscalls. May have been causing bugs. Note: This was fixed for x86_64 in r2163. Fix reconnect command to work after leaving server. (#5794) Fix dedicated server crashing when using MSG_ReadDelta*, though it only happens if someone modifies the engine. (#5449) Makefile fixes for OpenBSD by Jonathan Gray. (#5728) Save all arguments from connect for reconnect command. Remove unnecessary localhost check from reconnect command. Support r_srgb even without hardware support. Also tweak default autoexposure/tonemap settings to look good on both r_srgb 0 and 1. Changed the MacOS-X build system to make UB's containing i386 and x86_64 arches and made make-macosx.sh not build UB's but only standard binaries Fix spectator client being switched from follow to free after map_restart if following a client with a higher client number. Fix client unlinking issue caused by ent->s.number being set to followed client's ps->clientNum after map_restart. Reported by Ensiform. Changes from Ensiform: - In G_AddBot, try to allocate clientNum before doing anything else. - In G_AddBot, don't set SVF_BOT and inuse. It's done in ClientConnect, plus inuse causes ClientDisconnect to be run for no reason. - In G_AddBot, only set skill in bot useinfo once. - Avoid using cl->ps.clientNum to check if cl is a bot. Fix bot skill format so it doesn't always have a space at the beginning of it. More fixes to the macosx buildsystem. This removes the SDL Framework and makes use of a SDL library that is position independant. This also brings back PPC builds into the UB and also as a standa alone build choice. Have make-macosx.sh require the user to specify which architecture she/he wants to build for and suggest building UB's if the user is unaware of what architectures are Lets list all the valid options.
2017-07-09 21:21:12 +00:00
trap_SendConsoleCommand( EXEC_INSERT, va("clientkick %d\n", i) );
2011-02-18 14:31:32 +00:00
return qtrue;
}
return qfalse;
}
/*
===============
G_CountHumanPlayers
===============
*/
int G_CountHumanPlayers( int team ) {
int i, num;
gclient_t *cl;
num = 0;
for ( i=0 ; i< g_maxclients.integer ; i++ ) {
cl = level.clients + i;
if ( cl->pers.connected != CON_CONNECTED ) {
continue;
}
ioquake3 resync to revision 2398 from 2369. This is the last ioquake3 revision before ioquake3 changed from subversion to git at the beginning of 2013. #5808 - Include and use .glsl in source (rend2) #5812 - Use refdef's coordinates when drawing to screen shadow fbo, and separate depth texture and screen texture coordinates in glsl shaders. Include Rend2 renderer in MacOSX bundle Include OpenGL1 and Rend2 renderers in MacOSX UB Include Rend2 renderer in NSIS installer. Include OpenGL1 and Rend2 renderers in Loki Setup Installer. Have NSIS uninstaller delete rend2. Split light sample into direct and ambient parts when using deluxemaps or per-vertex light vectors. Fixes #5813. Fix writting voip data in demos (broke in r2102). Fix server ignoring client move commands if voip data is included. Allow changing cl_voip without restarting. Fix assert failing in CL_ParseVoip() while flipping cl_voip off and on. Only declare var_SampleToView in lightall shader when it is actually used. Fix a couple files not ending with a newline. Fix clients being able to reset their player state and respawn using donedl. Fix passing arg9 (qvm only), arg10, and arg11 to vmMain for native libs and non-i386 compiled or interpated qvms. (Currently they aren't use in vmMain in game, cgame, or ui.) Fix passing args[11] to args[15] from vm to engine on ppc64 and sparc64. Some of the args are used by game bot prediction syscalls. May have been causing bugs. Note: This was fixed for x86_64 in r2163. Fix reconnect command to work after leaving server. (#5794) Fix dedicated server crashing when using MSG_ReadDelta*, though it only happens if someone modifies the engine. (#5449) Makefile fixes for OpenBSD by Jonathan Gray. (#5728) Save all arguments from connect for reconnect command. Remove unnecessary localhost check from reconnect command. Support r_srgb even without hardware support. Also tweak default autoexposure/tonemap settings to look good on both r_srgb 0 and 1. Changed the MacOS-X build system to make UB's containing i386 and x86_64 arches and made make-macosx.sh not build UB's but only standard binaries Fix spectator client being switched from follow to free after map_restart if following a client with a higher client number. Fix client unlinking issue caused by ent->s.number being set to followed client's ps->clientNum after map_restart. Reported by Ensiform. Changes from Ensiform: - In G_AddBot, try to allocate clientNum before doing anything else. - In G_AddBot, don't set SVF_BOT and inuse. It's done in ClientConnect, plus inuse causes ClientDisconnect to be run for no reason. - In G_AddBot, only set skill in bot useinfo once. - Avoid using cl->ps.clientNum to check if cl is a bot. Fix bot skill format so it doesn't always have a space at the beginning of it. More fixes to the macosx buildsystem. This removes the SDL Framework and makes use of a SDL library that is position independant. This also brings back PPC builds into the UB and also as a standa alone build choice. Have make-macosx.sh require the user to specify which architecture she/he wants to build for and suggest building UB's if the user is unaware of what architectures are Lets list all the valid options.
2017-07-09 21:21:12 +00:00
if ( g_entities[i].r.svFlags & SVF_BOT ) {
2011-02-18 14:31:32 +00:00
continue;
}
if ( team >= 0 && cl->sess.sessionTeam != team ) {
continue;
}
num++;
}
return num;
}
/*
===============
G_CountBotPlayers
Check connected and connecting (delay join) bots.
2011-02-18 14:31:32 +00:00
===============
*/
int G_CountBotPlayers( int team ) {
int i, num;
2011-02-18 14:31:32 +00:00
gclient_t *cl;
num = 0;
for ( i=0 ; i< g_maxclients.integer ; i++ ) {
cl = level.clients + i;
if ( cl->pers.connected == CON_DISCONNECTED ) {
2011-02-18 14:31:32 +00:00
continue;
}
ioquake3 resync to revision 2398 from 2369. This is the last ioquake3 revision before ioquake3 changed from subversion to git at the beginning of 2013. #5808 - Include and use .glsl in source (rend2) #5812 - Use refdef's coordinates when drawing to screen shadow fbo, and separate depth texture and screen texture coordinates in glsl shaders. Include Rend2 renderer in MacOSX bundle Include OpenGL1 and Rend2 renderers in MacOSX UB Include Rend2 renderer in NSIS installer. Include OpenGL1 and Rend2 renderers in Loki Setup Installer. Have NSIS uninstaller delete rend2. Split light sample into direct and ambient parts when using deluxemaps or per-vertex light vectors. Fixes #5813. Fix writting voip data in demos (broke in r2102). Fix server ignoring client move commands if voip data is included. Allow changing cl_voip without restarting. Fix assert failing in CL_ParseVoip() while flipping cl_voip off and on. Only declare var_SampleToView in lightall shader when it is actually used. Fix a couple files not ending with a newline. Fix clients being able to reset their player state and respawn using donedl. Fix passing arg9 (qvm only), arg10, and arg11 to vmMain for native libs and non-i386 compiled or interpated qvms. (Currently they aren't use in vmMain in game, cgame, or ui.) Fix passing args[11] to args[15] from vm to engine on ppc64 and sparc64. Some of the args are used by game bot prediction syscalls. May have been causing bugs. Note: This was fixed for x86_64 in r2163. Fix reconnect command to work after leaving server. (#5794) Fix dedicated server crashing when using MSG_ReadDelta*, though it only happens if someone modifies the engine. (#5449) Makefile fixes for OpenBSD by Jonathan Gray. (#5728) Save all arguments from connect for reconnect command. Remove unnecessary localhost check from reconnect command. Support r_srgb even without hardware support. Also tweak default autoexposure/tonemap settings to look good on both r_srgb 0 and 1. Changed the MacOS-X build system to make UB's containing i386 and x86_64 arches and made make-macosx.sh not build UB's but only standard binaries Fix spectator client being switched from follow to free after map_restart if following a client with a higher client number. Fix client unlinking issue caused by ent->s.number being set to followed client's ps->clientNum after map_restart. Reported by Ensiform. Changes from Ensiform: - In G_AddBot, try to allocate clientNum before doing anything else. - In G_AddBot, don't set SVF_BOT and inuse. It's done in ClientConnect, plus inuse causes ClientDisconnect to be run for no reason. - In G_AddBot, only set skill in bot useinfo once. - Avoid using cl->ps.clientNum to check if cl is a bot. Fix bot skill format so it doesn't always have a space at the beginning of it. More fixes to the macosx buildsystem. This removes the SDL Framework and makes use of a SDL library that is position independant. This also brings back PPC builds into the UB and also as a standa alone build choice. Have make-macosx.sh require the user to specify which architecture she/he wants to build for and suggest building UB's if the user is unaware of what architectures are Lets list all the valid options.
2017-07-09 21:21:12 +00:00
if ( !(g_entities[i].r.svFlags & SVF_BOT) ) {
2011-02-18 14:31:32 +00:00
continue;
}
if ( team >= 0 && cl->sess.sessionTeam != team ) {
continue;
}
num++;
}
return num;
}
/*
===============
G_CheckMinimumPlayers
===============
*/
void G_CheckMinimumPlayers( void ) {
int minplayers;
int humanplayers, botplayers;
static int checkminimumplayers_time;
if (level.intermissiontime) return;
//only check once each 10 seconds
if (checkminimumplayers_time > level.time - 10000) {
return;
}
checkminimumplayers_time = level.time;
trap_Cvar_Update(&bot_minplayers);
minplayers = bot_minplayers.integer;
if (minplayers <= 0) return;
if (g_gametype.integer >= GT_TEAM) {
if (minplayers >= g_maxclients.integer / 2) {
minplayers = (g_maxclients.integer / 2) -1;
}
humanplayers = G_CountHumanPlayers( TEAM_RED );
botplayers = G_CountBotPlayers( TEAM_RED );
//
if (humanplayers + botplayers < minplayers) {
G_AddRandomBot( TEAM_RED );
} else if (humanplayers + botplayers > minplayers && botplayers) {
G_RemoveRandomBot( TEAM_RED );
}
//
humanplayers = G_CountHumanPlayers( TEAM_BLUE );
botplayers = G_CountBotPlayers( TEAM_BLUE );
//
if (humanplayers + botplayers < minplayers) {
G_AddRandomBot( TEAM_BLUE );
} else if (humanplayers + botplayers > minplayers && botplayers) {
G_RemoveRandomBot( TEAM_BLUE );
}
}
// STONELANCE - removed gametype
/*
else if (g_gametype.integer == GT_TOURNAMENT ) {
if (minplayers >= g_maxclients.integer) {
minplayers = g_maxclients.integer-1;
}
humanplayers = G_CountHumanPlayers( -1 );
botplayers = G_CountBotPlayers( -1 );
//
if (humanplayers + botplayers < minplayers) {
G_AddRandomBot( TEAM_FREE );
} else if (humanplayers + botplayers > minplayers && botplayers) {
// try to remove spectators first
if (!G_RemoveRandomBot( TEAM_SPECTATOR )) {
// just remove the bot that is playing
G_RemoveRandomBot( -1 );
}
}
}
// STONELANCE - UPDATE: enable this for all game modes
else if (g_gametype.integer == GT_FFA) {
if (minplayers >= g_maxclients.integer) {
minplayers = g_maxclients.integer-1;
}
humanplayers = G_CountHumanPlayers( TEAM_FREE );
botplayers = G_CountBotPlayers( TEAM_FREE );
//
if (humanplayers + botplayers < minplayers) {
G_AddRandomBot( TEAM_FREE );
} else if (humanplayers + botplayers > minplayers && botplayers) {
G_RemoveRandomBot( TEAM_FREE );
}
}
*/
// END
}
/*
===============
G_CheckBotSpawn
===============
*/
void G_CheckBotSpawn( void ) {
int n;
char userinfo[MAX_INFO_VALUE];
G_CheckMinimumPlayers();
for( n = 0; n < BOT_SPAWN_QUEUE_DEPTH; n++ ) {
if( !botSpawnQueue[n].spawnTime ) {
continue;
}
if ( botSpawnQueue[n].spawnTime > level.time ) {
continue;
}
ClientBegin( botSpawnQueue[n].clientNum );
botSpawnQueue[n].spawnTime = 0;
if( g_gametype.integer == GT_SINGLE_PLAYER ) {
trap_GetUserinfo( botSpawnQueue[n].clientNum, userinfo, sizeof(userinfo) );
PlayerIntroSound( Info_ValueForKey (userinfo, "model") );
}
}
}
/*
===============
AddBotToSpawnQueue
===============
*/
static void AddBotToSpawnQueue( int clientNum, int delay ) {
int n;
for( n = 0; n < BOT_SPAWN_QUEUE_DEPTH; n++ ) {
if( !botSpawnQueue[n].spawnTime ) {
botSpawnQueue[n].spawnTime = level.time + delay;
botSpawnQueue[n].clientNum = clientNum;
return;
}
}
G_Printf( S_COLOR_YELLOW "Unable to delay spawn\n" );
ClientBegin( clientNum );
}
/*
===============
G_RemoveQueuedBotBegin
Called on client disconnect to make sure the delayed spawn
doesn't happen on a freed index
===============
*/
void G_RemoveQueuedBotBegin( int clientNum ) {
int n;
for( n = 0; n < BOT_SPAWN_QUEUE_DEPTH; n++ ) {
if( botSpawnQueue[n].clientNum == clientNum ) {
botSpawnQueue[n].spawnTime = 0;
return;
}
}
}
/*
===============
G_BotConnect
===============
*/
qboolean G_BotConnect( int clientNum, qboolean restart ) {
bot_settings_t settings;
char userinfo[MAX_INFO_STRING];
trap_GetUserinfo( clientNum, userinfo, sizeof(userinfo) );
Q_strncpyz( settings.characterfile, Info_ValueForKey( userinfo, "characterfile" ), sizeof(settings.characterfile) );
settings.skill = atof( Info_ValueForKey( userinfo, "skill" ) );
if (!BotAISetupClient( clientNum, &settings, restart )) {
trap_DropClient( clientNum, "BotAISetupClient failed" );
return qfalse;
}
return qtrue;
}
/*
===============
G_AddBot
===============
*/
static void G_AddBot( const char *name, float skill, const char *team, int delay, char *altname) {
int clientNum;
int teamNum;
int botinfoNum;
2011-02-18 14:31:32 +00:00
char *botinfo;
char *key;
char *s;
char *botname;
char *model;
char *headmodel;
char userinfo[MAX_INFO_STRING];
ioquake3 resync to revision 2398 from 2369. This is the last ioquake3 revision before ioquake3 changed from subversion to git at the beginning of 2013. #5808 - Include and use .glsl in source (rend2) #5812 - Use refdef's coordinates when drawing to screen shadow fbo, and separate depth texture and screen texture coordinates in glsl shaders. Include Rend2 renderer in MacOSX bundle Include OpenGL1 and Rend2 renderers in MacOSX UB Include Rend2 renderer in NSIS installer. Include OpenGL1 and Rend2 renderers in Loki Setup Installer. Have NSIS uninstaller delete rend2. Split light sample into direct and ambient parts when using deluxemaps or per-vertex light vectors. Fixes #5813. Fix writting voip data in demos (broke in r2102). Fix server ignoring client move commands if voip data is included. Allow changing cl_voip without restarting. Fix assert failing in CL_ParseVoip() while flipping cl_voip off and on. Only declare var_SampleToView in lightall shader when it is actually used. Fix a couple files not ending with a newline. Fix clients being able to reset their player state and respawn using donedl. Fix passing arg9 (qvm only), arg10, and arg11 to vmMain for native libs and non-i386 compiled or interpated qvms. (Currently they aren't use in vmMain in game, cgame, or ui.) Fix passing args[11] to args[15] from vm to engine on ppc64 and sparc64. Some of the args are used by game bot prediction syscalls. May have been causing bugs. Note: This was fixed for x86_64 in r2163. Fix reconnect command to work after leaving server. (#5794) Fix dedicated server crashing when using MSG_ReadDelta*, though it only happens if someone modifies the engine. (#5449) Makefile fixes for OpenBSD by Jonathan Gray. (#5728) Save all arguments from connect for reconnect command. Remove unnecessary localhost check from reconnect command. Support r_srgb even without hardware support. Also tweak default autoexposure/tonemap settings to look good on both r_srgb 0 and 1. Changed the MacOS-X build system to make UB's containing i386 and x86_64 arches and made make-macosx.sh not build UB's but only standard binaries Fix spectator client being switched from follow to free after map_restart if following a client with a higher client number. Fix client unlinking issue caused by ent->s.number being set to followed client's ps->clientNum after map_restart. Reported by Ensiform. Changes from Ensiform: - In G_AddBot, try to allocate clientNum before doing anything else. - In G_AddBot, don't set SVF_BOT and inuse. It's done in ClientConnect, plus inuse causes ClientDisconnect to be run for no reason. - In G_AddBot, only set skill in bot useinfo once. - Avoid using cl->ps.clientNum to check if cl is a bot. Fix bot skill format so it doesn't always have a space at the beginning of it. More fixes to the macosx buildsystem. This removes the SDL Framework and makes use of a SDL library that is position independant. This also brings back PPC builds into the UB and also as a standa alone build choice. Have make-macosx.sh require the user to specify which architecture she/he wants to build for and suggest building UB's if the user is unaware of what architectures are Lets list all the valid options.
2017-07-09 21:21:12 +00:00
// have the server allocate a client slot
clientNum = trap_BotAllocateClient();
if ( clientNum == -1 ) {
G_Printf( S_COLOR_RED "Unable to add bot. All player slots are in use.\n" );
G_Printf( S_COLOR_RED "Start server with more 'open' slots (or check setting of sv_maxclients cvar).\n" );
return;
}
// set default team
if( !team || !*team ) {
if( g_gametype.integer >= GT_TEAM ) {
if( PickTeam(clientNum) == TEAM_RED) {
team = "red";
}
else {
team = "blue";
}
}
else {
team = "free";
}
}
2011-02-18 14:31:32 +00:00
// get the botinfo from bots.txt
if ( Q_stricmp( name, "random" ) == 0 ) {
if ( Q_stricmp( team, "red" ) == 0 || Q_stricmp( team, "r" ) == 0 ) {
teamNum = TEAM_RED;
}
else if ( Q_stricmp( team, "blue" ) == 0 || Q_stricmp( team, "b" ) == 0 ) {
teamNum = TEAM_BLUE;
}
else if ( !Q_stricmp( team, "spectator" ) || !Q_stricmp( team, "s" ) ) {
teamNum = TEAM_SPECTATOR;
}
else {
teamNum = TEAM_FREE;
}
botinfoNum = G_SelectRandomBotInfo( teamNum );
if ( botinfoNum < 0 ) {
G_Printf( S_COLOR_RED "Error: Cannot add random bot, no bot info available.\n" );
trap_BotFreeClient( clientNum );
return;
}
botinfo = G_GetBotInfoByNumber( botinfoNum );
}
else {
botinfo = G_GetBotInfoByName( name );
}
2011-02-18 14:31:32 +00:00
if ( !botinfo ) {
G_Printf( S_COLOR_RED "Error: Bot '%s' not defined\n", name );
trap_BotFreeClient( clientNum );
2011-02-18 14:31:32 +00:00
return;
}
// create the bot's userinfo
userinfo[0] = '\0';
botname = Info_ValueForKey( botinfo, "funname" );
if( !botname[0] ) {
botname = Info_ValueForKey( botinfo, "name" );
}
// check for an alternative name
if (altname && altname[0]) {
botname = altname;
}
Info_SetValueForKey( userinfo, "name", botname );
Info_SetValueForKey( userinfo, "rate", "25000" );
Info_SetValueForKey( userinfo, "snaps", "20" );
ioquake3 resync to revision 2398 from 2369. This is the last ioquake3 revision before ioquake3 changed from subversion to git at the beginning of 2013. #5808 - Include and use .glsl in source (rend2) #5812 - Use refdef's coordinates when drawing to screen shadow fbo, and separate depth texture and screen texture coordinates in glsl shaders. Include Rend2 renderer in MacOSX bundle Include OpenGL1 and Rend2 renderers in MacOSX UB Include Rend2 renderer in NSIS installer. Include OpenGL1 and Rend2 renderers in Loki Setup Installer. Have NSIS uninstaller delete rend2. Split light sample into direct and ambient parts when using deluxemaps or per-vertex light vectors. Fixes #5813. Fix writting voip data in demos (broke in r2102). Fix server ignoring client move commands if voip data is included. Allow changing cl_voip without restarting. Fix assert failing in CL_ParseVoip() while flipping cl_voip off and on. Only declare var_SampleToView in lightall shader when it is actually used. Fix a couple files not ending with a newline. Fix clients being able to reset their player state and respawn using donedl. Fix passing arg9 (qvm only), arg10, and arg11 to vmMain for native libs and non-i386 compiled or interpated qvms. (Currently they aren't use in vmMain in game, cgame, or ui.) Fix passing args[11] to args[15] from vm to engine on ppc64 and sparc64. Some of the args are used by game bot prediction syscalls. May have been causing bugs. Note: This was fixed for x86_64 in r2163. Fix reconnect command to work after leaving server. (#5794) Fix dedicated server crashing when using MSG_ReadDelta*, though it only happens if someone modifies the engine. (#5449) Makefile fixes for OpenBSD by Jonathan Gray. (#5728) Save all arguments from connect for reconnect command. Remove unnecessary localhost check from reconnect command. Support r_srgb even without hardware support. Also tweak default autoexposure/tonemap settings to look good on both r_srgb 0 and 1. Changed the MacOS-X build system to make UB's containing i386 and x86_64 arches and made make-macosx.sh not build UB's but only standard binaries Fix spectator client being switched from follow to free after map_restart if following a client with a higher client number. Fix client unlinking issue caused by ent->s.number being set to followed client's ps->clientNum after map_restart. Reported by Ensiform. Changes from Ensiform: - In G_AddBot, try to allocate clientNum before doing anything else. - In G_AddBot, don't set SVF_BOT and inuse. It's done in ClientConnect, plus inuse causes ClientDisconnect to be run for no reason. - In G_AddBot, only set skill in bot useinfo once. - Avoid using cl->ps.clientNum to check if cl is a bot. Fix bot skill format so it doesn't always have a space at the beginning of it. More fixes to the macosx buildsystem. This removes the SDL Framework and makes use of a SDL library that is position independant. This also brings back PPC builds into the UB and also as a standa alone build choice. Have make-macosx.sh require the user to specify which architecture she/he wants to build for and suggest building UB's if the user is unaware of what architectures are Lets list all the valid options.
2017-07-09 21:21:12 +00:00
Info_SetValueForKey( userinfo, "skill", va("%.2f", skill) );
Info_SetValueForKey( userinfo, "teampref", team );
2011-02-18 14:31:32 +00:00
if ( skill >= 1 && skill < 2 ) {
Info_SetValueForKey( userinfo, "handicap", "50" );
}
else if ( skill >= 2 && skill < 3 ) {
Info_SetValueForKey( userinfo, "handicap", "70" );
}
else if ( skill >= 3 && skill < 4 ) {
Info_SetValueForKey( userinfo, "handicap", "90" );
}
key = "model";
model = Info_ValueForKey( botinfo, key );
if ( !*model ) {
model = "visor/default";
}
Info_SetValueForKey( userinfo, key, model );
key = "team_model";
Info_SetValueForKey( userinfo, key, model );
// STONELANCE
// key = "headmodel";
key = "head";
// END
headmodel = Info_ValueForKey( botinfo, key );
if ( !*headmodel ) {
headmodel = model;
}
Info_SetValueForKey( userinfo, key, headmodel );
key = "team_headmodel";
Info_SetValueForKey( userinfo, key, headmodel );
key = "gender";
s = Info_ValueForKey( botinfo, key );
if ( !*s ) {
s = "male";
}
Info_SetValueForKey( userinfo, "sex", s );
key = "color1";
s = Info_ValueForKey( botinfo, key );
if ( !*s ) {
s = "4";
}
Info_SetValueForKey( userinfo, key, s );
key = "color2";
s = Info_ValueForKey( botinfo, key );
if ( !*s ) {
s = "5";
}
Info_SetValueForKey( userinfo, key, s );
s = Info_ValueForKey(botinfo, "aifile");
if (!*s ) {
trap_Print( S_COLOR_RED "Error: bot has no aifile specified\n" );
trap_BotFreeClient( clientNum );
2011-02-18 14:31:32 +00:00
return;
}
ioquake3 resync to revision 2398 from 2369. This is the last ioquake3 revision before ioquake3 changed from subversion to git at the beginning of 2013. #5808 - Include and use .glsl in source (rend2) #5812 - Use refdef's coordinates when drawing to screen shadow fbo, and separate depth texture and screen texture coordinates in glsl shaders. Include Rend2 renderer in MacOSX bundle Include OpenGL1 and Rend2 renderers in MacOSX UB Include Rend2 renderer in NSIS installer. Include OpenGL1 and Rend2 renderers in Loki Setup Installer. Have NSIS uninstaller delete rend2. Split light sample into direct and ambient parts when using deluxemaps or per-vertex light vectors. Fixes #5813. Fix writting voip data in demos (broke in r2102). Fix server ignoring client move commands if voip data is included. Allow changing cl_voip without restarting. Fix assert failing in CL_ParseVoip() while flipping cl_voip off and on. Only declare var_SampleToView in lightall shader when it is actually used. Fix a couple files not ending with a newline. Fix clients being able to reset their player state and respawn using donedl. Fix passing arg9 (qvm only), arg10, and arg11 to vmMain for native libs and non-i386 compiled or interpated qvms. (Currently they aren't use in vmMain in game, cgame, or ui.) Fix passing args[11] to args[15] from vm to engine on ppc64 and sparc64. Some of the args are used by game bot prediction syscalls. May have been causing bugs. Note: This was fixed for x86_64 in r2163. Fix reconnect command to work after leaving server. (#5794) Fix dedicated server crashing when using MSG_ReadDelta*, though it only happens if someone modifies the engine. (#5449) Makefile fixes for OpenBSD by Jonathan Gray. (#5728) Save all arguments from connect for reconnect command. Remove unnecessary localhost check from reconnect command. Support r_srgb even without hardware support. Also tweak default autoexposure/tonemap settings to look good on both r_srgb 0 and 1. Changed the MacOS-X build system to make UB's containing i386 and x86_64 arches and made make-macosx.sh not build UB's but only standard binaries Fix spectator client being switched from follow to free after map_restart if following a client with a higher client number. Fix client unlinking issue caused by ent->s.number being set to followed client's ps->clientNum after map_restart. Reported by Ensiform. Changes from Ensiform: - In G_AddBot, try to allocate clientNum before doing anything else. - In G_AddBot, don't set SVF_BOT and inuse. It's done in ClientConnect, plus inuse causes ClientDisconnect to be run for no reason. - In G_AddBot, only set skill in bot useinfo once. - Avoid using cl->ps.clientNum to check if cl is a bot. Fix bot skill format so it doesn't always have a space at the beginning of it. More fixes to the macosx buildsystem. This removes the SDL Framework and makes use of a SDL library that is position independant. This also brings back PPC builds into the UB and also as a standa alone build choice. Have make-macosx.sh require the user to specify which architecture she/he wants to build for and suggest building UB's if the user is unaware of what architectures are Lets list all the valid options.
2017-07-09 21:21:12 +00:00
Info_SetValueForKey( userinfo, "characterfile", s );
2011-02-18 14:31:32 +00:00
ioquake3 resync to revision 3385 from 3347. Fix going to previous browser source in q3_ui Limit ui_smallFont/ui_bigFont/cg_noTaunt cvars to missionpack Fix team chat box for spectators Don't draw crosshair 0 in Team Arena setup menu Make client for Windows x86_64 use OpenAL64.dll by default Fix loading renderer DLLs on Windows x86 Add Windows application manifest Disable DPI scaling on Windows ignore window resize event on fullscreen Don't reload arenas.txt/*.arena files in Team Arena UI Fix crash when out of memory in Team Arena's String_Alloc Fix in_nograb not releasing the mouse cursor Update UI player animation handling to match CGame Fix specifying minimum mac os version in make-macosx.sh Fix listen server sending snapshots each client frame Statically link libgcc on Windows Fix hit accuracy stats for lightning gun and shotgun kills Don't link to libGL at compile time Add common OpenGL version parsing + OpenGL 3 fixes Support parsing OpenGL ES version strings Fix setting cflags/libs from sdl2-config Load OpenGL ES 1.1 function procs [qcommon] Use unsigned types where wrapping arithmetic is intended OpenGL2: Fix brightness when r_autoExposure is disabled OpenGL2: Fix MD3 surface with zero shaders dividing by zero [botlib/be_aas_def.h] Change array size from MAX_PATH to MAX_QPATH Don't redefine MAX_PATH in bot code Fix memory leak in (unused) AAS_FloodAreas() Fix compiling GLSL shaders under Windows. Only draw cm_patch/bot debug polygons in world scenes Fix reading crash log when log wraps around buffer Don't send team overlay info to bots Fix a race condition in the makedirs target Fix shader corruption on OpenBSD
2017-11-04 11:30:30 +00:00
// don't send tinfo to bots, they don't parse it
Info_SetValueForKey( userinfo, "teamoverlay", "0" );
2011-02-18 14:31:32 +00:00
// register the userinfo
trap_SetUserinfo( clientNum, userinfo );
// have it connect to the game as a normal client
if ( ClientConnect( clientNum, qtrue, qtrue ) ) {
return;
}
if( delay == 0 ) {
ClientBegin( clientNum );
return;
}
AddBotToSpawnQueue( clientNum, delay );
}
/*
===============
Svcmd_AddBot_f
===============
*/
void Svcmd_AddBot_f( void ) {
float skill;
int delay;
char name[MAX_TOKEN_CHARS];
char altname[MAX_TOKEN_CHARS];
char string[MAX_TOKEN_CHARS];
char team[MAX_TOKEN_CHARS];
// are bots enabled?
if ( !trap_Cvar_VariableIntegerValue( "bot_enable" ) ) {
return;
}
// name
trap_Argv( 1, name, sizeof( name ) );
if ( !name[0] ) {
trap_Print( "Usage: Addbot <botname> [skill 1-5] [team] [msec delay] [altname]\n" );
2011-02-18 14:31:32 +00:00
return;
}
// skill
trap_Argv( 2, string, sizeof( string ) );
if ( !string[0] ) {
skill = 4;
}
else {
skill = Com_Clamp( 1, 5, atof( string ) );
2011-02-18 14:31:32 +00:00
}
// team
trap_Argv( 3, team, sizeof( team ) );
// delay
trap_Argv( 4, string, sizeof( string ) );
if ( !string[0] ) {
delay = 0;
}
else {
delay = atoi( string );
}
// alternative name
trap_Argv( 5, altname, sizeof( altname ) );
G_AddBot( name, skill, team, delay, altname );
// if this was issued during gameplay and we are playing locally,
// go ahead and load the bot's media immediately
if ( level.time - level.startTime > 1000 &&
trap_Cvar_VariableIntegerValue( "cl_running" ) ) {
trap_SendServerCommand( -1, "loaddefered\n" ); // FIXME: spelled wrong, but not changing for demo
}
}
/*
===============
Svcmd_BotList_f
===============
*/
void Svcmd_BotList_f( void ) {
int i;
char name[MAX_TOKEN_CHARS];
char funname[MAX_TOKEN_CHARS];
char model[MAX_TOKEN_CHARS];
char aifile[MAX_TOKEN_CHARS];
trap_Print("^1name model aifile funname\n");
2011-02-18 14:31:32 +00:00
for (i = 0; i < g_numBots; i++) {
ioquake3 resync to revision 3444 from 3393. Fix GCC 6 misleading-indentation warning add SECURITY.md OpenGL2: Restore adding fixed ambient light when HDR is enabled Few LCC memory fixes. fix a few potential buffer overwrite in Game VM Enable compiler optimization on all macOS architectures Don't allow qagame module to create "botlib.log" at ANY filesystem location Make FS_BuildOSPath for botlib.log consistent with typical usage tiny readme thing Remove extra plus sign from Huff_Compress() Fix VMs being able to change CVAR_PROTECTED cvars Don't register fs_game cvar everywhere just to get the value Don't let VMs change engine latch cvars immediately Fix fs_game '..' reading outside of home and base path Fix VMs forcing engine latch cvar to update to latched value Revert my recent cvar latch changes Revert "Don't let VMs change engine latch cvars immediately" Partially revert "Fix fs_game '..' reading outside of home and base path" Revert "Fix VMs forcing engine latch cvar to update to latched value" Fix exploit to bypass filename restrictions on Windows Changes to systemd q3a.service Fix Q_vsnprintf for mingw-w64 Fix timelimit causing an infinite map ending loop Fix invalid access to cluster 0 in AAS_AreaRouteToGoalArea() Fix negative frag/capturelimit causing an infinite map end loop OpenGL2: Fix dark lightmap on shader in mpteam6 Make FS_InvalidGameDir() consider subdirectories invalid [qcommon] Remove dead serialization code [qcommon] Make several zone variables and functions static. Fix MAC_OS_X_VERSION_MIN_REQUIRED for macOS 10.10 and later Increase q3_ui .arena filename list buffer size to 4096 bytes OpenGL2: Fix crash when BSP has deluxe maps and vertex lit surfaces Support Unicode characters greater than 0xFF in cl_consoleKeys Fix macOS app bundle with space in name OpenGL1: Use glGenTextures instead of hardcoded values Remove CON_FlushIn function and where STDIN needs flushing, use tcflush POSIX function Update libogg from 1.3.2 to 1.3.3 Rename (already updated) libogg-1.3.2 to libogg-1.3.3 Update libvorbis from 1.3.5 to 1.3.6 * Fix CVE-2018-5146 - out-of-bounds write on codebook decoding. * Fix CVE-2017-14632 - free() on unitialized data * Fix CVE-2017-14633 - out-of-bounds read Rename (already updated) libvorbis-1.3.5 to libvorbis-1.3.6 Update opus from 1.1.4 to 1.2.1 Rename (already updated) opus-1.1.4 to opus-1.2.1 Update opusfile from 0.8 to 0.9 Rename (already updated) opusfile-0.8 to opusfile-0.9 First swing at a CONTRIBUTING.md Allow loading system OpenAL library on macOS again Remove duplicate setting of FREETYPE_CFLAGS in Makefile Fix exploit to reset player by sending wrong serverId Fix "Going to CS_ZOMBIE for [clientname]" developer message Fix MSG_Read*String*() functions not being able to read last byte from message
2018-04-07 23:02:52 +00:00
Q_strncpyz(name, Info_ValueForKey( g_botInfos[i], "name" ), sizeof( name ));
2011-02-18 14:31:32 +00:00
if ( !*name ) {
strcpy(name, "UnnamedPlayer");
}
ioquake3 resync to revision 3444 from 3393. Fix GCC 6 misleading-indentation warning add SECURITY.md OpenGL2: Restore adding fixed ambient light when HDR is enabled Few LCC memory fixes. fix a few potential buffer overwrite in Game VM Enable compiler optimization on all macOS architectures Don't allow qagame module to create "botlib.log" at ANY filesystem location Make FS_BuildOSPath for botlib.log consistent with typical usage tiny readme thing Remove extra plus sign from Huff_Compress() Fix VMs being able to change CVAR_PROTECTED cvars Don't register fs_game cvar everywhere just to get the value Don't let VMs change engine latch cvars immediately Fix fs_game '..' reading outside of home and base path Fix VMs forcing engine latch cvar to update to latched value Revert my recent cvar latch changes Revert "Don't let VMs change engine latch cvars immediately" Partially revert "Fix fs_game '..' reading outside of home and base path" Revert "Fix VMs forcing engine latch cvar to update to latched value" Fix exploit to bypass filename restrictions on Windows Changes to systemd q3a.service Fix Q_vsnprintf for mingw-w64 Fix timelimit causing an infinite map ending loop Fix invalid access to cluster 0 in AAS_AreaRouteToGoalArea() Fix negative frag/capturelimit causing an infinite map end loop OpenGL2: Fix dark lightmap on shader in mpteam6 Make FS_InvalidGameDir() consider subdirectories invalid [qcommon] Remove dead serialization code [qcommon] Make several zone variables and functions static. Fix MAC_OS_X_VERSION_MIN_REQUIRED for macOS 10.10 and later Increase q3_ui .arena filename list buffer size to 4096 bytes OpenGL2: Fix crash when BSP has deluxe maps and vertex lit surfaces Support Unicode characters greater than 0xFF in cl_consoleKeys Fix macOS app bundle with space in name OpenGL1: Use glGenTextures instead of hardcoded values Remove CON_FlushIn function and where STDIN needs flushing, use tcflush POSIX function Update libogg from 1.3.2 to 1.3.3 Rename (already updated) libogg-1.3.2 to libogg-1.3.3 Update libvorbis from 1.3.5 to 1.3.6 * Fix CVE-2018-5146 - out-of-bounds write on codebook decoding. * Fix CVE-2017-14632 - free() on unitialized data * Fix CVE-2017-14633 - out-of-bounds read Rename (already updated) libvorbis-1.3.5 to libvorbis-1.3.6 Update opus from 1.1.4 to 1.2.1 Rename (already updated) opus-1.1.4 to opus-1.2.1 Update opusfile from 0.8 to 0.9 Rename (already updated) opusfile-0.8 to opusfile-0.9 First swing at a CONTRIBUTING.md Allow loading system OpenAL library on macOS again Remove duplicate setting of FREETYPE_CFLAGS in Makefile Fix exploit to reset player by sending wrong serverId Fix "Going to CS_ZOMBIE for [clientname]" developer message Fix MSG_Read*String*() functions not being able to read last byte from message
2018-04-07 23:02:52 +00:00
Q_strncpyz(funname, Info_ValueForKey( g_botInfos[i], "funname" ), sizeof( funname ));
2011-02-18 14:31:32 +00:00
if ( !*funname ) {
strcpy(funname, "");
}
ioquake3 resync to revision 3444 from 3393. Fix GCC 6 misleading-indentation warning add SECURITY.md OpenGL2: Restore adding fixed ambient light when HDR is enabled Few LCC memory fixes. fix a few potential buffer overwrite in Game VM Enable compiler optimization on all macOS architectures Don't allow qagame module to create "botlib.log" at ANY filesystem location Make FS_BuildOSPath for botlib.log consistent with typical usage tiny readme thing Remove extra plus sign from Huff_Compress() Fix VMs being able to change CVAR_PROTECTED cvars Don't register fs_game cvar everywhere just to get the value Don't let VMs change engine latch cvars immediately Fix fs_game '..' reading outside of home and base path Fix VMs forcing engine latch cvar to update to latched value Revert my recent cvar latch changes Revert "Don't let VMs change engine latch cvars immediately" Partially revert "Fix fs_game '..' reading outside of home and base path" Revert "Fix VMs forcing engine latch cvar to update to latched value" Fix exploit to bypass filename restrictions on Windows Changes to systemd q3a.service Fix Q_vsnprintf for mingw-w64 Fix timelimit causing an infinite map ending loop Fix invalid access to cluster 0 in AAS_AreaRouteToGoalArea() Fix negative frag/capturelimit causing an infinite map end loop OpenGL2: Fix dark lightmap on shader in mpteam6 Make FS_InvalidGameDir() consider subdirectories invalid [qcommon] Remove dead serialization code [qcommon] Make several zone variables and functions static. Fix MAC_OS_X_VERSION_MIN_REQUIRED for macOS 10.10 and later Increase q3_ui .arena filename list buffer size to 4096 bytes OpenGL2: Fix crash when BSP has deluxe maps and vertex lit surfaces Support Unicode characters greater than 0xFF in cl_consoleKeys Fix macOS app bundle with space in name OpenGL1: Use glGenTextures instead of hardcoded values Remove CON_FlushIn function and where STDIN needs flushing, use tcflush POSIX function Update libogg from 1.3.2 to 1.3.3 Rename (already updated) libogg-1.3.2 to libogg-1.3.3 Update libvorbis from 1.3.5 to 1.3.6 * Fix CVE-2018-5146 - out-of-bounds write on codebook decoding. * Fix CVE-2017-14632 - free() on unitialized data * Fix CVE-2017-14633 - out-of-bounds read Rename (already updated) libvorbis-1.3.5 to libvorbis-1.3.6 Update opus from 1.1.4 to 1.2.1 Rename (already updated) opus-1.1.4 to opus-1.2.1 Update opusfile from 0.8 to 0.9 Rename (already updated) opusfile-0.8 to opusfile-0.9 First swing at a CONTRIBUTING.md Allow loading system OpenAL library on macOS again Remove duplicate setting of FREETYPE_CFLAGS in Makefile Fix exploit to reset player by sending wrong serverId Fix "Going to CS_ZOMBIE for [clientname]" developer message Fix MSG_Read*String*() functions not being able to read last byte from message
2018-04-07 23:02:52 +00:00
Q_strncpyz(model, Info_ValueForKey( g_botInfos[i], "model" ), sizeof( model ));
2011-02-18 14:31:32 +00:00
if ( !*model ) {
strcpy(model, "visor/default");
}
ioquake3 resync to revision 3444 from 3393. Fix GCC 6 misleading-indentation warning add SECURITY.md OpenGL2: Restore adding fixed ambient light when HDR is enabled Few LCC memory fixes. fix a few potential buffer overwrite in Game VM Enable compiler optimization on all macOS architectures Don't allow qagame module to create "botlib.log" at ANY filesystem location Make FS_BuildOSPath for botlib.log consistent with typical usage tiny readme thing Remove extra plus sign from Huff_Compress() Fix VMs being able to change CVAR_PROTECTED cvars Don't register fs_game cvar everywhere just to get the value Don't let VMs change engine latch cvars immediately Fix fs_game '..' reading outside of home and base path Fix VMs forcing engine latch cvar to update to latched value Revert my recent cvar latch changes Revert "Don't let VMs change engine latch cvars immediately" Partially revert "Fix fs_game '..' reading outside of home and base path" Revert "Fix VMs forcing engine latch cvar to update to latched value" Fix exploit to bypass filename restrictions on Windows Changes to systemd q3a.service Fix Q_vsnprintf for mingw-w64 Fix timelimit causing an infinite map ending loop Fix invalid access to cluster 0 in AAS_AreaRouteToGoalArea() Fix negative frag/capturelimit causing an infinite map end loop OpenGL2: Fix dark lightmap on shader in mpteam6 Make FS_InvalidGameDir() consider subdirectories invalid [qcommon] Remove dead serialization code [qcommon] Make several zone variables and functions static. Fix MAC_OS_X_VERSION_MIN_REQUIRED for macOS 10.10 and later Increase q3_ui .arena filename list buffer size to 4096 bytes OpenGL2: Fix crash when BSP has deluxe maps and vertex lit surfaces Support Unicode characters greater than 0xFF in cl_consoleKeys Fix macOS app bundle with space in name OpenGL1: Use glGenTextures instead of hardcoded values Remove CON_FlushIn function and where STDIN needs flushing, use tcflush POSIX function Update libogg from 1.3.2 to 1.3.3 Rename (already updated) libogg-1.3.2 to libogg-1.3.3 Update libvorbis from 1.3.5 to 1.3.6 * Fix CVE-2018-5146 - out-of-bounds write on codebook decoding. * Fix CVE-2017-14632 - free() on unitialized data * Fix CVE-2017-14633 - out-of-bounds read Rename (already updated) libvorbis-1.3.5 to libvorbis-1.3.6 Update opus from 1.1.4 to 1.2.1 Rename (already updated) opus-1.1.4 to opus-1.2.1 Update opusfile from 0.8 to 0.9 Rename (already updated) opusfile-0.8 to opusfile-0.9 First swing at a CONTRIBUTING.md Allow loading system OpenAL library on macOS again Remove duplicate setting of FREETYPE_CFLAGS in Makefile Fix exploit to reset player by sending wrong serverId Fix "Going to CS_ZOMBIE for [clientname]" developer message Fix MSG_Read*String*() functions not being able to read last byte from message
2018-04-07 23:02:52 +00:00
Q_strncpyz(aifile, Info_ValueForKey( g_botInfos[i], "aifile"), sizeof( aifile ));
2011-02-18 14:31:32 +00:00
if (!*aifile ) {
strcpy(aifile, "bots/default_c.c");
}
trap_Print(va("%-16s %-16s %-20s %-20s\n", name, model, aifile, funname));
2011-02-18 14:31:32 +00:00
}
}
/*
===============
G_SpawnBots
===============
*/
static void G_SpawnBots( char *botList, int baseDelay ) {
char *bot;
char *p;
float skill;
int delay;
char bots[MAX_INFO_VALUE];
podium1 = NULL;
podium2 = NULL;
podium3 = NULL;
skill = trap_Cvar_VariableValue( "g_spSkill" );
if( skill < 1 ) {
trap_Cvar_Set( "g_spSkill", "1" );
skill = 1;
}
else if ( skill > 5 ) {
trap_Cvar_Set( "g_spSkill", "5" );
skill = 5;
}
Q_strncpyz( bots, botList, sizeof(bots) );
p = &bots[0];
delay = baseDelay;
while( *p ) {
//skip spaces
while( *p && *p == ' ' ) {
p++;
}
if( !*p ) {
2011-02-18 14:31:32 +00:00
break;
}
// mark start of bot name
bot = p;
// skip until space of null
while( *p && *p != ' ' ) {
p++;
}
if( *p ) {
*p++ = 0;
}
// we must add the bot this way, calling G_AddBot directly at this stage
// does "Bad Things"
trap_SendConsoleCommand( EXEC_INSERT, va("addbot %s %f free %i\n", bot, skill, delay) );
delay += BOT_BEGIN_DELAY_INCREMENT;
}
}
/*
===============
G_LoadBotsFromFile
===============
*/
static void G_LoadBotsFromFile( char *filename ) {
int len;
fileHandle_t f;
char buf[MAX_BOTS_TEXT];
len = trap_FS_FOpenFile( filename, &f, FS_READ );
if ( !f ) {
trap_Print( va( S_COLOR_RED "file not found: %s\n", filename ) );
2011-02-18 14:31:32 +00:00
return;
}
if ( len >= MAX_BOTS_TEXT ) {
trap_Print( va( S_COLOR_RED "file too large: %s is %i, max allowed is %i\n", filename, len, MAX_BOTS_TEXT ) );
2011-02-18 14:31:32 +00:00
trap_FS_FCloseFile( f );
return;
}
trap_FS_Read( buf, len, f );
buf[len] = 0;
trap_FS_FCloseFile( f );
g_numBots += G_ParseInfos( buf, MAX_BOTS - g_numBots, &g_botInfos[g_numBots] );
}
/*
===============
G_LoadBots
===============
*/
static void G_LoadBots( void ) {
vmCvar_t botsFile;
int numdirs;
char filename[128];
char dirlist[1024];
char* dirptr;
int i;
int dirlen;
if ( !trap_Cvar_VariableIntegerValue( "bot_enable" ) ) {
return;
}
g_numBots = 0;
trap_Cvar_Register( &botsFile, "g_botsFile", "", CVAR_INIT|CVAR_ROM );
if( *botsFile.string ) {
G_LoadBotsFromFile(botsFile.string);
}
else {
G_LoadBotsFromFile("scripts/bots.txt");
}
// get all bots from .bot files
numdirs = trap_FS_GetFileList("scripts", ".bot", dirlist, 1024 );
dirptr = dirlist;
for (i = 0; i < numdirs; i++, dirptr += dirlen+1) {
dirlen = strlen(dirptr);
strcpy(filename, "scripts/");
strcat(filename, dirptr);
G_LoadBotsFromFile(filename);
}
trap_Print( va( "%i bots parsed\n", g_numBots ) );
2011-02-18 14:31:32 +00:00
}
/*
===============
G_GetBotInfoByNumber
===============
*/
char *G_GetBotInfoByNumber( int num ) {
if( num < 0 || num >= g_numBots ) {
trap_Print( va( S_COLOR_RED "Invalid bot number: %i\n", num ) );
2011-02-18 14:31:32 +00:00
return NULL;
}
return g_botInfos[num];
}
/*
===============
G_GetBotInfoByName
===============
*/
char *G_GetBotInfoByName( const char *name ) {
int n;
char *value;
for ( n = 0; n < g_numBots ; n++ ) {
value = Info_ValueForKey( g_botInfos[n], "name" );
if ( !Q_stricmp( value, name ) ) {
return g_botInfos[n];
}
}
return NULL;
}
/*
===============
G_InitBots
===============
*/
void G_InitBots( qboolean restart ) {
int fragLimit;
int timeLimit;
const char *arenainfo;
char *strValue;
int basedelay;
char map[MAX_QPATH];
char serverinfo[MAX_INFO_STRING];
G_LoadBots();
G_LoadArenas();
trap_Cvar_Register( &bot_minplayers, "bot_minplayers", "0", CVAR_SERVERINFO );
if( g_gametype.integer == GT_SINGLE_PLAYER ) {
trap_GetServerinfo( serverinfo, sizeof(serverinfo) );
Q_strncpyz( map, Info_ValueForKey( serverinfo, "mapname" ), sizeof(map) );
arenainfo = G_GetArenaInfoByMap( map );
if ( !arenainfo ) {
return;
}
strValue = Info_ValueForKey( arenainfo, "fraglimit" );
fragLimit = atoi( strValue );
if ( fragLimit ) {
trap_Cvar_Set( "fraglimit", strValue );
}
else {
trap_Cvar_Set( "fraglimit", "0" );
}
strValue = Info_ValueForKey( arenainfo, "timelimit" );
timeLimit = atoi( strValue );
if ( timeLimit ) {
trap_Cvar_Set( "timelimit", strValue );
}
else {
trap_Cvar_Set( "timelimit", "0" );
}
if ( !fragLimit && !timeLimit ) {
trap_Cvar_Set( "fraglimit", "10" );
trap_Cvar_Set( "timelimit", "0" );
}
basedelay = BOT_BEGIN_DELAY_BASE;
strValue = Info_ValueForKey( arenainfo, "special" );
if( Q_stricmp( strValue, "training" ) == 0 ) {
basedelay += 10000;
}
if( !restart ) {
G_SpawnBots( Info_ValueForKey( arenainfo, "bots" ), basedelay );
}
}
}