summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Schwarz <lakitu7@gmail.com>2009-10-17 23:52:06 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:16:54 +0000
commit6656710cba61c602bfaf01ed506ee5c57859ab0e (patch)
treeb405229e13e20823eab1b5458770d8eadf889990
parent0a04cdb367d94c1316bf00de3d09f7b1bd3adb92 (diff)
* Fix buffer problems in CG_Say preventing locations from showing
* Fix showing your own location in CG_Say
-rw-r--r--src/cgame/cg_servercmds.c42
1 files changed, 26 insertions, 16 deletions
diff --git a/src/cgame/cg_servercmds.c b/src/cgame/cg_servercmds.c
index 0cf7f144..cfb3ad59 100644
--- a/src/cgame/cg_servercmds.c
+++ b/src/cgame/cg_servercmds.c
@@ -915,18 +915,19 @@ CG_Say
static void CG_Say( int clientNum, saymode_t mode, const char *text )
{
clientInfo_t *ci;
- char *prefix, *name;
- char *ignore = "";
- char *location = "";
- char tcolor = COLOR_WHITE;
- char color;
+ char *name;
+ char prefix[ 11 ] = "";
+ char *ignore = "";
+ int locationNum = 0;
+ char *location = "";
+ char tcolor = COLOR_WHITE;
+ char color;
if( clientNum >= 0 && clientNum < MAX_CLIENTS )
ci = &cgs.clientinfo[ clientNum ];
else
ci = NULL;
-
if( ci )
{
name = va( "%s" S_COLOR_WHITE, ci->name );
@@ -939,18 +940,27 @@ static void CG_Say( int clientNum, saymode_t mode, const char *text )
name = "console";
if( ci && cg_chatTeamPrefix.integer )
- prefix = va( "[^%c%c" S_COLOR_WHITE "] " S_COLOR_WHITE,
+ Com_sprintf( prefix, sizeof( prefix ), "[^%c%c" S_COLOR_WHITE "] " S_COLOR_WHITE,
tcolor, toupper( *( BG_TeamName( ci->team ) ) ) );
- else
- prefix = "";
- if( mode == SAY_TEAM || mode == SAY_AREA )
- // don't always use "unknown"
- if( ci && ci->location > 0 && ci->location < MAX_LOCATIONS )
+ if( ci && ( mode == SAY_TEAM || mode == SAY_AREA ) )
{
- const char *s = CG_ConfigString( CS_LOCATIONS + ci->location );
- if( *s )
- location = va( " (%s" S_COLOR_WHITE ")", s );
+ if( clientNum == cg.snap->ps.clientNum )
+ {
+ centity_t *locent;
+
+ locent = CG_GetPlayerLocation( );
+ locationNum = locent->currentState.generic1;
+ }
+ else
+ locationNum = ci->location;
+
+ if( locationNum > 0 && locationNum < MAX_LOCATIONS )
+ {
+ const char *s = CG_ConfigString( CS_LOCATIONS + locationNum );
+ if( *s )
+ location = va( " (%s" S_COLOR_WHITE ")", s );
+ }
}
if( ci && Com_ClientListContains( &cgs.ignoreList, clientNum ) )
@@ -976,7 +986,7 @@ static void CG_Say( int clientNum, saymode_t mode, const char *text )
CG_Printf( "%s%s[PLAYER]%s: " S_COLOR_MAGENTA "%s\n", ignore, prefix, name, text );
break;
case SAY_AREA:
- CG_Printf( "%s%s<%s>: " S_COLOR_BLUE "%s\n", ignore, prefix, name, text );
+ CG_Printf( "%s%s<%s>%s: " S_COLOR_BLUE "%s\n", ignore, prefix, name, location, text );
break;
case SAY_PRIVMSG:
case SAY_TPRIVMSG: