/*! * @file shared_network_data.h * some shared data from the NetworkManager */ #ifndef _SHARED_NETWORK_DATA #define _SHARED_NETWORK_DATA #include "base_object.h" #include "netdefs.h" #include "proxy/proxy_settings.h" //!< maximal connectinons for the server #define NET_MAX_CONNECTIONS 2 class NetworkStream; class Synchronizeable; /* and here is the class itsself*/ class SharedNetworkData : public BaseObject { public: inline static SharedNetworkData* getInstance() { if (!SharedNetworkData::singletonRef) SharedNetworkData::singletonRef = new SharedNetworkData(); return SharedNetworkData::singletonRef; } virtual ~SharedNetworkData(); /** @returns the next uniqueID free for an object */ inline int getNewUniqueID() { return ( this->nodeType != NET_CLIENT)?this->newUniqueID++:-1; } /** @returns true is this node is a master server */ inline bool isMasterServer() { return this->nodeType == NET_MASTER_SERVER; } /** @returns true is this node is a proxy server */ inline bool isProxyServer() { return this->nodeType == NET_PROXY_SERVER_ACTIVE; } /** @returns true is this node is a client*/ inline bool isClient() { return this->nodeType == NET_CLIENT; } /** sets the game server flag @param bGameServer true if it is a game server */ inline void setNodeType(int nodeType) { this->nodeType = nodeType; } /** @returns the maximum number of players for this server */ inline int getMaxPlayer() { return /*ProxySettings::getInstance()->getMaxPlayer()*/NET_MAX_CONNECTIONS; } /** @returns the hostID of the node */ inline int getHostID() { return this->hostID; } /** sets the hostID of this node @param hostID of the node */ inline void setHostID(int hostID) { this->hostID = hostID; } /** @returns the default synchronize stream */ inline NetworkStream* getDefaultSyncStream() { return this->defaultSyncStream; } /** sets the default sync stream @param defaultSyncStream the default sync stream */ inline void setDefaultSyncStream(NetworkStream* defaultSyncStream) { this->defaultSyncStream = defaultSyncStream; } private: SharedNetworkData(); private: int newUniqueID; //!< next uniqueID int nodeType; //!< saves the node type here int hostID; //!< The Host-ID of the Manager NetworkStream* defaultSyncStream; //!< default synchronize NetworkStream static SharedNetworkData* singletonRef; //!< Pointer to the only instance of this Class }; #endif /* _SHARED_NETWORK_DATA */