Changeset 2660 for code/branches/presentation/src
- Timestamp:
- Feb 14, 2009, 6:01:05 PM (16 years ago)
- Location:
- code/branches/presentation/src/network
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation/src/network/GamestateClient.cc
r2655 r2660 75 75 if(tempGamestate_==NULL) 76 76 return false; 77 bool isDiffed = tempGamestate_->isDiffed(); 77 78 int id = GAMESTATEID_INITIAL; 78 79 packet::Gamestate *processed = processGamestate(tempGamestate_); … … 83 84 84 85 if (!processed){ 85 //sendAck(0);86 sendAck(0); 86 87 return false; 87 88 } … … 89 90 tempGamestate_=NULL; 90 91 gamestateMap_[processed->getID()]=processed; 91 last_diff_ = processed->getID(); 92 if(isDiffed) 93 last_diff_ = processed->getBaseID(); 92 94 id = processed->getID(); 93 //sendAck(id);95 sendAck(id); 94 96 return true; 95 97 } … … 160 162 packet::Gamestate *base = gamestateMap_[gs->getBaseID()]; 161 163 if(!base){ 162 COUT(0) << "could not find base gamestate id: " << gs->getBaseID() << endl;164 COUT(3) << "could not find base gamestate id: " << gs->getBaseID() << endl; 163 165 delete gs; 164 166 return 0; … … 173 175 return gs; 174 176 else 175 COUT(0) << "could not spread gamestate" << endl; 177 { 178 COUT(3) << "could not spread gamestate" << endl; 176 179 return NULL; 180 } 177 181 } 178 182 -
code/branches/presentation/src/network/GamestateManager.cc
r2655 r2660 113 113 //why are we searching the same client's gamestate id as we searched in 114 114 //Server::sendGameState? 115 packet::Gamestate *gs ;115 packet::Gamestate *gs, *temp; 116 116 unsigned int gID = ClientInformation::findClient(clientID)->getGamestateID(); 117 117 if(!reference) 118 118 return 0; 119 119 gs = reference->doSelection(clientID, 10000); 120 temp = gs; 120 121 // gs = new packet::Gamestate(*reference); 121 122 // save the (undiffed) gamestate in the clients gamestate map … … 142 143 bool b = gs->compressData(); 143 144 assert(b); 145 COUT(4) << "sending gamestate with id " << gs->getID(); 146 if(gs->isDiffed()) 147 COUT(4) << " and baseid " << gs->getBaseID() << endl; 148 else 149 COUT(4) << endl; 144 150 return gs; 145 151 } -
code/branches/presentation/src/network/packet/Acknowledgement.cc
r2171 r2660 64 64 65 65 bool Acknowledgement::process(){ 66 COUT(0) << "processing ACK with ID: " << getAckID() << endl; 66 67 bool b = GamestateHandler::ackGamestate(getAckID(), clientID_); 67 68 delete this; -
code/branches/presentation/src/network/packet/Gamestate.cc
r2655 r2660 70 70 flags_ = flags_ | PACKET_FLAG_GAMESTATE; 71 71 data_=data; 72 header_ = new GamestateHeader(data_); 73 } 74 75 Gamestate::Gamestate(const Gamestate& g) : 76 Packet( *(Packet*)&g ) 77 { 78 flags_ = flags_ | PACKET_FLAG_GAMESTATE; 72 79 header_ = new GamestateHeader(data_); 73 80 } … … 146 153 bool Gamestate::spreadData(uint8_t mode) 147 154 { 155 COUT(4) << "processing gamestate with id " << header_->getID() << endl; 148 156 assert(data_); 149 157 assert(!header_->isCompressed()); -
code/branches/presentation/src/network/packet/Gamestate.h
r2655 r2660 48 48 class _NetworkExport GamestateHeader{ 49 49 public: 50 GamestateHeader(uint8_t *data){ data_ = data; *(uint32_t*)data_ = ENUM::Gamestate; }50 GamestateHeader(uint8_t *data){ assert(data); data_ = data; *(uint32_t*)data_ = ENUM::Gamestate; } 51 51 GamestateHeader(uint8_t *data, GamestateHeader* h) 52 {data_=data; memcpy(data_, h->data_, getSize()); }52 { assert(data); data_=data; memcpy(data_, h->data_, getSize()); } 53 53 static inline uint32_t getSize() 54 54 { return 21; } 55 55 56 56 inline int32_t getID() const 57 {return *(int32_t*)(data_+4); }57 { assert(data_); return *(int32_t*)(data_+4); } 58 58 inline void setID(int32_t id) 59 {*(int32_t*)(data_+4) = id; }59 { assert(data_); *(int32_t*)(data_+4) = id; } 60 60 61 61 inline int32_t getBaseID() const 62 {return *(int32_t*)(data_+8); }62 { assert(data_); return *(int32_t*)(data_+8); } 63 63 inline void setBaseID(int32_t id) 64 {*(int32_t*)(data_+8) = id; }64 { assert(data_); *(int32_t*)(data_+8) = id; } 65 65 66 66 inline uint32_t getDataSize() const 67 {return *(uint32_t*)(data_+12); }67 { assert(data_); return *(uint32_t*)(data_+12); } 68 68 inline void setDataSize(uint32_t size) 69 {*(uint32_t*)(data_+12) = size; }69 { assert(data_); *(uint32_t*)(data_+12) = size; } 70 70 71 71 inline uint32_t getCompSize() const 72 {return *(uint32_t*)(data_+16); }72 { assert(data_); return *(uint32_t*)(data_+16); } 73 73 inline void setCompSize(uint32_t size) 74 {*(uint32_t*)(data_+16) = size; }74 { assert(data_); *(uint32_t*)(data_+16) = size; } 75 75 76 76 inline bool isDiffed() const 77 {return *(int8_t*)(data_+20) & 0x1; }77 { assert(data_); return *(int8_t*)(data_+20) & 0x1; } 78 78 inline void setDiffed(bool b) 79 {*(int8_t*)(data_+20) = (b<<0) | (*(int8_t*)(data_+20) & 0x6 ); }79 { assert(data_); *(int8_t*)(data_+20) = (b<<0) | (*(int8_t*)(data_+20) & 0x6 ); } 80 80 81 81 inline bool isComplete() const 82 {return *(int8_t*)(data_+20) & 0x2; }82 { assert(data_); return *(int8_t*)(data_+20) & 0x2; } 83 83 inline void setComplete(bool b) 84 {*(int8_t*)(data_+20) = (b<<1) | (*(int8_t*)(data_+20) & 0x5 ); }84 { assert(data_); *(int8_t*)(data_+20) = (b<<1) | (*(int8_t*)(data_+20) & 0x5 ); } 85 85 86 86 inline bool isCompressed() const 87 {return *(int8_t*)(data_+20) & 0x4; }87 { assert(data_); return *(int8_t*)(data_+20) & 0x4; } 88 88 inline void setCompressed(bool b) 89 {*(int8_t*)(data_+20) = (b<<2) | (*(int8_t*)(data_+20) & 0x3 ); }89 { assert(data_); *(int8_t*)(data_+20) = (b<<2) | (*(int8_t*)(data_+20) & 0x3 ); } 90 90 91 91 inline void operator=(GamestateHeader& h) 92 {memcpy( data_, h.data_, getSize()); }92 { assert(data_); assert(h.data_); memcpy( data_, h.data_, getSize()); } 93 93 private: 94 94 uint8_t *data_; … … 107 107 Gamestate(uint8_t *data, unsigned int clientID); 108 108 Gamestate(uint8_t *data); 109 Gamestate(const Gamestate& g); 109 110 110 111 ~Gamestate();
Note: See TracChangeset
for help on using the changeset viewer.