diff options
Diffstat (limited to 'src/game')
-rw-r--r-- | src/game/g_admin.c | 4 | ||||
-rw-r--r-- | src/game/g_admin.h | 2 | ||||
-rw-r--r-- | src/game/g_cmds.c | 66 | ||||
-rw-r--r-- | src/game/g_local.h | 3 | ||||
-rw-r--r-- | src/game/g_main.c | 47 | ||||
-rw-r--r-- | src/game/g_svcmds.c | 6 |
6 files changed, 124 insertions, 4 deletions
diff --git a/src/game/g_admin.c b/src/game/g_admin.c index 375e560f..0cdd7bc0 100644 --- a/src/game/g_admin.c +++ b/src/game/g_admin.c @@ -568,11 +568,11 @@ static void admin_default_levels( void ) Q_strncpyz( g_admin_levels[ 3 ]->name, "^2Junior Admin", sizeof( l->name ) ); - Q_strncpyz( g_admin_levels[ 3 ]->flags, "iahCpPkm$", sizeof( l->flags ) ); + Q_strncpyz( g_admin_levels[ 3 ]->flags, "iahCpPkm$?", sizeof( l->flags ) ); Q_strncpyz( g_admin_levels[ 4 ]->name, "^3Senior Admin", sizeof( l->name ) ); - Q_strncpyz( g_admin_levels[ 4 ]->flags, "iahCpPkmBbe$", sizeof( l->flags ) ); + Q_strncpyz( g_admin_levels[ 4 ]->flags, "iahCpPkmBbe$?", sizeof( l->flags ) ); Q_strncpyz( g_admin_levels[ 5 ]->name, "^1Server Operator", sizeof( l->name ) ); diff --git a/src/game/g_admin.h b/src/game/g_admin.h index ee0f6ad7..bbd251e4 100644 --- a/src/game/g_admin.h +++ b/src/game/g_admin.h @@ -55,6 +55,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ! - admin commands cannot be used on them * @ - does not show up as an admin in !listplayers * $ - sees all information in !listplayers + * ? - receieves and can send /a admin messages */ #define ADMF_IMMUNITY '1' #define ADMF_NOCENSORFLOOD '2' /* TODO */ @@ -69,6 +70,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define ADMF_IMMUTABLE '!' #define ADMF_INCOGNITO '@' #define ADMF_SEESFULLLISTPLAYERS '$' +#define ADMF_ADMINCHAT '?' #define MAX_ADMIN_LISTITEMS 20 #define MAX_ADMIN_SHOWBANS 10 diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 7903590f..56617697 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -921,6 +921,14 @@ static void Cmd_Say_f( gentity_t *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 ) ) + { + G_AdminMessage( ent ); + return; + } + if( trap_Argc( ) < 2 ) return; @@ -3079,6 +3087,7 @@ commands_t cmds[ ] = { { "vsay_local", CMD_MESSAGE|CMD_INTERMISSION, Cmd_VSay_f }, { "m", CMD_MESSAGE|CMD_INTERMISSION, G_PrivateMessage }, { "mt", CMD_MESSAGE|CMD_INTERMISSION, G_PrivateMessage }, + { "a", CMD_MESSAGE|CMD_INTERMISSION, G_AdminMessage }, { "score", CMD_INTERMISSION, ScoreboardMessage }, @@ -3415,3 +3424,60 @@ void G_PrivateMessage( gentity_t *ent ) } } +/* +================= +G_AdminMessage + +Send a message to all active admins +================= +*/ +void G_AdminMessage( gentity_t *ent ) +{ + char cmd[ 12 ]; + char prefix[ 50 ]; + char *msg; + int skiparg = 0; + + // Check permissions and add the appropriate user [prefix] + if( !ent ) + { + Com_sprintf( prefix, sizeof( prefix ), "[CONSOLE]:" ); + } + else if( !G_admin_permission( ent, ADMF_ADMINCHAT ) ) + { + if( !g_publicAdminMessages.integer ) + { + ADMP( "Sorry, but use of /a by non-admins has been disabled.\n" ); + return; + } + else + { + Com_sprintf( prefix, sizeof( prefix ), "[PLAYER]%s" S_COLOR_WHITE ":", ent->client->pers.netname ); + ADMP( "Your message has been sent to any available admins and to the server logs.\n" ); + } + } + else + { + Com_sprintf( prefix, sizeof( prefix ), "[ADMIN]%s" S_COLOR_WHITE ":", ent->client->pers.netname ); + } + + // Parse out 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 ) + { + ADMP( va( "usage: %s [message]\n", cmd ) ); + return; + } + + msg = G_SayConcatArgs( 1 + skiparg ); + + // Send it + G_AdminsPrintf( prefix, "%s\n", msg ); + +} + diff --git a/src/game/g_local.h b/src/game/g_local.h index d94e99f9..589c6c12 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -678,6 +678,7 @@ void G_ChangeTeam( gentity_t *ent, team_t newTeam ); void G_SanitiseString( char *in, char *out, int len ); void G_PrivateMessage( gentity_t *ent ); void Cmd_Test_f( gentity_t *ent ); +void G_AdminMessage( gentity_t *ent ); qboolean G_FloodLimited( gentity_t *ent ); // @@ -924,6 +925,7 @@ void G_MapConfigs( const char *mapname ); void CalculateRanks( void ); void FindIntermissionPoint( void ); void G_RunThink( gentity_t *ent ); +void QDECL G_AdminsPrintf( const char *prefix, const char *fmt, ... ); void QDECL G_LogPrintf( const char *fmt, ... ); void SendScoreboardMessageToAllClients( void ); void QDECL G_Printf( const char *fmt, ... ); @@ -1164,6 +1166,7 @@ extern vmCvar_t g_adminTempBan; extern vmCvar_t g_dretchPunt; extern vmCvar_t g_privateMessages; +extern vmCvar_t g_publicAdminMessages; void trap_Print( const char *fmt ); void trap_Error( const char *fmt ); diff --git a/src/game/g_main.c b/src/game/g_main.c index fc0651ea..808fed57 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -137,6 +137,7 @@ vmCvar_t g_adminTempBan; vmCvar_t g_dretchPunt; vmCvar_t g_privateMessages; +vmCvar_t g_publicAdminMessages; vmCvar_t g_tag; @@ -263,6 +264,7 @@ static cvarTable_t gameCvarTable[ ] = { &g_dretchPunt, "g_dretchPunt", "0", CVAR_ARCHIVE, 0, qfalse }, { &g_privateMessages, "g_privateMessages", "1", CVAR_ARCHIVE, 0, qfalse }, + { &g_publicAdminMessages, "g_publicAdminMessages", "1", CVAR_ARCHIVE, 0, qfalse }, { &g_tag, "g_tag", "main", CVAR_INIT, 0, qfalse }, @@ -1573,9 +1575,52 @@ void ExitLevel( void ) /* ================= +G_AdminsPrintf + +Print to all active server admins, and to the logfile, and to the server console +Prepend *prefix, or '[SERVER]' if no *prefix is given +================= +*/ +void QDECL G_AdminsPrintf( const char *prefix, const char *fmt, ... ) +{ + va_list argptr; + char string[ 1024 ]; + char outstring[ 1024 ]; + int i; + + // Format the text + va_start( argptr, fmt ); + Q_vsnprintf( string, sizeof( string ), fmt, argptr ); + va_end( argptr ); + + // If there is no prefix, assume that this function was called directly and we should add one + if( !prefix || !prefix[ 0 ] ) + { + prefix = "[SERVER]:"; + } + + // Create the final string + Com_sprintf( outstring, sizeof( outstring ), "%s " S_COLOR_MAGENTA "%s", prefix, string ); + + // Send to all appropriate clients + for( i = 0; i < level.maxclients; i++ ) + { + if( G_admin_permission( &g_entities[ i ], ADMF_ADMINCHAT) ) + { + trap_SendServerCommand( i, va( "print \"%s\"", outstring ) ); + } + } + + // Send to the logfile and server console + G_LogPrintf("adminmsg: %s", outstring ); +} + + +/* +================= G_LogPrintf -Print to the logfile with a time stamp if it is open +Print to the logfile with a time stamp if it is open, and to the server console ================= */ void QDECL G_LogPrintf( const char *fmt, ... ) diff --git a/src/game/g_svcmds.c b/src/game/g_svcmds.c index 3ac6a322..80a8247b 100644 --- a/src/game/g_svcmds.c +++ b/src/game/g_svcmds.c @@ -725,7 +725,11 @@ qboolean ConsoleCommand( void ) G_PrivateMessage( NULL ); return qtrue; } - + else if( !Q_stricmp( cmd, "a" ) ) + { + G_AdminMessage( NULL ); + return qtrue; + } G_Printf( "unknown command: %s\n", cmd ); return qtrue; } |