Changeset 3084 for code/trunk/src/network/packet
- Timestamp:
- May 26, 2009, 9:20:57 PM (16 years ago)
- Location:
- code/trunk
- Files:
-
- 7 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/network/packet/CMakeLists.txt
r2710 r3084 1 1 ADD_SOURCE_FILES(NETWORK_SRC_FILES 2 2 Packet.cc 3 Acknowledgement.cc 3 4 Chat.cc 4 5 ClassID.cc 5 Acknowledgement.cc 6 DeleteObjects.cc 7 FunctionIDs.cc 8 FunctionCalls.cc 6 9 Gamestate.cc 7 10 Welcome.cc 8 DeleteObjects.cc9 11 ) -
code/trunk/src/network/packet/ClassID.cc
r2773 r3084 93 93 } 94 94 95 COUT( 0) << "classid packetSize is " << packetSize << endl;95 COUT(5) << "classid packetSize is " << packetSize << endl; 96 96 97 97 } -
code/trunk/src/network/packet/FunctionCalls.cc
- Property svn:eol-style set to native
-
code/trunk/src/network/packet/FunctionCalls.h
- Property svn:eol-style set to native
-
code/trunk/src/network/packet/FunctionIDs.cc
- Property svn:eol-style set to native
-
code/trunk/src/network/packet/FunctionIDs.h
- Property svn:eol-style set to native
-
code/trunk/src/network/packet/Gamestate.cc
r2896 r3084 21 21 * 22 22 * Author: 23 * Oliver Scheuss , (C) 200823 * Oliver Scheuss 24 24 * Co-authors: 25 25 * ... … … 107 107 for(it = ObjectList<Synchronisable>::begin(); it; ++it){ 108 108 109 tempsize=it->getSize(id, mode); 109 // tempsize=it->getSize(id, mode); 110 111 tempsize = it->getData(mem, id, mode); 112 if ( tempsize != 0 ) 113 dataVector_.push_back( obj(it->getObjectID(), it->getCreatorID(), tempsize, mem-data_) ); 114 110 115 #ifndef NDEBUG 111 116 if(currentsize+tempsize > size){ … … 123 128 }// stop allocate additional memory 124 129 #endif 125 126 if ( it->doSync( id, mode ) ) 127 dataMap_.push_back( obj(it->getObjectID(), it->getCreatorID(), tempsize, mem-data_) ); 128 if(!it->getData(mem, id, mode)) 129 return false; // mem pointer gets automatically increased because of call by reference 130 // if(!it->getData(mem, id, mode)) 131 // return false; // mem pointer gets automatically increased because of call by reference 130 132 // increase size counter by size of current synchronisable 131 133 currentsize+=tempsize; … … 177 179 } 178 180 } 179 180 181 // In debug mode, check first, whether there are no duplicate objectIDs 181 182 #ifndef NDEBUG 182 ObjectList<Synchronisable>::iterator it; 183 for (it = ObjectList<Synchronisable>::begin(); it != ObjectList<Synchronisable>::end(); ++it) { 184 if (it->getObjectID() == OBJECTID_UNKNOWN) { 185 if (it->objectMode_ != 0x0) { 186 COUT(0) << "Found object with OBJECTID_UNKNOWN on the client with objectMode != 0x0!" << std::endl; 187 COUT(0) << "Possible reason for this error: Client created a synchronized object without the Server's approval." << std::endl; 188 COUT(0) << "Objects class: " << it->getIdentifier()->getName() << std::endl; 189 assert(false); 183 if(this->getID()%1000==0){ 184 std::list<uint32_t> v1; 185 ObjectList<Synchronisable>::iterator it; 186 for (it = ObjectList<Synchronisable>::begin(); it != ObjectList<Synchronisable>::end(); ++it) { 187 if (it->getObjectID() == OBJECTID_UNKNOWN) { 188 if (it->objectMode_ != 0x0) { 189 COUT(0) << "Found object with OBJECTID_UNKNOWN on the client with objectMode != 0x0!" << std::endl; 190 COUT(0) << "Possible reason for this error: Client created a synchronized object without the Server's approval." << std::endl; 191 COUT(0) << "Objects class: " << it->getIdentifier()->getName() << std::endl; 192 assert(false); 193 } 190 194 } 191 }192 else {193 ObjectList<Synchronisable>::iterator it2;194 for (it2 = ObjectList<Synchronisable>::begin(); it2 != ObjectList<Synchronisable>::end(); ++it2) {195 if (it->getObjectID() == it2->getObjectID() && *it != *it2) {196 COUT(0) << "Found duplicate objectIDs on the client!" << std::endl197 << "Are you sure you don't create a Sychnronisable objcect with 'new' \198 that doesn't have objectMode = 0x0?" << std::endl;199 assert(false);195 else { 196 std::list<uint32_t>::iterator it2; 197 for (it2 = v1.begin(); it2 != v1.end(); ++it2) { 198 if (it->getObjectID() == *it2) { 199 COUT(0) << "Found duplicate objectIDs on the client!" << std::endl 200 << "Are you sure you don't create a Sychnronisable objcect with 'new' \ 201 that doesn't have objectMode = 0x0?" << std::endl; 202 assert(false); 203 } 200 204 } 205 v1.push_back(it->getObjectID()); 201 206 } 202 207 } … … 221 226 uint8_t *d1 = data_+GamestateHeader::getSize(); 222 227 uint8_t *d2 = gs.data_+GamestateHeader::getSize(); 228 GamestateHeader* h1 = new GamestateHeader(data_); 229 GamestateHeader* h2 = new GamestateHeader(gs.data_); 230 assert(h1->getDataSize() == h2->getDataSize()); 223 231 assert(!isCompressed()); 224 232 assert(!gs.isCompressed()); 225 while(d1<data_+header_->getDataSize()) 226 { 227 if(*d1!=*d2) 228 return false; 229 d1++; 230 d2++; 231 } 232 return true; 233 return memcmp(d1, d2, h1->getDataSize())==0; 233 234 } 234 235 … … 357 358 } 358 359 360 // Gamestate *Gamestate::diff(Gamestate *base) 361 // { 362 // assert(data_); 363 // assert(!header_->isCompressed()); 364 // assert(!header_->isDiffed()); 365 // GamestateHeader diffHeader(base->data_); 366 // uint8_t *basep = GAMESTATE_START(base->data_), *gs = GAMESTATE_START(this->data_); 367 // uint32_t of=0; // pointers offset 368 // uint32_t dest_length=0; 369 // dest_length=header_->getDataSize(); 370 // if(dest_length==0) 371 // return NULL; 372 // uint8_t *ndata = new uint8_t[dest_length*sizeof(uint8_t)+GamestateHeader::getSize()]; 373 // uint8_t *dest = ndata + GamestateHeader::getSize(); 374 // 375 // 376 // // LOOP-UNROLLED DIFFING 377 // uint32_t *dest32 = (uint32_t*)dest, *base32 = (uint32_t*)basep, *gs32 = (uint32_t*)gs; 378 // // diff in 4-byte steps 379 // while( of < (uint32_t)(header_->getDataSize())/4 ){ 380 // if( of < (uint32_t)(diffHeader.getDataSize())/4 ) 381 // { 382 // *(dest32+of)=*(base32+of) ^ *(gs32+of); // do the xor 383 // ++of; 384 // } 385 // else 386 // { 387 // *(dest32+of)=*(gs32+of); // same as 0 ^ *(gs32+of) 388 // ++of; 389 // } 390 // } 391 // for( unsigned int of2 = 0; of2 < header_->getDataSize()%4; ++of2 ) 392 // { 393 // if( of*4+of2 < diffHeader.getDataSize() ) 394 // { 395 // *(dest+4*of+of2)=*(basep+4*of+of2) ^ *(gs+4*of+of2); // do the xor 396 // } 397 // else 398 // { 399 // *(dest+4*of+of2)=*(gs+4*of+of2); // same as 0 ^ *(gs32+of) 400 // } 401 // } 402 // 403 // Gamestate *g = new Gamestate(ndata, getClientID()); 404 // *(g->header_) = *header_; 405 // g->header_->setDiffed( true ); 406 // g->header_->setBaseID( base->getID() ); 407 // g->flags_=flags_; 408 // g->packetDirection_ = packetDirection_; 409 // return g; 410 // } 411 359 412 Gamestate* Gamestate::doSelection(unsigned int clientID, unsigned int targetSize){ 360 413 assert(data_); … … 378 431 379 432 //call TrafficControl 380 TrafficControl::getInstance()->processObjectList( clientID, header_->getID(), &dataMap_ );433 TrafficControl::getInstance()->processObjectList( clientID, header_->getID(), dataVector_ ); 381 434 382 435 //copy in the zeros 383 for(it=dataMap_.begin(); it!=dataMap_.end();){ 436 // std::list<obj>::iterator itt; 437 // COUT(0) << "myvector contains:"; 438 // for ( itt=dataVector_.begin() ; itt!=dataVector_.end(); itt++ ) 439 // COUT(0) << " " << (*itt).objID; 440 // COUT(0) << endl; 441 for(it=dataVector_.begin(); it!=dataVector_.end();){ 384 442 SynchronisableHeader oldobjectheader(origdata); 385 443 SynchronisableHeader newobjectheader(newdata); -
code/trunk/src/network/packet/Gamestate.h
r2896 r3084 21 21 * 22 22 * Author: 23 * Oliver Scheuss , (C) 200823 * Oliver Scheuss 24 24 * Co-authors: 25 25 * ... … … 37 37 #include <string.h> 38 38 #include <map> 39 #include < list>39 #include <vector> 40 40 #include <cassert> 41 41 #ifndef NDEBUG … … 120 120 bool compressData(); 121 121 bool decompressData(); 122 bool operator ==(packet::Gamestate gs); 122 123 123 124 // Packet functions … … 126 127 virtual inline bool process(); 127 128 128 bool operator ==(packet::Gamestate gs);129 129 private: 130 130 uint32_t calcGamestateSize(int32_t id, uint8_t mode=0x0); 131 std::list<obj> data Map_;131 std::list<obj> dataVector_; 132 132 GamestateHeader* header_; 133 133 }; -
code/trunk/src/network/packet/Packet.cc
r2773 r3084 39 39 40 40 #include "Acknowledgement.h" 41 #include "DeleteObjects.h" 41 42 #include "Chat.h" 42 43 #include "ClassID.h" 44 #include "FunctionCalls.h" 45 #include "FunctionIDs.h" 43 46 #include "Gamestate.h" 44 47 #include "Welcome.h" 45 #include "DeleteObjects.h"46 48 #include "network/Host.h" 47 49 #include "core/CoreIncludes.h" … … 153 155 case ENUM::Welcome: 154 156 case ENUM::DeleteObjects: 157 case ENUM::FunctionIDs: 158 case ENUM::FunctionCalls: 155 159 break; 156 160 default: … … 170 174 unsigned int clientID = ClientInformation::findClient(&peer->address)->getID(); 171 175 Packet *p = 0; 172 COUT( 5) << "packet type: " << *(ENUM::Type *)&data[_PACKETID] << std::endl;176 COUT(6) << "packet type: " << *(ENUM::Type *)&data[_PACKETID] << std::endl; 173 177 switch( *(ENUM::Type *)(data + _PACKETID) ) 174 178 { 175 179 case ENUM::Acknowledgement: 176 COUT( 4) << "ack" << std::endl;180 COUT(5) << "ack" << std::endl; 177 181 p = new Acknowledgement( data, clientID ); 178 182 break; 179 183 case ENUM::Chat: 180 COUT( 4) << "chat" << std::endl;184 COUT(5) << "chat" << std::endl; 181 185 p = new Chat( data, clientID ); 182 186 break; 183 187 case ENUM::ClassID: 184 COUT( 4) << "classid" << std::endl;188 COUT(5) << "classid" << std::endl; 185 189 p = new ClassID( data, clientID ); 186 190 break; 187 191 case ENUM::Gamestate: 188 COUT( 4) << "gamestate" << std::endl;192 COUT(5) << "gamestate" << std::endl; 189 193 // TODO: remove brackets 190 194 p = new Gamestate( data, clientID ); 191 195 break; 192 196 case ENUM::Welcome: 193 COUT( 4) << "welcome" << std::endl;197 COUT(5) << "welcome" << std::endl; 194 198 p = new Welcome( data, clientID ); 195 199 break; 196 200 case ENUM::DeleteObjects: 197 COUT( 4) << "deleteobjects" << std::endl;201 COUT(5) << "deleteobjects" << std::endl; 198 202 p = new DeleteObjects( data, clientID ); 203 break; 204 case ENUM::FunctionCalls: 205 COUT(5) << "functionCalls" << std::endl; 206 p = new FunctionCalls( data, clientID ); 207 break; 208 case ENUM::FunctionIDs: 209 COUT(5) << "functionIDs" << std::endl; 210 p = new FunctionIDs( data, clientID ); 199 211 break; 200 212 default: -
code/trunk/src/network/packet/Packet.h
r2773 r3084 45 45 enum Type{ 46 46 Acknowledgement, 47 Chat, 48 ClassID, 49 DeleteObjects, 50 FunctionIDs, 51 FunctionCalls, 47 52 Gamestate, 48 ClassID, 49 Chat, 50 Welcome, 51 DeleteObjects 53 Welcome 52 54 }; 53 55 } … … 66 68 virtual unsigned int getSize() const =0; 67 69 virtual bool process()=0; 68 uint32_t getFlags()70 inline uint32_t getFlags() 69 71 { return flags_; } 70 in t getClientID()72 inline int getClientID() 71 73 { return clientID_; } 72 void setClientID( int id )74 inline void setClientID( int id ) 73 75 { clientID_ = id; } 74 76 … … 78 80 Packet(uint8_t *data, unsigned int clientID); 79 81 // Packet(ENetPacket *packet, ENetPeer *peer); 82 inline bool isDataENetAllocated() const 83 { return bDataENetAllocated_; } 84 80 85 uint32_t flags_; 81 86 unsigned int clientID_;
Note: See TracChangeset
for help on using the changeset viewer.