From a2abdae1179414204035003451b5a10746b46d75 Mon Sep 17 00:00:00 2001 From: "M. Kristall" Date: Sat, 3 Oct 2009 12:02:28 +0000 Subject: * (bug 2965) Strip colour codes from log messages (Ben Millwood) * (bug 3596) Buying a battlesuit allows player to pass through some map geometry (/dev/humancontroller) * (bug 3679) Remove redundant stage trigger checks (Chris "Lakitu7" Schwartz) * (bug 3761) selling all upgrades removes energy ammo (/dev/humancontroller) * Remove some duplicate code * !showbans did not properly show all valid bans when some bans had expired * Log renames between ClientConnect and ClientBegin --- src/game/g_admin.c | 54 +++++++++++++++++++++++------------- src/game/g_buildable.c | 74 +++++++++----------------------------------------- src/game/g_client.c | 17 ++++-------- src/game/g_cmds.c | 47 ++++++++------------------------ src/game/g_combat.c | 41 +++++++++++++++++++++++++++- src/game/g_local.h | 5 +--- src/game/g_main.c | 5 ++-- 7 files changed, 109 insertions(+), 134 deletions(-) (limited to 'src') diff --git a/src/game/g_admin.c b/src/game/g_admin.c index 36a873b2..b7aae83e 100644 --- a/src/game/g_admin.c +++ b/src/game/g_admin.c @@ -2348,6 +2348,7 @@ qboolean G_admin_listplayers( gentity_t *ent, int skiparg ) qboolean G_admin_showbans( gentity_t *ent, int skiparg ) { int i, found = 0; + int max = 0, count; int t; char duration[ 32 ]; char name_fmt[ 32 ] = { "%s" }; @@ -2372,48 +2373,66 @@ qboolean G_admin_showbans( gentity_t *ent, int skiparg ) continue; } found++; + max = i; } - if( G_SayArgc() < 3 + skiparg ) + if( G_SayArgc() == 2 + skiparg ) { G_SayArgv( 1 + skiparg, skip, sizeof( skip ) ); start = atoi( skip ); // showbans 1 means start with ban 0 if( start > 0 ) - start -= 1; + start--; else if( start < 0 ) - start = found + start; + { + for( i = max, count = 0; i > 0 && count < -start; i-- ) + { + if( g_admin_bans[ i ]->expires == 0 || + ( g_admin_bans[ i ]->expires - t ) > 0 ) + count++; + } + + start = i; + } } 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, count = 0; i < MAX_ADMIN_BANS && g_admin_bans[ i ] && + count < MAX_ADMIN_SHOWBANS; i++ ) { + if( g_admin_bans[ i ]->expires != 0 && + ( g_admin_bans[ i ]->expires - t ) < 1 ) + continue; + + count++; + G_DecolorString( g_admin_bans[ i ]->name, n1, sizeof( n1 ) ); G_DecolorString( g_admin_bans[ i ]->banner, n2, sizeof( n2 ) ); + if( strlen( n1 ) > max_name ) - { max_name = strlen( n1 ); - } + if( strlen( n2 ) > max_banner ) max_banner = strlen( n2 ); } - if( start >= found ) + if( start > max ) { - ADMP( va( "^3!showbans: ^7there are %d active bans\n", found ) ); + ADMP( va( "^3!showbans: ^7%d is the last valid ban\n", max + 1 ) ); return qfalse; } ADMBP_begin(); - for( i = start; i < MAX_ADMIN_BANS && g_admin_bans[ i ] && - ( i - start ) < MAX_ADMIN_SHOWBANS; i++ ) + for( i = start, count = 0; i < MAX_ADMIN_BANS && g_admin_bans[ i ] && + count < MAX_ADMIN_SHOWBANS; i++ ) { if( g_admin_bans[ i ]->expires != 0 && ( g_admin_bans[ i ]->expires - t ) < 1 ) continue; + count++; + // only print out the the date part of made date[ 0 ] = '\0'; made = g_admin_bans[ i ]->made; @@ -2451,16 +2470,13 @@ qboolean G_admin_showbans( gentity_t *ent, int skiparg ) g_admin_bans[ i ]->reason ) ); } - ADMBP( va( "^3!showbans:^7 showing bans %d - %d of %d. ", + ADMBP( va( "^3!showbans:^7 showing bans %d - %d of %d (%d total).", ( found ) ? ( start + 1 ) : 0, - ( ( start + MAX_ADMIN_SHOWBANS ) > found ) ? - found : ( start + MAX_ADMIN_SHOWBANS ), + i, + max + 1, found ) ); - if( ( start + MAX_ADMIN_SHOWBANS ) < found ) - { - ADMBP( va( "run !showbans %d to see more", - ( start + MAX_ADMIN_SHOWBANS + 1 ) ) ); - } + if( i + MAX_ADMIN_SHOWBANS < max ) + ADMBP( va( " run !showbans %d to see more", i + 1 ) ); ADMBP( "\n" ); ADMBP_end(); return qtrue; diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c index 33c1ca96..8e5d0ad4 100644 --- a/src/game/g_buildable.c +++ b/src/game/g_buildable.c @@ -23,9 +23,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "g_local.h" -// from g_combat.c -extern char *modNames[ ]; - /* ================ G_SetBuildableAnim @@ -82,23 +79,6 @@ gentity_t *G_CheckSpawnPoint( int spawnNum, vec3_t origin, vec3_t normal, displacement = ( maxs[ 2 ] + MAX_ALIEN_BBOX ) * M_ROOT3; VectorMA( origin, displacement, normal, localOrigin ); - - trap_Trace( &tr, origin, NULL, NULL, localOrigin, spawnNum, MASK_SHOT ); - - if( tr.entityNum != ENTITYNUM_NONE ) - return &g_entities[ tr.entityNum ]; - - trap_Trace( &tr, localOrigin, cmins, cmaxs, localOrigin, -1, MASK_PLAYERSOLID ); - - if( tr.entityNum == ENTITYNUM_NONE ) - { - if( spawnOrigin != NULL ) - VectorCopy( localOrigin, spawnOrigin ); - - return NULL; - } - else - return &g_entities[ tr.entityNum ]; } else if( spawn == BA_H_SPAWN ) { @@ -106,24 +86,22 @@ gentity_t *G_CheckSpawnPoint( int spawnNum, vec3_t origin, vec3_t normal, VectorCopy( origin, localOrigin ); localOrigin[ 2 ] += maxs[ 2 ] + fabs( cmins[ 2 ] ) + 1.0f; + } + else + return NULL; - trap_Trace( &tr, origin, NULL, NULL, localOrigin, spawnNum, MASK_SHOT ); + trap_Trace( &tr, origin, NULL, NULL, localOrigin, spawnNum, MASK_SHOT ); - if( tr.entityNum != ENTITYNUM_NONE ) - return &g_entities[ tr.entityNum ]; + if( tr.entityNum != ENTITYNUM_NONE ) + return &g_entities[ tr.entityNum ]; - trap_Trace( &tr, localOrigin, cmins, cmaxs, localOrigin, -1, MASK_PLAYERSOLID ); + trap_Trace( &tr, localOrigin, cmins, cmaxs, localOrigin, -1, MASK_PLAYERSOLID ); - if( tr.entityNum == ENTITYNUM_NONE ) - { - if( spawnOrigin != NULL ) - VectorCopy( localOrigin, spawnOrigin ); + if( tr.entityNum != ENTITYNUM_NONE ) + return &g_entities[ tr.entityNum ]; - return NULL; - } - else - return &g_entities[ tr.entityNum ]; - } + if( spawnOrigin != NULL ) + VectorCopy( localOrigin, spawnOrigin ); return NULL; } @@ -603,20 +581,7 @@ void AGeneric_Die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, i else self->nextthink = level.time; //blast immediately - if( attacker && attacker->client ) - { - if( attacker->client->ps.stats[ STAT_TEAM ] == TEAM_ALIENS && - !self->deconstruct ) - G_TeamCommand( TEAM_ALIENS, - va( "print \"%s ^3DESTROYED^7 by teammate %s^7\n\"", - BG_Buildable( self->s.modelindex )->humanName, - attacker->client->pers.netname ) ); - G_LogPrintf( "Decon: %i %i %i: %s destroyed %s by %s\n", - attacker->client->ps.clientNum, self->s.modelindex, mod, - attacker->client->pers.netname, - BG_Buildable( self->s.modelindex )->name, - modNames[ mod ] ); - } + G_LogDestruction( self, attacker, mod ); } /* @@ -2314,20 +2279,7 @@ void HSpawn_Die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int self->nextthink = level.time; //blast immediately } - if( attacker && attacker->client ) - { - if( attacker->client->ps.stats[ STAT_TEAM ] == TEAM_HUMANS && - !self->deconstruct ) - G_TeamCommand( TEAM_HUMANS, - va( "print \"%s ^3DESTROYED^7 by teammate %s^7\n\"", - BG_Buildable( self->s.modelindex )->humanName, - attacker->client->pers.netname ) ); - G_LogPrintf( "Decon: %i %i %i: %s destroyed %s by %s\n", - attacker->client->ps.clientNum, self->s.modelindex, mod, - attacker->client->pers.netname, - BG_Buildable( self->s.modelindex )->name, - modNames[ mod ] ); - } + G_LogDestruction( self, attacker, mod ); } /* diff --git a/src/game/g_client.c b/src/game/g_client.c index eefc266b..6320df2f 100644 --- a/src/game/g_client.c +++ b/src/game/g_client.c @@ -990,10 +990,6 @@ void ClientUserinfoChanged( int clientNum ) if( strcmp( oldname, newname ) ) { - // in case we need to revert and there's no oldname - if( client->pers.connected != CON_CONNECTED ) - Q_strncpyz( oldname, "UnnamedPlayer", sizeof( oldname ) ); - if( client->pers.nameChangeTime && ( level.time - client->pers.nameChangeTime ) <= ( g_minNameChangePeriod.value * 1000 ) ) @@ -1019,7 +1015,7 @@ void ClientUserinfoChanged( int clientNum ) if( revertName ) { - Q_strncpyz( client->pers.netname, oldname, + Q_strncpyz( client->pers.netname, *oldname ? oldname : "UnnamedPlayer", sizeof( client->pers.netname ) ); Info_SetValueForKey( userinfo, "name", oldname ); trap_SetUserinfo( clientNum, userinfo ); @@ -1039,13 +1035,13 @@ void ClientUserinfoChanged( int clientNum ) if( client->sess.spectatorState == SPECTATOR_SCOREBOARD ) Q_strncpyz( client->pers.netname, "scoreboard", sizeof( client->pers.netname ) ); - if( client->pers.connected == CON_CONNECTED ) + if( *oldname ) { if( strcmp( oldname, client->pers.netname ) ) { trap_SendServerCommand( -1, va( "print \"%s" S_COLOR_WHITE " renamed to %s" S_COLOR_WHITE "\n\"", oldname, client->pers.netname ) ); - G_LogPrintf( "ClientRename: %i [%s] (%s) \"%s\" -> \"%s\"\n", clientNum, + G_LogPrintf( "ClientRename: %i [%s] (%s) \"%s^7\" -> \"%s^7\"\n", clientNum, client->pers.ip, client->pers.guid, oldname, client->pers.netname ); G_admin_namelog_update( client, qfalse ); } @@ -1055,9 +1051,6 @@ void ClientUserinfoChanged( int clientNum ) health = atoi( Info_ValueForKey( userinfo, "handicap" ) ); client->pers.maxHealth = health; - if( client->pers.maxHealth < 1 || client->pers.maxHealth > 100 ) - client->pers.maxHealth = 100; - if( client->pers.classSelection == PCL_NONE ) { //This looks hacky and frankly it is. The clientInfo string needs to hold different @@ -1231,7 +1224,7 @@ char *ClientConnect( int clientNum, qboolean firstTime ) // get and distribute relevent paramters ClientUserinfoChanged( clientNum ); - G_LogPrintf( "ClientConnect: %i [%s] (%s) \"%s\"\n", clientNum, + G_LogPrintf( "ClientConnect: %i [%s] (%s) \"%s^7\"\n", clientNum, client->pers.ip, client->pers.guid, client->pers.netname ); // don't do the "xxx connected" messages if they were caried over from previous level @@ -1667,7 +1660,7 @@ void ClientDisconnect( int clientNum ) if( ent->client->pers.connection ) ent->client->pers.connection->clientNum = -1; - G_LogPrintf( "ClientDisconnect: %i [%s] (%s) \"%s\"\n", clientNum, + G_LogPrintf( "ClientDisconnect: %i [%s] (%s) \"%s^7\"\n", clientNum, ent->client->pers.ip, ent->client->pers.guid, ent->client->pers.netname ); trap_UnlinkEntity( ent ); diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 48bc3a0a..82d3828d 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -844,14 +844,14 @@ void G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chatText ) { default: case SAY_ALL: - G_LogPrintf( "say: %s: %s\n", ent->client->pers.netname, chatText ); + G_LogPrintf( "say: %s^7: %s\n", ent->client->pers.netname, chatText ); Com_sprintf( name, sizeof( name ), "%s%s%c%c"EC": ", prefix, ent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE ); color = COLOR_GREEN; break; case SAY_TEAM: - G_LogPrintf( "sayteam: %s: %s\n", ent->client->pers.netname, chatText ); + G_LogPrintf( "sayteam: %s^7: %s\n", ent->client->pers.netname, chatText ); if( Team_GetLocationMsg( ent, location, sizeof( location ) ) ) Com_sprintf( name, sizeof( name ), EC"(%s%c%c"EC") (%s)"EC": ", ent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE, location ); @@ -956,7 +956,7 @@ static void Cmd_Tell_f( gentity_t *ent ) p = ConcatArgs( 2 ); - G_LogPrintf( "tell: %s to %s: %s\n", ent->client->pers.netname, target->client->pers.netname, p ); + G_LogPrintf( "tell: %s^7 to %s^7: %s\n", ent->client->pers.netname, target->client->pers.netname, p ); G_Say( ent, target, SAY_TELL, p ); // don't tell to the player self if it was already directed to this player // also don't send the chat back to a bot @@ -1156,7 +1156,7 @@ void Cmd_CallVote_f( gentity_t *ent ) !Q_stricmp( arg1, "mute" ) || !Q_stricmp( arg1, "unmute" ) ) { - int clientNums[ MAX_CLIENTS ] = { -1 }; + int clientNums[ MAX_CLIENTS ]; if( !arg2[ 0 ] ) { @@ -1176,12 +1176,6 @@ void Cmd_CallVote_f( gentity_t *ent ) clientNum = G_ClientNumberFromString( arg2 ); } - if( clientNum != -1 && - level.clients[ clientNum ].pers.connected == CON_DISCONNECTED ) - { - clientNum = -1; - } - if( clientNum != -1 ) { Q_strncpyz( name, level.clients[ clientNum ].pers.netname, @@ -1207,7 +1201,7 @@ void Cmd_CallVote_f( gentity_t *ent ) if( level.clients[ clientNum ].pers.localClient ) { trap_SendServerCommand( ent-g_entities, - "print \"callvote: host is immute from vote kick\n\"" ); + "print \"callvote: host is immune from vote kick\n\"" ); return; } @@ -1394,7 +1388,7 @@ void Cmd_CallTeamVote_f( gentity_t *ent ) !Q_stricmp( arg1, "denybuild" ) || !Q_stricmp( arg1, "allowbuild" ) ) { - int clientNums[ MAX_CLIENTS ] = { -1 }; + int clientNums[ MAX_CLIENTS ]; if( !arg2[ 0 ] ) { @@ -1421,12 +1415,6 @@ void Cmd_CallTeamVote_f( gentity_t *ent ) clientNum = -1; } - if( clientNum != -1 && - level.clients[ clientNum ].pers.connected == CON_DISCONNECTED ) - { - clientNum = -1; - } - if( clientNum != -1 ) { Q_strncpyz( name, level.clients[ clientNum ].pers.netname, @@ -1654,7 +1642,7 @@ static qboolean G_RoomForClassChange( gentity_t *ent, class_t class, vec3_t newO } // find what the new origin would be on a level surface - newOrigin[ 2 ] += fabs( toMins[ 2 ] ) - fabs( fromMins[ 2 ] ); + newOrigin[ 2 ] -= toMins[ 2 ] - fromMins[ 2 ]; //compute a place up in the air to start the real trace VectorCopy( newOrigin, temp ); @@ -1966,18 +1954,7 @@ void Cmd_Destroy_f( gentity_t *ent ) } else { - G_TeamCommand( ent->client->pers.teamSelection, - va( "print \"%s ^3DECONSTRUCTED^7 by %s^7\n\"", - BG_Buildable( traceEnt->s.modelindex )->humanName, - ent->client->pers.netname ) ); - - G_LogPrintf( "Decon: %i %i 0: %s deconstructed %s\n", - ent->client->ps.clientNum, - traceEnt->s.modelindex, - ent->client->pers.netname, - BG_Buildable( traceEnt->s.modelindex )->humanName ); - - G_Damage( traceEnt, ent, ent, forward, tr.endpos, ent->health, 0, MOD_SUICIDE ); + G_LogDestruction( traceEnt, ent, MOD_UNKNOWN ); G_FreeEntity( traceEnt ); } @@ -2251,7 +2228,7 @@ void Cmd_Buy_f( gentity_t *ent ) G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOROOMBSUITON ); return; } - VectorCopy( newOrigin, ent->s.pos.trBase ); + VectorCopy( newOrigin, ent->client->ps.origin ); ent->client->ps.stats[ STAT_CLASS ] = PCL_HUMAN_BSUIT; ent->client->pers.classSelection = PCL_HUMAN_BSUIT; ent->client->ps.eFlags ^= EF_TELEPORT_BIT; @@ -2354,7 +2331,7 @@ void Cmd_Sell_f( gentity_t *ent ) G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOROOMBSUITOFF ); return; } - VectorCopy( newOrigin, ent->s.pos.trBase ); + VectorCopy( newOrigin, ent->client->ps.origin ); ent->client->ps.stats[ STAT_CLASS ] = PCL_HUMAN; ent->client->pers.classSelection = PCL_HUMAN; ent->client->ps.eFlags ^= EF_TELEPORT_BIT; @@ -2419,7 +2396,7 @@ void Cmd_Sell_f( gentity_t *ent ) G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOROOMBSUITOFF ); continue; } - VectorCopy( newOrigin, ent->s.pos.trBase ); + VectorCopy( newOrigin, ent->client->ps.origin ); ent->client->ps.stats[ STAT_CLASS ] = PCL_HUMAN; ent->client->pers.classSelection = PCL_HUMAN; ent->client->ps.eFlags ^= EF_TELEPORT_BIT; @@ -3385,7 +3362,7 @@ void G_PrivateMessage( gentity_t *ent ) ADMP( va( "^%cPrivate message: ^7%s\n", color, msg ) ); ADMP( va( "%s\n", str ) ); - G_LogPrintf( "%s: %s: %s: %s\n", + G_LogPrintf( "%s: %s^7: %s^7: %s\n", ( teamonly ) ? "tprivmsg" : "privmsg", ( ent ) ? ent->client->pers.netname : "console", name, msg ); diff --git a/src/game/g_combat.c b/src/game/g_combat.c index cc2cb07a..c153eb82 100644 --- a/src/game/g_combat.c +++ b/src/game/g_combat.c @@ -246,7 +246,7 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int else obit = modNames[ meansOfDeath ]; - G_LogPrintf("Kill: %i %i %i: %s killed %s by %s\n", + G_LogPrintf("Kill: %i %i %i: %s^7 killed %s^7 by %s\n", killer, self->s.number, meansOfDeath, killerName, self->client->pers.netname, obit ); @@ -1335,3 +1335,42 @@ qboolean G_RadiusDamage( vec3_t origin, gentity_t *attacker, float damage, return hitClient; } + +/* +================ +G_LogDestruction + +Log deconstruct/destroy events +================ +*/ +void G_LogDestruction( gentity_t *self, gentity_t *actor, int mod ) +{ + if( !actor || !actor->client ) + return; + + if( actor->client->ps.stats[ STAT_TEAM ] == + BG_Buildable( self->s.modelindex )->team ) + { + G_TeamCommand( actor->client->ps.stats[ STAT_TEAM ], + va( "print \"%s ^3%s^7 by %s\n\"", + BG_Buildable( self->s.modelindex )->humanName, + mod == MOD_UNKNOWN ? "DECONSTRUCTED" : "DESTROYED", + actor->client->pers.netname ) ); + } + + if( mod == MOD_UNKNOWN ) + G_LogPrintf( "Decon: %d %d %d: %s^7 deconstructed %s\n", + actor->client->ps.clientNum, + self->s.modelindex, + mod, + actor->client->pers.netname, + BG_Buildable( self->s.modelindex )->name ); + else + G_LogPrintf( "Decon: %d %d %d: %s^7 destroyed %s by %s\n", + actor->client->ps.clientNum, + self->s.modelindex, + mod, + actor->client->pers.netname, + BG_Buildable( self->s.modelindex )->name, + modNames[ mod ] ); +} diff --git a/src/game/g_local.h b/src/game/g_local.h index 087e9395..bd5cdc78 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -801,6 +801,7 @@ qboolean G_SelectiveRadiusDamage( vec3_t origin, gentity_t *attacker, float dam float G_RewardAttackers( gentity_t *self ); void body_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int meansOfDeath ); void AddScore( gentity_t *ent, int score ); +void G_LogDestruction( gentity_t *self, gentity_t *actor, int mod ); void G_InitDamageLocations( void ); @@ -911,10 +912,6 @@ void FireWeapon( gentity_t *ent ); void FireWeapon2( gentity_t *ent ); void FireWeapon3( gentity_t *ent ); -// -// g_cmds.c -// - // // g_main.c // diff --git a/src/game/g_main.c b/src/game/g_main.c index b39b7141..bcda98ab 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -1602,7 +1602,7 @@ Print to the logfile with a time stamp if it is open void QDECL G_LogPrintf( const char *fmt, ... ) { va_list argptr; - char string[ 1024 ]; + char string[ 1024 ], decolored[ 1024 ]; int min, tens, sec; sec = level.time / 1000; @@ -1624,7 +1624,8 @@ void QDECL G_LogPrintf( const char *fmt, ... ) if( !level.logFile ) return; - trap_FS_Write( string, strlen( string ), level.logFile ); + G_DecolorString( string, decolored, sizeof( decolored ) ); + trap_FS_Write( decolored, strlen( decolored ), level.logFile ); } /* -- cgit