bool ServerConnectDaemon::inConnectQueue( PlayerID &new_player_id )
{
    ConnectQueueElement connect_request;

    unsigned long iterator;
    bool       completed;

    connect_queue.resetIterator( &iterator );

    connect_request = connect_queue.incIterator( &iterator, &completed );

    while( completed == false ) {
        if ( connect_request.new_player_id.getNetworkID() ==
                new_player_id.getNetworkID() ) {
            return( true );
        }

        connect_request = connect_queue.incIterator( &iterator, &completed );
    }

    if ( (connection_state != _connect_state_idle) &&
            (connect_player_id.getNetworkID() == new_player_id.getNetworkID()  )
       )
        return( true );

    return( false );
}
bool ServerConnectDaemon::inConnectQueue( PlayerID &new_player_id )
{
    std::list<ConnectQueueElement>::iterator i;
    for(i = connect_queue.begin(); i != connect_queue.end(); ++i) {
        const ConnectQueueElement& connect_request = *i;

        if ( connect_request.new_player_id.getNetworkID() ==
                new_player_id.getNetworkID() ) {
            return true;
        }
    }

    if ( (connection_state != connect_state_idle) &&
            (connect_player_id.getNetworkID() == new_player_id.getNetworkID()  )
       )
        return true;

    return false;
}
int NetworkServerUnix::sendMessage(const PlayerID& player_id,
                                   NetMessage* message, size_t size, int flags)
{
#ifdef NETWORKDEBUG
    LOG( ( "SEND >> Class: %d ID: %d", message->message_class,
           message->message_id ) );
#endif
    message->size = size;

    try {
        serversocket->sendMessage(player_id.getNetworkID(),	(char *) message,
                                  message->size, ! (flags & _network_send_no_guarantee));
    } catch(Exception e) {
        LOG ( ("Network send error when sending to client %d.",
               player_id.getNetworkID()) );
        //return -1;
    }

    NetworkState::incPacketsSent(message->size);

    return 0;
}
bool ServerConnectDaemon::disconnectClient( PlayerID player_id )
{
    SERVER->shutdownClientTransport(player_id.getNetworkID());

    SERVER->removeClientFromSendList(player_id);
    ObjectiveInterface::disownPlayerObjectives(player_id.getIndex());
    UnitInterface::destroyPlayerUnits(player_id.getIndex());
    PlayerInterface::disconnectPlayerCleanup( player_id );

	for(std::list<ConnectQueueElement>::iterator i = connect_queue.begin();
			i != connect_queue.end(); /*nothing */) {
		if(i->new_player_id == player_id) {
			i = connect_queue.erase(i);
			continue;
		}

		++i;
	}
	if(connect_player_id == player_id) {
		connection_state = connect_state_idle;
	}

    return true;
}
void NetworkServerUnix::shutdownClientTransport(const PlayerID &client_id)
{
    assert(serversocket != 0);
    serversocket->removeClient(client_id.getNetworkID());
}