summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cgame/cg_draw.c9
-rw-r--r--src/cgame/cg_ents.c24
-rw-r--r--src/cgame/cg_local.h7
-rw-r--r--src/cgame/cg_players.c28
-rw-r--r--src/cgame/cg_syscalls.c5
-rw-r--r--src/game/bg_public.h2
-rw-r--r--src/game/g_target.c7
-rw-r--r--src/game/g_team.c42
8 files changed, 92 insertions, 32 deletions
diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c
index 5f28cc57..0f407803 100644
--- a/src/cgame/cg_draw.c
+++ b/src/cgame/cg_draw.c
@@ -2261,10 +2261,17 @@ CG_DrawLocation
static void CG_DrawLocation( rectDef_t *rect, float scale, int textalign, vec4_t color )
{
const char *location;
+ centity_t *locent;
float maxX;
float tx = rect->x, ty = rect->y;
maxX = rect->x + rect->w;
- location = CG_ConfigString( CS_LOCATIONS + cgs.clientinfo[ cg.clientNum ].location );
+
+ locent = CG_GetLocation( &cg_entities[ cg.clientNum ] );
+ if( locent )
+ location = CG_ConfigString( CS_LOCATIONS + locent->currentState.generic1 );
+ else
+ location = CG_ConfigString( CS_LOCATIONS );
+
if( UI_Text_Width( location, scale, 0 ) < rect->w )
CG_AlignText( rect, location, scale, 0.0f, 0.0f, textalign, VALIGN_CENTER, &tx, &ty );
diff --git a/src/cgame/cg_ents.c b/src/cgame/cg_ents.c
index e8a217db..54409aee 100644
--- a/src/cgame/cg_ents.c
+++ b/src/cgame/cg_ents.c
@@ -811,6 +811,26 @@ static void CG_LightFlare( centity_t *cent )
/*
=========================
+CG_LinkLocation
+=========================
+*/
+void CG_LinkLocation( centity_t *cent )
+{
+ centity_t *tempent;
+
+ for( tempent = cg.locationHead; tempent; tempent = tempent->nextLocation )
+ {
+ if( tempent == cent )
+ return;
+ }
+
+ cent->nextLocation = cg.locationHead;
+ cg.locationHead = cent;
+
+}
+
+/*
+=========================
CG_AdjustPositionForMover
Also called by client movement prediction code
@@ -1090,6 +1110,10 @@ static void CG_AddCEntity( centity_t *cent )
case ET_LIGHTFLARE:
CG_LightFlare( cent );
break;
+
+ case ET_LOCATION:
+ CG_LinkLocation( cent );
+ break;
}
}
diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h
index f2807044..764d8183 100644
--- a/src/cgame/cg_local.h
+++ b/src/cgame/cg_local.h
@@ -682,6 +682,7 @@ typedef struct centity_s
qboolean valid;
qboolean oldValid;
+ struct centity_s *nextLocation;
} centity_t;
@@ -1161,6 +1162,8 @@ typedef struct
float healthCrossFade;
int nextWeaponClickTime;
+
+ centity_t *locationHead;
} cg_t;
@@ -1646,6 +1649,7 @@ void CG_PrecacheClientInfo( class_t class, char *model, char *skin );
sfxHandle_t CG_CustomSound( int clientNum, const char *soundName );
void CG_PlayerDisconnect( vec3_t org );
void CG_Bleed( vec3_t origin, vec3_t normal, int entityNum );
+centity_t *CG_GetLocation( centity_t *cent );
//
// cg_buildable.c
@@ -1707,7 +1711,7 @@ void CG_PositionEntityOnTag( refEntity_t *entity, const refEntity_t *pare
qhandle_t parentModel, char *tagName );
void CG_PositionRotatedEntityOnTag( refEntity_t *entity, const refEntity_t *parent,
qhandle_t parentModel, char *tagName );
-
+void CG_LinkLocation( centity_t* cent );
@@ -1984,6 +1988,7 @@ void trap_R_AddRefEntityToScene( const refEntity_t *re );
// significant construction
void trap_R_AddPolyToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts );
void trap_R_AddPolysToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts, int numPolys );
+qboolean trap_R_inPVS( const vec3_t p1, const vec3_t p2 );
void trap_R_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b );
void trap_R_AddAdditiveLightToScene( const vec3_t org, float intensity, float r, float g, float b );
int trap_R_LightForPoint( vec3_t point, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir );
diff --git a/src/cgame/cg_players.c b/src/cgame/cg_players.c
index 6fa577f6..54c5acd4 100644
--- a/src/cgame/cg_players.c
+++ b/src/cgame/cg_players.c
@@ -2369,3 +2369,31 @@ void CG_PlayerDisconnect( vec3_t org )
}
}
+centity_t *CG_GetLocation( centity_t *cent )
+{
+ centity_t *eloc, *best;
+ float bestlen, len;
+ vec3_t origin;
+ trace_t tr;
+
+ best = NULL;
+ bestlen = 3.0f * 8192.0f * 8192.0f;
+
+ VectorCopy( cent->lerpOrigin, origin );
+
+ for( eloc = cg.locationHead; eloc; eloc = eloc->nextLocation )
+ {
+ len = DistanceSquared(origin, eloc->lerpOrigin);
+
+ if( len > bestlen )
+ continue;
+
+ if( !trap_R_inPVS( origin, eloc->lerpOrigin ) )
+ continue;
+
+ bestlen = len;
+ best = eloc;
+ }
+
+ return best;
+}
diff --git a/src/cgame/cg_syscalls.c b/src/cgame/cg_syscalls.c
index 01b7ca85..b990ab8e 100644
--- a/src/cgame/cg_syscalls.c
+++ b/src/cgame/cg_syscalls.c
@@ -345,6 +345,11 @@ void trap_R_AddPolyToScene( qhandle_t hShader , int numVerts, const polyVert_t *
syscall( CG_R_ADDPOLYTOSCENE, hShader, numVerts, verts );
}
+qboolean trap_R_inPVS( const vec3_t p1, const vec3_t p2 )
+{
+ syscall( CG_R_INPVS, p1, p2 );
+}
+
void trap_R_AddPolysToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts, int num )
{
syscall( CG_R_ADDPOLYSTOSCENE, hShader, numVerts, verts, num );
diff --git a/src/game/bg_public.h b/src/game/bg_public.h
index b40863df..df1bc0ba 100644
--- a/src/game/bg_public.h
+++ b/src/game/bg_public.h
@@ -1167,6 +1167,8 @@ typedef enum
ET_BUILDABLE, // buildable type
+ ET_LOCATION,
+
ET_MISSILE,
ET_MOVER,
ET_BEAM,
diff --git a/src/game/g_target.c b/src/game/g_target.c
index b2c2d9ab..9e110162 100644
--- a/src/game/g_target.c
+++ b/src/game/g_target.c
@@ -298,10 +298,10 @@ static void target_location_linkup( gentity_t *ent )
for( i = 0, ent = g_entities, n = 1; i < level.num_entities; i++, ent++)
{
- if( ent->classname && !Q_stricmp( ent->classname, "target_location" ) )
+ if( ent->s.eType == ET_LOCATION )
{
// lets overload some variables!
- ent->health = n; // use for location marking
+ ent->s.generic1 = n; // use for location marking
trap_SetConfigstring( CS_LOCATIONS + n, ent->message );
n++;
ent->nextTrain = level.locationHead;
@@ -323,7 +323,8 @@ void SP_target_location( gentity_t *self )
{
self->think = target_location_linkup;
self->nextthink = level.time + 200; // Let them all spawn first
-
+ self->s.eType = ET_LOCATION;
+ trap_LinkEntity( self ); // make the server send them to the clients
G_SetOrigin( self, self->s.origin );
}
diff --git a/src/game/g_team.c b/src/game/g_team.c
index 845ea65e..7ec6855c 100644
--- a/src/game/g_team.c
+++ b/src/game/g_team.c
@@ -77,7 +77,7 @@ gentity_t *Team_GetLocation( gentity_t *ent )
best = NULL;
bestlen = 3.0f * 8192.0f * 8192.0f;
- VectorCopy( ent->client->ps.origin, origin );
+ VectorCopy( ent->r.currentOrigin, origin );
for( eloc = level.locationHead; eloc; eloc = eloc->nextTrain )
{
@@ -160,28 +160,9 @@ void TeamplayInfoMessage( gentity_t *ent )
int h, a = 0;
int clients[ TEAM_MAXOVERLAY ];
- //hack: always send each client's teaminfo to it for CG_PLAYER_LOCATION
- h = ent->client->ps.stats[ STAT_HEALTH ];
- if( h < 0 )
- h = 0;
-
- trap_SendServerCommand( ent - g_entities,
- va("tinfo %i %i %i %i %i %i",
- 1,
- ent - g_entities,
- ent->client->pers.location,
- h,
- a,
- ent->client->ps.weapon ) );
-
if( ! ent->client->pers.teamInfo )
return;
- if( !ent->inuse ||
- ( !( ent->client->ps.stats[ STAT_TEAM ] == TEAM_HUMANS ) &&
- !( ent->client->ps.stats[ STAT_TEAM ] == TEAM_ALIENS ) ) )
- return;
-
// figure out what client should be on the display
// we are limited to 8, but we want to use the top eight players
// but in client order (so they don't keep changing position on the overlay)
@@ -247,12 +228,17 @@ void CheckTeamStatus( void )
if( ent->client->pers.connected != CON_CONNECTED )
continue;
- loc = Team_GetLocation( ent );
- if( loc )
- ent->client->pers.location = loc->health;
- else
- ent->client->pers.location = 0;
-
+ if( ent->inuse && ( ent->client->ps.stats[ STAT_TEAM ] == TEAM_HUMANS ||
+ ent->client->ps.stats[ STAT_TEAM ] == TEAM_ALIENS ) )
+ {
+
+ loc = Team_GetLocation( ent );
+
+ if( loc )
+ ent->client->pers.location = loc->s.generic1;
+ else
+ ent->client->pers.location = 0;
+ }
}
for( i = 0; i < g_maxclients.integer; i++ )
@@ -261,7 +247,9 @@ void CheckTeamStatus( void )
if( ent->client->pers.connected != CON_CONNECTED )
continue;
- TeamplayInfoMessage( ent );
+ if( ent->inuse && ( ent->client->ps.stats[ STAT_TEAM ] == TEAM_HUMANS ||
+ ent->client->ps.stats[ STAT_TEAM ] == TEAM_ALIENS ) )
+ TeamplayInfoMessage( ent );
}
}
}