g-bot.c > G_RemoveRandomBot is buggy

DD 0000spam at gmail.com
Fri Dec 29 04:33:02 EST 2006


This is used in conjunction with bot_minplayers, removing bots to keep
players number same as bot_minplayers, not counting spectators.
Problem is when custom bots use certain fun names and Q_CleanStr is
not working properly on or with them.

2 examples (without "") of errors when server tries to kick them:

"^1P^3u^4^2M^1p^3K^2i^1N^3a^2T^1o^3R"
Player PuMpKiNaToR is not on the server

"Mu ^1v.2"
Usage: kick <player name>
kick all = kick everyone
kick allbots = kick all bots

This was outputted into console. I was wondering who is trying to kick
some player all night. :)

I fixed the problem on our servers by kicking them by client number
instead of going thru all this name cleaning mess. Here is my fix, you
can use it in ioq3 or silently ignore it.

NEW CODE:
/*
===============
G_RemoveRandomBot
===============
*/
int G_RemoveRandomBot( int team ) {
        int i;
// DD   char netname[36];
        gclient_t       *cl;

        for ( i=0 ; i< g_maxclients.integer ; i++ ) {
                cl = level.clients + i;
                if ( cl->pers.connected != CON_CONNECTED ) {
                        continue;
                }
                if ( !(g_entities[cl->ps.clientNum].r.svFlags & SVF_BOT) ) {
                        continue;
                }
                if ( team >= 0 && cl->sess.sessionTeam != team ) {
                        continue;
                }
// DD           strcpy(netname, cl->pers.netname);
// DD           Q_CleanStr(netname);
                // DD kick by clientnum instead
                trap_SendConsoleCommand( EXEC_INSERT, va("clientkick
%i\n", cl->ps.clientNum) );
                return qtrue;
        }
        return qfalse;
}


OLD CODE:
/*
===============
G_RemoveRandomBot
===============
*/
int G_RemoveRandomBot( int team ) {
	int i;
	char netname[36];
	gclient_t	*cl;

	for ( i=0 ; i< g_maxclients.integer ; i++ ) {
		cl = level.clients + i;
		if ( cl->pers.connected != CON_CONNECTED ) {
			continue;
		}
		if ( !(g_entities[cl->ps.clientNum].r.svFlags & SVF_BOT) ) {
			continue;
		}
		if ( team >= 0 && cl->sess.sessionTeam != team ) {
			continue;
		}
		strcpy(netname, cl->pers.netname);
		Q_CleanStr(netname);
		trap_SendConsoleCommand( EXEC_INSERT, va("kick %s\n", netname) );
		return qtrue;
	}
	return qfalse;
}

dyn
vogonhq.com



More information about the quake3 mailing list