mirror of
https://github.com/UberGames/lilium-voyager.git
synced 2025-02-12 06:42:29 +00:00
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.
This commit is contained in:
parent
b791040f42
commit
a57a5cfd9b
2 changed files with 17 additions and 24 deletions
|
@ -248,7 +248,7 @@ void G_AddRandomBot( int team ) {
|
||||||
if ( cl->pers.connected != CON_CONNECTED ) {
|
if ( cl->pers.connected != CON_CONNECTED ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ( !(g_entities[cl->ps.clientNum].r.svFlags & SVF_BOT) ) {
|
if ( !(g_entities[i].r.svFlags & SVF_BOT) ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ( team >= 0 && cl->sess.sessionTeam != team ) {
|
if ( team >= 0 && cl->sess.sessionTeam != team ) {
|
||||||
|
@ -271,7 +271,7 @@ void G_AddRandomBot( int team ) {
|
||||||
if ( cl->pers.connected != CON_CONNECTED ) {
|
if ( cl->pers.connected != CON_CONNECTED ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ( !(g_entities[cl->ps.clientNum].r.svFlags & SVF_BOT) ) {
|
if ( !(g_entities[i].r.svFlags & SVF_BOT) ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ( team >= 0 && cl->sess.sessionTeam != team ) {
|
if ( team >= 0 && cl->sess.sessionTeam != team ) {
|
||||||
|
@ -312,13 +312,13 @@ int G_RemoveRandomBot( int team ) {
|
||||||
if ( cl->pers.connected != CON_CONNECTED ) {
|
if ( cl->pers.connected != CON_CONNECTED ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ( !(g_entities[cl->ps.clientNum].r.svFlags & SVF_BOT) ) {
|
if ( !(g_entities[i].r.svFlags & SVF_BOT) ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ( team >= 0 && cl->sess.sessionTeam != team ) {
|
if ( team >= 0 && cl->sess.sessionTeam != team ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
trap_SendConsoleCommand( EXEC_INSERT, va("clientkick %d\n", cl->ps.clientNum) );
|
trap_SendConsoleCommand( EXEC_INSERT, va("clientkick %d\n", i) );
|
||||||
return qtrue;
|
return qtrue;
|
||||||
}
|
}
|
||||||
return qfalse;
|
return qfalse;
|
||||||
|
@ -339,7 +339,7 @@ int G_CountHumanPlayers( int team ) {
|
||||||
if ( cl->pers.connected != CON_CONNECTED ) {
|
if ( cl->pers.connected != CON_CONNECTED ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ( g_entities[cl->ps.clientNum].r.svFlags & SVF_BOT ) {
|
if ( g_entities[i].r.svFlags & SVF_BOT ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ( team >= 0 && cl->sess.sessionTeam != team ) {
|
if ( team >= 0 && cl->sess.sessionTeam != team ) {
|
||||||
|
@ -365,7 +365,7 @@ int G_CountBotPlayers( int team ) {
|
||||||
if ( cl->pers.connected != CON_CONNECTED ) {
|
if ( cl->pers.connected != CON_CONNECTED ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ( !(g_entities[cl->ps.clientNum].r.svFlags & SVF_BOT) ) {
|
if ( !(g_entities[i].r.svFlags & SVF_BOT) ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ( team >= 0 && cl->sess.sessionTeam != team ) {
|
if ( team >= 0 && cl->sess.sessionTeam != team ) {
|
||||||
|
@ -562,7 +562,6 @@ G_AddBot
|
||||||
static void G_AddBot( const char *name, float skill, const char *team, int delay, char *altname) {
|
static void G_AddBot( const char *name, float skill, const char *team, int delay, char *altname) {
|
||||||
int clientNum;
|
int clientNum;
|
||||||
char *botinfo;
|
char *botinfo;
|
||||||
gentity_t *bot;
|
|
||||||
char *key;
|
char *key;
|
||||||
char *s;
|
char *s;
|
||||||
char *botname;
|
char *botname;
|
||||||
|
@ -570,6 +569,14 @@ static void G_AddBot( const char *name, float skill, const char *team, int delay
|
||||||
char *headmodel;
|
char *headmodel;
|
||||||
char userinfo[MAX_INFO_STRING];
|
char userinfo[MAX_INFO_STRING];
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
|
||||||
// get the botinfo from bots.txt
|
// get the botinfo from bots.txt
|
||||||
botinfo = G_GetBotInfoByName( name );
|
botinfo = G_GetBotInfoByName( name );
|
||||||
if ( !botinfo ) {
|
if ( !botinfo ) {
|
||||||
|
@ -591,7 +598,7 @@ static void G_AddBot( const char *name, float skill, const char *team, int delay
|
||||||
Info_SetValueForKey( userinfo, "name", botname );
|
Info_SetValueForKey( userinfo, "name", botname );
|
||||||
Info_SetValueForKey( userinfo, "rate", "25000" );
|
Info_SetValueForKey( userinfo, "rate", "25000" );
|
||||||
Info_SetValueForKey( userinfo, "snaps", "20" );
|
Info_SetValueForKey( userinfo, "snaps", "20" );
|
||||||
Info_SetValueForKey( userinfo, "skill", va("%1.2f", skill) );
|
Info_SetValueForKey( userinfo, "skill", va("%5.2f", skill) );
|
||||||
|
|
||||||
if ( skill >= 1 && skill < 2 ) {
|
if ( skill >= 1 && skill < 2 ) {
|
||||||
Info_SetValueForKey( userinfo, "handicap", "50" );
|
Info_SetValueForKey( userinfo, "handicap", "50" );
|
||||||
|
@ -647,16 +654,8 @@ static void G_AddBot( const char *name, float skill, const char *team, int delay
|
||||||
trap_Print( S_COLOR_RED "Error: bot has no aifile specified\n" );
|
trap_Print( S_COLOR_RED "Error: bot has no aifile specified\n" );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Info_SetValueForKey( userinfo, "characterfile", s );
|
||||||
|
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// initialize the bot settings
|
|
||||||
if( !team || !*team ) {
|
if( !team || !*team ) {
|
||||||
if( g_gametype.integer >= GT_TEAM ) {
|
if( g_gametype.integer >= GT_TEAM ) {
|
||||||
if( PickTeam(clientNum) == TEAM_RED) {
|
if( PickTeam(clientNum) == TEAM_RED) {
|
||||||
|
@ -670,14 +669,8 @@ static void G_AddBot( const char *name, float skill, const char *team, int delay
|
||||||
team = "red";
|
team = "red";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Info_SetValueForKey( userinfo, "characterfile", Info_ValueForKey( botinfo, "aifile" ) );
|
|
||||||
Info_SetValueForKey( userinfo, "skill", va( "%5.2f", skill ) );
|
|
||||||
Info_SetValueForKey( userinfo, "team", team );
|
Info_SetValueForKey( userinfo, "team", team );
|
||||||
|
|
||||||
bot = &g_entities[ clientNum ];
|
|
||||||
bot->r.svFlags |= SVF_BOT;
|
|
||||||
bot->inuse = qtrue;
|
|
||||||
|
|
||||||
// register the userinfo
|
// register the userinfo
|
||||||
trap_SetUserinfo( clientNum, userinfo );
|
trap_SetUserinfo( clientNum, userinfo );
|
||||||
|
|
||||||
|
|
|
@ -1231,7 +1231,7 @@ void CheckIntermissionExit( void ) {
|
||||||
if ( cl->pers.connected != CON_CONNECTED ) {
|
if ( cl->pers.connected != CON_CONNECTED ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ( g_entities[cl->ps.clientNum].r.svFlags & SVF_BOT ) {
|
if ( g_entities[i].r.svFlags & SVF_BOT ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue