Changeset 6417 for code/trunk/src/libraries/network/packet
- Timestamp:
- Dec 25, 2009, 10:23:58 PM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/libraries/network/packet/Acknowledgement.cc
r5781 r6417 38 38 #define _PACKETID 0 39 39 #define _ACKID _PACKETID + sizeof(packet::Type::Value) 40 40 41 41 Acknowledgement::Acknowledgement( unsigned int id, unsigned int clientID ) 42 42 : Packet() -
code/trunk/src/libraries/network/packet/Chat.cc
r5781 r6417 35 35 namespace orxonox { 36 36 namespace packet { 37 37 38 38 #define PACKET_FLAGS_CHAT PacketFlag::Reliable 39 39 #define _PACKETID 0 -
code/trunk/src/libraries/network/packet/ClassID.cc
r5929 r6417 48 48 ClassID::ClassID( ) : Packet(){ 49 49 Identifier *id; 50 std::string classname;51 50 unsigned int nrOfClasses=0; 52 51 unsigned int packetSize=2*sizeof(uint32_t); //space for the packetID and for the nrofclasses … … 58 57 std::map<std::string, Identifier*>::const_iterator it = Identifier::getStringIdentifierMapBegin(); 59 58 for(;it != Identifier::getStringIdentifierMapEnd();++it){ 60 id = (*it).second;59 id = it->second; 61 60 if(id == NULL || !id->hasFactory()) 62 61 continue; 63 c lassname = id->getName();62 const std::string& classname = id->getName(); 64 63 network_id = id->getNetworkID(); 65 64 // now push the network id and the classname to the stack -
code/trunk/src/libraries/network/packet/ClassID.h
r6073 r6417 36 36 namespace packet { 37 37 38 38 39 39 /** 40 40 @author -
code/trunk/src/libraries/network/packet/DeleteObjects.cc
r5781 r6417 41 41 #define _QUANTITY _PACKETID + sizeof(Type::Value) 42 42 #define _OBJECTIDS _QUANTITY + sizeof(uint32_t) 43 43 44 44 DeleteObjects::DeleteObjects() 45 45 : Packet() … … 71 71 for(unsigned int i=0; i<number; i++){ 72 72 unsigned int temp = Synchronisable::popDeletedObject(); 73 // assert(temp<10000); //ugly hack74 73 *reinterpret_cast<uint32_t*>(tdata) = temp; 75 COUT(4) << temp << " ";74 COUT(4) << temp << ' '; 76 75 tdata += sizeof(uint32_t); 77 76 } -
code/trunk/src/libraries/network/packet/FunctionCalls.cc
r5781 r6417 36 36 namespace orxonox { 37 37 namespace packet { 38 38 39 39 #define PACKET_FLAGS_FUNCTIONCALLS PacketFlag::Reliable 40 40 #define _PACKETID 0 41 41 const unsigned int FUNCTIONCALLS_MEM_ALLOCATION = 1000; 42 42 43 43 FunctionCalls::FunctionCalls() 44 44 : Packet() … … 171 171 void FunctionCalls::addCallStatic( uint32_t networkID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5){ 172 172 assert(!isDataENetAllocated()); 173 173 174 174 // first determine the size that has to be reserved for this call 175 175 uint32_t callsize = 2*sizeof(uint32_t)+sizeof(uint8_t); //size for network-function-id and nrOfArguments and for bool isStatic … … 200 200 } 201 201 } 202 202 203 203 // now allocated mem if neccessary 204 204 if( currentSize_ + callsize > currentMemBlocks_*FUNCTIONCALLS_MEM_ALLOCATION ) … … 210 210 data_ = temp; 211 211 } 212 212 213 213 // now serialise the mt values and copy the function id and isStatic 214 214 uint8_t* temp = data_+currentSize_; … … 240 240 //currentSize_ += callsize; 241 241 currentSize_ = temp-data_; 242 242 243 243 } 244 244 245 245 void FunctionCalls::addCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5){ 246 246 assert(!isDataENetAllocated()); 247 247 248 248 // first determine the size that has to be reserved for this call 249 249 uint32_t callsize = 3*sizeof(uint32_t)+sizeof(uint8_t); //size for network-function-id and nrOfArguments and the objectID … … 274 274 } 275 275 } 276 276 277 277 // now allocated mem if neccessary 278 278 if( currentSize_ + callsize > currentMemBlocks_*FUNCTIONCALLS_MEM_ALLOCATION ) … … 284 284 data_ = temp; 285 285 } 286 286 287 287 // now serialise the mt values and copy the function id 288 288 uint8_t* temp = data_+currentSize_; … … 314 314 } 315 315 currentSize_ += callsize; 316 316 317 317 } 318 318 -
code/trunk/src/libraries/network/packet/FunctionIDs.cc
r5781 r6417 47 47 48 48 FunctionIDs::FunctionIDs( ) : Packet(){ 49 std::string functionname; 50 unsigned int nrOfFunctions=0; 49 unsigned int nrOfFunctions=0; 51 50 unsigned int packetSize=2*sizeof(uint32_t); //space for the packetID and for the nroffunctions 52 51 uint32_t networkID; 53 52 flags_ = flags_ | PACKET_FLAGS_FUNCTIONIDS; 54 53 std::queue<std::pair<uint32_t, std::string> > tempQueue; 55 54 56 55 //calculate total needed size (for all strings and integers) 57 56 ObjectList<NetworkFunctionBase>::iterator it; 58 57 for(it = ObjectList<NetworkFunctionBase>::begin(); it; ++it){ 59 functionname = it->getName();58 const std::string& functionname = it->getName(); 60 59 networkID = it->getNetworkID(); 61 60 // now push the network id and the classname to the stack … … 64 63 packetSize += (functionname.size()+1)+sizeof(uint32_t)+sizeof(uint32_t); // reserver size for the functionname string, the functionname length and the networkID 65 64 } 66 65 67 66 this->data_=new uint8_t[ packetSize ]; 68 67 //set the appropriate packet id 69 68 assert(this->data_); 70 69 *(Type::Value *)(this->data_ + _PACKETID ) = Type::FunctionIDs; 71 70 72 71 uint8_t *temp=data_+sizeof(uint32_t); 73 72 // save the number of all classes 74 73 *(uint32_t*)temp = nrOfFunctions; 75 74 temp += sizeof(uint32_t); 76 75 77 76 // now save all classids and classnames 78 77 std::pair<uint32_t, std::string> tempPair; … … 85 84 temp+=2*sizeof(uint32_t)+tempPair.second.size()+1; 86 85 } 87 86 88 87 COUT(5) << "FunctionIDs packetSize is " << packetSize << endl; 89 88 90 89 } 91 90 … … 106 105 temp += sizeof(uint32_t); 107 106 totalsize += sizeof(uint32_t); // storage size for nr of all classes 108 107 109 108 for(unsigned int i=0; i<nrOfFunctions; i++){ 110 109 totalsize += 2*sizeof(uint32_t) + *(uint32_t*)(temp + sizeof(uint32_t)); // for each network function add size for id, sizeof(string) and length of string itself to totalsize … … 121 120 uint32_t stringsize; 122 121 unsigned char *functionname; 123 122 124 123 COUT(4) << "=== processing functionids: " << endl; 125 124 std::pair<uint32_t, std::string> tempPair; … … 127 126 nrOfFunctions = *(uint32_t*)temp; 128 127 temp += sizeof(uint32_t); 129 128 130 129 for( int i=0; i<nrOfFunctions; i++){ 131 130 networkID = *(uint32_t*)temp; -
code/trunk/src/libraries/network/packet/FunctionIDs.h
r6073 r6417 36 36 namespace packet { 37 37 38 38 39 39 /** 40 40 @author -
code/trunk/src/libraries/network/packet/Gamestate.cc
r5929 r6417 95 95 return false; 96 96 } 97 97 98 98 // create the header object 99 99 assert( header_ == 0 ); … … 105 105 ObjectList<Synchronisable>::iterator it; 106 106 for(it = ObjectList<Synchronisable>::begin(); it; ++it){ 107 107 108 108 // tempsize=it->getSize(id, mode); 109 109 … … 111 111 if ( tempsize != 0 ) 112 112 dataVector_.push_back( obj(it->getObjectID(), it->getCreatorID(), tempsize, mem-data_) ); 113 113 114 114 #ifndef NDEBUG 115 115 if(currentsize+tempsize > size){ … … 362 362 assert(!header_->isCompressed() && !base->header_->isCompressed()); 363 363 assert(!header_->isDiffed()); 364 364 365 365 uint8_t *basep = GAMESTATE_START(base->data_); 366 366 uint8_t *gs = GAMESTATE_START(this->data_); 367 367 uint32_t dest_length = header_->getDataSize(); 368 368 369 369 if(dest_length==0) 370 370 return NULL; 371 371 372 372 uint8_t *ndata = new uint8_t[dest_length*sizeof(uint8_t)+GamestateHeader::getSize()]; 373 373 uint8_t *dest = GAMESTATE_START(ndata); 374 374 375 375 rawDiff( dest, gs, basep, header_->getDataSize(), base->header_->getDataSize() ); 376 376 #ifndef NDEBUG … … 398 398 assert(!header_->isCompressed() && !base->header_->isCompressed()); 399 399 assert(header_->isDiffed()); 400 400 401 401 uint8_t *basep = GAMESTATE_START(base->data_); 402 402 uint8_t *gs = GAMESTATE_START(this->data_); 403 403 uint32_t dest_length = header_->getDataSize(); 404 404 405 405 if(dest_length==0) 406 406 return NULL; 407 407 408 408 uint8_t *ndata = new uint8_t[dest_length*sizeof(uint8_t)+GamestateHeader::getSize()]; 409 409 uint8_t *dest = ndata + GamestateHeader::getSize(); 410 410 411 411 rawDiff( dest, gs, basep, header_->getDataSize(), base->header_->getDataSize() ); 412 412 413 413 Gamestate *g = new Gamestate(ndata, getClientID()); 414 414 assert(g->header_); … … 437 437 // uint8_t *ndata = new uint8_t[dest_length*sizeof(uint8_t)+GamestateHeader::getSize()]; 438 438 // uint8_t *dest = ndata + GamestateHeader::getSize(); 439 // 440 // 439 // 440 // 441 441 // // LOOP-UNROLLED DIFFING 442 442 // uint32_t *dest32 = (uint32_t*)dest, *base32 = (uint32_t*)basep, *gs32 = (uint32_t*)gs; … … 465 465 // } 466 466 // } 467 // 467 // 468 468 // Gamestate *g = new Gamestate(ndata, getClientID()); 469 469 // *(g->header_) = *header_; … … 481 481 uint64_t* bd = (uint64_t*)basedata; 482 482 uint64_t* nd = (uint64_t*)newdata; 483 483 484 484 unsigned int i; 485 485 for( i=0; i<datalength/8; i++ ) … … 529 529 // COUT(0) << "myvector contains:"; 530 530 // for ( itt=dataVector_.begin() ; itt!=dataVector_.end(); itt++ ) 531 // COUT(0) << " "<< (*itt).objID;531 // COUT(0) << ' ' << (*itt).objID; 532 532 // COUT(0) << endl; 533 533 for(it=dataVector_.begin(); it!=dataVector_.end();){ 534 534 SynchronisableHeader oldobjectheader(origdata); 535 535 SynchronisableHeader newobjectheader(newdata); 536 if ( (*it).objSize == 0 )536 if ( it->objSize == 0 ) 537 537 { 538 538 ++it; … … 541 541 objectsize = oldobjectheader.getDataSize(); 542 542 objectOffset=SynchronisableHeader::getSize(); //skip the size and the availableData variables in the objectheader 543 if ( (*it).objID == oldobjectheader.getObjectID() ){543 if ( it->objID == oldobjectheader.getObjectID() ){ 544 544 memcpy(newdata, origdata, objectsize); 545 545 assert(newobjectheader.isDataAvailable()==true); -
code/trunk/src/libraries/network/packet/Packet.cc
r6105 r6417 101 101 @brief 102 102 Destroys a packet completely. 103 104 That also means destroying the ENetPacket if one exists. There 103 104 That also means destroying the ENetPacket if one exists. There 105 105 */ 106 106 Packet::~Packet(){
Note: See TracChangeset
for help on using the changeset viewer.