diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/game/bg_pmove.c | 4 | ||||
-rw-r--r-- | src/game/g_active.c | 46 | ||||
-rw-r--r-- | src/game/g_admin.c | 285 | ||||
-rw-r--r-- | src/game/g_buildable.c | 81 | ||||
-rw-r--r-- | src/game/g_client.c | 26 | ||||
-rw-r--r-- | src/game/g_cmds.c | 161 | ||||
-rw-r--r-- | src/game/g_combat.c | 17 | ||||
-rw-r--r-- | src/game/g_main.c | 24 | ||||
-rw-r--r-- | src/game/g_svcmds.c | 4 |
9 files changed, 286 insertions, 362 deletions
diff --git a/src/game/bg_pmove.c b/src/game/bg_pmove.c index e1129dcf..d0f0a1c6 100644 --- a/src/game/bg_pmove.c +++ b/src/game/bg_pmove.c @@ -2694,10 +2694,10 @@ PM_BeginWeaponChange */ static void PM_BeginWeaponChange( int weapon ) { - if( weapon < WP_NONE || weapon >= WP_NUM_WEAPONS ) + if( weapon <= WP_NONE || weapon >= WP_NUM_WEAPONS ) return; - if( !BG_InventoryContainsWeapon( weapon, pm->ps->stats ) && weapon != WP_NONE ) + if( !BG_InventoryContainsWeapon( weapon, pm->ps->stats ) ) return; if( pm->ps->weaponstate == WEAPON_DROPPING ) diff --git a/src/game/g_active.c b/src/game/g_active.c index e4ba5c9b..63e9feaf 100644 --- a/src/game/g_active.c +++ b/src/game/g_active.c @@ -286,7 +286,7 @@ void ClientImpacts( gentity_t *ent, pmove_t *pm ) // see G_UnlaggedDetectCollisions(), this is the inverse of that. // if our movement is blocked by another player's real position, - // don't use the unlagged position for them because they are + // don't use the unlagged position for them because they are // blocking or server-side Pmove() from reaching it if( other->client && other->client->unlaggedCalc.used ) other->client->unlaggedCalc.used = qfalse; @@ -973,8 +973,8 @@ void SendPendingPredictableEvents( playerState_t *ps ) ============== G_UnlaggedStore - Called on every server frame. Stores position data for the client at that - into client->unlaggedHist[] and the time into level.unlaggedTimes[]. + Called on every server frame. Stores position data for the client at that + into client->unlaggedHist[] and the time into level.unlaggedTimes[]. This data is used by G_UnlaggedCalc() ============== */ @@ -983,24 +983,24 @@ void G_UnlaggedStore( void ) int i = 0; gentity_t *ent; unlagged_t *save; - + if( !g_unlagged.integer ) return; - level.unlaggedIndex++; + level.unlaggedIndex++; if( level.unlaggedIndex >= MAX_UNLAGGED_MARKERS ) level.unlaggedIndex = 0; level.unlaggedTimes[ level.unlaggedIndex ] = level.time; - + for( i = 0; i < level.maxclients; i++ ) { ent = &g_entities[ i ]; save = &ent->client->unlaggedHist[ level.unlaggedIndex ]; - save->used = qfalse; + save->used = qfalse; if( !ent->r.linked || !( ent->r.contents & CONTENTS_BODY ) ) continue; if( ent->client->pers.connected != CON_CONNECTED ) - continue; + continue; VectorCopy( ent->r.mins, save->mins ); VectorCopy( ent->r.maxs, save->maxs ); VectorCopy( ent->s.pos.trBase, save->origin ); @@ -1011,7 +1011,7 @@ void G_UnlaggedStore( void ) /* ============== G_UnlaggedClear - + Mark all unlaggedHist[] markers for this client invalid. Useful for preventing teleporting and death. ============== @@ -1043,7 +1043,7 @@ void G_UnlaggedCalc( int time, gentity_t *rewindEnt ) if( !g_unlagged.integer ) return; - + // clear any calculated values from a previous run for( i = 0; i < level.maxclients; i++ ) { @@ -1075,10 +1075,10 @@ void G_UnlaggedCalc( int time, gentity_t *rewindEnt ) level.unlaggedTimes[ startIndex ]; if( frameMsec > 0 ) { - lerp = ( float )( time - level.unlaggedTimes[ startIndex ] ) - / ( float )frameMsec; + lerp = ( float )( time - level.unlaggedTimes[ startIndex ] ) / + ( float )frameMsec; } - + for( i = 0; i < level.maxclients; i++ ) { ent = &g_entities[ i ]; @@ -1119,10 +1119,10 @@ void G_UnlaggedOff( void ) { int i = 0; gentity_t *ent; - + if( !g_unlagged.integer ) return; - + for( i = 0; i < level.maxclients; i++ ) { ent = &g_entities[ i ]; @@ -1155,10 +1155,10 @@ void G_UnlaggedOn( vec3_t muzzle, float range ) int i = 0; gentity_t *ent; unlagged_t *calc; - + if( !g_unlagged.integer ) return; - + for( i = 0; i < level.maxclients; i++ ) { ent = &g_entities[ i ]; @@ -1179,7 +1179,7 @@ void G_UnlaggedOn( vec3_t muzzle, float range ) float maxRadius = ( r1 > r2 ) ? r1 : r2; if( Distance( muzzle, calc->origin ) > range + maxRadius ) - continue; + continue; } // create a backup of the real positions @@ -1796,6 +1796,7 @@ void SpectatorClientEndFrame( gentity_t *ent ) { gclient_t *cl; int clientNum, flags; + int score, ping; // if we are doing a chase cam or a remote view, grab the latest info if( ent->client->sess.spectatorState == SPECTATOR_FOLLOW ) @@ -1808,10 +1809,19 @@ void SpectatorClientEndFrame( gentity_t *ent ) { if( cl->sess.sessionTeam != TEAM_SPECTATOR ) { + // Save flags = ( cl->ps.eFlags & ~( EF_VOTED | EF_TEAMVOTED ) ) | ( ent->client->ps.eFlags & ( EF_VOTED | EF_TEAMVOTED ) ); + score = ent->client->ps.persistant[ PERS_SCORE ]; + ping = ent->client->ps.ping; + + // Copy ent->client->ps = cl->ps; + + // Restore ent->client->ps.eFlags = flags; + ent->client->ps.persistant[ PERS_SCORE ] = score; + ent->client->ps.ping = ping; } ent->client->ps.clientNum = clientNum; diff --git a/src/game/g_admin.c b/src/game/g_admin.c index a6004b8f..b99fdea7 100644 --- a/src/game/g_admin.c +++ b/src/game/g_admin.c @@ -11,7 +11,7 @@ and Travis Maurer. The functionality of this code mimics the behaviour of the currently inactive project shrubet (http://www.etstats.com/shrubet/index.php?ver=2) -by Ryan Mannion. However, shrubet was a closed-source project and +by Ryan Mannion. However, shrubet was a closed-source project and none of it's code has been copied, only it's functionality. Tremulous is free software; you can redistribute it @@ -36,7 +36,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA static char g_bfb[ 32000 ]; // note: list ordered alphabetically -g_admin_cmd_t g_admin_cmds[ ] = +g_admin_cmd_t g_admin_cmds[ ] = { {"admintest", G_admin_admintest, "a", "display your current admin level", @@ -47,7 +47,7 @@ g_admin_cmd_t g_admin_cmds[ ] = "restore a player's ability to build", "[^3name|slot#^7]" }, - + {"allready", G_admin_allready, "y", "makes everyone ready in intermission", "" @@ -79,12 +79,12 @@ g_admin_cmd_t g_admin_cmds[ ] = "kick a player with an optional reason", "(^5reason^7)" }, - + {"listadmins", G_admin_listadmins, "D", "display a list of all server admins and their levels", "(^5name|start admin#^7)" }, - + {"listlayouts", G_admin_listlayouts, "L", "display a list of all available layouts for a map", "(^5mapname^7)" @@ -94,12 +94,12 @@ g_admin_cmd_t g_admin_cmds[ ] = "display a list of players, their client numbers and their levels", "" }, - + {"lock", G_admin_lock, "K", "lock a team to prevent anyone from joining it", "[^3a|h^7]" }, - + {"map", G_admin_map, "M", "load a map (and optionally force layout)", "[^3mapname^7] (^5layout^7)" @@ -109,7 +109,7 @@ g_admin_cmd_t g_admin_cmds[ ] = "mute a player", "[^3name|slot#^7]" }, - + {"namelog", G_admin_namelog, "e", "display a list of names used by recently connected players", "(^5name^7)" @@ -167,7 +167,7 @@ g_admin_cmd_t g_admin_cmds[ ] = "unbans a player specified by the slot as seen in showbans", "[^3ban slot#^7]" }, - + {"unlock", G_admin_unlock, "K", "unlock a locked team", "[^3a|h^7]" @@ -213,7 +213,7 @@ qboolean G_admin_permission( gentity_t *ent, char flag ) { if( *flags == flag ) return qfalse; - else if( *flags == '+' ) + if( *flags == '+' ) break; } } @@ -225,16 +225,9 @@ qboolean G_admin_permission( gentity_t *ent, char flag ) return qfalse; } // flags with significance only for individuals ( - // like ADMF_INCOGNITO and ADMF_IMMUTABLE are NOT covered + // like ADMF_INCOGNITO and ADMF_IMMUTABLE are NOT covered // by the '*' wildcard. They must be specified manually. - switch( flag ) - { - case ADMF_INCOGNITO: - case ADMF_IMMUTABLE: - return qfalse; - default: - return qtrue; - } + return ( flag != ADMF_INCOGNITO && flag != ADMF_IMMUTABLE ); } flags++; } @@ -258,16 +251,9 @@ qboolean G_admin_permission( gentity_t *ent, char flag ) return qfalse; } // flags with significance only for individuals ( - // like ADMF_INCOGNITO and ADMF_IMMUTABLE are NOT covered + // like ADMF_INCOGNITO and ADMF_IMMUTABLE are NOT covered // by the '*' wildcard. They must be specified manually. - switch( flag ) - { - case ADMF_INCOGNITO: - case ADMF_IMMUTABLE: - return qfalse; - default: - return qtrue; - } + return ( flag != ADMF_INCOGNITO && flag != ADMF_IMMUTABLE ); } flags++; } @@ -285,17 +271,14 @@ qboolean G_admin_name_check( gentity_t *ent, char *name, char *err, int len ) G_SanitiseName( name, name2 ); - if( !Q_stricmp( name2, "UnnamedPlayer" ) ) + if( !Q_stricmp( name2, "UnnamedPlayer" ) ) return qtrue; for( i = 0; i < level.maxclients; i++ ) { client = &level.clients[ i ]; - if( client->pers.connected != CON_CONNECTING - && client->pers.connected != CON_CONNECTED ) - { + if( client->pers.connected == CON_DISCONNECTED ) continue; - } // can rename ones self to the same name using different colors if( i == ( ent - g_entities ) ) @@ -397,7 +380,6 @@ static void admin_writeconfig( void ) { fileHandle_t f; int len, i, j; - qtime_t qt; int t; char levels[ MAX_STRING_CHARS ] = {""}; @@ -407,7 +389,7 @@ static void admin_writeconfig( void ) " configuration will not be saved to a file.\n" ); return; } - t = trap_RealTime( &qt ); + t = trap_RealTime( NULL ); len = trap_FS_FOpenFile( g_admin.string, &f, FS_WRITE ); if( len < 0 ) { @@ -448,7 +430,7 @@ static void admin_writeconfig( void ) // don't write expired bans // if expires is 0, then it's a perm ban if( g_admin_bans[ i ]->expires != 0 && - ( g_admin_bans[ i ]->expires - t ) < 1 ) + ( g_admin_bans[ i ]->expires - t ) < 1 ) continue; trap_FS_Write( "[ban]\n", 6, f ); @@ -492,7 +474,7 @@ static void admin_writeconfig( void ) static void admin_readconfig_string( char **cnf, char *s, int size ) { - char * t; + char *t; //COM_MatchToken(cnf, "="); t = COM_ParseExt( cnf, qfalse ); @@ -510,8 +492,8 @@ static void admin_readconfig_string( char **cnf, char *s, int size ) s[ 0 ] = '\0'; while( t[ 0 ] ) { - if( ( s[ 0 ] == '\0' && strlen( t ) <= size ) - || ( strlen( t ) + strlen( s ) < size ) ) + if( ( s[ 0 ] == '\0' && strlen( t ) <= size ) || + ( strlen( t ) + strlen( s ) < size ) ) { Q_strcat( s, size, t ); @@ -526,7 +508,7 @@ static void admin_readconfig_string( char **cnf, char *s, int size ) static void admin_readconfig_int( char **cnf, int *v ) { - char * t; + char *t; //COM_MatchToken(cnf, "="); t = COM_ParseExt( cnf, qfalse ); @@ -548,7 +530,7 @@ static void admin_readconfig_int( char **cnf, int *v ) // ones to make new installs easier for admins static void admin_default_levels( void ) { - g_admin_level_t * l; + g_admin_level_t *l; int i; for( i = 0; i < MAX_ADMIN_LEVELS && g_admin_levels[ i ]; i++ ) @@ -625,7 +607,7 @@ static qboolean admin_command_permission( gentity_t *ent, char *command ) if( !ent ) return qtrue; - level = ent->client->pers.adminLevel; + level = ent->client->pers.adminLevel; for( i = 0; i < MAX_ADMIN_COMMANDS && g_admin_commands[ i ]; i++ ) { if( !Q_stricmp( command, g_admin_commands[ i ]->command ) ) @@ -656,14 +638,14 @@ static void admin_log( gentity_t *admin, char *cmd, int skiparg ) char name[ MAX_NAME_LENGTH ]; if( !g_adminLog.string[ 0 ] ) - return ; + return; len = trap_FS_FOpenFile( g_adminLog.string, &f, FS_APPEND ); if( len < 0 ) { G_Printf( "admin_log: error could not open %s\n", g_adminLog.string ); - return ; + return; } sec = level.time / 1000; @@ -753,7 +735,7 @@ static int admin_listadmins( gentity_t *ent, int start, char *search ) gentity_t *vic; int l = 0; qboolean dup = qfalse; - + ADMBP_begin(); // print out all connected players regardless of level if name searching @@ -763,7 +745,7 @@ static int admin_listadmins( gentity_t *ent, int start, char *search ) if( vic->client && vic->client->pers.connected != CON_CONNECTED ) continue; - + l = vic->client->pers.adminLevel; G_SanitiseName( vic->client->pers.netname, name ); @@ -773,8 +755,8 @@ static int admin_listadmins( gentity_t *ent, int start, char *search ) for( j = 0; j <= 8; j++ ) guid_stub[ j ] = vic->client->pers.guid[ j + 24 ]; guid_stub[ j ] = '\0'; - - lname[ 0 ] = '\0'; + + lname[ 0 ] = '\0'; Q_strncpyz( lname_fmt, "%s", sizeof( lname_fmt ) ); for( j = 0; j < MAX_ADMIN_LEVELS && g_admin_levels[ j ]; j++ ) { @@ -798,15 +780,15 @@ static int admin_listadmins( gentity_t *ent, int start, char *search ) drawn++; } - for( i = start; i < MAX_ADMIN_ADMINS && g_admin_admins[ i ] - && drawn < MAX_ADMIN_LISTITEMS; i++ ) + for( i = start; i < MAX_ADMIN_ADMINS && g_admin_admins[ i ] && + drawn < MAX_ADMIN_LISTITEMS; i++ ) { if( search[ 0 ] ) { G_SanitiseName( g_admin_admins[ i ]->name, name ); if( !strstr( name, search ) ) continue; - + // verify we don't have the same guid/name pair in connected players // since we don't want to draw the same player twice dup = qfalse; @@ -816,8 +798,8 @@ static int admin_listadmins( gentity_t *ent, int start, char *search ) if( !vic->client || vic->client->pers.connected != CON_CONNECTED ) continue; G_SanitiseName( vic->client->pers.netname, name2 ); - if( !Q_stricmp( vic->client->pers.guid, g_admin_admins[ i ]->guid ) - && strstr( name2, search ) ) + if( !Q_stricmp( vic->client->pers.guid, g_admin_admins[ i ]->guid ) && + strstr( name2, search ) ) { dup = qtrue; break; @@ -829,8 +811,8 @@ static int admin_listadmins( gentity_t *ent, int start, char *search ) for( j = 0; j <= 8; j++ ) guid_stub[ j ] = g_admin_admins[ i ]->guid[ j + 24 ]; guid_stub[ j ] = '\0'; - - lname[ 0 ] = '\0'; + + lname[ 0 ] = '\0'; Q_strncpyz( lname_fmt, "%s", sizeof( lname_fmt ) ); for( j = 0; j < MAX_ADMIN_LEVELS && g_admin_levels[ j ]; j++ ) { @@ -885,11 +867,10 @@ qboolean G_admin_ban_check( char *userinfo, char *reason, int rlen ) { char *guid, *ip; int i; - qtime_t qt; int t; - - *reason = '\0'; - t = trap_RealTime( &qt ); + + *reason = '\0'; + t = trap_RealTime( NULL ); if( !*userinfo ) return qfalse; ip = Info_ValueForKey( userinfo, "ip" ); @@ -915,7 +896,7 @@ qboolean G_admin_ban_check( char *userinfo, char *reason, int rlen ) g_admin_bans[ i ]->reason, duration ); - G_Printf("Banned player tried to connect from IP %s\n", ip); + G_Printf( "Banned player tried to connect from IP %s\n", ip ); return qtrue; } if( *guid && !Q_stricmp( g_admin_bans[ i ]->guid, guid ) ) @@ -931,7 +912,7 @@ qboolean G_admin_ban_check( char *userinfo, char *reason, int rlen ) g_admin_bans[ i ]->reason, duration ); - G_Printf("Banned player tried to connect with GUID %s\n", guid); + G_Printf( "Banned player tried to connect with GUID %s\n", guid ); return qtrue; } } @@ -1035,14 +1016,14 @@ void G_admin_namelog_update( gclient_t *client, qboolean disconnect ) continue; } - if( !Q_stricmp( client->pers.ip, g_admin_namelog[ i ]->ip ) - && !Q_stricmp( client->pers.guid, g_admin_namelog[ i ]->guid ) ) + if( !Q_stricmp( client->pers.ip, g_admin_namelog[ i ]->ip ) && + !Q_stricmp( client->pers.guid, g_admin_namelog[ i ]->guid ) ) { - for( j = 0; j < MAX_ADMIN_NAMELOG_NAMES - && g_admin_namelog[ i ]->name[ j ][ 0 ]; j++ ) + for( j = 0; j < MAX_ADMIN_NAMELOG_NAMES && + g_admin_namelog[ i ]->name[ j ][ 0 ]; j++ ) { G_SanitiseName( g_admin_namelog[ i ]->name[ j ], n2 ); - if( !Q_stricmp( n1, n2 ) ) + if( !Q_stricmp( n1, n2 ) ) break; } if( j == MAX_ADMIN_NAMELOG_NAMES ) @@ -1065,7 +1046,7 @@ void G_admin_namelog_update( gclient_t *client, qboolean disconnect ) } namelog = G_Alloc( sizeof( g_admin_namelog_t ) ); memset( namelog, 0, sizeof( namelog ) ); - for( j = 0; j < MAX_ADMIN_NAMELOG_NAMES ; j++ ) + for( j = 0; j < MAX_ADMIN_NAMELOG_NAMES; j++ ) namelog->name[ j ][ 0 ] = '\0'; Q_strncpyz( namelog->ip, client->pers.ip, sizeof( namelog->ip ) ); Q_strncpyz( namelog->guid, client->pers.guid, sizeof( namelog->guid ) ); @@ -1077,7 +1058,7 @@ void G_admin_namelog_update( gclient_t *client, qboolean disconnect ) qboolean G_admin_readconfig( gentity_t *ent, int skiparg ) { - g_admin_level_t * l = NULL; + g_admin_level_t *l = NULL; g_admin_admin_t *a = NULL; g_admin_ban_t *b = NULL; g_admin_command_t *c = NULL; @@ -1099,7 +1080,7 @@ qboolean G_admin_readconfig( gentity_t *ent, int skiparg ) return qfalse; } - len = trap_FS_FOpenFile( g_admin.string, &f, FS_READ ) ; + len = trap_FS_FOpenFile( g_admin.string, &f, FS_READ ); if( len < 0 ) { ADMP( va( "^3!readconfig: ^7could not open admin config file %s\n", @@ -1313,10 +1294,7 @@ qboolean G_admin_readconfig( gentity_t *ent, int skiparg ) t = COM_Parse( &cnf ); } if( level_open ) - { - g_admin_levels[ lc++ ] = l; - } if( admin_open ) g_admin_admins[ ac++ ] = a; if( ban_open ) @@ -1332,8 +1310,8 @@ qboolean G_admin_readconfig( gentity_t *ent, int skiparg ) { char n[ MAX_NAME_LENGTH ] = {""}; int i = 0; - - // max printable name length for formatting + + // max printable name length for formatting for( i = 0; i < MAX_ADMIN_LEVELS && g_admin_levels[ i ]; i++ ) { G_DecolorString( l->name, n ); @@ -1347,9 +1325,8 @@ qboolean G_admin_readconfig( gentity_t *ent, int skiparg ) qboolean G_admin_time( gentity_t *ent, int skiparg ) { qtime_t qt; - int t; - t = trap_RealTime( &qt ); + trap_RealTime( &qt ); ADMP( va( "^3!time: ^7local time is %02i:%02i:%02i\n", qt.tm_hour, qt.tm_min, qt.tm_sec ) ); return qtrue; @@ -1382,9 +1359,9 @@ qboolean G_admin_setlevel( gentity_t *ent, int skiparg ) G_SayArgv( 2 + skiparg, lstr, sizeof( lstr ) ); l = atoi( lstr ); G_SanitiseName( testname, name ); - for( i = 0; i < sizeof( name ) && name[ i ] ; i++ ) + for( i = 0; i < sizeof( name ) && name[ i ]; i++ ) { - if( name[ i ] < '0' || name[ i ] > '9' ) + if( !isdigit( name[ i ] ) ) { numeric = qfalse; break; @@ -1419,12 +1396,11 @@ qboolean G_admin_setlevel( gentity_t *ent, int skiparg ) return qfalse; } - if( numeric && id >= 0 && id < level.maxclients ) + if( numeric && id >= 0 && id < level.maxclients ) vic = &g_entities[ id ]; - if( vic && vic->client && vic->client->pers.connected == CON_CONNECTED ) + if( vic && vic->client && vic->client->pers.connected == CON_CONNECTED ) { - vic = &g_entities[ id ]; Q_strncpyz( adminname, vic->client->pers.netname, sizeof( adminname ) ); Q_strncpyz( guid, vic->client->pers.guid, sizeof( guid ) ); matches = 1; @@ -1467,8 +1443,8 @@ qboolean G_admin_setlevel( gentity_t *ent, int skiparg ) if( !vic->client || vic->client->pers.connected != CON_CONNECTED ) continue; G_SanitiseName( vic->client->pers.netname, testname2 ); - if( !Q_stricmp( vic->client->pers.guid, g_admin_admins[ i ]->guid ) - && strstr( testname2, name ) ) + if( !Q_stricmp( vic->client->pers.guid, g_admin_admins[ i ]->guid ) && + strstr( testname2, name ) ) { dup = qtrue; break; @@ -1534,12 +1510,12 @@ qboolean G_admin_setlevel( gentity_t *ent, int skiparg ) g_admin_admins[ i ] = a; } - AP( va( + AP( va( "print \"^3!setlevel: ^7%s^7 was given level %d admin rights by %s\n\"", adminname, l, ( ent ) ? ent->client->pers.netname : "console" ) ); if( vic ) vic->client->pers.adminLevel = l; - + if( !g_admin.string[ 0 ] ) ADMP( "^3!setlevel: ^7WARNING g_admin not set, not saving admin record " "to a file\n" ); @@ -1553,7 +1529,7 @@ static qboolean admin_create_ban( gentity_t *ent, char *guid, char *ip, int seconds, - char *reason ) + char *reason ) { g_admin_ban_t *b = NULL; qtime_t qt; @@ -1642,7 +1618,7 @@ qboolean G_admin_kick( gentity_t *ent, int skiparg ) if( g_admin.string[ 0 ] ) admin_writeconfig(); } - + trap_SendServerCommand( pids[ 0 ], va( "disconnect \"You have been kicked.\n%s^7\nreason:\n%s\"", ( ent ) ? va( "admin:\n%s", ent->client->pers.netname ) : "", @@ -1706,7 +1682,7 @@ qboolean G_admin_ban( gentity_t *ent, int skiparg ) modifier = 60 * 60; else if( secs[ lastchar ] == 'm' ) modifier = 60; - else if( secs[ lastchar ] < '0' || secs[ lastchar ] > '9' ) + else if( !isdigit( secs[ lastchar ] ) ) secs[ lastchar ] = '\0'; } seconds = atoi( secs ); @@ -1741,14 +1717,14 @@ qboolean G_admin_ban( gentity_t *ent, int skiparg ) if( g_admin_namelog[ i ]->slot == -1 ) continue; - if( !Q_stricmp( va( "%d", g_admin_namelog[ i ]->slot ), s2 ) ) + if( !Q_stricmp( va( "%d", g_admin_namelog[ i ]->slot ), search ) ) { logmatches = 1; logmatch = i; exactmatch = qtrue; break; } - } + } for( i = 0; !exactmatch && i < MAX_ADMIN_NAMELOGS && g_admin_namelog[ i ]; @@ -1758,31 +1734,31 @@ qboolean G_admin_ban( gentity_t *ent, int skiparg ) if( g_admin_namelog[ i ]->banned ) continue; - if( !Q_stricmp( g_admin_namelog[ i ]->ip, s2 ) ) + if( !Q_stricmp( g_admin_namelog[ i ]->ip, search ) ) { logmatches = 1; logmatch = i; exactmatch = qtrue; break; } - for( j = 0; j < MAX_ADMIN_NAMELOG_NAMES - && g_admin_namelog[ i ]->name[ j ][ 0 ]; j++ ) + for( j = 0; j < MAX_ADMIN_NAMELOG_NAMES && + g_admin_namelog[ i ]->name[ j ][ 0 ]; j++ ) { - G_SanitiseName(g_admin_namelog[ i ]->name[ j ], n2); + G_SanitiseName( g_admin_namelog[ i ]->name[ j ], n2 ); if( strstr( n2, s2 ) ) { if( logmatch != i ) logmatches++; - logmatch = i; + logmatch = i; } } } - - if( !logmatches ) + + if( !logmatches ) { ADMP( "^3!ban: ^7no player found by that name, IP, or slot number\n" ); return qfalse; - } + } else if( logmatches > 1 ) { ADMBP_begin(); @@ -1792,16 +1768,16 @@ qboolean G_admin_ban( gentity_t *ent, int skiparg ) for( j = 0; j <= 8; j++ ) guid_stub[ j ] = g_admin_namelog[ i ]->guid[ j + 24 ]; guid_stub[ j ] = '\0'; - for( j = 0; j < MAX_ADMIN_NAMELOG_NAMES - && g_admin_namelog[ i ]->name[ j ][ 0 ]; j++ ) + for( j = 0; j < MAX_ADMIN_NAMELOG_NAMES && + g_admin_namelog[ i ]->name[ j ][ 0 ]; j++ ) { - G_SanitiseName(g_admin_namelog[ i ]->name[ j ], n2); + G_SanitiseName( g_admin_namelog[ i ]->name[ j ], n2 ); if( strstr( n2, s2 ) ) { if( g_admin_namelog[ i ]->slot > -1 ) ADMBP( "^3" ); ADMBP( va( "%-2s (*%s) %15s ^7'%s^7'\n", - (g_admin_namelog[ i ]->slot > -1) ? + ( g_admin_namelog[ i ]->slot > -1 ) ? va( "%d", g_admin_namelog[ i ]->slot ) : "-", guid_stub, g_admin_namelog[ i ]->ip, @@ -1812,7 +1788,7 @@ qboolean G_admin_ban( gentity_t *ent, int skiparg ) ADMBP_end(); return qfalse; } - + G_admin_duration( ( seconds ) ? seconds : -1, duration, sizeof( duration ) ); @@ -1829,7 +1805,7 @@ qboolean G_admin_ban( gentity_t *ent, int skiparg ) g_admin_namelog[ logmatch ]->name[ 0 ], g_admin_namelog[ logmatch ]->guid, g_admin_namelog[ logmatch ]->ip, - seconds, reason ); + seconds, reason ); g_admin_namelog[ logmatch ]->banned = qtrue; @@ -1838,7 +1814,7 @@ qboolean G_admin_ban( gentity_t *ent, int skiparg ) else admin_writeconfig(); - if(g_admin_namelog[ logmatch ]->slot == -1 ) + if( g_admin_namelog[ logmatch ]->slot == -1 ) { // client is already disconnected so stop here AP( va( "print \"^3!ban:^7 %s^7 has been banned by %s^7 " @@ -1869,10 +1845,7 @@ qboolean G_admin_unban( gentity_t *ent, int skiparg ) { int bnum; char bs[ 4 ]; - qtime_t qt; - int t; - t = trap_RealTime( &qt ); if( G_SayArgc() < 2 + skiparg ) { ADMP( "^3!unban: ^7usage: !unban [ban #]\n" ); @@ -1890,7 +1863,7 @@ qboolean G_admin_unban( gentity_t *ent, int skiparg ) ADMP( "^3!unban: ^7invalid ban #\n" ); return qfalse; } - g_admin_bans[ bnum -1 ]->expires = t; + g_admin_bans[ bnum - 1 ]->expires = trap_RealTime( NULL ); AP( va( "print \"^3!unban: ^7ban #%d for %s^7 has been removed by %s\n\"", bnum, g_admin_bans[ bnum - 1 ]->name, @@ -1960,7 +1933,7 @@ qboolean G_admin_map( gentity_t *ent, int skiparg ) { char map[ MAX_QPATH ]; char layout[ MAX_QPATH ] = { "" }; - + if( G_SayArgc( ) < 2 + skiparg ) { ADMP( "^3!map: ^7usage: !map [map] (layout)\n" ); @@ -2055,7 +2028,6 @@ qboolean G_admin_mute( gentity_t *ent, int skiparg ) vic->client->pers.netname, ( ent ) ? ent->client->pers.netname : "console" ) ); } - ClientUserinfoChanged( pids[ 0 ] ); return qtrue; } @@ -2118,23 +2090,18 @@ qboolean G_admin_denybuild( gentity_t *ent, int skiparg ) vic->client->pers.netname, ( ent ) ? ent->client->pers.netname : "console" ) ); } - ClientUserinfoChanged( pids[ 0 ] ); return qtrue; } qboolean G_admin_listadmins( gentity_t *ent, int skiparg ) { int i, found = 0; - qtime_t qt; - int t; char search[ MAX_NAME_LENGTH ] = {""}; char s[ MAX_NAME_LENGTH ] = {""}; int start = 0; qboolean numeric = qtrue; int drawn = 0; - t = trap_RealTime( &qt ); - for( i = 0; i < MAX_ADMIN_ADMINS && g_admin_admins[ i ]; i++ ) { if( g_admin_admins[ i ]->level == 0 ) @@ -2152,11 +2119,11 @@ qboolean G_admin_listadmins( gentity_t *ent, int skiparg ) G_SayArgv( 1 + skiparg, s, sizeof( s ) ); for( i = 0; i < sizeof( s ) && s[ i ]; i++ ) { - if( s[ i ] >= '0' && s[ i ] <= '9' ) + if( isdigit( s[ i ] ) ) continue; - numeric = qfalse; + numeric = qfalse; } - if( numeric ) + if( numeric ) { start = atoi( s ); if( start > 0 ) @@ -2211,12 +2178,12 @@ qboolean G_admin_listlayouts( gentity_t *ent, int skiparg ) char *s; char layout[ MAX_QPATH ] = { "" }; int i = 0; - - if( G_SayArgc( ) == 2 + skiparg ) - G_SayArgv( 1 +skiparg, map, sizeof( map ) ); + + if( G_SayArgc( ) == 2 + skiparg ) + G_SayArgv( 1 + skiparg, map, sizeof( map ) ); else trap_Cvar_VariableStringBuffer( "mapname", map, sizeof( map ) ); - + count = G_LayoutList( map, list, sizeof( list ) ); ADMBP_begin( ); ADMBP( va( "^3!listlayouts:^7 %d layouts found for '%s':\n", count, map ) ); @@ -2258,7 +2225,7 @@ qboolean G_admin_listplayers( gentity_t *ent, int skiparg ) char lname_fmt[ 5 ]; ADMBP_begin(); - ADMBP( va( "^3!listplayers^7: %d players connected:\n", + ADMBP( va( "^3!listplayers: ^7%d players connected:\n", level.numConnectedClients ) ); for( i = 0; i < level.maxclients; i++ ) { @@ -2308,9 +2275,8 @@ qboolean G_admin_listplayers( gentity_t *ent, int skiparg ) { if( !Q_stricmp( g_admin_admins[ j ]->guid, p->pers.guid ) ) { - // don't gather aka or level info if the admin is incognito - if( G_admin_permission( &g_entities[ i ], ADMF_INCOGNITO ) ) + if( ent && G_admin_permission( &g_entities[ i ], ADMF_INCOGNITO ) ) { break; } @@ -2341,15 +2307,15 @@ qboolean G_admin_listplayers( gentity_t *ent, int skiparg ) } } - - if( G_admin_permission(ent, ADMF_SEESFULLLISTPLAYERS ) ) + + if( G_admin_permission( ent, ADMF_SEESFULLLISTPLAYERS ) ) { ADMBP( va( "%2i %s%s^7 %-2i %s^7 (*%s) ^1%1s%1s^7 %s^7 %s%s^7%s\n", i, c, t, l, - ( *lname ) ? lname2 : "", + ( *lname ) ? lname2 : "", guid_stub, muted, denied, @@ -2376,7 +2342,6 @@ qboolean G_admin_listplayers( gentity_t *ent, int skiparg ) qboolean G_admin_showbans( gentity_t *ent, int skiparg ) { int i, found = 0; - qtime_t qt; int t; char duration[ 32 ]; char name_fmt[ 32 ] = { "%s" }; @@ -2391,12 +2356,12 @@ qboolean G_admin_showbans( gentity_t *ent, int skiparg ) char n1[ MAX_NAME_LENGTH ] = {""}; char n2[ MAX_NAME_LENGTH ] = {""}; - t = trap_RealTime( &qt ); + t = trap_RealTime( NULL ); for( i = 0; i < MAX_ADMIN_BANS && g_admin_bans[ i ]; i++ ) { - if( g_admin_bans[ i ]->expires != 0 - && ( g_admin_bans[ i ]->expires - t ) < 1 ) + if( g_admin_bans[ i ]->expires != 0 && + ( g_admin_bans[ i ]->expires - t ) < 1 ) { continue; } @@ -2417,8 +2382,8 @@ qboolean G_admin_showbans( gentity_t *ent, int skiparg ) if( start >= MAX_ADMIN_BANS || start < 0 ) start = 0; - for( i = start; i < MAX_ADMIN_BANS && g_admin_bans[ i ] - && ( i - start ) < MAX_ADMIN_SHOWBANS; i++ ) + for( i = start; i < MAX_ADMIN_BANS && g_admin_bans[ i ] && + ( i - start ) < MAX_ADMIN_SHOWBANS; i++ ) { G_DecolorString( g_admin_bans[ i ]->name, n1 ); G_DecolorString( g_admin_bans[ i ]->banner, n2 ); @@ -2436,11 +2401,11 @@ qboolean G_admin_showbans( gentity_t *ent, int skiparg ) return qfalse; } ADMBP_begin(); - for( i = start; i < MAX_ADMIN_BANS && g_admin_bans[ i ] - && ( i - start ) < MAX_ADMIN_SHOWBANS; i++ ) + for( i = start; i < MAX_ADMIN_BANS && g_admin_bans[ i ] && + ( i - start ) < MAX_ADMIN_SHOWBANS; i++ ) { - if( g_admin_bans[ i ]->expires != 0 - && ( g_admin_bans[ i ]->expires - t ) < 1 ) + if( g_admin_bans[ i ]->expires != 0 && + ( g_admin_bans[ i ]->expires - t ) < 1 ) continue; // only print out the the date part of made @@ -2463,12 +2428,12 @@ qboolean G_admin_showbans( gentity_t *ent, int skiparg ) G_DecolorString( g_admin_bans[ i ]->name, n1 ); Com_sprintf( name_fmt, sizeof( name_fmt ), "%%%is", ( max_name + strlen( g_admin_bans[ i ]->name ) - strlen( n1 ) ) ); - Com_sprintf( n1, sizeof( n1 ), name_fmt, g_admin_bans[ i ]->name ); + Com_sprintf( n1, sizeof( n1 ), name_fmt, g_admin_bans[ i ]->name ); G_DecolorString( g_admin_bans[ i ]->banner, n2 ); Com_sprintf( banner_fmt, sizeof( banner_fmt ), "%%%is", ( max_banner + strlen( g_admin_bans[ i ]->banner ) - strlen( n2 ) ) ); - Com_sprintf( n2, sizeof( n2 ), banner_fmt, g_admin_bans[ i ]->banner ); + Com_sprintf( n2, sizeof( n2 ), banner_fmt, g_admin_bans[ i ]->banner ); ADMBP( va( "%4i %s^7 %-15s %-8s %s^7 %-10s\n \\__ %s\n", ( i + 1 ), @@ -2663,7 +2628,7 @@ qboolean G_admin_allready( gentity_t *ent, int skiparg ) cl->readyToExit = 1; } AP( va( "print \"^3!allready:^7 %s^7 says everyone is READY now\n\"", - ( ent ) ? ent->client->pers.netname : "console" ) ); + ( ent ) ? ent->client->pers.netname : "console" ) ); return qtrue; } @@ -2672,7 +2637,7 @@ qboolean G_admin_cancelvote( gentity_t *ent, int skiparg ) if(!level.voteTime && !level.teamVoteTime[ 0 ] && !level.teamVoteTime[ 1 ] ) { - ADMP( "^3!cancelvote^7: no vote in progress\n" ); + ADMP( "^3!cancelvote: ^7no vote in progress\n" ); return qfalse; } level.voteNo = level.numConnectedClients; @@ -2693,7 +2658,7 @@ qboolean G_admin_passvote( gentity_t *ent, int skiparg ) { if(!level.voteTime && !level.teamVoteTime[ 0 ] && !level.teamVoteTime[ 1 ] ) { - ADMP( "^3!passvote^7: no vote in progress\n" ); + ADMP( "^3!passvote: ^7no vote in progress\n" ); return qfalse; } level.voteYes = level.numConnectedClients; @@ -2728,7 +2693,7 @@ qboolean G_admin_spec999( gentity_t *ent, int skiparg ) { G_ChangeTeam( vic, PTE_NONE ); AP( va( "print \"^3!spec999: ^7%s^7 moved ^7%s^7 to spectators\n\"", - ( ent ) ? ent->client->pers.netname : "console", + ( ent ) ? ent->client->pers.netname : "console", vic->client->pers.netname ) ); } } @@ -2760,7 +2725,7 @@ qboolean G_admin_rename( gentity_t *ent, int skiparg ) ADMP( va( "^3!rename: ^7%s\n", err ) ); return qfalse; } - victim = &g_entities[ pids[ 0 ] ] ; + victim = &g_entities[ pids[ 0 ] ]; if( !admin_higher( ent, victim ) ) { ADMP( "^3!rename: ^7sorry, but your intended victim has a higher admin" @@ -2850,7 +2815,7 @@ qboolean G_admin_namelog( gentity_t *ent, int skiparg ) if( search[0] ) { found = qfalse; - for( j = 0; j < MAX_ADMIN_NAMELOG_NAMES && + for( j = 0; j < MAX_ADMIN_NAMELOG_NAMES && g_admin_namelog[ i ]->name[ j ][ 0 ]; j++ ) { G_SanitiseName( g_admin_namelog[ i ]->name[ j ], n2 ); @@ -2869,17 +2834,17 @@ qboolean G_admin_namelog( gentity_t *ent, int skiparg ) guid_stub[ j ] = '\0'; if( g_admin_namelog[ i ]->slot > -1 ) ADMBP( "^3" ); - ADMBP( va( "%-2s (*%s) %15s^7", - (g_admin_namelog[ i ]->slot > -1 ) ? + ADMBP( va( "%-2s (*%s) %15s^7", + ( g_admin_namelog[ i ]->slot > -1 ) ? va( "%d", g_admin_namelog[ i ]->slot ) : "-", guid_stub, g_admin_namelog[ i ]->ip ) ); - for( j = 0; j < MAX_ADMIN_NAMELOG_NAMES && + for( j = 0; j < MAX_ADMIN_NAMELOG_NAMES && g_admin_namelog[ i ]->name[ j ][ 0 ]; j++ ) { ADMBP( va( " '%s^7'", g_admin_namelog[ i ]->name[ j ] ) ); } - ADMBP( "\n" ); - } + ADMBP( "\n" ); + } ADMBP( va( "^3!namelog:^7 %d recent clients found\n", printed ) ); ADMBP_end(); return qtrue; @@ -2930,7 +2895,7 @@ qboolean G_admin_lock( gentity_t *ent, int skiparg ) ( team == PTE_ALIENS ) ? "Alien" : "Human", ( ent ) ? ent->client->pers.netname : "console" ) ); return qtrue; -} +} qboolean G_admin_unlock( gentity_t *ent, int skiparg ) { @@ -2952,7 +2917,7 @@ qboolean G_admin_unlock( gentity_t *ent, int skiparg ) ADMP( va( "^3!unlock: ^7invalid team\"%c\"\n", teamName[0] ) ); return qfalse; } - + if( team == PTE_ALIENS ) { if( !level.alienTeamLocked ) @@ -2977,7 +2942,7 @@ qboolean G_admin_unlock( gentity_t *ent, int skiparg ) ( team == PTE_ALIENS ) ? "Alien" : "Human", ( ent ) ? ent->client->pers.netname : "console" ) ); return qtrue; -} +} /* ================ @@ -2989,14 +2954,18 @@ qboolean G_admin_unlock( gentity_t *ent, int skiparg ) */ void G_admin_print( gentity_t *ent, char *m ) { - if( ent ) trap_SendServerCommand( ent - level.gentities, va( "print \"%s\"", m ) ); else { char m2[ MAX_STRING_CHARS ]; - G_DecolorString( m, m2 ); - G_Printf( m2 ); + if( !trap_Cvar_VariableIntegerValue( "com_ansiColor" ) ) + { + G_DecolorString( m, m2 ); + G_Printf( m2 ); + } + else + G_Printf( m ); } } diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c index dfefb0be..bad5e157 100644 --- a/src/game/g_buildable.c +++ b/src/game/g_buildable.c @@ -140,7 +140,7 @@ static int G_NumberOfDependants( gentity_t *self ) int i, n = 0; gentity_t *ent; - for ( i = 1, ent = g_entities + i; i < level.num_entities; i++, ent++ ) + for( i = MAX_CLIENTS, ent = g_entities + i; i < level.num_entities; i++, ent++ ) { if( ent->s.eType != ET_BUILDABLE ) continue; @@ -167,7 +167,7 @@ static qboolean G_FindPower( gentity_t *self ) gentity_t *ent; gentity_t *closestPower = NULL; int distance = 0; - int minDistance = 10000; + int minDistance = REPEATER_BASESIZE + 1; vec3_t temp_v; if( self->biteam != BIT_HUMANS ) @@ -185,27 +185,25 @@ static qboolean G_FindPower( gentity_t *self ) self->parentNode = NULL; //iterate through entities - for( i = 1, ent = g_entities + i; i < level.num_entities; i++, ent++ ) + for( i = MAX_CLIENTS, ent = g_entities + i; i < level.num_entities; i++, ent++ ) { if( ent->s.eType != ET_BUILDABLE ) continue; //if entity is a power item calculate the distance to it if( ( ent->s.modelindex == BA_H_REACTOR || ent->s.modelindex == BA_H_REPEATER ) && - ent->spawned && ent->health > 0 ) + ent->spawned && ent->powered && ent->health > 0 ) { VectorSubtract( self->s.origin, ent->s.origin, temp_v ); distance = VectorLength( temp_v ); // Always prefer a reactor if there is one in range - if( ent->s.modelindex == BA_H_REACTOR && ent->powered && - distance <= REACTOR_BASESIZE ) + if( ent->s.modelindex == BA_H_REACTOR && distance <= REACTOR_BASESIZE ) { self->parentNode = ent; return qtrue; } - else if( distance < minDistance && ent->powered && - distance <= REPEATER_BASESIZE ) + else if( distance < minDistance ) { closestPower = ent; minDistance = distance; @@ -283,7 +281,7 @@ int G_FindDCC( gentity_t *self ) return 0; //iterate through entities - for( i = 1, ent = g_entities + i; i < level.num_entities; i++, ent++ ) + for( i = MAX_CLIENTS, ent = g_entities + i; i < level.num_entities; i++, ent++ ) { if( ent->s.eType != ET_BUILDABLE ) continue; @@ -344,7 +342,7 @@ static qboolean G_FindOvermind( gentity_t *self ) self->overmindNode = NULL; //iterate through entities - for( i = 1, ent = g_entities + i; i < level.num_entities; i++, ent++ ) + for( i = MAX_CLIENTS, ent = g_entities + i; i < level.num_entities; i++, ent++ ) { if( ent->s.eType != ET_BUILDABLE ) continue; @@ -403,7 +401,7 @@ qboolean G_FindCreep( gentity_t *self ) if( self->client || self->parentNode == NULL || !self->parentNode->inuse || self->parentNode->health <= 0 ) { - for ( i = MAX_CLIENTS, ent = g_entities + i; i < level.num_entities; i++, ent++ ) + for( i = MAX_CLIENTS, ent = g_entities + i; i < level.num_entities; i++, ent++ ) { if( ent->s.eType != ET_BUILDABLE ) continue; @@ -769,11 +767,9 @@ Think function for Alien Overmind */ void AOvermind_Think( gentity_t *self ) { - int entityList[ MAX_GENTITIES ]; - vec3_t range = { OVERMIND_ATTACK_RANGE, OVERMIND_ATTACK_RANGE, OVERMIND_ATTACK_RANGE }; - vec3_t mins, maxs; - int i, num; - gentity_t *enemy; + vec3_t range = { OVERMIND_ATTACK_RANGE, OVERMIND_ATTACK_RANGE, OVERMIND_ATTACK_RANGE }; + vec3_t mins, maxs; + int i; VectorAdd( self->s.origin, range, maxs ); VectorSubtract( self->s.origin, range, mins ); @@ -781,20 +777,11 @@ void AOvermind_Think( gentity_t *self ) if( self->spawned && ( self->health > 0 ) ) { //do some damage - num = trap_EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES ); - for( i = 0; i < num; i++ ) + if( G_SelectiveRadiusDamage( self->s.pos.trBase, self, self->splashDamage, + self->splashRadius, self, MOD_OVERMIND, PTE_ALIENS ) ) { - enemy = &g_entities[ entityList[ i ] ]; - - if( enemy->client && enemy->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) - { - self->timestamp = level.time; - G_SelectiveRadiusDamage( self->s.pos.trBase, self, self->splashDamage, - self->splashRadius, self, MOD_OVERMIND, PTE_ALIENS ); - G_SetBuildableAnim( self, BANIM_ATTACK1, qfalse ); - - break; - } + self->timestamp = level.time; + G_SetBuildableAnim( self, BANIM_ATTACK1, qfalse ); } // just in case an egg finishes building after we tell overmind to stfu @@ -1252,10 +1239,7 @@ qboolean AHovel_Blocked( gentity_t *hovel, gentity_t *player, qboolean provideEx G_SetClientViewAngle( player, angles ); } - if( tr.fraction < 1.0f ) - return qtrue; - else - return qfalse; + return tr.fraction < 1.0f; } /* @@ -2782,7 +2766,7 @@ static itemBuildError_t G_SufficientBPAvailable( buildable_t buildable, return bpError; // Check for buildable<->buildable collisions - for( i = 1, ent = g_entities + i; i < level.num_entities; i++, ent++ ) + for( i = MAX_CLIENTS, ent = g_entities + i; i < level.num_entities; i++, ent++ ) { if( ent->s.eType != ET_BUILDABLE ) continue; @@ -2800,7 +2784,7 @@ static itemBuildError_t G_SufficientBPAvailable( buildable_t buildable, level.numBuildablesForRemoval = 0; // Build a list of buildable entities - for( i = 1, ent = g_entities + i; i < level.num_entities; i++, ent++ ) + for( i = MAX_CLIENTS, ent = g_entities + i; i < level.num_entities; i++, ent++ ) { if( ent->s.eType != ET_BUILDABLE ) continue; @@ -3145,9 +3129,9 @@ static gentity_t *G_Build( gentity_t *builder, buildable_t buildable, vec3_t ori { // initial base layout created by server - if( builder->s.origin2[ 0 ] - || builder->s.origin2[ 1 ] - || builder->s.origin2[ 2 ] ) + if( builder->s.origin2[ 0 ] || + builder->s.origin2[ 1 ] || + builder->s.origin2[ 2 ] ) { VectorCopy( builder->s.origin2, normal ); } @@ -3533,7 +3517,7 @@ void G_LayoutSave( char *name ) return; } - G_Printf("layoutsave: saving layout to %s\n", fileName ); + G_Printf( "layoutsave: saving layout to %s\n", fileName ); for( i = MAX_CLIENTS; i < level.num_entities; i++ ) { @@ -3643,15 +3627,17 @@ void G_LayoutSelect( void ) Q_strncpyz( layouts2, layouts, sizeof( layouts2 ) ); l = &layouts2[ 0 ]; layouts[ 0 ] = '\0'; - s = COM_ParseExt( &l, qfalse ); - while( *s ) + while( 1 ) { + s = COM_ParseExt( &l, qfalse ); + if( !*s ) + break; + if( !Q_stricmp( s, "*BUILTIN*" ) ) { Q_strcat( layouts, sizeof( layouts ), s ); Q_strcat( layouts, sizeof( layouts ), " " ); cnt++; - s = COM_ParseExt( &l, qfalse ); continue; } @@ -3664,7 +3650,6 @@ void G_LayoutSelect( void ) } else G_Printf( S_COLOR_YELLOW "WARNING: layout \"%s\" does not exist\n", s ); - s = COM_ParseExt( &l, qfalse ); } if( !cnt ) { @@ -3677,16 +3662,18 @@ void G_LayoutSelect( void ) Q_strncpyz( layouts2, layouts, sizeof( layouts2 ) ); l = &layouts2[ 0 ]; - s = COM_ParseExt( &l, qfalse ); - while( *s ) + while( 1 ) { + s = COM_ParseExt( &l, qfalse ); + if( !*s ) + break; + Q_strncpyz( level.layout, s, sizeof( level.layout ) ); cnt++; if( cnt >= layoutNum ) break; - s = COM_ParseExt( &l, qfalse ); } - G_Printf("using layout \"%s\" from list ( %s)\n", level.layout, layouts ); + G_Printf( "using layout \"%s\" from list (%s)\n", level.layout, layouts ); } /* diff --git a/src/game/g_client.c b/src/game/g_client.c index f9742109..3022a9cc 100644 --- a/src/game/g_client.c +++ b/src/game/g_client.c @@ -801,7 +801,6 @@ ClientCheckName static void ClientCleanName( const char *in, char *out, int outSize ) { int len, colorlessLen; - char ch; char *p; int spaces; @@ -814,42 +813,33 @@ static void ClientCleanName( const char *in, char *out, int outSize ) *p = 0; spaces = 0; - while( 1 ) + for( ; *in; in++ ) { - ch = *in++; - if( !ch ) - break; - // don't allow leading spaces - if( !*p && ch == ' ' ) + if( colorlessLen == 0 && *in == ' ' ) continue; // check colors - if( ch == Q_COLOR_ESCAPE ) + if( Q_IsColorString( in ) ) { - // solo trailing carat is not a color prefix - if( !*in ) - break; + in++; // don't allow black in a name, period if( ColorIndex( *in ) == 0 ) - { - in++; continue; - } // make sure room in dest for both chars if( len > outSize - 2 ) break; - *out++ = ch; - *out++ = *in++; + *out++ = Q_COLOR_ESCAPE; + *out++ = *in; len += 2; continue; } // don't allow too many consecutive spaces - if( ch == ' ' ) + if( *in == ' ' ) { spaces++; if( spaces > 3 ) @@ -861,7 +851,7 @@ static void ClientCleanName( const char *in, char *out, int outSize ) if( len > outSize - 1 ) break; - *out++ = ch; + *out++ = *in; colorlessLen++; len++; } diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 2c5a9764..3c01256b 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -53,7 +53,7 @@ void G_SanitiseName( char *in, char *out ) skip = qfalse; } - if( *in == 27 || *in == '^' ) + if( *in == 27 || Q_IsColorString( in ) ) { in += 2; // skip color code continue; @@ -193,7 +193,7 @@ int G_ClientNumbersFromString( char *s, int *plist, int max ) // we must assume that if only a number is provided, it is a clientNum return 0; } - + // now look for name matches G_SanitiseName( s, s2 ); if( strlen( s2 ) < 1 ) @@ -557,9 +557,6 @@ void G_LeaveTeam( gentity_t *self ) if( !ent->inuse ) continue; - // clean up projectiles - if( ent->s.eType == ET_MISSILE && ent->r.ownerNum == self->s.number ) - G_FreeEntity( ent ); if( ent->client && ent->client->pers.connected == CON_CONNECTED ) { // cure poison @@ -567,6 +564,8 @@ void G_LeaveTeam( gentity_t *self ) ent->client->lastPoisonClient == self ) ent->client->ps.stats[ STAT_STATE ] &= ~SS_POISONED; } + else if( ent->s.eType == ET_MISSILE && ent->r.ownerNum == self->s.number ) + G_FreeEntity( ent ); } } @@ -618,9 +617,9 @@ void Cmd_Team_f( gentity_t *ent ) trap_Argv( 1, s, sizeof( s ) ); - if( !strlen( s ) ) + if( !s[ 0 ] ) { - trap_SendServerCommand( ent-g_entities, va("print \"team: %i\n\"", + trap_SendServerCommand( ent-g_entities, va( "print \"team: %i\n\"", oldteam ) ); return; } @@ -640,8 +639,8 @@ void Cmd_Team_f( gentity_t *ent ) if( level.alienTeamLocked ) { trap_SendServerCommand( ent-g_entities, - va( "print \"Alien team has been ^1LOCKED\n\"" ) ); - return; + "print \"Alien team has been ^1LOCKED\n\"" ); + return; } else if( level.humanTeamLocked ) { @@ -663,8 +662,8 @@ void Cmd_Team_f( gentity_t *ent ) if( level.humanTeamLocked ) { trap_SendServerCommand( ent-g_entities, - va( "print \"Human team has been ^1LOCKED\n\"" ) ); - return; + "print \"Human team has been ^1LOCKED\n\"" ); + return; } else if( level.alienTeamLocked ) { @@ -765,7 +764,7 @@ static void G_SayTo( gentity_t *ent, gentity_t *other, int mode, int color, cons if( BG_ClientListTest( &other->client->sess.ignoreList, ent-g_entities ) ) ignore = qtrue; - + trap_SendServerCommand( other-g_entities, va( "%s \"%s%s%c%c%s%s\"", mode == SAY_TEAM ? "tchat" : "chat", ( ignore ) ? "[skipnotify]" : "", @@ -785,9 +784,9 @@ void G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chatText ) char text[ MAX_SAY_TEXT ]; char location[ 64 ]; - if (g_chatTeamPrefix.integer) + if( g_chatTeamPrefix.integer ) { - switch( ent->client->pers.teamSelection) + switch( ent->client->pers.teamSelection ) { default: case PTE_NONE: @@ -852,7 +851,7 @@ void G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chatText ) other = &g_entities[ j ]; G_SayTo( ent, other, mode, color, name, text ); } - + if( g_adminParseSay.integer ) { G_admin_cmd_check ( ent, qtrue ); @@ -878,8 +877,8 @@ static void Cmd_Say_f( gentity_t *ent ) // 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 /m ", 12 ) || + !Q_stricmpn( args, "say /mt ", 8 ) || !Q_stricmpn( args, "say_team /mt ", 13 ) ) { G_PrivateMessage( ent ); @@ -969,9 +968,9 @@ void Cmd_CallVote_f( gentity_t *ent ) return; } - if( g_voteLimit.integer > 0 - && ent->client->pers.voteCount >= g_voteLimit.integer - && !G_admin_permission( ent, ADMF_NO_VOTE_LIMIT ) ) + if( g_voteLimit.integer > 0 && + ent->client->pers.voteCount >= g_voteLimit.integer && + !G_admin_permission( ent, ADMF_NO_VOTE_LIMIT ) ) { trap_SendServerCommand( ent-g_entities, va( "print \"You have already called the maximum number of votes (%d)\n\"", @@ -1013,11 +1012,11 @@ void Cmd_CallVote_f( gentity_t *ent ) if( G_ClientNumbersFromString( arg2, clientNums, MAX_CLIENTS ) == 1 ) { // there was only one partial name match - clientNum = clientNums[ 0 ]; + clientNum = clientNums[ 0 ]; } else { - // look for an exact name match (sets clientNum to -1 if it fails) + // look for an exact name match (sets clientNum to -1 if it fails) clientNum = G_ClientNumberFromString( ent, arg2 ); } @@ -1040,7 +1039,7 @@ void Cmd_CallVote_f( gentity_t *ent ) return; } } - + if( !Q_stricmp( arg1, "kick" ) ) { if( G_admin_permission( &g_entities[ clientNum ], ADMF_IMMUNITY ) ) @@ -1136,7 +1135,7 @@ void Cmd_CallVote_f( gentity_t *ent ) level.voteNo = 0; ent->client->pers.vote = qtrue; - for( i = 0 ; i < level.maxclients ; i++ ) + for( i = 0; i < level.maxclients; i++ ) level.clients[i].ps.eFlags &= ~EF_VOTED; ent->client->ps.eFlags |= EF_VOTED; @@ -1190,7 +1189,7 @@ void Cmd_CallTeamVote_f( gentity_t *ent ) char arg2[ MAX_STRING_TOKENS ]; int clientNum = -1; char name[ MAX_NETNAME ]; - + team = ent->client->pers.teamSelection; if( team == PTE_ALIENS ) @@ -1208,9 +1207,9 @@ void Cmd_CallTeamVote_f( gentity_t *ent ) return; } - if( g_voteLimit.integer > 0 - && ent->client->pers.voteCount >= g_voteLimit.integer - && !G_admin_permission( ent, ADMF_NO_VOTE_LIMIT ) ) + if( g_voteLimit.integer > 0 && + ent->client->pers.voteCount >= g_voteLimit.integer && + !G_admin_permission( ent, ADMF_NO_VOTE_LIMIT ) ) { trap_SendServerCommand( ent-g_entities, va( "print \"You have already called the maximum number of votes (%d)\n\"", @@ -1227,7 +1226,7 @@ void Cmd_CallTeamVote_f( gentity_t *ent ) trap_SendServerCommand( ent-g_entities, "print \"Invalid team vote string\n\"" ); return; } - + // detect clientNum for partial name match votes if( !Q_stricmp( arg1, "kick" ) || !Q_stricmp( arg1, "denybuild" ) || @@ -1245,11 +1244,11 @@ void Cmd_CallTeamVote_f( gentity_t *ent ) if( G_ClientNumbersFromString( arg2, clientNums, MAX_CLIENTS ) == 1 ) { // there was only one partial name match - clientNum = clientNums[ 0 ]; + clientNum = clientNums[ 0 ]; } else { - // look for an exact name match (sets clientNum to -1 if it fails) + // look for an exact name match (sets clientNum to -1 if it fails) clientNum = G_ClientNumberFromString( ent, arg2 ); } @@ -1259,7 +1258,7 @@ void Cmd_CallTeamVote_f( gentity_t *ent ) { clientNum = -1; } - + if( clientNum != -1 && level.clients[ clientNum ].pers.connected == CON_DISCONNECTED ) { @@ -1366,7 +1365,7 @@ void Cmd_CallTeamVote_f( gentity_t *ent ) level.teamVoteNo[ cs_offset ] = 0; ent->client->pers.teamVote = qtrue; - for( i = 0 ; i < level.maxclients ; i++ ) + for( i = 0; i < level.maxclients; i++ ) { if( level.clients[ i ].ps.stats[ STAT_PTEAM ] == team ) level.clients[ i ].ps.eFlags &= ~EF_TEAMVOTED; @@ -1432,13 +1431,13 @@ void Cmd_SetViewpos_f( gentity_t *ent ) if( trap_Argc( ) != 5 ) { - trap_SendServerCommand( ent-g_entities, va( "print \"usage: setviewpos x y z yaw\n\"" ) ); + trap_SendServerCommand( ent-g_entities, "print \"usage: setviewpos x y z yaw\n\"" ); return; } VectorClear( angles ); - for( i = 0 ; i < 3 ; i++ ) + for( i = 0; i < 3; i++ ) { trap_Argv( i + 1, buffer, sizeof( buffer ) ); origin[ i ] = atof( buffer ); @@ -1507,10 +1506,7 @@ static qboolean G_RoomForClassChange( gentity_t *ent, pClass_t class, ent->s.number, MASK_PLAYERSOLID ); //check there is room to evolve - if( !tr.startsolid && tr.fraction == 1.0f ) - return qtrue; - else - return qfalse; + return ( !tr.startsolid && tr.fraction == 1.0f ); } /* @@ -1677,26 +1673,16 @@ void Cmd_Class_f( gentity_t *ent ) ClientUserinfoChanged( clientNum ); VectorCopy( infestOrigin, ent->s.pos.trBase ); ClientSpawn( ent, ent, ent->s.pos.trBase, ent->s.apos.trBase ); - return; } else - { G_TriggerMenu2( clientNum, MN_A_CANTEVOLVE, newClass ); - return; - } } else - { G_TriggerMenu( clientNum, MN_A_NOEROOM ); - return; - } } } else if( ent->client->pers.teamSelection == PTE_HUMANS ) - { G_TriggerMenu( clientNum, MN_H_DEADTOCLASS ); - return; - } } @@ -1795,7 +1781,9 @@ void Cmd_Destroy_f( gentity_t *ent ) if( g_markDeconstruct.integer ) { - if( g_markDeconstruct.integer ) + if( !deconstruct ) + G_Damage( traceEnt, ent, ent, forward, tr.endpos, ent->health, 0, MOD_SUICIDE ); + else if( g_markDeconstruct.integer ) { traceEnt->deconstruct = qtrue; // Mark buildable for deconstruction traceEnt->deconstructTime = level.time; @@ -1813,17 +1801,14 @@ void Cmd_Destroy_f( gentity_t *ent ) ent->client->pers.netname, BG_FindNameForBuildable( traceEnt->s.modelindex ) ); - if( !deconstruct ) - G_Damage( traceEnt, ent, ent, forward, tr.endpos, ent->health, 0, MOD_SUICIDE ); - else - { - G_Damage( traceEnt, ent, ent, forward, tr.endpos, ent->health, 0, MOD_SUICIDE ); - G_FreeEntity( traceEnt ); - } + G_Damage( traceEnt, ent, ent, forward, tr.endpos, ent->health, 0, MOD_SUICIDE ); + G_FreeEntity( traceEnt ); + } - if( !g_cheats.integer ) - ent->client->ps.stats[ STAT_MISC ] += - BG_FindBuildTimeForBuildable( traceEnt->s.modelindex ); + if( !g_cheats.integer ) + { + ent->client->ps.stats[ STAT_MISC ] += + BG_FindBuildTimeForBuildable( traceEnt->s.modelindex ); } } } @@ -1900,7 +1885,7 @@ Cmd_ToggleItem_f void Cmd_ToggleItem_f( gentity_t *ent ) { char s[ MAX_TOKEN_CHARS ]; - int upgrade, weapon, i; + int upgrade, weapon; trap_Argv( 1, s, sizeof( s ) ); upgrade = BG_FindUpgradeNumForName( s ); @@ -1916,23 +1901,7 @@ void Cmd_ToggleItem_f( gentity_t *ent ) if( ent->client->ps.weapon != WP_BLASTER ) weapon = WP_BLASTER; else - { - //find a held weapon which isn't the blaster - for( i = WP_NONE + 1; i < WP_NUM_WEAPONS; i++ ) - { - if( i == WP_BLASTER ) - continue; - - if( BG_InventoryContainsWeapon( i, ent->client->ps.stats ) ) - { - weapon = i; - break; - } - } - - if( i == WP_NUM_WEAPONS ) - weapon = WP_BLASTER; - } + weapon = WP_NONE; G_ForceWeaponChange( ent, weapon ); } @@ -2007,21 +1976,21 @@ void Cmd_Buy_f( gentity_t *ent ) // Only humans can buy stuff if( BG_FindTeamForWeapon( weapon ) != WUT_HUMANS ) { - trap_SendServerCommand( ent-g_entities, va( "print \"You can't buy alien items\n\"" ) ); + trap_SendServerCommand( ent-g_entities, "print \"You can't buy alien items\n\"" ); return; } //are we /allowed/ to buy this? if( !BG_FindPurchasableForWeapon( weapon ) ) { - trap_SendServerCommand( ent-g_entities, va( "print \"You can't buy this item\n\"" ) ); + trap_SendServerCommand( ent-g_entities, "print \"You can't buy this item\n\"" ); return; } //are we /allowed/ to buy this? if( !BG_FindStagesForWeapon( weapon, g_humanStage.integer ) || !BG_WeaponIsAllowed( weapon ) ) { - trap_SendServerCommand( ent-g_entities, va( "print \"You can't buy this item\n\"" ) ); + trap_SendServerCommand( ent-g_entities, "print \"You can't buy this item\n\"" ); return; } @@ -2074,21 +2043,21 @@ void Cmd_Buy_f( gentity_t *ent ) // Only humans can buy stuff if( BG_FindTeamForUpgrade( upgrade ) != WUT_HUMANS ) { - trap_SendServerCommand( ent-g_entities, va( "print \"You can't buy alien items\n\"" ) ); + trap_SendServerCommand( ent-g_entities, "print \"You can't buy alien items\n\"" ); return; } //are we /allowed/ to buy this? if( !BG_FindPurchasableForUpgrade( upgrade ) ) { - trap_SendServerCommand( ent-g_entities, va( "print \"You can't buy this item\n\"" ) ); + trap_SendServerCommand( ent-g_entities, "print \"You can't buy this item\n\"" ); return; } //are we /allowed/ to buy this? if( !BG_FindStagesForUpgrade( upgrade, g_humanStage.integer ) || !BG_UpgradeIsAllowed( upgrade ) ) { - trap_SendServerCommand( ent-g_entities, va( "print \"You can't buy this item\n\"" ) ); + trap_SendServerCommand( ent-g_entities, "print \"You can't buy this item\n\"" ); return; } @@ -2161,7 +2130,7 @@ void Cmd_Sell_f( gentity_t *ent ) //are we /allowed/ to sell this? if( !BG_FindPurchasableForWeapon( weapon ) ) { - trap_SendServerCommand( ent-g_entities, va( "print \"You can't sell this weapon\n\"" ) ); + trap_SendServerCommand( ent-g_entities, "print \"You can't sell this weapon\n\"" ); return; } @@ -2190,7 +2159,7 @@ void Cmd_Sell_f( gentity_t *ent ) //are we /allowed/ to sell this? if( !BG_FindPurchasableForUpgrade( upgrade ) ) { - trap_SendServerCommand( ent-g_entities, va( "print \"You can't sell this item\n\"" ) ); + trap_SendServerCommand( ent-g_entities, "print \"You can't sell this item\n\"" ); return; } //remove upgrade if carried @@ -2699,7 +2668,7 @@ void Cmd_PTRCVerify_f( gentity_t *ent ) trap_Argv( 1, s, sizeof( s ) ); - if( !strlen( s ) ) + if( !s[ 0 ] ) return; code = atoi( s ); @@ -2743,7 +2712,7 @@ void Cmd_PTRCRestore_f( gentity_t *ent ) trap_Argv( 1, s, sizeof( s ) ); - if( !strlen( s ) ) + if( !s[ 0 ] ) return; code = atoi( s ); @@ -2794,12 +2763,12 @@ static void Cmd_Ignore_f( gentity_t *ent ) if( trap_Argc() < 2 ) { trap_SendServerCommand( ent-g_entities, va( "print \"[skipnotify]" - "%s: usage \\%s [clientNum | partial name match]\n\"", cmd, cmd ) ); + "usage: %s [clientNum | partial name match]\n\"", cmd ) ); return; } Q_strncpyz( name, ConcatArgs( 1 ), sizeof( name ) ); - matches = G_ClientNumbersFromString( name, pids, MAX_CLIENTS ); + matches = G_ClientNumbersFromString( name, pids, MAX_CLIENTS ); if( matches < 1 ) { trap_SendServerCommand( ent-g_entities, va( "print \"[skipnotify]" @@ -3050,7 +3019,7 @@ int G_SayArgc() { if( *s == ' ' ) { - s++; + s++; if( *s != ' ' ) { c++; @@ -3140,9 +3109,9 @@ char *G_SayConcatArgs(int start) } void G_DecolorString( char *in, char *out ) -{ +{ while( *in ) { - if( *in == 27 || *in == '^' ) { + if( *in == 27 || Q_IsColorString( in ) ) { in++; if( *in ) in++; @@ -3197,7 +3166,7 @@ void G_PrivateMessage( gentity_t *ent ) { int count = 0; - for( i=0; i < pcount; i++ ) + for( i = 0; i < pcount; i++ ) { tmpent = &g_entities[ pids[ i ] ]; @@ -3248,9 +3217,9 @@ void G_PrivateMessage( gentity_t *ent ) { trap_SendServerCommand( pids[ i ], va( "print \">> to reply, say: /m %d [your message] <<\n\"", - ( ent - g_entities ) ) ); + ( ent - g_entities ) ) ); } - trap_SendServerCommand( pids[ i ], va( + trap_SendServerCommand( pids[ i ], va( "cp \"^%cprivate message from ^7%s^7\"", color, ( ent ) ? ent->client->pers.netname : "console" ) ); } diff --git a/src/game/g_combat.c b/src/game/g_combat.c index 1abb9780..003ade97 100644 --- a/src/game/g_combat.c +++ b/src/game/g_combat.c @@ -987,13 +987,13 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, } else if( !g_friendlyFire.integer ) { - if( !g_friendlyFireHumans.integer - && targ->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) + if( !g_friendlyFireHumans.integer && + targ->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) { return; } - if( !g_friendlyFireAliens.integer - && targ->client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS ) + if( !g_friendlyFireAliens.integer && + targ->client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS ) { return; } @@ -1238,14 +1238,16 @@ qboolean G_SelectiveRadiusDamage( vec3_t origin, gentity_t *attacker, float dama points = damage * ( 1.0 - dist / radius ); - if( CanDamage( ent, origin ) ) + if( CanDamage( ent, origin ) && ent->client && + ent->client->ps.stats[ STAT_PTEAM ] != team ) { VectorSubtract( ent->r.currentOrigin, origin, dir ); // push the center of mass higher than the origin so players // get knocked into the air more dir[ 2 ] += 24; - G_SelectiveDamage( ent, NULL, attacker, dir, origin, - (int)points, DAMAGE_RADIUS|DAMAGE_NO_LOCDAMAGE, mod, team ); + hitClient = qtrue; + G_Damage( ent, NULL, attacker, dir, origin, + (int)points, DAMAGE_RADIUS|DAMAGE_NO_LOCDAMAGE, mod ); } } @@ -1315,6 +1317,7 @@ qboolean G_RadiusDamage( vec3_t origin, gentity_t *attacker, float damage, // push the center of mass higher than the origin so players // get knocked into the air more dir[ 2 ] += 24; + hitClient = qtrue; G_Damage( ent, NULL, attacker, dir, origin, (int)points, DAMAGE_RADIUS|DAMAGE_NO_LOCDAMAGE, mod ); } diff --git a/src/game/g_main.c b/src/game/g_main.c index a1219909..b753bdc7 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -220,14 +220,14 @@ static cvarTable_t gameCvarTable[ ] = { &g_alienMaxStage, "g_alienMaxStage", DEFAULT_ALIEN_MAX_STAGE, 0, 0, qfalse }, { &g_alienStage2Threshold, "g_alienStage2Threshold", DEFAULT_ALIEN_STAGE2_THRESH, 0, 0, qfalse }, { &g_alienStage3Threshold, "g_alienStage3Threshold", DEFAULT_ALIEN_STAGE3_THRESH, 0, 0, qfalse }, - + { &g_unlagged, "g_unlagged", "1", CVAR_SERVERINFO | CVAR_ARCHIVE, 0, qfalse }, { &g_disabledEquipment, "g_disabledEquipment", "", CVAR_ROM, 0, qfalse }, { &g_disabledClasses, "g_disabledClasses", "", CVAR_ROM, 0, qfalse }, { &g_disabledBuildables, "g_disabledBuildables", "", CVAR_ROM, 0, qfalse }, - { &g_chatTeamPrefix, "g_chatTeamPrefix", "0", CVAR_ARCHIVE }, + { &g_chatTeamPrefix, "g_chatTeamPrefix", "0", CVAR_ARCHIVE, 0, qfalse }, { &g_markDeconstruct, "g_markDeconstruct", "1", CVAR_SERVERINFO | CVAR_ARCHIVE, 0, qfalse }, @@ -248,13 +248,13 @@ static cvarTable_t gameCvarTable[ ] = { &g_adminParseSay, "g_adminParseSay", "1", CVAR_ARCHIVE, 0, qfalse }, { &g_adminNameProtect, "g_adminNameProtect", "1", CVAR_ARCHIVE, 0, qfalse }, { &g_adminTempBan, "g_adminTempBan", "120", CVAR_ARCHIVE, 0, qfalse }, - + { &g_dretchPunt, "g_dretchPunt", "0", CVAR_ARCHIVE, 0, qfalse }, { &g_privateMessages, "g_privateMessages", "1", CVAR_ARCHIVE, 0, qfalse }, - + { &g_tag, "g_tag", "main", CVAR_INIT, 0, qfalse }, - + { &g_rankings, "g_rankings", "0", 0, 0, qfalse} }; @@ -507,7 +507,7 @@ void G_MapConfigs( const char *mapname ) trap_SendConsoleCommand( EXEC_APPEND, va( "exec \"%s/default.cfg\"\n", g_mapConfigs.string ) ); - + trap_SendConsoleCommand( EXEC_APPEND, va( "exec \"%s/%s.cfg\"\n", g_mapConfigs.string, mapname ) ); @@ -577,9 +577,7 @@ void G_InitGame( int levelTime, int randomSeed, int restart ) // we're done with g_mapConfigs, so reset this for the next map trap_Cvar_Set( "g_mapConfigsLoaded", "0" ); - if ( g_admin.string[ 0 ] ) { - G_admin_readconfig( NULL, 0 ); - } + G_admin_readconfig( NULL, 0 ); // initialize all entities for this game memset( g_entities, 0, MAX_GENTITIES * sizeof( g_entities[ 0 ] ) ); @@ -1302,7 +1300,6 @@ void CalculateRanks( void ) int ff = 0; level.numConnectedClients = 0; - level.numNonSpectatorClients = 0; level.numPlayingClients = 0; level.numVotingClients = 0; // don't count bots level.numAlienClients = 0; @@ -1326,9 +1323,6 @@ void CalculateRanks( void ) if( level.clients[ i ].pers.teamSelection != PTE_NONE ) { level.numPlayingClients++; - if( level.clients[ i ].sess.sessionTeam != TEAM_SPECTATOR ) - level.numNonSpectatorClients++; - if( level.clients[ i ].pers.teamSelection == PTE_ALIENS ) { level.numAlienClients++; @@ -1344,6 +1338,8 @@ void CalculateRanks( void ) } } } + level.numNonSpectatorClients = level.numLiveAlienClients + + level.numLiveHumanClients; level.numteamVotingClients[ 0 ] = level.numHumanClients; level.numteamVotingClients[ 1 ] = level.numAlienClients; P[ i + 1 ] = '\0'; @@ -2345,7 +2341,7 @@ void G_RunFrame( int levelTime ) ClientEndFrame( ent ); } - // save position information for all active clients + // save position information for all active clients G_UnlaggedStore( ); end = trap_Milliseconds(); diff --git a/src/game/g_svcmds.c b/src/game/g_svcmds.c index 34ff66c5..7cf3a97d 100644 --- a/src/game/g_svcmds.c +++ b/src/game/g_svcmds.c @@ -344,9 +344,9 @@ void Svcmd_EntityList_f( void ) int e; gentity_t *check; - check = g_entities + 1; + check = g_entities; - for( e = 1; e < level.num_entities; e++, check++ ) + for( e = 0; e < level.num_entities; e++, check++ ) { if( !check->inuse ) continue; |