[6678] | 1 | /* |
---|
| 2 | orxonox - the future of 3D-vertical-scrollers |
---|
| 3 | |
---|
| 4 | Copyright (C) 2004 orx |
---|
| 5 | |
---|
| 6 | This program is free software; you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 9 | any later version. |
---|
| 10 | |
---|
| 11 | ### File Specific: |
---|
| 12 | main-programmer: Patrick Boenzli |
---|
| 13 | */ |
---|
| 14 | |
---|
| 15 | |
---|
| 16 | #define DEBUG_MODULE_NETWORK |
---|
| 17 | |
---|
| 18 | #include "shared_network_data.h" |
---|
| 19 | #include "netdefs.h" |
---|
[9406] | 20 | #include "state.h" |
---|
[6678] | 21 | |
---|
[9494] | 22 | #include "network_stream.h" |
---|
| 23 | |
---|
[9406] | 24 | #include "debug.h" |
---|
[6678] | 25 | |
---|
| 26 | |
---|
[9869] | 27 | ObjectListDefinition(SharedNetworkData); |
---|
[6678] | 28 | SharedNetworkData* SharedNetworkData::singletonRef = NULL; |
---|
| 29 | |
---|
| 30 | /** |
---|
| 31 | * Standard constructor |
---|
| 32 | */ |
---|
| 33 | SharedNetworkData::SharedNetworkData() |
---|
| 34 | { |
---|
| 35 | /* set the class id for the base object */ |
---|
[9869] | 36 | this->registerObject(this, SharedNetworkData::_objectList); |
---|
[6678] | 37 | |
---|
[9494] | 38 | this->nodeType = NET_MASTER_SERVER; |
---|
[6678] | 39 | this->hostID = -1; |
---|
| 40 | this->defaultSyncStream = NULL; |
---|
[9406] | 41 | |
---|
| 42 | // setUniqueID( maxCon+2 ) because we need one id for every handshake |
---|
| 43 | // and one for handshake to reject client maxCon+1 |
---|
| 44 | this->newUniqueID = 2; |
---|
[6678] | 45 | } |
---|
| 46 | |
---|
| 47 | |
---|
| 48 | /** |
---|
| 49 | * Standard destructor |
---|
| 50 | */ |
---|
| 51 | SharedNetworkData::~SharedNetworkData() |
---|
[9110] | 52 | { |
---|
| 53 | SharedNetworkData::singletonRef = NULL; |
---|
| 54 | } |
---|
[9494] | 55 | |
---|
| 56 | |
---|
| 57 | |
---|
| 58 | /** @return true if this user is connected to the local host */ |
---|
| 59 | bool SharedNetworkData::isUserLocal( int userID) |
---|
| 60 | { |
---|
| 61 | return this->defaultSyncStream->isUserLocal(userID); |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | |
---|
| 65 | /** @returns true if this user is a master server */ |
---|
| 66 | bool SharedNetworkData::isUserMasterServer( int userID ) |
---|
| 67 | { |
---|
| 68 | return this->defaultSyncStream->isUserMasterServer(userID); |
---|
| 69 | } |
---|
| 70 | |
---|
| 71 | |
---|
| 72 | /** @returns true if this user is a proxy server */ |
---|
| 73 | bool SharedNetworkData::isUserProxyServerActive( int userID ) |
---|
| 74 | { |
---|
| 75 | return this->defaultSyncStream->isUserProxyServerActive(userID); |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | |
---|
| 79 | /** @returns true if this user is a client */ |
---|
| 80 | bool SharedNetworkData::isUserClient( int userID ) |
---|
| 81 | { |
---|
| 82 | return this->defaultSyncStream->isUserClient(userID); |
---|
| 83 | } |
---|