Changeset 2660 for code/branches/presentation/src/network/packet
- Timestamp:
- Feb 14, 2009, 6:01:05 PM (16 years ago)
- Location:
- code/branches/presentation/src/network/packet
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
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.