summaryrefslogtreecommitdiff
path: root/src/cgame
diff options
context:
space:
mode:
Diffstat (limited to 'src/cgame')
-rw-r--r--src/cgame/cg_local.h3
-rw-r--r--src/cgame/cg_main.c7
-rw-r--r--src/cgame/cg_servercmds.c95
3 files changed, 69 insertions, 36 deletions
diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h
index a3a5535f..248f4453 100644
--- a/src/cgame/cg_local.h
+++ b/src/cgame/cg_local.h
@@ -1477,6 +1477,7 @@ extern vmCvar_t cg_synchronousClients;
extern vmCvar_t cg_stats;
extern vmCvar_t cg_paused;
extern vmCvar_t cg_blood;
+extern vmCvar_t cg_teamOverlayUserinfo;
extern vmCvar_t cg_teamChatsOnly;
extern vmCvar_t cg_noVoiceChats;
extern vmCvar_t cg_noVoiceText;
@@ -1536,6 +1537,8 @@ extern vmCvar_t cg_voice;
extern vmCvar_t cg_emoticons;
+extern vmCvar_t cg_chatTeamPrefix;
+
//
// cg_main.c
//
diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c
index 3be1782f..d7076a10 100644
--- a/src/cgame/cg_main.c
+++ b/src/cgame/cg_main.c
@@ -153,6 +153,7 @@ vmCvar_t cg_synchronousClients;
vmCvar_t cg_stats;
vmCvar_t cg_paused;
vmCvar_t cg_blood;
+vmCvar_t cg_teamOverlayUserinfo;
vmCvar_t cg_teamChatsOnly;
vmCvar_t cg_noPrintDuplicate;
vmCvar_t cg_noVoiceChats;
@@ -214,6 +215,7 @@ vmCvar_t cg_voice;
vmCvar_t cg_emoticons;
+vmCvar_t cg_chatTeamPrefix;
typedef struct
{
@@ -268,6 +270,7 @@ static cvarTable_t cvarTable[ ] =
{ &cg_thirdPersonPitchFollow, "cg_thirdPersonPitchFollow", "0", 0 },
{ &cg_thirdPersonShoulderViewMode, "cg_thirdPersonShoulderViewMode", "1", CVAR_ARCHIVE },
{ &cg_stats, "cg_stats", "0", 0 },
+ { &cg_teamOverlayUserinfo, "teamoverlay", "1", CVAR_ARCHIVE|CVAR_USERINFO },
{ &cg_teamChatsOnly, "cg_teamChatsOnly", "0", CVAR_ARCHIVE },
{ &cg_noPrintDuplicate, "cg_noPrintDuplicate", "0", CVAR_ARCHIVE },
{ &cg_noVoiceChats, "cg_noVoiceChats", "0", CVAR_ARCHIVE },
@@ -341,7 +344,9 @@ static cvarTable_t cvarTable[ ] =
{ &cg_voice, "voice", "default", CVAR_USERINFO|CVAR_ARCHIVE},
- { &cg_emoticons, "cg_emoticons", "1", CVAR_LATCH|CVAR_ARCHIVE}
+ { &cg_emoticons, "cg_emoticons", "1", CVAR_LATCH|CVAR_ARCHIVE},
+
+ { &cg_chatTeamPrefix, "cg_chatTeamPrefix", "1", CVAR_ARCHIVE}
};
static int cvarTableSize = sizeof( cvarTable ) / sizeof( cvarTable[0] );
diff --git a/src/cgame/cg_servercmds.c b/src/cgame/cg_servercmds.c
index 78769644..4c462fe6 100644
--- a/src/cgame/cg_servercmds.c
+++ b/src/cgame/cg_servercmds.c
@@ -917,23 +917,38 @@ void CG_Menu( int menu, int arg )
CG_Say
=================
*/
-static void CG_Say( int clientNum, char *text )
+static void CG_Say( int clientNum, const char *text )
{
clientInfo_t *ci;
- char sayText[ MAX_SAY_TEXT ] = {""};
-
- if( clientNum < 0 || clientNum >= MAX_CLIENTS )
- return;
+ char sayText[ MAX_STRING_CHARS ];
+ char *prefix, *name;
- ci = &cgs.clientinfo[ clientNum ];
- Com_sprintf( sayText, sizeof( sayText ),
- "%s: " S_COLOR_WHITE S_COLOR_GREEN "%s" S_COLOR_WHITE "\n",
- ci->name, text );
+ if( clientNum >= 0 && clientNum < MAX_CLIENTS )
+ ci = &cgs.clientinfo[ clientNum ];
+ else
+ ci = NULL;
+
+ if( ci && cg_chatTeamPrefix.integer )
+ prefix = va( "[%c] ", toupper( *( BG_TeamName( ci->team ) ) ) );
+ else
+ prefix = "";
+
+ if( ci )
+ name = ci->name;
+ else
+ name = "console";
+
+ Com_sprintf( sayText, sizeof( sayText ), "%s%s: " S_COLOR_GREEN "%s\n",
+ prefix, name, text );
- if( Com_ClientListContains( &cgs.ignoreList, clientNum ) )
+ if( ci && ( cg_teamChatsOnly.integer ||
+ Com_ClientListContains( &cgs.ignoreList, clientNum ) ) )
CG_Printf( "[skipnotify]%s", sayText );
else
+ {
CG_Printf( "%s", sayText );
+ trap_S_StartLocalSound( cgs.media.talkSound, CHAN_LOCAL_SOUND );
+ }
}
/*
@@ -941,23 +956,43 @@ static void CG_Say( int clientNum, char *text )
CG_SayTeam
=================
*/
-static void CG_SayTeam( int clientNum, char *text )
+static void CG_SayTeam( int clientNum, const char *text )
{
clientInfo_t *ci;
- char sayText[ MAX_SAY_TEXT ] = {""};
+ char sayText[ MAX_STRING_CHARS ];
+ char *location = "", *name;
- if( clientNum < 0 || clientNum >= MAX_CLIENTS )
- return;
+ if( clientNum >= 0 && clientNum < MAX_CLIENTS )
+ ci = &cgs.clientinfo[ clientNum ];
+ else
+ ci = NULL;
- ci = &cgs.clientinfo[ clientNum ];
- Com_sprintf( sayText, sizeof( sayText ),
- "%s: " S_COLOR_CYAN "%s" S_COLOR_WHITE "\n",
- ci->name, text );
+ // don't always use "unknown"
+ if( ci && ci->location > 0 && ci->location < MAX_LOCATIONS )
+ {
+ const char *s = CG_ConfigString( CS_LOCATIONS + ci->location );
+ if( *s )
+ location = va( " (%s" S_COLOR_WHITE ")", s );
+ }
- if( Com_ClientListContains( &cgs.ignoreList, clientNum ) )
+ if( ci )
+ name = ci->name;
+ else
+ name = "console";
+
+ Com_sprintf( sayText, sizeof( sayText ), "%s%s: " S_COLOR_CYAN "%s\n",
+ name, location, text );
+
+ if( ci && Com_ClientListContains( &cgs.ignoreList, clientNum ) )
CG_Printf( "[skipnotify]%s", sayText );
else
+ {
CG_Printf( "%s", sayText );
+ if( cg.snap->ps.stats[ STAT_TEAM ] == TEAM_ALIENS )
+ trap_S_StartLocalSound( cgs.media.alienTalkSound, CHAN_LOCAL_SOUND );
+ else if( cg.snap->ps.stats[ STAT_TEAM ] == TEAM_HUMANS )
+ trap_S_StartLocalSound( cgs.media.humanTalkSound, CHAN_LOCAL_SOUND );
+ }
}
/*
@@ -1123,28 +1158,18 @@ CG_Chat_f
*/
static void CG_Chat_f( void )
{
- char cmd[ 6 ], text[ MAX_SAY_TEXT ];
+ char cmd[ 6 ];
qboolean team;
trap_Argv( 0, cmd, sizeof( cmd ) );
team = Q_stricmp( cmd, "chat" );
- if( team && cg_teamChatsOnly.integer )
- return;
-
- Q_strncpyz( text, CG_Argv( 1 ), sizeof( text ) );
+ trap_Argv( 1, cmd, sizeof( cmd ) );
- if( Q_stricmpn( text, "[skipnotify]", 12 ) )
- {
- if( team && cg.snap->ps.stats[ STAT_TEAM ] == TEAM_ALIENS )
- trap_S_StartLocalSound( cgs.media.alienTalkSound, CHAN_LOCAL_SOUND );
- else if( team && cg.snap->ps.stats[ STAT_TEAM ] == TEAM_HUMANS )
- trap_S_StartLocalSound( cgs.media.humanTalkSound, CHAN_LOCAL_SOUND );
- else
- trap_S_StartLocalSound( cgs.media.talkSound, CHAN_LOCAL_SOUND );
- }
-
- CG_Printf( "%s\n", text );
+ if( team )
+ CG_SayTeam( atoi( cmd ), CG_Argv( 2 ) );
+ else
+ CG_Say( atoi( cmd ), CG_Argv( 2 ) );
}
/*