[ioquake3] 118/136: Show client's name in callvote clientkick vote display message
Simon McVittie
smcv at debian.org
Thu Jun 15 09:09:17 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 71512bb1fd8c955011cc82fe93d69d69c1575721
Author: Zack Middleton <zack at cloemail.com>
Date: Wed Jun 7 20:15:51 2017 -0500
Show client's name in callvote clientkick vote display message
Make callvote always kick by client num so player can't rename to
avoid being kicked. Don't allow calling a vote to kick host or
non-existent players.
---
code/game/g_cmds.c | 59 +++++++++++++++++++++++++++++++++++-------------------
1 file changed, 38 insertions(+), 21 deletions(-)
diff --git a/code/game/g_cmds.c b/code/game/g_cmds.c
index 70681c7c..7606edb 100644
--- a/code/game/g_cmds.c
+++ b/code/game/g_cmds.c
@@ -192,31 +192,35 @@ Returns a player number for either a number or name string
Returns -1 if invalid
==================
*/
-int ClientNumberFromString( gentity_t *to, char *s ) {
+int ClientNumberFromString( gentity_t *to, char *s, qboolean checkNums, qboolean checkNames ) {
gclient_t *cl;
int idnum;
char cleanName[MAX_STRING_CHARS];
- // numeric values could be slot numbers
- if ( StringIsInteger( s ) ) {
- idnum = atoi( s );
- if ( idnum >= 0 && idnum < level.maxclients ) {
- cl = &level.clients[idnum];
- if ( cl->pers.connected == CON_CONNECTED ) {
- return idnum;
+ if ( checkNums ) {
+ // numeric values could be slot numbers
+ if ( StringIsInteger( s ) ) {
+ idnum = atoi( s );
+ if ( idnum >= 0 && idnum < level.maxclients ) {
+ cl = &level.clients[idnum];
+ if ( cl->pers.connected == CON_CONNECTED ) {
+ return idnum;
+ }
}
}
}
- // check for a name match
- for ( idnum=0,cl=level.clients ; idnum < level.maxclients ; idnum++,cl++ ) {
- if ( cl->pers.connected != CON_CONNECTED ) {
- continue;
- }
- Q_strncpyz(cleanName, cl->pers.netname, sizeof(cleanName));
- Q_CleanStr(cleanName);
- if ( !Q_stricmp( cleanName, s ) ) {
- return idnum;
+ if ( checkNames ) {
+ // check for a name match
+ for ( idnum=0,cl=level.clients ; idnum < level.maxclients ; idnum++,cl++ ) {
+ if ( cl->pers.connected != CON_CONNECTED ) {
+ continue;
+ }
+ Q_strncpyz(cleanName, cl->pers.netname, sizeof(cleanName));
+ Q_CleanStr(cleanName);
+ if ( !Q_stricmp( cleanName, s ) ) {
+ return idnum;
+ }
}
}
@@ -734,7 +738,7 @@ void Cmd_Follow_f( gentity_t *ent ) {
}
trap_Argv( 1, arg, sizeof( arg ) );
- i = ClientNumberFromString( ent, arg );
+ i = ClientNumberFromString( ent, arg, qtrue, qtrue );
if ( i == -1 ) {
return;
}
@@ -966,7 +970,7 @@ static void Cmd_Tell_f( gentity_t *ent ) {
}
trap_Argv( 1, arg, sizeof( arg ) );
- targetNum = ClientNumberFromString( ent, arg );
+ targetNum = ClientNumberFromString( ent, arg, qtrue, qtrue );
if ( targetNum == -1 ) {
return;
}
@@ -1092,7 +1096,7 @@ static void Cmd_VoiceTell_f( gentity_t *ent, qboolean voiceonly ) {
}
trap_Argv( 1, arg, sizeof( arg ) );
- targetNum = ClientNumberFromString( ent, arg );
+ targetNum = ClientNumberFromString( ent, arg, qtrue, qtrue );
if ( targetNum == -1 ) {
return;
}
@@ -1221,7 +1225,7 @@ void Cmd_GameCommand_f( gentity_t *ent ) {
}
trap_Argv( 1, arg, sizeof( arg ) );
- targetNum = ClientNumberFromString( ent, arg );
+ targetNum = ClientNumberFromString( ent, arg, qtrue, qtrue );
if ( targetNum == -1 ) {
return;
}
@@ -1365,6 +1369,19 @@ void Cmd_CallVote_f( gentity_t *ent ) {
}
Com_sprintf( level.voteString, sizeof( level.voteString ), "vstr nextmap");
Com_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ), "%s", level.voteString );
+ } else if ( !Q_stricmp( arg1, "clientkick" ) || !Q_stricmp( arg1, "kick" ) ) {
+ i = ClientNumberFromString( ent, arg2, !Q_stricmp( arg1, "clientkick" ), !Q_stricmp( arg1, "kick" ) );
+ if ( i == -1 ) {
+ return;
+ }
+
+ if ( level.clients[i].pers.localClient ) {
+ trap_SendServerCommand( ent - g_entities, "print \"Cannot kick host player.\n\"" );
+ return;
+ }
+
+ Com_sprintf( level.voteString, sizeof( level.voteString ), "clientkick %d", i );
+ Com_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ), "kick %s", level.clients[i].pers.netname );
} else {
Com_sprintf( level.voteString, sizeof( level.voteString ), "%s \"%s\"", arg1, arg2 );
Com_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ), "%s", level.voteString );
--
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