diff options
author | Roman Tetelman <kevlarman@gmail.com> | 2009-10-03 13:12:54 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-03 00:16:33 +0000 |
commit | 35b32cb279049ff764534fdc153bf37b00c6a004 (patch) | |
tree | e9e2dc50a3305e1e1d8556224ffd1a506521954c /src/game | |
parent | ea3939f5a0e08267b482def6d49e4c438f7c4663 (diff) |
* store credits in pers.credit instead of ps.stats[ PERS_CREDIT ]
Diffstat (limited to 'src/game')
-rw-r--r-- | src/game/g_client.c | 15 | ||||
-rw-r--r-- | src/game/g_cmds.c | 2 | ||||
-rw-r--r-- | src/game/g_local.h | 2 | ||||
-rw-r--r-- | src/game/g_ptr.c | 5 | ||||
-rw-r--r-- | src/game/g_team.c | 19 |
5 files changed, 18 insertions, 25 deletions
diff --git a/src/game/g_client.c b/src/game/g_client.c index 1f1f7029..f0eaeeb0 100644 --- a/src/game/g_client.c +++ b/src/game/g_client.c @@ -91,15 +91,18 @@ void G_AddCreditToClient( gclient_t *client, short credit, qboolean cap ) if( !client ) return; - client->ps.persistant[ PERS_CREDIT ] += credit; - capAmount = client->ps.stats[ STAT_TEAM ] == TEAM_ALIENS ? + client->pers.credit += credit; + capAmount = client->pers.teamSelection == TEAM_ALIENS ? ALIEN_MAX_CREDITS : HUMAN_MAX_CREDITS; - if( cap && client->ps.persistant[ PERS_CREDIT ] > capAmount ) - client->ps.persistant[ PERS_CREDIT ] = capAmount; + if( cap && client->pers.credit > capAmount ) + client->pers.credit = capAmount; - if( client->ps.persistant[ PERS_CREDIT ] < 0 ) - client->ps.persistant[ PERS_CREDIT ] = 0; + if( client->pers.credit < 0 ) + client->pers.credit = 0; + + // Copy to ps so the client can access it + client->ps.persistant[ PERS_CREDIT ] = client->pers.credit; } diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 3a38fc85..f6164ac8 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -2975,7 +2975,7 @@ void Cmd_PTRCRestore_f( gentity_t *ent ) G_ChangeTeam( ent, connection->clientTeam ); // set the correct credit - ent->client->ps.persistant[ PERS_CREDIT ] = 0; + ent->client->pers.credit = 0; G_AddCreditToClient( ent->client, connection->clientCredit, qtrue ); } } diff --git a/src/game/g_local.h b/src/game/g_local.h index 05b9701b..0202be7e 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -324,7 +324,7 @@ typedef struct int nameChanges; // used to save persistant[] values while in SPECTATOR_FOLLOW mode - int savedCredit; + int credit; // votes qboolean vote; diff --git a/src/game/g_ptr.c b/src/game/g_ptr.c index 869df256..1afef0e9 100644 --- a/src/game/g_ptr.c +++ b/src/game/g_ptr.c @@ -62,10 +62,7 @@ void G_UpdatePTRConnection( gclient_t *client ) if( client && client->pers.connection ) { client->pers.connection->clientTeam = client->pers.teamSelection; - if( client->pers.teamSelection == TEAM_NONE ) - client->pers.connection->clientCredit = client->pers.savedCredit; - else - client->pers.connection->clientCredit = client->ps.persistant[ PERS_CREDIT ]; + client->pers.connection->clientCredit = client->pers.credit; } } diff --git a/src/game/g_team.c b/src/game/g_team.c index 856e0f20..5a2d5438 100644 --- a/src/game/g_team.c +++ b/src/game/g_team.c @@ -145,31 +145,24 @@ void G_ChangeTeam( gentity_t *ent, team_t newTeam ) if( oldTeam == TEAM_NONE ) { - // ps.persistant[] from a spectator cannot be trusted - ent->client->ps.persistant[ PERS_CREDIT ] = ent->client->pers.savedCredit; + // Copy credits to ps for the client + ent->client->ps.persistant[ PERS_CREDIT ] = ent->client->pers.credit; } else if( oldTeam == TEAM_HUMANS && newTeam == TEAM_ALIENS ) { // Convert from human to alien credits - ent->client->ps.persistant[ PERS_CREDIT ] = - (int)( ent->client->ps.persistant[ PERS_CREDIT ] * + ent->client->pers.credit = + (int)( ent->client->pers.credit * ALIEN_MAX_CREDITS / HUMAN_MAX_CREDITS + 0.5f ); } else if( oldTeam == TEAM_ALIENS && newTeam == TEAM_HUMANS ) { // Convert from alien to human credits - ent->client->ps.persistant[ PERS_CREDIT ] = - (int)( ent->client->ps.persistant[ PERS_CREDIT ] * + ent->client->pers.credit = + (int)( ent->client->pers.credit * HUMAN_MAX_CREDITS / ALIEN_MAX_CREDITS + 0.5f ); } - if( newTeam == TEAM_NONE ) - { - // save values before the client enters the spectator team and their - // ps.persistant[] values become trashed - ent->client->pers.savedCredit = ent->client->ps.persistant[ PERS_CREDIT ]; - } - ClientUserinfoChanged( ent->client->ps.clientNum ); if( oldTeam != TEAM_NONE && newTeam != TEAM_NONE ) |