summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoman Tetelman <kevlarman@gmail.com>2009-10-03 11:55:12 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:15:31 +0000
commitbf88e3e18ce55a397e2ec674c3541c606a0fe8ea (patch)
treec459570d6a6008c0a1abe4ff3499a41ea457ffd3 /src
parent1402c0d169f3db4af74084cd323312c05b14db3b (diff)
* revert part of r77 to allow clients to keep their credits
* put back clientPersistant_t.savedCredits
Diffstat (limited to 'src')
-rw-r--r--src/game/g_cmds.c32
-rw-r--r--src/game/g_local.h3
2 files changed, 33 insertions, 2 deletions
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c
index bd819988..48bc3a0a 100644
--- a/src/game/g_cmds.c
+++ b/src/game/g_cmds.c
@@ -595,8 +595,36 @@ void G_ChangeTeam( gentity_t *ent, team_t newTeam )
ClientSpawn( ent, NULL, NULL, NULL );
ent->client->pers.joinedATeam = qtrue;
ent->client->pers.teamChangeTime = level.time;
- ent->client->pers.credit = 0;
- ent->client->ps.persistant[ PERS_CREDIT ] = 0;
+
+ if( oldTeam == TEAM_NONE )
+ {
+ // ps.persistant[] from a spectator cannot be trusted
+ ent->client->ps.persistant[ PERS_CREDIT ] = ent->client->pers.savedCredit;
+ }
+ 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 ] *
+ 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 ] *
+ HUMAN_MAX_CREDITS / ALIEN_MAX_CREDITS + 0.5f );
+ }
+
+ ent->client->pers.credit = ent->client->ps.persistant[ PERS_CREDIT ];
+
+ 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 );
}
diff --git a/src/game/g_local.h b/src/game/g_local.h
index 764892ab..d7bb0a6f 100644
--- a/src/game/g_local.h
+++ b/src/game/g_local.h
@@ -323,6 +323,9 @@ typedef struct
int credit;
int ping;
+ // used to save persistant[] values while in SPECTATOR_FOLLOW mode
+ int savedCredit;
+
// votes
qboolean vote;
qboolean teamVote;