Changeset 2132 for code/branches/objecthierarchy/src/network/packet
- Timestamp:
- Nov 4, 2008, 5:12:31 PM (16 years ago)
- Location:
- code/branches/objecthierarchy/src/network/packet
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/network/packet/Gamestate.cc
r2112 r2132 71 71 } 72 72 73 bool Gamestate::collectData(int id, int mode)74 { 75 int tempsize=0, currentsize=0;73 bool Gamestate::collectData(int id, uint8_t mode) 74 { 75 unsigned int tempsize=0, currentsize=0; 76 76 assert(data_==0); 77 int size = calcGamestateSize(id, mode);77 unsigned int size = calcGamestateSize(id, mode); 78 78 79 79 COUT(4) << "G.ST.Man: producing gamestate with id: " << id << std::endl; … … 86 86 } 87 87 88 #ifndef NDEBUG89 std::list<Synchronisable*> slist;90 std::list<Synchronisable*>::iterator iit;91 #endif92 88 //start collect data synchronisable by synchronisable 93 89 uint8_t *mem=data_; … … 98 94 99 95 if(currentsize+tempsize > size){ 96 assert(0); // if we don't use multithreading this part shouldn't be neccessary 100 97 // start allocate additional memory 101 98 COUT(3) << "G.St.Man: need additional memory" << std::endl; … … 110 107 }// stop allocate additional memory 111 108 112 #ifndef NDEBUG113 for(iit=slist.begin(); iit!=slist.end(); iit++)114 assert((*iit)!=*it);115 slist.push_back(*it);116 #endif117 109 118 110 //if(it->doSelection(id)) … … 127 119 //start write gamestate header 128 120 HEADER->packetType = ENUM::Gamestate; 129 assert( *(ENUM::Type *)(data_) == ENUM::Gamestate);130 121 HEADER->datasize = currentsize; 131 122 HEADER->id = id; … … 140 131 } 141 132 142 bool Gamestate::spreadData( int mode)133 bool Gamestate::spreadData(uint8_t mode) 143 134 { 144 135 assert(data_); … … 163 154 bool b = s->updateData(mem, mode); 164 155 assert(b); 165 //if(!s->updateData(mem, mode))166 //return false;167 156 } 168 157 } … … 367 356 assert(it->second->objectID==oldobjectheader->objectID); 368 357 *newobjectheader = *oldobjectheader; 369 objectOffset=sizeof( uint8_t)+sizeof(bool); //skip the size and the availableData variables in the objectheader358 objectOffset=sizeof(synchronisableHeader); //skip the size and the availableData variables in the objectheader 370 359 if(it->second->doSelection(HEADER->id)){ 371 360 newobjectheader->dataAvailable=true; //TODO: probably not neccessary … … 565 554 566 555 567 unsigned int Gamestate::calcGamestateSize(unsigned int id, int mode)568 { 569 int size=0;556 unsigned int Gamestate::calcGamestateSize(unsigned int id, uint8_t mode) 557 { 558 unsigned int size=0; 570 559 // get the start of the Synchronisable list 571 560 ObjectList<Synchronisable>::iterator it; -
code/branches/objecthierarchy/src/network/packet/Gamestate.h
r2112 r2132 69 69 ~Gamestate(); 70 70 71 bool collectData(int id, int mode=0x0);72 bool spreadData( int mode=0x0);71 bool collectData(int id, uint8_t mode=0x0); 72 bool spreadData( uint8_t mode=0x0); 73 73 int getID(); 74 74 bool isDiffed(); … … 90 90 bool operator ==(packet::Gamestate gs); 91 91 private: 92 unsigned int calcGamestateSize(unsigned int id, int mode=0x0);92 unsigned int calcGamestateSize(unsigned int id, uint8_t mode=0x0); 93 93 void removeObject(ObjectListIterator<Synchronisable> &it); 94 94 std::map<unsigned int, Synchronisable*> dataMap_; -
code/branches/objecthierarchy/src/network/packet/Packet.cc
r2112 r2132 53 53 #define _PACKETID 0 54 54 55 std::map< ENetPacket *, Packet *> Packet::packetMap_;55 std::map<size_t, Packet *> Packet::packetMap_; 56 56 57 57 Packet::Packet(){ … … 134 134 // Add the packet to a global list so we can access it again once enet calls our 135 135 // deletePacket method. We can of course only give a one argument function to the ENet C library. 136 packetMap_[ enetPacket_] = this;136 packetMap_[(size_t)(void*)enetPacket_] = this; 137 137 } 138 138 #ifndef NDEBUG … … 208 208 void Packet::deletePacket(ENetPacket *enetPacket){ 209 209 // Get our Packet from a gloabal map with all Packets created in the send() method of Packet. 210 std::map< ENetPacket*, Packet*>::iterator it = packetMap_.find(enetPacket);210 std::map<size_t, Packet*>::iterator it = packetMap_.find((size_t)enetPacket); 211 211 assert(it != packetMap_.end()); 212 212 // Make sure we don't delete it again in the destructor -
code/branches/objecthierarchy/src/network/packet/Packet.h
r2112 r2132 92 92 bool bDataENetAllocated_; 93 93 private: 94 static std::map< ENetPacket *, Packet *> packetMap_;94 static std::map<size_t, Packet *> packetMap_; 95 95 ENetPacket *enetPacket_; 96 96 };
Note: See TracChangeset
for help on using the changeset viewer.