diff options
author | M. Kristall <mkpdev@gmail.com> | 2009-10-12 20:23:36 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-03 00:16:48 +0000 |
commit | 6e5fbea644646afa82130be9bf366d866c9838ca (patch) | |
tree | a671d873b76bf8ca581b733b96f9148c52e4b7da /src/game | |
parent | ea793aff3bddd1792dc223cf946b33ed1318fd7f (diff) |
* Move more things to cgame
* Bring back "teamoverlay" cvar and default it to 1
* Add "cg_chatTeamPrefix" cvar
Diffstat (limited to 'src/game')
-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 | 9 | ||||
-rw-r--r-- | src/game/g_svcmds.c | 10 | ||||
-rw-r--r-- | src/game/g_target.c | 54 | ||||
-rw-r--r-- | src/game/g_team.c | 44 |
6 files changed, 41 insertions, 145 deletions
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index e4d4f180..e82a7b56 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -664,10 +664,8 @@ void Cmd_Team_f( gentity_t *ent ) G_Say ================== */ -static void G_SayTo( gentity_t *ent, gentity_t *other, int mode, int color, const char *name, const char *message ) +static void G_SayTo( gentity_t *ent, gentity_t *other, int mode, const char *message ) { - qboolean ignore = qfalse; - if( !other ) return; @@ -691,33 +689,18 @@ static void G_SayTo( gentity_t *ent, gentity_t *other, int mode, int color, cons // specs with ADMF_SPEC_ALLCHAT flag can see team chat } - if( ent && Com_ClientListContains( &other->client->sess.ignoreList, ent-g_entities ) ) - ignore = qtrue; - - trap_SendServerCommand( other-g_entities, va( "%s \"%s%s%c%c%s%s\"", + trap_SendServerCommand( other-g_entities, va( "%s %d \"%s\"", mode == SAY_TEAM ? "tchat" : "chat", - ( ignore ) ? "[skipnotify]" : "", - name, Q_COLOR_ESCAPE, color, message, S_COLOR_WHITE ) ); + ent ? ent-g_entities : -1, + message ) ); } void G_Say( gentity_t *ent, int mode, const char *chatText ) { int j; gentity_t *other; - int color; - const char *prefix; - char name[ 64 ]; // don't let text be too long for malicious reasons char text[ MAX_SAY_TEXT ]; - char location[ 64 ]; - - if( ent ) - { - prefix = BG_TeamName( ent->client->pers.teamSelection ); - prefix = va( "[%c] ", toupper( *prefix ) ); - } - else - prefix = ""; // check if blocked by g_specChat 0 if( ( !g_specChat.integer ) && ( mode != SAY_TEAM ) && @@ -736,9 +719,6 @@ void G_Say( gentity_t *ent, int mode, const char *chatText ) G_LogPrintf( "Say: %d \"%s" S_COLOR_WHITE "\": " S_COLOR_GREEN "%s\n", ( ent ) ? ent - g_entities : -1, ( ent ) ? ent->client->pers.netname : "console", chatText ); - Com_sprintf( name, sizeof( name ), "%s%s" S_COLOR_WHITE ": ", prefix, - ( ent ) ? ent->client->pers.netname : "console" ); - color = COLOR_GREEN; break; case SAY_TEAM: @@ -748,13 +728,6 @@ void G_Say( gentity_t *ent, int mode, const char *chatText ) G_LogPrintf( "SayTeam: %d \"%s" S_COLOR_WHITE "\": " S_COLOR_CYAN "%s\n", ent - g_entities, ent->client->pers.netname, chatText ); - if( Team_GetLocationMsg( ent, location, sizeof( location ) ) ) - Com_sprintf( name, sizeof( name ), "(%s" S_COLOR_WHITE ") (%s): ", - ent->client->pers.netname, location ); - else - Com_sprintf( name, sizeof( name ), "(%s" S_COLOR_WHITE "): ", - ent->client->pers.netname ); - color = COLOR_CYAN; break; } @@ -764,7 +737,7 @@ void G_Say( gentity_t *ent, int mode, const char *chatText ) for( j = 0; j < level.maxclients; j++ ) { other = &g_entities[ j ]; - G_SayTo( ent, other, mode, color, name, text ); + G_SayTo( ent, other, mode, text ); } if( g_adminParseSay.integer ) @@ -777,30 +750,22 @@ static void Cmd_SayArea_f( gentity_t *ent ) { int entityList[ MAX_GENTITIES ]; int num, i; - int color = COLOR_BLUE; - const char *prefix; vec3_t range = { 1000.0f, 1000.0f, 1000.0f }; vec3_t mins, maxs; char *msg = ConcatArgs( 1 ); - char name[ 64 ]; for(i = 0; i < 3; i++ ) range[ i ] = g_sayAreaRange.value; - - prefix = BG_TeamName( ent->client->pers.teamSelection ); - prefix = va( "[%c] ", toupper( *prefix ) ); G_LogPrintf( "SayArea: %d \"%s" S_COLOR_WHITE "\": " S_COLOR_BLUE "%s\n", ent - g_entities, ent->client->pers.netname, msg ); - Com_sprintf( name, sizeof( name ), "%s<%s%c%c> ", - prefix, ent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE ); VectorAdd( ent->s.origin, range, maxs ); VectorSubtract( ent->s.origin, range, mins ); num = trap_EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES ); for( i = 0; i < num; i++ ) - G_SayTo( ent, &g_entities[ entityList[ i ] ], SAY_TEAM, color, name, msg ); + G_SayTo( ent, &g_entities[ entityList[ i ] ], SAY_TEAM, msg ); //Send to ADMF_SPEC_ALLCHAT candidates for( i = 0; i < level.maxclients; i++ ) @@ -808,7 +773,7 @@ static void Cmd_SayArea_f( gentity_t *ent ) if( g_entities[ i ].client->pers.teamSelection == TEAM_NONE && G_admin_permission( &g_entities[ i ], ADMF_SPEC_ALLCHAT ) ) { - G_SayTo( ent, &g_entities[ i ], SAY_TEAM, color, name, msg ); + G_SayTo( ent, &g_entities[ i ], SAY_TEAM, msg ); } } } @@ -3185,22 +3150,7 @@ void Cmd_PrivateMessage_f( gentity_t *ent ) if( i > 0 ) Q_strcat( str, sizeof( str ), "^7, " ); Q_strcat( str, sizeof( str ), tmpent->client->pers.netname ); - trap_SendServerCommand( pids[ i ], va( - "chat \"%s^%c -> ^7%s^7: (%d recipient%s): ^%c%s^7\" %i", - ( ent ) ? ent->client->pers.netname : "console", - color, - name, - matches, - ( matches == 1 ) ? "" : "s", - color, - msg, - ent ? ent-g_entities : -1 ) ); - if( ent ) - { - trap_SendServerCommand( pids[ i ], va( - "print \">> to reply, say: /m %d [your message] <<\n\"", - ( ent - g_entities ) ) ); - } + G_SayTo( ent, tmpent, teamonly ? SAY_TEAM : SAY_ALL, msg ); 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_local.h b/src/game/g_local.h index f16cf383..c9d06285 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -570,7 +570,6 @@ typedef struct vec3_t intermission_origin; // also used for spectator spawns vec3_t intermission_angle; - qboolean locationLinked; // target_locations get linked gentity_t *locationHead; // head of the location list int numAlienSpawns; @@ -991,7 +990,6 @@ qboolean OnSameTeam( gentity_t *ent1, gentity_t *ent2 ); void G_LeaveTeam( gentity_t *self ); void G_ChangeTeam( gentity_t *ent, team_t newTeam ); gentity_t *Team_GetLocation( gentity_t *ent ); -qboolean Team_GetLocationMsg( gentity_t *ent, char *loc, int loclen ); void TeamplayInfoMessage( gentity_t *ent ); void CheckTeamStatus( void ); void G_UpdateTeamConfigStrings( void ); @@ -1107,7 +1105,6 @@ extern vmCvar_t g_mapRotationNodes; extern vmCvar_t g_mapRotationStack; extern vmCvar_t g_nextMap; extern vmCvar_t g_initialMapRotation; -extern vmCvar_t g_chatTeamPrefix; extern vmCvar_t g_sayAreaRange; extern vmCvar_t g_debugVoices; diff --git a/src/game/g_main.c b/src/game/g_main.c index 82a790d9..1386afa2 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -1643,15 +1643,14 @@ void QDECL G_AdminMessage( gentity_t *ent, const char *fmt, ... ) // Create the final string Q_strcat( outstring, sizeof( outstring ), string ); - Com_sprintf( string, sizeof( string ), "chat \"%s\"", outstring ); + Com_sprintf( string, sizeof( string ), "chat %d \"%s\"", + ent ? ent - g_entities : -1, outstring ); // Send to all appropriate clients for( i = 0; i < level.maxclients; i++ ) - { - if( G_admin_permission( &g_entities[ i ], ADMF_ADMINCHAT ) ) + if( G_admin_permission( &g_entities[ i ], ADMF_ADMINCHAT ) ) trap_SendServerCommand( i, string ); - } - + // Send to the logfile and server console G_LogPrintf( "AdminMsg: %d \"%s" S_COLOR_WHITE "\": %s\n", ent ? ent - g_entities : -1, ent ? ent->client->pers.netname : "console", diff --git a/src/game/g_svcmds.c b/src/game/g_svcmds.c index 818cdfc7..275db7b6 100644 --- a/src/game/g_svcmds.c +++ b/src/game/g_svcmds.c @@ -354,7 +354,6 @@ static void Svcmd_MapRotation_f( void ) static void Svcmd_TeamMessage_f( void ) { char teamNum[ 2 ]; - const char* prefix; team_t team; if( trap_Argc( ) < 3 ) @@ -372,11 +371,8 @@ static void Svcmd_TeamMessage_f( void ) return; } - prefix = BG_TeamName( team ); - prefix = va( "[%c] ", toupper( *prefix ) ); - - G_TeamCommand( team, va( "tchat \"(console): " S_COLOR_CYAN "%s\"", ConcatArgs( 2 ) ) ); - G_LogPrintf( "SayTeam: -1 \"console\": " S_COLOR_CYAN "%s\n", ConcatArgs( 2 ) ); + G_TeamCommand( team, va( "tchat -1 \"%s\"", ConcatArgs( 2 ) ) ); + G_LogPrintf( "SayTeam: -1 \"console\": %s\n", ConcatArgs( 2 ) ); } static void Svcmd_CenterPrint_f( void ) @@ -491,7 +487,7 @@ static void Svcmd_PrintQueue_f( void ) static void Svcmd_Chat_f( void ) { char *s = ConcatArgs( 1 ); - trap_SendServerCommand( -1, va( "chat \"%s\"", s ) ); + trap_SendServerCommand( -1, va( "chat -1 \"%s\"", s ) ); G_LogPrintf("chat: %s\n", s ); } diff --git a/src/game/g_target.c b/src/game/g_target.c index c545c299..adca4b3f 100644 --- a/src/game/g_target.c +++ b/src/game/g_target.c @@ -288,35 +288,6 @@ void SP_target_position( gentity_t *self ) G_SetOrigin( self, self->s.origin ); } -static void target_location_linkup( gentity_t *ent ) -{ - int i; - int n; - - if( level.locationLinked ) - return; - - level.locationLinked = qtrue; - - level.locationHead = NULL; - - trap_SetConfigstring( CS_LOCATIONS, "unknown" ); - - for( i = 0, ent = g_entities, n = 1; i < level.num_entities; i++, ent++) - { - if( ent->s.eType == ET_LOCATION ) - { - // lets overload some variables! - ent->s.generic1 = n; // use for location marking - trap_SetConfigstring( CS_LOCATIONS + n, ent->message ); - n++; - ent->nextTrain = level.locationHead; - level.locationHead = ent; - } - } - // All linked together now -} - /*QUAKED target_location (0 0.5 0) (-8 -8 -8) (8 8 8) Set "message" to the name of this location. Set "count" to 0-7 for color. @@ -327,11 +298,32 @@ in site, closest in distance */ void SP_target_location( gentity_t *self ) { - self->think = target_location_linkup; - self->nextthink = level.time + 200; // Let them all spawn first + static int n = 1; + char *message; self->s.eType = ET_LOCATION; self->r.svFlags = SVF_BROADCAST; trap_LinkEntity( self ); // make the server send them to the clients + if( !level.locationHead ) + trap_SetConfigstring( CS_LOCATIONS, "unknown" ); + if( self->count ) + { + if( self->count < 0 ) + self->count = 0; + + if( self->count > 7 ) + self->count = 7; + + message = va( "%c%c%s" S_COLOR_WHITE, Q_COLOR_ESCAPE, self->count + '0', + self->message); + } + else + message = self->message; + trap_SetConfigstring( CS_LOCATIONS + n, message ); + self->nextTrain = level.locationHead; + self->health = n; // use for location marking + level.locationHead = self; + n++; + G_SetOrigin( self, self->s.origin ); } diff --git a/src/game/g_team.c b/src/game/g_team.c index 51258089..db55c625 100644 --- a/src/game/g_team.c +++ b/src/game/g_team.c @@ -253,23 +253,18 @@ gentity_t *Team_GetLocation( gentity_t *ent ) { gentity_t *eloc, *best; float bestlen, len; - vec3_t origin; best = NULL; bestlen = 3.0f * 8192.0f * 8192.0f; - VectorCopy( ent->r.currentOrigin, origin ); - for( eloc = level.locationHead; eloc; eloc = eloc->nextTrain ) { - len = ( origin[ 0 ] - eloc->r.currentOrigin[ 0 ] ) * ( origin[ 0 ] - eloc->r.currentOrigin[ 0 ] ) - + ( origin[ 1 ] - eloc->r.currentOrigin[ 1 ] ) * ( origin[ 1 ] - eloc->r.currentOrigin[ 1 ] ) - + ( origin[ 2 ] - eloc->r.currentOrigin[ 2 ] ) * ( origin[ 2 ] - eloc->r.currentOrigin[ 2 ] ); + len = DistanceSquared( ent->r.currentOrigin, eloc->r.currentOrigin ); if( len > bestlen ) continue; - if( !trap_InPVS( origin, eloc->r.currentOrigin ) ) + if( !trap_InPVS( ent->r.currentOrigin, eloc->r.currentOrigin ) ) continue; bestlen = len; @@ -280,39 +275,6 @@ gentity_t *Team_GetLocation( gentity_t *ent ) } -/* -=========== -Team_GetLocationMsg - -Report a location message for the player. Uses placed nearby target_location entities -============ -*/ -qboolean Team_GetLocationMsg( gentity_t *ent, char *loc, int loclen ) -{ - gentity_t *best; - - best = Team_GetLocation( ent ); - - if( !best ) - return qfalse; - - if( best->count ) - { - if( best->count < 0 ) - best->count = 0; - - if( best->count > 7 ) - best->count = 7; - - Com_sprintf( loc, loclen, "%c%c%s" S_COLOR_WHITE, Q_COLOR_ESCAPE, best->count + '0', best->message ); - } - else - Com_sprintf( loc, loclen, "%s", best->message ); - - return qtrue; -} - - /*---------------------------------------------------------------------------*/ static int QDECL SortClients( const void *a, const void *b ) @@ -391,7 +353,7 @@ void TeamplayInfoMessage( gentity_t *ent ) } } - trap_SendServerCommand( ent - g_entities, va( "tinfo %i %s", cnt, string ) ); + trap_SendServerCommand( ent - g_entities, va( "tinfo %i%s", cnt, string ) ); } void CheckTeamStatus( void ) |