Changeset 7575 in orxonox.OLD for branches/network/src/lib
- Timestamp:
- May 10, 2006, 4:48:27 PM (19 years ago)
- Location:
- branches/network/src/lib
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/lang/base_object.cc
r7444 r7575 83 83 assert (!(this->classID & classID & !CL_MASK_SUBSUPER_CLASS_IDA )); 84 84 85 this->leafClassID = classID; 85 86 this->classID |= (long)classID; 86 87 this->className = className; … … 106 107 * Factory::fabricate(Object->getLeafClassID()); 107 108 */ 108 ClassIDBaseObject::getLeafClassID() const109 const ClassID& BaseObject::getLeafClassID() const 109 110 { 110 assert (this->classList != NULL); 111 return this->classList->getLeafClassID(); 111 return this->leafClassID; 112 112 } 113 113 -
branches/network/src/lib/lang/base_object.h
r7444 r7575 41 41 /** @returns the classID of the corresponding Object */ 42 42 inline int getClassID() const { return this->classID; }; 43 ClassIDgetLeafClassID() const;43 const ClassID& getLeafClassID() const; 44 44 45 45 bool isA (ClassID classID) const; … … 58 58 std::string className; //!< the name of the class 59 59 long classID; //!< this is the id from the class_id.h enumeration 60 ClassID leafClassID; //!< The Leaf Class ID 60 61 61 62 ClassList* classList; //!< Pointer to the ClassList this Object is inside of -
branches/network/src/lib/network/network_stream.cc
r7571 r7575 64 64 this->networkProtocol = new NetworkProtocol(); 65 65 this->connectionMonitor = new ConnectionMonitor(); 66 this->maxConnections = MAX_CONNECTIONS;67 66 } 68 67 … … 131 130 // setUniqueID( maxCon+2 ) because we need one id for every handshake 132 131 // and one for handshake to reject client maxCon+1 133 this->networkGameManager->setUniqueID( this->maxConnections+ 2 );132 this->networkGameManager->setUniqueID( MAX_CONNECTIONS + 2 ); 134 133 135 134 } … … 142 141 assert( peers[0].handshake == NULL ); 143 142 peers[0].handshake = hs; 143 // peers[0].handshake->setSynchronized( true ); 144 this->connectSynchronizeable(*hs); 144 145 //this->connectSynchronizeable(*hs); 145 PRINTF(0)("NetworkStream: %s\n", hs->getName());146 PRINTF(0)("NetworkStream: Handshake created: %s\n", hs->getName()); 146 147 } 147 148 … … 194 195 } 195 196 197 handleHandshakes(); 198 handleUpstream(); 199 handleDownstream(); 196 200 197 201 … … 354 358 } else 355 359 { 356 clientId = 0;360 clientId = 1; 357 361 358 362 for ( PeerList::iterator it = peers.begin(); it != peers.end(); it++ ) … … 366 370 } 367 371 368 if ( clientId > this->maxConnections)372 if ( clientId > MAX_CONNECTIONS ) 369 373 { 370 374 peers[clientId].handshake->doReject( "too many connections" ); … … 419 423 (*it)->getUniqueID(), (*it)->beSynchronized()); 420 424 } 421 PRINT(0)(" Maximal Connections: %i\n", this->maxConnections);425 PRINT(0)(" Maximal Connections: %i\n", MAX_CONNECTIONS ); 422 426 423 427 } … … 486 490 offset = INTSIZE; //make already space for length 487 491 488 if ( peer->second.socket )492 if ( !peer->second.socket ) 489 493 continue; 490 494 … … 504 508 { 505 509 Synchronizeable & sync = **it; 510 511 if ( !sync.beSynchronized() || sync.getUniqueID() < 0 ) 512 continue; 513 514 //if handshake not finished only sync handshake 515 if ( peer->second.handshake && sync.getLeafClassID() != CL_HANDSHAKE ) 516 continue; 517 518 PRINTF(0)("syncing: id:%d name:%s\n", sync.getUniqueID(), sync.getClassName()); 506 519 507 520 assert( offset + INTSIZE <= UDP_PACKET_SIZE ); 508 521 509 n = Converter::intToByteArray( sync.getUniqueID(), buf + offset, UDP_PACKET_SIZE - offset ); 522 //server fakes uniqueid=0 for handshake 523 if ( this->isServer() && sync.getUniqueID() < MAX_CONNECTIONS - 1 ) 524 n = Converter::intToByteArray( 0, buf + offset, UDP_PACKET_SIZE - offset ); 525 else 526 n = Converter::intToByteArray( sync.getUniqueID(), buf + offset, UDP_PACKET_SIZE - offset ); 510 527 assert( n == INTSIZE ); 511 528 offset += n; … … 517 534 518 535 assert( peer->second.socket->writePacket( buf, offset ) ); 536 PRINTF(0)("send packet: %d\n", offset); 519 537 } 520 538 } … … 537 555 for ( PeerList::iterator peer = peers.begin(); peer != peers.end(); peer++ ) 538 556 { 557 if ( !peer->second.socket ) 558 continue; 559 539 560 packetLength = peer->second.socket->readPacket( buf, UDP_PACKET_SIZE ); 561 562 if ( packetLength < 4*INTSIZE ) 563 { 564 if ( packetLength != 0 ) 565 PRINTF(1)("got too small packet: %d\n", packetLength); 566 continue; 567 } 540 568 541 569 assert( Converter::byteArrayToInt( buf, &length ) == INTSIZE ); … … 543 571 assert( Converter::byteArrayToInt( buf + 2*INTSIZE, &fromState ) == INTSIZE ); 544 572 assert( Converter::byteArrayToInt( buf + 3*INTSIZE, &ackedState ) == INTSIZE ); 573 574 PRINTF(0)("got packet: %d, %d\n", length, packetLength); 545 575 546 576 //if this is an old state drop it … … 565 595 566 596 for ( SynchronizeableList::iterator it = synchronizeables.begin(); it != synchronizeables.end(); it++ ) 567 { 568 if ( (*it)->getUniqueID() == uniqueId ) 597 { 598 // client thinks his handshake has id 0!!!!! 599 if ( (*it)->getUniqueID() == uniqueId || ( uniqueId == 0 && (*it)->getUniqueID() == peer->second.userId ) ) 569 600 { 570 601 sync = *it; -
branches/network/src/lib/network/network_stream.h
r7565 r7575 60 60 inline bool isActive() const { return this->bActive; } 61 61 62 inline int getMaxConnections(){ return maxConnections; }62 inline int getMaxConnections(){ return MAX_CONNECTIONS; } 63 63 64 64 virtual void processData(); … … 94 94 95 95 int myHostId; 96 int maxConnections;97 96 98 97 int currentState; -
branches/network/src/lib/network/synchronizeable.cc
r7565 r7575 41 41 this->networkStream = NULL; 42 42 this->bSynchronize = false; 43 this->mLeafClassId = getLeafClassID(); 44 43 45 44 if( State::isOnline()) 46 45 { … … 53 52 /* make sure loadClassId is first synced var because this is read by networkStream */ 54 53 assert( syncVarList.size() == 0 ); 55 this->registerVar( new SynchronizeableInt( &this->mLeafClassId, &this->mLeafClassId, "leafClassId" ) );56 54 this->registerVar( new SynchronizeableInt( (int*)&this->getLeafClassID(), (int*)&this->getLeafClassID(), "leafClassId" ) ); 55 57 56 this->registerVar( new SynchronizeableInt( &this->owner, &this->owner, "owner" ) ); 58 57 this->registerVar( new SynchronizeableString( &this->objectName, &this->objectName, "objectName" ) ); … … 309 308 this->varChangeHandler( changes ); 310 309 311 assert( i == length -1);310 assert( i == length ); 312 311 313 312 return length; -
branches/network/src/lib/network/udp_server_socket.h
r7565 r7575 20 20 #include <vector> 21 21 22 #define UDP_PACKET_SIZE 1024 22 #define UDP_PACKET_SIZE 10240 23 23 #define MAX_NEW_CONNECTIONS 8 24 24
Note: See TracChangeset
for help on using the changeset viewer.