diff options
Diffstat (limited to 'src/game/g_cmds.c')
-rw-r--r-- | src/game/g_cmds.c | 177 |
1 files changed, 38 insertions, 139 deletions
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 2265aaa9..3508be28 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -751,11 +751,6 @@ void G_Say( gentity_t *ent, saymode_t mode, const char *chatText ) other = &g_entities[ j ]; G_SayTo( ent, other, mode, text ); } - - if( g_adminParseSay.integer ) - { - G_admin_cmd_check ( ent, qtrue ); - } } /* @@ -786,8 +781,6 @@ static void Cmd_SayArea_f( gentity_t *ent ) vec3_t range = { 1000.0f, 1000.0f, 1000.0f }; vec3_t mins, maxs; char *msg; - char cmd[ sizeof( "say_team" ) ]; - int skiparg = 0; if( ent->client->pers.teamSelection == TEAM_NONE ) { @@ -802,20 +795,13 @@ static void Cmd_SayArea_f( gentity_t *ent ) return; } - // Skip say/say_team if this was used from one of those - G_SayArgv( 0, cmd, sizeof( cmd ) ); - if( !Q_stricmp( cmd, "say" ) || !Q_stricmp( cmd, "say_team" ) ) - { - skiparg = 1; - G_SayArgv( 1, cmd, sizeof( cmd ) ); - } - if( G_SayArgc( ) < 2 + skiparg ) + if( trap_Argc( ) < 2 ) { - ADMP( va( "usage: %s [message]\n", cmd ) ); + ADMP( "usage: say_area [message]\n" ); return; } - msg = G_SayConcatArgs( 1 + skiparg ); + msg = ConcatArgs( 1 ); for(i = 0; i < 3; i++ ) range[ i ] = g_sayAreaRange.value; @@ -850,43 +836,16 @@ Cmd_Say_f static void Cmd_Say_f( gentity_t *ent ) { char *p; - char *args; + char cmd[ MAX_TOKEN_CHARS ]; saymode_t mode = SAY_ALL; - args = G_SayConcatArgs( 0 ); - if( Q_stricmpn( args, "say_team ", 9 ) == 0 ) - mode = SAY_TEAM; - - // support parsing /m out of say text since some people have a hard - // time figuring out what the console is. - if( !Q_stricmpn( args, "say /m ", 7 ) || - !Q_stricmpn( args, "say_team /m ", 12 ) || - !Q_stricmpn( args, "say /mt ", 8 ) || - !Q_stricmpn( args, "say_team /mt ", 13 ) ) - { - Cmd_PrivateMessage_f( ent ); - return; - } - - // support parsing /a out of say text for the same reason - if( !Q_stricmpn( args, "say /a ", 7 ) || - !Q_stricmpn( args, "say_team /a ", 12 ) ) - { - Cmd_AdminMessage_f( ent ); - return; - } - - // support parsing /say_area out of say text for the same reason - if( !Q_stricmpn( args, "say /say_area ", 14 ) || - !Q_stricmpn( args, "say_team /say_area ", 19 ) ) - { - Cmd_SayArea_f( ent ); - return; - } - if( trap_Argc( ) < 2 ) return; + trap_Argv( 0, cmd, sizeof( cmd ) ); + if( Q_stricmp( cmd, "say_team" ) == 0 ) + mode = SAY_TEAM; + p = ConcatArgs( 1 ); G_Say( ent, mode, p ); @@ -1141,7 +1100,7 @@ void Cmd_CallVote_f( gentity_t *ent ) } Com_sprintf( level.voteString[ team ], sizeof( level.voteString[ team ] ), - "!ban %s \"1s%s\" vote kick", level.clients[ clientNum ].pers.ip, + "ban %s \"1s%s\" vote kick", level.clients[ clientNum ].pers.ip, g_adminTempBan.string ); Com_sprintf( level.voteDisplayString[ team ], sizeof( level.voteDisplayString[ team ] ), @@ -1159,7 +1118,7 @@ void Cmd_CallVote_f( gentity_t *ent ) } Com_sprintf( level.voteString[ team ], sizeof( level.voteString[ team ] ), - "!mute %d", clientNum ); + "mute %d", clientNum ); Com_sprintf( level.voteDisplayString[ team ], sizeof( level.voteDisplayString[ team ] ), "Mute player '%s'", name ); @@ -1174,7 +1133,7 @@ void Cmd_CallVote_f( gentity_t *ent ) } Com_sprintf( level.voteString[ team ], sizeof( level.voteString[ team ] ), - "!unmute %d", clientNum ); + "unmute %d", clientNum ); Com_sprintf( level.voteDisplayString[ team ], sizeof( level.voteDisplayString[ team ] ), "Unmute player '%s'", name ); @@ -1274,7 +1233,7 @@ void Cmd_CallVote_f( gentity_t *ent ) } Com_sprintf( level.voteString[ team ], sizeof( level.voteString[ team ] ), - "!denybuild %d", clientNum ); + "denybuild %d", clientNum ); Com_sprintf( level.voteDisplayString[ team ], sizeof( level.voteDisplayString[ team ] ), "Take away building rights from '%s'", name ); @@ -1289,7 +1248,7 @@ void Cmd_CallVote_f( gentity_t *ent ) } Com_sprintf( level.voteString[ team ], sizeof( level.voteString[ team ] ), - "!allowbuild %d", clientNum ); + "allowbuild %d", clientNum ); Com_sprintf( level.voteDisplayString[ team ], sizeof( level.voteDisplayString[ team ] ), "Allow '%s' to build", name ); @@ -2982,7 +2941,7 @@ void ClientCommand( int clientNum ) if( !command ) { - if( !G_admin_cmd_check( ent, qfalse ) ) + if( !G_admin_cmd_check( ent ) ) trap_SendServerCommand( clientNum, va( "print \"Unknown command %s\n\"", cmd ) ); return; @@ -3050,71 +3009,29 @@ void ClientCommand( int clientNum ) command->cmdHandler( ent ); } -/* -================= -G_SayArgc -G_SayArgv -G_SayConcatArgs - -trap_Argc, trap_Argv, and ConcatArgs consider say text as a single argument -These functions assemble the text and re-parse it on word boundaries -================= -*/ -int G_SayArgc( void ) +void G_ListCommands( gentity_t *ent ) { - int c = 0; - char *s; - - s = ConcatArgs( 0 ); - while( 1 ) - { - while( *s == ' ' ) - s++; - if( !*s ) - break; - c++; - while( *s && *s != ' ' ) - s++; - } - return c; -} + int i; + char out[ MAX_STRING_CHARS ] = ""; + int len, outlen; -qboolean G_SayArgv( int n, char *buffer, int bufferLength ) -{ - char *s; + outlen = 0; - if( bufferLength < 1 ) - return qfalse; - if( n < 0 ) - return qfalse; - s = G_SayConcatArgs( n ); - if( !*s ) - return qfalse; - while( *s && *s != ' ' && bufferLength > 1 ) + for( i = 0; i < numCmds; i++ ) { - *buffer++ = *s++; - bufferLength--; - } - *buffer = 0; - return qtrue; -} - -char *G_SayConcatArgs( int start ) -{ - char *s; + len = strlen( cmds[ i ].cmdName ) + 1; + if( len + outlen >= sizeof( out ) - 1 ) + { + trap_SendServerCommand( ent - g_entities, va( "cmds%s\n", out ) ); + outlen = 0; + } - s = ConcatArgs( 0 ); - while( 1 ) - { - while( *s == ' ' ) - s++; - if( !*s || start == 0 ) - break; - start--; - while( *s && *s != ' ' ) - s++; + strcpy( out + outlen, va( " %s", cmds[ i ].cmdName ) ); + outlen += len; } - return s; + + trap_SendServerCommand( ent - g_entities, va( "cmds%s\n", out ) ); + G_admin_cmdlist( ent ); } void G_DecolorString( char *in, char *out, int len ) @@ -3141,7 +3058,6 @@ void Cmd_PrivateMessage_f( gentity_t *ent ) char *msg; char color; int i, pcount; - int skipargs = 0; int count = 0; qboolean teamonly = qfalse; @@ -3151,14 +3067,8 @@ void Cmd_PrivateMessage_f( gentity_t *ent ) return; } - // parse arguments - G_SayArgv( 0, cmd, sizeof( cmd ) ); - if( !Q_stricmp( cmd, "say" ) || !Q_stricmp( cmd, "say_team" ) ) - { - skipargs = 1; - G_SayArgv( 1, cmd, sizeof( cmd ) ); - } - if( G_SayArgc( ) < 3+skipargs ) + trap_Argv( 0, cmd, sizeof( cmd ) ); + if( trap_Argc( ) < 3 ) { ADMP( va( "usage: %s [name|slot#] [message]\n", cmd ) ); return; @@ -3167,9 +3077,8 @@ void Cmd_PrivateMessage_f( gentity_t *ent ) if( !Q_stricmp( cmd, "mt" ) || !Q_stricmp( cmd, "/mt" ) ) teamonly = qtrue; - // figure out the name matches - G_SayArgv( 1+skipargs, name, sizeof( name ) ); - msg = G_SayConcatArgs( 2+skipargs ); + trap_Argv( 1, name, sizeof( name ) ); + msg = ConcatArgs( 2 ); pcount = G_ClientNumbersFromString( name, pids, MAX_CLIENTS ); // send the message @@ -3209,9 +3118,6 @@ Send a message to all active admins */ void Cmd_AdminMessage_f( gentity_t *ent ) { - char cmd[ sizeof( "say_team" ) ]; - int skiparg = 0; - // Check permissions and add the appropriate user [prefix] if( !G_admin_permission( ent, ADMF_ADMINCHAT ) ) { @@ -3227,19 +3133,12 @@ void Cmd_AdminMessage_f( gentity_t *ent ) } } - // Skip say/say_team if this was used from one of those - G_SayArgv( 0, cmd, sizeof( cmd ) ); - if( !Q_stricmp( cmd, "say" ) || !Q_stricmp( cmd, "say_team" ) ) - { - skiparg = 1; - G_SayArgv( 1, cmd, sizeof( cmd ) ); - } - if( G_SayArgc( ) < 2 + skiparg ) + if( trap_Argc( ) < 2 ) { - ADMP( va( "usage: %s [message]\n", cmd ) ); + ADMP( "usage: a [message]\n" ); return; } - G_AdminMessage( ent, G_SayConcatArgs( 1 + skiparg ) ); + G_AdminMessage( ent, ConcatArgs( 1 ) ); } |