From f62e00c4ac73d7b3803cad8bd8eaa260531b0381 Mon Sep 17 00:00:00 2001 From: /dev/humancontroller Date: Sun, 13 Jul 2014 19:16:08 +0200 Subject: also use configstring #CS_LOCATIONS+0 for storing location names includes some refactoring --- src/cgame/cg_draw.c | 7 +++---- src/cgame/cg_players.c | 4 ++-- src/cgame/cg_servercmds.c | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) (limited to 'src/cgame') diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c index 4d70b343..690df742 100644 --- a/src/cgame/cg_draw.c +++ b/src/cgame/cg_draw.c @@ -2645,10 +2645,9 @@ static void CG_DrawLocation( rectDef_t *rect, float scale, int textalign, vec4_t maxX = rect->x + rect->w; locent = CG_GetPlayerLocation( ); - if( locent ) - location = CG_ConfigString( CS_LOCATIONS + locent->currentState.generic1 ); - else - location = CG_ConfigString( CS_LOCATIONS ); + if( !locent ) + return; + location = CG_ConfigString( CS_LOCATIONS + locent->currentState.generic1 ); // need to skip horiz. align if it's too long, but valign must be run either way if( UI_Text_Width( location, scale ) < rect->w ) diff --git a/src/cgame/cg_players.c b/src/cgame/cg_players.c index 0060d661..6338ceaf 100644 --- a/src/cgame/cg_players.c +++ b/src/cgame/cg_players.c @@ -2381,7 +2381,7 @@ centity_t *CG_GetPlayerLocation( void ) vec3_t origin; best = NULL; - bestlen = 3.0f * 8192.0f * 8192.0f; + bestlen = 0.0f; VectorCopy( cg.predictedPlayerState.origin, origin ); @@ -2393,7 +2393,7 @@ centity_t *CG_GetPlayerLocation( void ) len = DistanceSquared(origin, eloc->lerpOrigin); - if( len > bestlen ) + if( best != NULL && len > bestlen ) continue; if( !trap_R_inPVS( origin, eloc->lerpOrigin ) ) diff --git a/src/cgame/cg_servercmds.c b/src/cgame/cg_servercmds.c index fec4cfae..f4fb1d54 100644 --- a/src/cgame/cg_servercmds.c +++ b/src/cgame/cg_servercmds.c @@ -909,12 +909,12 @@ static void CG_Say( int clientNum, saymode_t mode, const char *text ) if( locent ) locationNum = locent->currentState.generic1; else - locationNum = 0; + locationNum = -1; } else locationNum = ci->location; - if( locationNum > 0 && locationNum < MAX_LOCATIONS ) + if( locationNum >= 0 && locationNum < MAX_LOCATIONS ) { const char *s = CG_ConfigString( CS_LOCATIONS + locationNum ); -- cgit