Changeset 6658 in orxonox.OLD for branches/network
- Timestamp:
- Jan 23, 2006, 2:43:50 PM (19 years ago)
- Location:
- branches/network/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/network/network_manager.cc
r6654 r6658 25 25 26 26 #include "debug.h" 27 27 #include "shell_command.h" 28 28 29 29 /* include your own header */ … … 33 33 /* using namespace std is default, this needs to be here */ 34 34 using namespace std; 35 36 SHELL_COMMAND(debug, NetworkManager, debug); 35 37 36 38 … … 112 114 this->bGameServer = true; 113 115 this->defaultSyncStream = new NetworkStream(port); 116 PRINTF(0)("CREATE SERVER\n"); 114 117 this->bGameServer = true; 115 118 SDL_Delay(20); … … 142 145 void NetworkManager::connectSynchronizeable(Synchronizeable& sync) 143 146 { 144 this->defaultSyncStream->connectSynchronizeable(sync); 147 if( this->defaultSyncStream) 148 this->defaultSyncStream->connectSynchronizeable(sync); 145 149 } 146 150 … … 170 174 this->hostID = id; 171 175 } 176 177 178 179 /** 180 * debug output 181 */ 182 void NetworkManager::debug() 183 { 184 this->defaultSyncStream->debug(); 185 } -
branches/network/src/lib/network/network_manager.h
r6654 r6658 53 53 inline NetworkStream* getDefaultSyncStream() { return this->defaultSyncStream; } 54 54 55 void debug(); 56 55 57 56 58 private: -
branches/network/src/lib/network/network_stream.cc
r6634 r6658 84 84 // setUniqueID( maxCon+2 ) because we need one id for every handshake 85 85 // and one for handshake to reject client maxCon+1 86 this->networkGameManager->setUniqueID( this->maxConnections +2 );86 this->networkGameManager->setUniqueID( this->maxConnections + 2 ); 87 87 this->connectSynchronizeable( *(this->networkGameManager) ); 88 88 … … 141 141 } 142 142 143 143 144 void NetworkStream::disconnectSynchronizeable(Synchronizeable& sync) 144 145 { … … 216 217 /* DOWNSTREAM */ 217 218 219 220 218 221 int dataLength; 219 222 int reciever; … … 221 224 for (SynchronizeableList::iterator it = synchronizeables.begin(); it!=synchronizeables.end(); it++) 222 225 { 223 if ( (*it)!=NULL /*&& (*it)->getOwner() == myHostId*/ )226 if ( (*it)!=NULL && (*it)->beSynchronized() /*&& (*it)->getOwner() == myHostId*/ ) 224 227 { 225 228 do { … … 416 419 417 420 421 422 void NetworkStream::debug() 423 { 424 PRINT(0)("=================NetworkStream::debug()====\n"); 425 PRINT(0)(" Host ID: %i\n", this->myHostId); 426 427 PRINT(0)(" Connected Synchronizeables:\n"); 428 for (SynchronizeableList::iterator it = synchronizeables.begin(); it!=synchronizeables.end(); it++) 429 { 430 PRINT(0)(" Synchronizeable of class: %s::%s, with unique ID: %i\n", (*it)->getClassName(), (*it)->getName(), (*it)->getUniqueID()); 431 } 432 433 PRINT(0)(" Maximal Connections: %i\n", this->maxConnections); 434 PRINT(0)("===========================================\n"); 435 436 } 437 438 439 440 441 442 443 444 445 446 447 448 449 450 -
branches/network/src/lib/network/network_stream.h
r6634 r6658 57 57 inline bool isUserIdActive( int userID ) { if (userID>=networkSockets.size()) return false; else return networkSockets[userID]!=NULL; } 58 58 59 void debug(); 60 61 59 62 private: 60 NetworkProtocol* networkProtocol; 61 ConnectionMonitor* connectionMonitor; 62 SynchronizeableList synchronizeables; 63 NetworkSocketVector networkSockets; 64 HandshakeVector handshakes; 65 ServerSocket* serverSocket; 66 int type; 67 Header packetHeader; 68 bool bActive; 69 std::list<int> freeSocketSlots; 63 void updateConnectionList(); 70 64 71 int myHostId;72 int maxConnections;73 65 74 NetworkGameManager* networkGameManager; 66 private: 67 NetworkProtocol* networkProtocol; 68 ConnectionMonitor* connectionMonitor; 69 SynchronizeableList synchronizeables; 70 NetworkSocketVector networkSockets; 71 HandshakeVector handshakes; 72 ServerSocket* serverSocket; 73 int type; 74 Header packetHeader; 75 bool bActive; 76 std::list<int> freeSocketSlots; 75 77 76 void updateConnectionList(); 78 int myHostId; 79 int maxConnections; 80 81 NetworkGameManager* networkGameManager; 77 82 }; 78 83 #endif /* _NETWORK_STREAM */ -
branches/network/src/lib/network/synchronizeable.cc
r6424 r6658 18 18 19 19 #include "synchronizeable.h" 20 20 21 #include "netdefs.h" 21 22 #include "network_manager.h" 23 #include "network_game_manager.h" 22 24 #include "network_stream.h" 25 26 #include "assert.h" 23 27 24 28 … … 29 33 { 30 34 this->setClassID(CL_SYNCHRONIZEABLE, "Synchronizeable"); 31 owner = 0;32 state = 0;33 hostID = NetworkManager::getInstance()->getHostID();35 this->owner = 0; 36 this->state = 0; 37 this->hostID = NetworkManager::getInstance()->getHostID(); 34 38 this->setIsServer(this->hostID == 0); 35 uniqueID = -1;39 this->uniqueID = -1; 36 40 this->networkStream = NULL; 37 41 this->setRequestedSync( false ); 38 42 this->setIsOutOfSync( !(this->isServer()) ); 43 44 this->bSynchronize = false; 45 NetworkStream* nd; 46 if( this->isA(CL_NETWORK_GAME_MANAGER)) 47 { 48 nd = NetworkGameManager::getInstance()->getNetworkStream(); 49 assert(nd != NULL); 50 nd->connectSynchronizeable(*this); 51 } 39 52 } 40 53 … … 50 63 } 51 64 65 52 66 /** 53 67 * write data to NetworkStream … … 57 71 PRINTF(5)("Synchronizeable::writeBytes was called\n"); 58 72 } 73 59 74 60 75 /** … … 87 102 } 88 103 104 89 105 /** 90 106 * Sets the outofsync flag to a given value … … 100 116 } 101 117 118 102 119 /** 103 120 * Determines if the server flag is set … … 108 125 return (this->state & STATE_SERVER) >0; 109 126 } 127 110 128 111 129 /** … … 118 136 } 119 137 138 120 139 /** 121 140 * Determines if the requestedSync flag is set … … 126 145 return (this->state & STATE_REQUESTEDSYNC) >0; 127 146 } 147 128 148 129 149 /** -
branches/network/src/lib/network/synchronizeable.h
r6654 r6658 197 197 198 198 inline void setNetworkStream(NetworkStream* stream) { this->networkStream = stream; } 199 inline NetworkStream* getNetworkStream() { return this->networkStream; } 199 200 200 201 … … 210 211 bool bSynchronize; 211 212 212 std::list<int> synchronizeRequests;213 std::list<int> synchronizeRequests; 213 214 214 215 }; -
branches/network/src/orxonox.cc
r6426 r6658 280 280 NetworkManager::getInstance()->createServer(port); 281 281 } 282 283 282 return 0; 284 283 } -
branches/network/src/world_entities/playable.cc
r6589 r6658 36 36 // the reference to the Current Player is NULL, because we dont have one at the beginning. 37 37 this->currentPlayer = NULL; 38 } 38 39 this->setSynchronized(true); 40 } 41 42 39 43 40 44 Playable::~Playable() … … 57 61 } 58 62 63 59 64 void Playable::removeWeapon(Weapon* weapon) 60 65 { … … 63 68 this->weaponConfigChanged(); 64 69 } 70 65 71 66 72 void Playable::nextWeaponConfig() … … 70 76 } 71 77 78 72 79 void Playable::previousWeaponConfig() 73 80 { … … 76 83 } 77 84 85 78 86 void Playable::weaponConfigChanged() 79 87 { … … 81 89 this->currentPlayer->weaponConfigChanged(); 82 90 } 91 83 92 84 93 /**
Note: See TracChangeset
for help on using the changeset viewer.