Changeset 5935 for code/branches/pickup/src/libraries/network/packet
- Timestamp:
- Oct 13, 2009, 5:05:17 PM (15 years ago)
- Location:
- code/branches/pickup
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pickup
- Property svn:mergeinfo changed
-
code/branches/pickup/src/libraries/network/packet/CMakeLists.txt
r5781 r5935 1 1 ADD_SOURCE_FILES(NETWORK_SRC_FILES 2 COMPILATION_BEGIN PacketCompilation.cc 2 3 Acknowledgement.cc 3 4 Chat.cc … … 9 10 Packet.cc 10 11 Welcome.cc 12 COMPILATION_END 11 13 ) 12 14 -
code/branches/pickup/src/libraries/network/packet/ClassID.cc
r5781 r5935 49 49 Identifier *id; 50 50 std::string classname; 51 unsigned int nrOfClasses=0; 51 unsigned int nrOfClasses=0; 52 52 unsigned int packetSize=2*sizeof(uint32_t); //space for the packetID and for the nrofclasses 53 53 uint32_t network_id; 54 54 flags_ = flags_ | PACKET_FLAGS_CLASSID; 55 55 std::queue<std::pair<uint32_t, std::string> > tempQueue; 56 56 57 57 //calculate total needed size (for all strings and integers) 58 std::map<std::string, Identifier*>::const_iterator it = Factory::getFactoryMapBegin();59 for(;it != Factory::getFactoryMapEnd();++it){58 std::map<std::string, Identifier*>::const_iterator it = Identifier::getStringIdentifierMapBegin(); 59 for(;it != Identifier::getStringIdentifierMapEnd();++it){ 60 60 id = (*it).second; 61 if(id == NULL )61 if(id == NULL || !id->hasFactory()) 62 62 continue; 63 63 classname = id->getName(); 64 64 network_id = id->getNetworkID(); 65 if(network_id==0)66 COUT(3) << "we got a null class id: " << id->getName() << std::endl;67 65 // now push the network id and the classname to the stack 68 66 tempQueue.push( std::pair<unsigned int, std::string>(network_id, classname) ); … … 70 68 packetSize += (classname.size()+1)+sizeof(uint32_t)+sizeof(uint32_t); 71 69 } 72 70 73 71 this->data_=new uint8_t[ packetSize ]; 74 72 //set the appropriate packet id 75 73 assert(this->data_); 76 74 *(Type::Value *)(this->data_ + _PACKETID ) = Type::ClassID; 77 75 78 76 uint8_t *temp=data_+sizeof(uint32_t); 79 77 // save the number of all classes 80 78 *(uint32_t*)temp = nrOfClasses; 81 79 temp += sizeof(uint32_t); 82 80 83 81 // now save all classids and classnames 84 82 std::pair<uint32_t, std::string> tempPair; … … 91 89 temp+=2*sizeof(uint32_t)+tempPair.second.size()+1; 92 90 } 93 91 94 92 COUT(5) << "classid packetSize is " << packetSize << endl; 95 93 96 94 } 97 95 … … 111 109 temp += sizeof(uint32_t); 112 110 totalsize += sizeof(uint32_t); // storage size for nr of all classes 113 111 114 112 for(unsigned int i=0; i<nrOfClasses; i++){ 115 113 totalsize += 2*sizeof(uint32_t) + *(uint32_t*)(temp + sizeof(uint32_t)); … … 125 123 uint32_t stringsize; 126 124 unsigned char *classname; 127 128 129 //clea nthe map of network ids130 Factory::cleanNetworkIDs();131 125 126 127 //clear the map of network ids 128 Identifier::clearNetworkIDs(); 129 132 130 COUT(4) << "=== processing classids: " << endl; 133 131 std::pair<uint32_t, std::string> tempPair; … … 136 134 nrOfClasses = *(uint32_t*)temp; 137 135 temp += sizeof(uint32_t); 138 136 139 137 for( int i=0; i<nrOfClasses; i++){ 140 138 networkID = *(uint32_t*)temp; -
code/branches/pickup/src/libraries/network/packet/Gamestate.cc
r5781 r5935 378 378 rawDiff( dest2, dest, basep, header_->getDataSize(), base->header_->getDataSize() ); 379 379 assert( memcmp( dest2, gs, dest_length) == 0 ); 380 delete dest2; 380 381 #endif 381 382
Note: See TracChangeset
for help on using the changeset viewer.