Changeset 6387 for code/branches/presentation2/src/libraries/network/packet
- Timestamp:
- Dec 21, 2009, 1:18:36 PM (15 years ago)
- Location:
- code/branches/presentation2/src/libraries/network/packet
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2/src/libraries/network/packet/Acknowledgement.cc
r5781 r6387 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/branches/presentation2/src/libraries/network/packet/Chat.cc
r5781 r6387 35 35 namespace orxonox { 36 36 namespace packet { 37 37 38 38 #define PACKET_FLAGS_CHAT PacketFlag::Reliable 39 39 #define _PACKETID 0 -
code/branches/presentation2/src/libraries/network/packet/ClassID.h
r6073 r6387 36 36 namespace packet { 37 37 38 38 39 39 /** 40 40 @author -
code/branches/presentation2/src/libraries/network/packet/DeleteObjects.cc
r6192 r6387 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() -
code/branches/presentation2/src/libraries/network/packet/FunctionCalls.cc
r5781 r6387 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/branches/presentation2/src/libraries/network/packet/FunctionIDs.cc
r5781 r6387 53 53 flags_ = flags_ | PACKET_FLAGS_FUNCTIONIDS; 54 54 std::queue<std::pair<uint32_t, std::string> > tempQueue; 55 55 56 56 //calculate total needed size (for all strings and integers) 57 57 ObjectList<NetworkFunctionBase>::iterator it; … … 64 64 packetSize += (functionname.size()+1)+sizeof(uint32_t)+sizeof(uint32_t); // reserver size for the functionname string, the functionname length and the networkID 65 65 } 66 66 67 67 this->data_=new uint8_t[ packetSize ]; 68 68 //set the appropriate packet id 69 69 assert(this->data_); 70 70 *(Type::Value *)(this->data_ + _PACKETID ) = Type::FunctionIDs; 71 71 72 72 uint8_t *temp=data_+sizeof(uint32_t); 73 73 // save the number of all classes 74 74 *(uint32_t*)temp = nrOfFunctions; 75 75 temp += sizeof(uint32_t); 76 76 77 77 // now save all classids and classnames 78 78 std::pair<uint32_t, std::string> tempPair; … … 85 85 temp+=2*sizeof(uint32_t)+tempPair.second.size()+1; 86 86 } 87 87 88 88 COUT(5) << "FunctionIDs packetSize is " << packetSize << endl; 89 89 90 90 } 91 91 … … 106 106 temp += sizeof(uint32_t); 107 107 totalsize += sizeof(uint32_t); // storage size for nr of all classes 108 108 109 109 for(unsigned int i=0; i<nrOfFunctions; i++){ 110 110 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 121 uint32_t stringsize; 122 122 unsigned char *functionname; 123 123 124 124 COUT(4) << "=== processing functionids: " << endl; 125 125 std::pair<uint32_t, std::string> tempPair; … … 127 127 nrOfFunctions = *(uint32_t*)temp; 128 128 temp += sizeof(uint32_t); 129 129 130 130 for( int i=0; i<nrOfFunctions; i++){ 131 131 networkID = *(uint32_t*)temp; -
code/branches/presentation2/src/libraries/network/packet/FunctionIDs.h
r6073 r6387 36 36 namespace packet { 37 37 38 38 39 39 /** 40 40 @author -
code/branches/presentation2/src/libraries/network/packet/Gamestate.cc
r5929 r6387 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_); … … 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++ ) -
code/branches/presentation2/src/libraries/network/packet/Packet.cc
r6105 r6387 101 101 @brief 102 102 Destroys a packet completely. 103 103 104 104 That also means destroying the ENetPacket if one exists. There 105 105 */
Note: See TracChangeset
for help on using the changeset viewer.