diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/game/g_client.c | 14 | ||||
-rw-r--r-- | src/game/g_cmds.c | 54 | ||||
-rw-r--r-- | src/game/g_local.h | 1 |
3 files changed, 51 insertions, 18 deletions
diff --git a/src/game/g_client.c b/src/game/g_client.c index 75136661..041821a2 100644 --- a/src/game/g_client.c +++ b/src/game/g_client.c @@ -1661,20 +1661,13 @@ void ClientDisconnect( int clientNum ) return; G_admin_namelog_update( ent->client, qtrue ); + G_LeaveTeam( ent ); // stop any following clients for( i = 0; i < level.maxclients; i++ ) { // remove any /ignore settings for this clientNum BG_ClientListRemove( &level.clients[ i ].sess.ignoreList, clientNum ); - - if( level.clients[ i ].sess.sessionTeam == TEAM_SPECTATOR && - level.clients[ i ].sess.spectatorState == SPECTATOR_FOLLOW && - level.clients[ i ].sess.spectatorClient == clientNum ) - { - if( !G_FollowNewClient( &g_entities[ i ], 1 ) ) - G_StopFollowing( &g_entities[ i ] ); - } } // send effect if they were completely connected @@ -1688,11 +1681,6 @@ void ClientDisconnect( int clientNum ) G_LogPrintf( "ClientDisconnect: %i [%s] (%s) \"%s\"\n", clientNum, ent->client->pers.ip, ent->client->pers.guid, ent->client->pers.netname ); - if( ent->client->pers.teamSelection == PTE_ALIENS ) - G_RemoveFromSpawnQueue( &level.alienSpawnQueue, ent->client->ps.clientNum ); - else if( ent->client->pers.teamSelection == PTE_HUMANS ) - G_RemoveFromSpawnQueue( &level.humanSpawnQueue, ent->client->ps.clientNum ); - trap_UnlinkEntity( ent ); ent->s.modelindex = 0; ent->inuse = qfalse; 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 ) || diff --git a/src/game/g_local.h b/src/game/g_local.h index a059751f..0015e54e 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -682,6 +682,7 @@ int G_SayArgc( void ); qboolean G_SayArgv( int n, char *buffer, int bufferLength ); char *G_SayConcatArgs( int start ); void G_DecolorString( char *in, char *out ); +void G_LeaveTeam( gentity_t *self ); void G_ChangeTeam( gentity_t *ent, pTeam_t newTeam ); void G_SanitiseName( char *in, char *out ); void G_PrivateMessage( gentity_t *ent ); |