# network_base.h

Go to the documentation of this file.

    00001 /* $Id: network_base.h 14730 2008-12-23 20:52:27Z rubidium $ */
    00002
    00005 #ifndef NETWORK_BASE_H
    00006 #define NETWORK_BASE_H
    00007
    00008 #ifdef ENABLE_NETWORK
    00009
    00010 #include "network_type.h"
    00011 #include "../oldpool.h"
    00012
    00013 DECLARE_OLD_POOL(NetworkClientInfo, NetworkClientInfo, NCI_BITS_PER_POOL_BLOCK, MAX_CLIENT_SLOTS >> NCI_BITS_PER_POOL_BLOCK);
    00014
    00015 struct NetworkClientInfo : PoolItem<NetworkClientInfo, ClientIndex, &_NetworkClientInfo_pool> {
    00016   ClientID client_id;
    00017   char client_name[NETWORK_CLIENT_NAME_LENGTH];
    00018   byte client_lang;
    00019   CompanyID client_playas;
    00020   uint32 client_ip;
    00021   Date join_date;
    00022   char unique_id[NETWORK_UNIQUE_ID_LENGTH];
    00023
    00024   NetworkClientInfo(ClientID client_id = INVALID_CLIENT_ID) : client_id(client_id) {}
    00025   ~NetworkClientInfo() { client_id = INVALID_CLIENT_ID; }
    00026
    00027   inline bool IsValid() const { return client_id != INVALID_CLIENT_ID; }
    00028 };
    00029
    00030 static inline bool IsValidNetworkClientInfoIndex(ClientIndex index)
    00031 {
    00032   return (uint)index < GetNetworkClientInfoPoolSize() && GetNetworkClientInfo(index)->IsValid();
    00033 }
    00034
    00035 #define FOR_ALL_CLIENT_INFOS_FROM(d, start) for (d = GetNetworkClientInfo(start); d != NULL; d = (d->index + 1U < GetNetworkClientInfoPoolSize()) ? GetNetworkClientInfo(d->index + 1U) : NULL) if (d->IsValid())
    00036 #define FOR_ALL_CLIENT_INFOS(d) FOR_ALL_CLIENT_INFOS_FROM(d, 0)
    00037
    00038 #endif /* ENABLE_NETWORK */
    00039 #endif /* NETWORK_BASE_H */