Пример #1
0
/*
===========
ClientDisconnect

Called when a player drops from the server.
Will not be called between levels.

This should NOT be called directly by any game logic,
call trap_DropClient(), which will call this and do
server system housekeeping.
============
*/
void ClientDisconnect( int clientNum )
{
  gentity_t *ent;
  gentity_t *tent;
  int       i;
  buildHistory_t *ptr;

  ent = g_entities + clientNum;

  if( !ent->client )
    return;

  // look through the bhist and readjust it if the referenced ent has left
  for( ptr = level.buildHistory; ptr; ptr = ptr->next )
  {
    if( ptr->ent == ent )
    {
      ptr->ent = NULL;
      Q_strncpyz( ptr->name, ent->client->pers.netname, MAX_NETNAME );
    }
  }

  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 );
  }

  // send effect if they were completely connected
  if( ent->client->pers.connected == CON_CONNECTED &&
      ent->client->sess.sessionTeam != TEAM_SPECTATOR )
  {
    tent = G_TempEntity( ent->client->ps.origin, EV_PLAYER_TELEPORT_OUT );
    tent->s.clientNum = ent->s.clientNum;
  }

  if( ent->client->pers.connection )
    ent->client->pers.connection->clientNum = -1;

  G_LogPrintf( "ClientDisconnect: %i [%s] (%s) \"%s\"\n", clientNum,
   ent->client->pers.ip, ent->client->pers.guid, ent->client->pers.netname );

  trap_UnlinkEntity( ent );
  ent->s.modelindex = 0;
  ent->inuse = qfalse;
  ent->classname = "disconnected";
  ent->client->pers.connected = CON_DISCONNECTED;
  ent->client->ps.persistant[ PERS_TEAM ] = TEAM_FREE;
  ent->client->sess.sessionTeam = TEAM_FREE;

  trap_SetConfigstring( CS_PLAYERS + clientNum, "");

  CalculateRanks( );
}
/*
===========
ClientDisconnect

Called when a player drops from the server.
Will not be called between levels.

This should NOT be called directly by any game logic,
call trap_DropClient(), which will call this and do
server system housekeeping.
============
*/
void ClientDisconnect( int clientNum )
{
  gentity_t *ent;
  gentity_t *tent;
  int       i;

  ent = g_entities + clientNum;

  if( !ent->client )
    return;

  G_admin_namelog_update( ent->client, qtrue );
  G_LeaveTeam( ent );
  G_Vote( ent, qfalse );

  // 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 );
  }

  // send effect if they were completely connected
  if( ent->client->pers.connected == CON_CONNECTED &&
      ent->client->sess.spectatorState == SPECTATOR_NOT )
  {
    tent = G_TempEntity( ent->client->ps.origin, EV_PLAYER_TELEPORT_OUT );
    tent->s.clientNum = ent->s.clientNum;
  }

  if( ent->client->pers.connection )
    ent->client->pers.connection->clientNum = -1;

  G_LogPrintf( "ClientDisconnect: %i [%s] (%s) \"%s\"\n", clientNum,
   ent->client->pers.ip, ent->client->pers.guid, ent->client->pers.netname );

  trap_UnlinkEntity( ent );
  ent->s.modelindex = 0;
  ent->inuse = qfalse;
  ent->classname = "disconnected";
  ent->client->pers.connected = CON_DISCONNECTED;
  ent->client->sess.spectatorState =
      ent->client->ps.persistant[ PERS_SPECSTATE ] = SPECTATOR_NOT;

  trap_SetConfigstring( CS_PLAYERS + clientNum, "");

  CalculateRanks( );
}