summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game/bg_pmove.c9
-rw-r--r--src/game/bg_voice.c2
-rw-r--r--src/game/g_admin.c90
-rw-r--r--src/game/g_cmds.c43
-rw-r--r--src/game/g_local.h6
-rw-r--r--src/game/g_main.c16
-rw-r--r--src/game/g_svcmds.c4
-rw-r--r--src/ui/ui_atoms.c4
8 files changed, 112 insertions, 62 deletions
diff --git a/src/game/bg_pmove.c b/src/game/bg_pmove.c
index 0f4b112e..745bca4e 100644
--- a/src/game/bg_pmove.c
+++ b/src/game/bg_pmove.c
@@ -2750,6 +2750,11 @@ static void PM_BeginWeaponChange( int weapon )
if( pm->ps->weaponstate == WEAPON_DROPPING )
return;
+ // cancel a reload
+ pm->ps->pm_flags &= ~PMF_WEAPON_RELOAD;
+ if( pm->ps->weaponstate == WEAPON_RELOADING )
+ pm->ps->weaponTime = 0;
+
//special case to prevent storing a charged up lcannon
if( pm->ps->weapon == WP_LUCIFER_CANNON )
pm->ps->stats[ STAT_MISC ] = 0;
@@ -3087,7 +3092,9 @@ static void PM_Weapon( void )
}
// check for end of clip
- if( ( !pm->ps->ammo || ( pm->ps->pm_flags & PMF_WEAPON_RELOAD ) ) && pm->ps->clips )
+ if( !BG_Weapon( pm->ps->weapon )->infiniteAmmo &&
+ ( pm->ps->ammo <= 0 || ( pm->ps->pm_flags & PMF_WEAPON_RELOAD ) ) &&
+ pm->ps->clips > 0 )
{
pm->ps->pm_flags &= ~PMF_WEAPON_RELOAD;
pm->ps->weaponstate = WEAPON_RELOADING;
diff --git a/src/game/bg_voice.c b/src/game/bg_voice.c
index 91f65617..2290d0ae 100644
--- a/src/game/bg_voice.c
+++ b/src/game/bg_voice.c
@@ -314,7 +314,7 @@ static voiceTrack_t *BG_VoiceParseCommand( int handle )
voiceTracks = voiceTracks->next;
}
- if( !trap_FS_FOpenFile( va( "%s", token.string ), NULL, FS_READ ) )
+ if( !trap_FS_FOpenFile( token.string, NULL, FS_READ ) )
{
int line;
char filename[ MAX_QPATH ];
diff --git a/src/game/g_admin.c b/src/game/g_admin.c
index 5ac2461a..9618e83e 100644
--- a/src/game/g_admin.c
+++ b/src/game/g_admin.c
@@ -745,9 +745,17 @@ static int admin_listadmins( gentity_t *ent, int start, char *search )
{
if( g_admin_levels[ j ]->level == l )
{
- Com_sprintf( lname, sizeof( lname ), va( "%%%is",
- Q_PrintStrlen( g_admin_levels[ j ]->name ) - admin_level_maxname -
- strlen( g_admin_levels[ j ]->name ) ), g_admin_levels[ j ]->name );
+ int k, colorlen;
+
+ for( colorlen = k = 0; g_admin_levels[ j ]->name[ k ]; k++ )
+ {
+ if( Q_IsColorString( &g_admin_levels[ j ]->name[ k ] ) )
+ colorlen += 2;
+ }
+
+ Com_sprintf( lname, sizeof( lname ), "%*s",
+ admin_level_maxname + colorlen,
+ g_admin_levels[ j ]->name );
break;
}
}
@@ -797,9 +805,17 @@ static int admin_listadmins( gentity_t *ent, int start, char *search )
{
if( g_admin_levels[ j ]->level == g_admin_admins[ i ]->level )
{
- Com_sprintf( lname, sizeof( lname ), va( "%%%is",
- Q_PrintStrlen( g_admin_levels[ j ]->name ) - admin_level_maxname -
- strlen( g_admin_levels[ j ]->name ) ), g_admin_levels[ j ]->name );
+ int k, colorlen;
+
+ for( colorlen = k = 0; g_admin_levels[ j ]->name[ k ]; k++ )
+ {
+ if( Q_IsColorString( &g_admin_levels[ j ]->name[ k ] ) )
+ colorlen += 2;
+ }
+
+ Com_sprintf( lname, sizeof( lname ), "%*s",
+ admin_level_maxname + colorlen,
+ g_admin_levels[ j ]->name );
break;
}
}
@@ -1518,10 +1534,8 @@ int G_admin_parse_time( const char *time )
if( !isdigit( *time ) )
return -1;
while( isdigit( *time ) )
- {
num = num * 10 + *time++ - '0';
- continue;
- }
+
if( !*time )
break;
switch( *time++ )
@@ -1645,7 +1659,7 @@ qboolean G_admin_ban( gentity_t *ent, int skiparg )
}
else
{
- ADMP( "^3!ban: ^7ban duration must be positive\n" );
+ ADMP( "^3!ban: ^7you may not issue permanent bans\n" );
return qfalse;
}
reason = G_SayConcatArgs( 2 + skiparg );
@@ -1784,7 +1798,7 @@ qboolean G_admin_ban( gentity_t *ent, int skiparg )
"admin:\n%s^7\nduration:\n%s\nreason:\n%s\"",
( ent ) ? ent->client->pers.netname : "console",
duration,
- ( *reason ) ? reason : "kicked by admin" ) );
+ ( *reason ) ? reason : "banned by admin" ) );
trap_DropClient( g_admin_namelog[ logmatch ]->slot,
va( "has been banned by %s^7, duration: %s, reason: %s",
@@ -2250,11 +2264,9 @@ qboolean G_admin_listplayers( gentity_t *ent, int skiparg )
char n2[ MAX_NAME_LENGTH ] = {""};
char n3[ MAX_NAME_LENGTH ] = {""};
char lname[ MAX_NAME_LENGTH ];
- char lname2[ MAX_NAME_LENGTH ];
char guid_stub[ 9 ];
char muted[ 2 ], denied[ 2 ];
int l;
- char lname_fmt[ 5 ];
ADMBP_begin();
ADMBP( va( "^3!listplayers: ^7%d players connected:\n",
@@ -2322,22 +2334,23 @@ qboolean G_admin_listplayers( gentity_t *ent, int skiparg )
}
}
lname[ 0 ] = '\0';
- Q_strncpyz( lname_fmt, "%s", sizeof( lname_fmt ) );
for( j = 0; j < MAX_ADMIN_LEVELS && g_admin_levels[ j ]; j++ )
{
if( g_admin_levels[ j ]->level == l )
{
- Q_strncpyz( lname, g_admin_levels[ j ]->name, sizeof( lname ) );
- if( *lname )
+ int k, colorlen;
+
+ for( colorlen = k = 0; g_admin_levels[ j ]->name[ k ]; k++ )
{
- G_DecolorString( lname, lname2, sizeof( lname2 ) );
- Com_sprintf( lname_fmt, sizeof( lname_fmt ), "%%%is",
- ( admin_level_maxname + strlen( lname ) - strlen( lname2 ) ) );
- Com_sprintf( lname2, sizeof( lname2 ), lname_fmt, lname );
+ if( Q_IsColorString( &g_admin_levels[ j ]->name[ k ] ) )
+ colorlen += 2;
}
+
+ Com_sprintf( lname, sizeof( lname ), "%*s",
+ admin_level_maxname + colorlen,
+ g_admin_levels[ j ]->name );
break;
}
-
}
if( G_admin_permission( ent, ADMF_SEESFULLLISTPLAYERS ) )
@@ -2347,7 +2360,7 @@ qboolean G_admin_listplayers( gentity_t *ent, int skiparg )
c,
t,
l,
- ( *lname ) ? lname2 : "",
+ lname,
guid_stub,
muted,
denied,
@@ -2377,14 +2390,14 @@ qboolean G_admin_showbans( gentity_t *ent, int skiparg )
int max = -1, count;
int t;
char duration[ 32 ];
- int max_name = 1, max_banner = 1;
+ int max_name = 1, max_banner = 1, colorlen;
int len;
int secs;
int start = 0;
char skip[ 11 ];
char date[ 11 ];
char *made;
- int j;
+ int j, k;
char n1[ MAX_NAME_LENGTH ] = {""};
char n2[ MAX_NAME_LENGTH ] = {""};
@@ -2401,6 +2414,12 @@ qboolean G_admin_showbans( gentity_t *ent, int skiparg )
max = i;
}
+ if( max < 0 )
+ {
+ ADMP( "^3!showbans: ^7no bans to display\n" );
+ return qfalse;
+ }
+
if( G_SayArgc() == 2 + skiparg )
{
G_SayArgv( 1 + skiparg, skip, sizeof( skip ) );
@@ -2473,12 +2492,23 @@ qboolean G_admin_showbans( gentity_t *ent, int skiparg )
secs = ( g_admin_bans[ i ]->expires - t );
G_admin_duration( secs, duration, sizeof( duration ) );
- Com_sprintf( n1, sizeof( n1 ), va( "%%%is",
- Q_PrintStrlen( g_admin_bans[ i ]->name ) - max_name -
- strlen( g_admin_bans[ i ]->name ) ), g_admin_bans[ i ]->name );
- Com_sprintf( n2, sizeof( n2 ), va( "%%%is",
- Q_PrintStrlen( g_admin_bans[ i ]->banner ) - max_banner -
- strlen( g_admin_bans[ i ]->banner ) ), g_admin_bans[ i ]->banner );
+ for( colorlen = k = 0; g_admin_bans[ i ]->name[ k ]; k++ )
+ {
+ if( Q_IsColorString( &g_admin_bans[ i ]->name[ k ] ) )
+ colorlen += 2;
+ }
+
+ Com_sprintf( n1, sizeof( n1 ), "%*s", max_name + colorlen,
+ g_admin_bans[ i ]->name );
+
+ for( colorlen = k = 0; g_admin_bans[ i ]->banner[ k ]; k++ )
+ {
+ if( Q_IsColorString( &g_admin_bans[ i ]->banner[ k ] ) )
+ colorlen += 2;
+ }
+
+ Com_sprintf( n2, sizeof( n2 ), "%*s", max_banner + colorlen,
+ g_admin_bans[ i ]->banner );
ADMBP( va( "%4i %s^7 %-15s %-8s %s^7 %-10s\n \\__ %s\n",
( i + 1 ),
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c
index 1c47e77d..4fb3dcb1 100644
--- a/src/game/g_cmds.c
+++ b/src/game/g_cmds.c
@@ -784,7 +784,7 @@ static void Cmd_Say_f( gentity_t *ent )
!Q_stricmpn( args, "say /mt ", 8 ) ||
!Q_stricmpn( args, "say_team /mt ", 13 ) )
{
- G_PrivateMessage( ent );
+ Cmd_PrivateMessage_f( ent );
return;
}
@@ -792,7 +792,7 @@ static void Cmd_Say_f( gentity_t *ent )
if( !Q_stricmpn( args, "say /a ", 7 ) ||
!Q_stricmpn( args, "say_team /a ", 12 ) )
{
- G_AdminMessage( ent );
+ Cmd_AdminMessage_f( ent );
return;
}
@@ -2409,6 +2409,17 @@ Cmd_Reload_f
*/
void Cmd_Reload_f( gentity_t *ent )
{
+ playerState_t *ps = &ent->client->ps;
+
+ // weapon doesn't ever need reloading
+ if( BG_Weapon( ps->weapon )->infiniteAmmo )
+ return;
+
+ // don't reload when full
+ if( ps->ammo == BG_Weapon( ps->weapon )->maxAmmo )
+ return;
+
+ // the animation, ammo refilling etc. is handled by PM_Weapon
if( ent->client->ps.weaponstate != WEAPON_RELOADING )
ent->client->ps.pm_flags |= PMF_WEAPON_RELOAD;
}
@@ -2954,9 +2965,9 @@ commands_t cmds[ ] = {
{ "vsay", CMD_MESSAGE|CMD_INTERMISSION, Cmd_VSay_f },
{ "vsay_team", CMD_MESSAGE|CMD_INTERMISSION, Cmd_VSay_f },
{ "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 },
+ { "m", CMD_MESSAGE|CMD_INTERMISSION, Cmd_PrivateMessage_f },
+ { "mt", CMD_MESSAGE|CMD_INTERMISSION, Cmd_PrivateMessage_f },
+ { "a", CMD_MESSAGE|CMD_INTERMISSION, Cmd_AdminMessage_f },
{ "score", CMD_INTERMISSION, ScoreboardMessage },
@@ -3166,7 +3177,7 @@ void G_DecolorString( char *in, char *out, int len )
*out = '\0';
}
-void G_PrivateMessage( gentity_t *ent )
+void Cmd_PrivateMessage_f( gentity_t *ent )
{
int pids[ MAX_CLIENTS ];
int ignoreids[ MAX_CLIENTS ];
@@ -3298,14 +3309,14 @@ void G_PrivateMessage( gentity_t *ent )
/*
=================
-G_AdminMessage
+Cmd_AdminMessage_f
Send a message to all active admins
=================
*/
-void G_AdminMessage( gentity_t *ent )
+void Cmd_AdminMessage_f( gentity_t *ent )
{
- char cmd[ 12 ];
+ char cmd[ sizeof( "say_team" ) ];
char prefix[ 50 ];
char *msg;
int skiparg = 0;
@@ -3324,16 +3335,19 @@ void G_AdminMessage( gentity_t *ent )
}
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" );
+ 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 );
+ 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
+ // 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" ) )
{
@@ -3349,7 +3363,6 @@ void G_AdminMessage( gentity_t *ent )
msg = G_SayConcatArgs( 1 + skiparg );
// Send it
- G_AdminsPrintf( prefix, "%s\n", msg );
-
+ G_AdminMessage( prefix, "%s", msg );
}
diff --git a/src/game/g_local.h b/src/game/g_local.h
index 96031ec6..5f9029a9 100644
--- a/src/game/g_local.h
+++ b/src/game/g_local.h
@@ -678,9 +678,9 @@ qboolean G_SayArgv( int n, char *buffer, int bufferLength );
char *G_SayConcatArgs( int start );
void G_DecolorString( char *in, char *out, int len );
void G_SanitiseString( char *in, char *out, int len );
-void G_PrivateMessage( gentity_t *ent );
+void Cmd_PrivateMessage_f( gentity_t *ent );
void Cmd_Test_f( gentity_t *ent );
-void G_AdminMessage( gentity_t *ent );
+void Cmd_AdminMessage_f( gentity_t *ent );
qboolean G_FloodLimited( gentity_t *ent );
//
@@ -927,7 +927,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_AdminMessage( const char *prefix, const char *fmt, ... );
void QDECL G_LogPrintf( const char *fmt, ... );
void SendScoreboardMessageToAllClients( void );
void QDECL G_Printf( const char *fmt, ... );
diff --git a/src/game/g_main.c b/src/game/g_main.c
index b46c1b2e..a5e56869 100644
--- a/src/game/g_main.c
+++ b/src/game/g_main.c
@@ -1624,44 +1624,44 @@ void ExitLevel( void )
/*
=================
-G_AdminsPrintf
+G_AdminMessage
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, ... )
+void QDECL G_AdminMessage( const char *prefix, const char *fmt, ... )
{
va_list argptr;
char string[ 1024 ];
char outstring[ 1024 ];
- int i;
+ 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 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 );
+ 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( "chat \"%s\"", outstring ) );
- }
}
// Send to the logfile and server console
- G_LogPrintf("adminmsg: %s", outstring );
+ G_LogPrintf("adminmsg: %s\n", outstring );
}
diff --git a/src/game/g_svcmds.c b/src/game/g_svcmds.c
index 80a8247b..24fd5388 100644
--- a/src/game/g_svcmds.c
+++ b/src/game/g_svcmds.c
@@ -722,12 +722,12 @@ qboolean ConsoleCommand( void )
}
else if( !Q_stricmp( cmd, "m" ) )
{
- G_PrivateMessage( NULL );
+ Cmd_PrivateMessage_f( NULL );
return qtrue;
}
else if( !Q_stricmp( cmd, "a" ) )
{
- G_AdminMessage( NULL );
+ Cmd_AdminMessage_f( NULL );
return qtrue;
}
G_Printf( "unknown command: %s\n", cmd );
diff --git a/src/ui/ui_atoms.c b/src/ui/ui_atoms.c
index 58add010..32df5491 100644
--- a/src/ui/ui_atoms.c
+++ b/src/ui/ui_atoms.c
@@ -39,7 +39,7 @@ void QDECL Com_Error( int level, const char *error, ... )
Q_vsnprintf( text, sizeof( text ), error, argptr );
va_end( argptr );
- trap_Error( va( "%s", text ) );
+ trap_Error( text );
}
void QDECL Com_Printf( const char *msg, ... )
@@ -51,7 +51,7 @@ void QDECL Com_Printf( const char *msg, ... )
Q_vsnprintf( text, sizeof( text ), msg, argptr );
va_end( argptr );
- trap_Print( va( "%s", text ) );
+ trap_Print( text );
}