summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authorM. Kristall <mkpdev@gmail.com>2012-07-13 01:20:54 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:18:17 +0000
commitc78e04f4c834d88dbada2e961e65b43c7bfbf424 (patch)
tree7348a70d38933bb3e4978778d616bc02edccdc72 /src/game
parent22f97fece2bce63f57e0b8fca275281429705c9c (diff)
* Smarter way to check if teamoverlay info should be sent; don't send upgrade
field for aliens
Diffstat (limited to 'src/game')
-rw-r--r--src/game/g_active.c6
-rw-r--r--src/game/g_client.c10
-rw-r--r--src/game/g_cmds.c8
-rw-r--r--src/game/g_combat.c5
-rw-r--r--src/game/g_local.h9
-rw-r--r--src/game/g_team.c62
6 files changed, 67 insertions, 33 deletions
diff --git a/src/game/g_active.c b/src/game/g_active.c
index 5adfa847..edd57a6a 100644
--- a/src/game/g_active.c
+++ b/src/game/g_active.c
@@ -1845,7 +1845,11 @@ void ClientEndFrame( gentity_t *ent )
else
ent->s.eFlags &= ~EF_CONNECTION;
- ent->client->ps.stats[ STAT_HEALTH ] = ent->health; // FIXME: get rid of ent->health...
+ if( ent->client->ps.stats[ STAT_HEALTH ] != ent->health )
+ {
+ ent->client->ps.stats[ STAT_HEALTH ] = ent->health; // FIXME: get rid of ent->health...
+ ent->client->pers.infoChangeTime = level.time;
+ }
// respawn if dead
if( ent->client->ps.stats[ STAT_HEALTH ] <= 0 && level.time >= ent->client->respawnTime )
diff --git a/src/game/g_client.c b/src/game/g_client.c
index 88e75d0b..96b16c3d 100644
--- a/src/game/g_client.c
+++ b/src/game/g_client.c
@@ -980,9 +980,13 @@ char *ClientUserinfoChanged( int clientNum, qboolean forceName )
s = Info_ValueForKey( userinfo, "teamoverlay" );
if( atoi( s ) != 0 )
- client->pers.teamInfo = qtrue;
+ {
+ // teamoverlay was enabled so we need an update
+ if( client->pers.teamInfo == 0 )
+ client->pers.teamInfo = 1;
+ }
else
- client->pers.teamInfo = qfalse;
+ client->pers.teamInfo = 0;
s = Info_ValueForKey( userinfo, "cg_unlagged" );
if( !s[0] || atoi( s ) != 0 )
@@ -1516,6 +1520,8 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn, vec3_t origin, vec3_t angles
// clear entity state values
BG_PlayerStateToEntityState( &client->ps, &ent->s, qtrue );
+
+ client->pers.infoChangeTime = level.time;
}
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c
index 664df9fa..5299af18 100644
--- a/src/game/g_cmds.c
+++ b/src/game/g_cmds.c
@@ -2238,10 +2238,14 @@ void Cmd_Buy_f( gentity_t *ent )
G_AddCreditToClient( ent->client, -(short)BG_Upgrade( upgrade )->price, qfalse );
}
else
+ {
G_TriggerMenu( ent->client->ps.clientNum, MN_H_UNKNOWNITEM );
+ return;
+ }
//update ClientInfo
ClientUserinfoChanged( ent->client->ps.clientNum, qfalse );
+ ent->client->pers.infoChangeTime = level.time;
}
@@ -2412,10 +2416,14 @@ void Cmd_Sell_f( gentity_t *ent )
}
}
else
+ {
G_TriggerMenu( ent->client->ps.clientNum, MN_H_UNKNOWNITEM );
+ return;
+ }
//update ClientInfo
ClientUserinfoChanged( ent->client->ps.clientNum, qfalse );
+ ent->client->pers.infoChangeTime = level.time;
}
diff --git a/src/game/g_combat.c b/src/game/g_combat.c
index fcdc2ee2..6cb06309 100644
--- a/src/game/g_combat.c
+++ b/src/game/g_combat.c
@@ -419,6 +419,8 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int
}
trap_LinkEntity( self );
+
+ self->client->pers.infoChangeTime = level.time;
}
/*
@@ -1139,7 +1141,10 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker,
targ->health = targ->health - take;
if( targ->client )
+ {
targ->client->ps.stats[ STAT_HEALTH ] = targ->health;
+ targ->client->pers.infoChangeTime = level.time;
+ }
targ->lastDamageTime = level.time;
targ->nextRegenTime = level.time + ALIEN_REGEN_DAMAGE_TIME;
diff --git a/src/game/g_local.h b/src/game/g_local.h
index 81700620..05fea6df 100644
--- a/src/game/g_local.h
+++ b/src/game/g_local.h
@@ -310,7 +310,7 @@ typedef struct
char netname[ MAX_NAME_LENGTH ];
int enterTime; // level.time the client entered the game
int location; // player locations
- qboolean teamInfo; // send team overlay updates?
+ int teamInfo; // level.time of team overlay update (disabled = 0)
float flySpeed; // for spectator/noclip moves
qboolean disableBlueprintErrors; // should the buildable blueprint never be hidden from the players?
@@ -340,9 +340,10 @@ typedef struct
char guid[ 33 ];
addr_t ip;
char voice[ MAX_VOICE_NAME_LEN ];
- qboolean useUnlagged;
- // keep track of other players' info for tinfo
- char cinfo[ MAX_CLIENTS ][ 16 ];
+ qboolean useUnlagged;
+
+ // level.time when teamoverlay info changed so we know to tell other players
+ int infoChangeTime;
} clientPersistant_t;
#define MAX_UNLAGGED_MARKERS 10
diff --git a/src/game/g_team.c b/src/game/g_team.c
index a527ff91..ec387acd 100644
--- a/src/game/g_team.c
+++ b/src/game/g_team.c
@@ -301,15 +301,15 @@ Format:
*/
void TeamplayInfoMessage( gentity_t *ent )
{
- char entry[ 19 ], string[ 1143 ];
+ char entry[ 17 ],
+ string[ ( MAX_CLIENTS - 1 ) * ( sizeof( entry ) - 1 ) + 1 ];
int i, j;
int team, stringlength;
- int sent = 0;
gentity_t *player;
gclient_t *cl;
upgrade_t upgrade = UP_NONE;
int curWeaponClass = WP_NONE ; // sends weapon for humans, class for aliens
- char *tmp;
+ char *format;
if( !g_allowTeamOverlay.integer )
return;
@@ -328,10 +328,15 @@ void TeamplayInfoMessage( gentity_t *ent )
else
team = ent->client->pers.teamSelection;
+ if( team == TEAM_ALIENS )
+ format = " %i %i %i %i"; // aliens don't have upgrades
+ else
+ format = " %i %i %i %i %i";
+
string[ 0 ] = '\0';
stringlength = 0;
- for( i = 0; i < MAX_CLIENTS; i++)
+ for( i = 0; i < level.maxclients; i++)
{
player = g_entities + i ;
cl = player->client;
@@ -340,6 +345,10 @@ void TeamplayInfoMessage( gentity_t *ent )
!player->inuse )
continue;
+ // only update if changed since last time
+ if( cl->pers.infoChangeTime <= ent->client->pers.teamInfo )
+ continue;
+
if( cl->sess.spectatorState != SPECTATOR_NOT )
{
curWeaponClass = WP_NONE;
@@ -367,36 +376,28 @@ void TeamplayInfoMessage( gentity_t *ent )
curWeaponClass = cl->ps.stats[ STAT_CLASS ];
upgrade = UP_NONE;
}
-
- tmp = va( "%i %i %i %i",
- player->client->pers.location,
- player->client->ps.stats[ STAT_HEALTH ] < 1 ? 0 :
- player->client->ps.stats[ STAT_HEALTH ],
- curWeaponClass,
- upgrade );
- if( !strcmp( ent->client->pers.cinfo[ i ], tmp ) )
- continue;
-
- Q_strncpyz( ent->client->pers.cinfo[ i ], tmp,
- sizeof( ent->client->pers.cinfo[ i ] ) );
-
- Com_sprintf( entry, sizeof( entry ), " %i %s", i, tmp );
+ Com_sprintf( entry, sizeof( entry ), format, i,
+ cl->pers.location,
+ cl->ps.stats[ STAT_HEALTH ] < 1 ? 0 : cl->ps.stats[ STAT_HEALTH ],
+ curWeaponClass,
+ upgrade );
j = strlen( entry );
- if( stringlength + j > sizeof( string ) )
+ // this should not happen if entry and string sizes are correct
+ if( stringlength + j >= sizeof( string ) )
break;
strcpy( string + stringlength, entry );
stringlength += j;
- sent++;
}
- if( !sent )
- return;
-
- trap_SendServerCommand( ent - g_entities, va( "tinfo%s", string ) );
+ if( string[ 0 ] )
+ {
+ trap_SendServerCommand( ent - g_entities, va( "tinfo%s", string ) );
+ ent->client->pers.teamInfo = level.time;
+ }
}
void CheckTeamStatus( void )
@@ -421,9 +422,18 @@ void CheckTeamStatus( void )
loc = Team_GetLocation( ent );
if( loc )
- ent->client->pers.location = loc->s.generic1;
- else
+ {
+ if( ent->client->pers.location != loc->s.generic1 )
+ {
+ ent->client->pers.infoChangeTime = level.time;
+ ent->client->pers.location = loc->s.generic1;
+ }
+ }
+ else if( ent->client->pers.location != 0 )
+ {
+ ent->client->pers.infoChangeTime = level.time;
ent->client->pers.location = 0;
+ }
}
}