diff options
author | Tony J. White <tjw@tjw.org> | 2007-04-27 04:19:11 +0000 |
---|---|---|
committer | Tony J. White <tjw@tjw.org> | 2007-04-27 04:19:11 +0000 |
commit | a75a973733f62c9f1fe6f1c1787762db78973771 (patch) | |
tree | 3f99d6eb3e508e5cf793987bb95ae129eed8bbac /src/game/g_cmds.c | |
parent | bd0a1caa94f32c752ac2c4a589010bc5f4392acb (diff) |
* (bug 2958) new function G_LeaveTeam() takes care of cancelling out a player's
active missles, poision, and spectators following him when he
switches teams. (M. Kristall)
Diffstat (limited to 'src/game/g_cmds.c')
-rw-r--r-- | src/game/g_cmds.c | 54 |
1 files changed, 49 insertions, 5 deletions
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 4c204361..fe56d2ed 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -587,6 +587,54 @@ void Cmd_Kill_f( gentity_t *ent ) } /* +================== +G_LeaveTeam +================== +*/ +void G_LeaveTeam( gentity_t *self ) +{ + pTeam_t team = self->client->pers.teamSelection; + gentity_t *ent; + int i; + + if( team == PTE_ALIENS ) + G_RemoveFromSpawnQueue( &level.alienSpawnQueue, self->client->ps.clientNum ); + else if( team == PTE_HUMANS ) + G_RemoveFromSpawnQueue( &level.humanSpawnQueue, self->client->ps.clientNum ); + else + return; + + for( i = 0; i < level.num_entities; i++ ) + { + ent = &g_entities[ i ]; + if( !ent->inuse ) + continue; + + // clean up projectiles + if( ent->s.eType == ET_MISSILE && ent->r.ownerNum == self->s.number ) + G_FreeEntity( ent ); + if( ent->client && ent->client->pers.connected == CON_CONNECTED ) + { + // stop following clients + if( ent->client->sess.sessionTeam == TEAM_SPECTATOR && + ent->client->sess.spectatorState == SPECTATOR_FOLLOW && + ent->client->sess.spectatorClient == self->client->ps.clientNum ) + { + if( !G_FollowNewClient( ent, 1 ) ) + G_StopFollowing( ent ); + } + // cure poison + if( ent->client->ps.stats[ STAT_STATE ] & SS_POISONCLOUDED && + ent->client->lastPoisonCloudedClient == self ) + ent->client->ps.stats[ STAT_STATE ] &= ~SS_POISONCLOUDED; + if( ent->client->ps.stats[ STAT_STATE ] & SS_POISONED && + ent->client->lastPoisonClient == self ) + ent->client->ps.stats[ STAT_STATE ] &= ~SS_POISONED; + } + } +} + +/* ================= G_ChangeTeam ================= @@ -598,13 +646,9 @@ void G_ChangeTeam( gentity_t *ent, pTeam_t newTeam ) if( oldTeam == newTeam ) return; + G_LeaveTeam( ent ); ent->client->pers.teamSelection = newTeam; - if( oldTeam == PTE_ALIENS ) - G_RemoveFromSpawnQueue( &level.alienSpawnQueue, ent->client->ps.clientNum ); - else if( oldTeam == PTE_HUMANS ) - G_RemoveFromSpawnQueue( &level.humanSpawnQueue, ent->client->ps.clientNum ); - // under certain circumstances, clients can keep their kills and credits // when switching teams if( G_admin_permission( ent, ADMF_TEAMCHANGEFREE ) || |