[6678] | 1 | /*! |
---|
| 2 | * @file shared_network_data.h |
---|
| 3 | * some shared data from the NetworkManager |
---|
| 4 | */ |
---|
| 5 | |
---|
| 6 | #ifndef _SHARED_NETWORK_DATA |
---|
| 7 | #define _SHARED_NETWORK_DATA |
---|
| 8 | |
---|
| 9 | #include "base_object.h" |
---|
[9347] | 10 | #include "netdefs.h" |
---|
| 11 | #include "proxy/proxy_settings.h" |
---|
[6678] | 12 | |
---|
[9384] | 13 | //!< maximal connectinons for the server |
---|
[9387] | 14 | #define NET_MAX_CONNECTIONS 2 |
---|
[6678] | 15 | |
---|
| 16 | class NetworkStream; |
---|
| 17 | class Synchronizeable; |
---|
| 18 | |
---|
[9347] | 19 | |
---|
[6678] | 20 | /* and here is the class itsself*/ |
---|
| 21 | class SharedNetworkData : public BaseObject |
---|
| 22 | { |
---|
| 23 | |
---|
| 24 | public: |
---|
| 25 | inline static SharedNetworkData* getInstance() { if (!SharedNetworkData::singletonRef) SharedNetworkData::singletonRef = new SharedNetworkData(); |
---|
| 26 | return SharedNetworkData::singletonRef; } |
---|
| 27 | virtual ~SharedNetworkData(); |
---|
| 28 | |
---|
| 29 | /** @returns the next uniqueID free for an object */ |
---|
[9347] | 30 | inline int getNewUniqueID() { return ( this->nodeType != NET_CLIENT)?this->newUniqueID++:-1; } |
---|
[6678] | 31 | |
---|
[9347] | 32 | /** @returns true is this node is a master server */ |
---|
| 33 | inline bool isMasterServer() { return this->nodeType == NET_MASTER_SERVER; } |
---|
| 34 | /** @returns true is this node is a proxy server */ |
---|
| 35 | inline bool isProxyServer() { return this->nodeType == NET_PROXY_SERVER_ACTIVE; } |
---|
| 36 | /** @returns true is this node is a client*/ |
---|
| 37 | inline bool isClient() { return this->nodeType == NET_CLIENT; } |
---|
[6678] | 38 | /** sets the game server flag @param bGameServer true if it is a game server */ |
---|
[9347] | 39 | inline void setNodeType(int nodeType) { this->nodeType = nodeType; } |
---|
[6678] | 40 | |
---|
[9347] | 41 | /** @returns the maximum number of players for this server */ |
---|
[9388] | 42 | inline int getMaxPlayer() { return ProxySettings::getInstance()->getMaxPlayer(); } |
---|
[9347] | 43 | |
---|
[6678] | 44 | /** @returns the hostID of the node */ |
---|
| 45 | inline int getHostID() { return this->hostID; } |
---|
| 46 | /** sets the hostID of this node @param hostID of the node */ |
---|
| 47 | inline void setHostID(int hostID) { this->hostID = hostID; } |
---|
| 48 | |
---|
| 49 | /** @returns the default synchronize stream */ |
---|
| 50 | inline NetworkStream* getDefaultSyncStream() { return this->defaultSyncStream; } |
---|
| 51 | /** sets the default sync stream @param defaultSyncStream the default sync stream */ |
---|
| 52 | inline void setDefaultSyncStream(NetworkStream* defaultSyncStream) { this->defaultSyncStream = defaultSyncStream; } |
---|
| 53 | |
---|
| 54 | |
---|
| 55 | private: |
---|
| 56 | SharedNetworkData(); |
---|
| 57 | |
---|
| 58 | |
---|
| 59 | private: |
---|
| 60 | int newUniqueID; //!< next uniqueID |
---|
[9347] | 61 | int nodeType; //!< saves the node type here |
---|
| 62 | |
---|
[6678] | 63 | int hostID; //!< The Host-ID of the Manager |
---|
| 64 | NetworkStream* defaultSyncStream; //!< default synchronize NetworkStream |
---|
| 65 | |
---|
| 66 | static SharedNetworkData* singletonRef; //!< Pointer to the only instance of this Class |
---|
| 67 | |
---|
| 68 | }; |
---|
| 69 | |
---|
| 70 | |
---|
| 71 | |
---|
| 72 | #endif /* _SHARED_NETWORK_DATA */ |
---|