diff options
author | Roman Tetelman <kevlarman@gmail.com> | 2009-10-03 11:55:12 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-03 00:15:31 +0000 |
commit | bf88e3e18ce55a397e2ec674c3541c606a0fe8ea (patch) | |
tree | c459570d6a6008c0a1abe4ff3499a41ea457ffd3 /src/game/g_cmds.c | |
parent | 1402c0d169f3db4af74084cd323312c05b14db3b (diff) |
* revert part of r77 to allow clients to keep their credits
* put back clientPersistant_t.savedCredits
Diffstat (limited to 'src/game/g_cmds.c')
-rw-r--r-- | src/game/g_cmds.c | 32 |
1 files changed, 30 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 ); } |