Changeset 6190 in orxonox.OLD for branches/network/src/lib/network/network_stream.cc
- Timestamp:
- Dec 20, 2005, 2:51:37 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/network/network_stream.cc
r6139 r6190 27 27 #include "synchronizeable.h" 28 28 #include "network_manager.h" 29 #include "network_game_manager.h" 29 30 #include "list.h" 30 31 #include "debug.h" … … 77 78 this->handshakes.push_back( NULL ); 78 79 this->bActive = true; 80 this->networkGameManager = new NetworkGameManager(); 81 // setUniqueID( maxCon+2 ) because we need one id for every handshake 82 // and one for handshake to reject client maxCon+1 83 this->networkGameManager->setUniqueID( this->maxConnections+2 ); 84 this->connectSynchronizeable( *(this->networkGameManager) ); 79 85 80 86 this->setMaxConnections( 10 ); … … 88 94 this->bActive = false; 89 95 this->serverSocket = NULL; 96 this->networkGameManager = NULL; 90 97 myHostId = 0; 91 98 } … … 175 182 } 176 183 PRINT(0)("handshake finished\n"); 184 185 this->networkGameManager = new NetworkGameManager(); 186 this->networkGameManager->setUniqueID( handshakes[i]->getNetworkGameManagerId() ); 187 this->connectSynchronizeable( *(this->networkGameManager) ); 188 177 189 delete handshakes[i]; 178 190 handshakes[i] = NULL; 179 //TODO: replace handshake by entitymanager180 191 } 181 192 else … … 199 210 for (SynchronizeableList::iterator it = synchronizeables.begin(); it!=synchronizeables.end(); it++) 200 211 { 201 //TODO: remove items from synchronizeables if they dont exist202 212 if ( (*it)!=NULL && (*it)->getOwner() == myHostId ) 203 213 { … … 214 224 dataLength = networkProtocol->createHeader((byte*)downBuffer, dataLength, DATA_STREAM_BUFFER_SIZE, static_cast<const Synchronizeable&>(*(*it))); 215 225 216 //FIXME: this is a hack, find a better way217 226 Header* header = (Header*)downBuffer; 218 if ( header->synchronizeableID <100)227 if ( header->synchronizeableID < this->maxConnections ) 219 228 header->synchronizeableID = 0; 220 229 … … 284 293 { 285 294 if ( *it && (*it)->getUniqueID()==header.synchronizeableID ) 286 (*it)->writeBytes(upBuffer+sizeof(header), dataLength );295 (*it)->writeBytes(upBuffer+sizeof(header), dataLength, i); 287 296 } 288 297 … … 306 315 freeSocketSlots.pop_back(); 307 316 networkSockets[clientId] = tempNetworkSocket; 308 handshakes[clientId] = new Handshake(true, clientId );317 handshakes[clientId] = new Handshake(true, clientId, this->networkGameManager->getUniqueID()); 309 318 handshakes[clientId]->setUniqueID(clientId); 310 319 } else … … 312 321 clientId = networkSockets.size(); 313 322 networkSockets.push_back(tempNetworkSocket); 314 Handshake* tHs = new Handshake(true, clientId );323 Handshake* tHs = new Handshake(true, clientId, this->networkGameManager->getUniqueID()); 315 324 tHs->setUniqueID(clientId); 316 325 handshakes.push_back(tHs); … … 374 383 } 375 384 this->maxConnections = n; 376 } 377 378 385 this->networkGameManager->setUniqueID( n+2 ); 386 } 387 388
Note: See TracChangeset
for help on using the changeset viewer.