- Timestamp:
- Dec 12, 2010, 11:13:01 PM (15 years ago)
- Location:
- code/branches/network5
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network5
- Property svn:mergeinfo changed
/code/branches/network3 (added) merged: 7333,7336-7337,7344 /code/branches/network4 (added) merged: 7497,7718,7753-7755
- Property svn:mergeinfo changed
-
code/branches/network5/src/libraries/network/packet/Gamestate.h
r7163 r7758 48 48 class _NetworkExport GamestateHeader{ 49 49 public: 50 GamestateHeader(uint8_t *data){ assert(data); data_ = data; *(uint32_t*)data_ = Type::Gamestate; } 51 GamestateHeader(uint8_t *data, GamestateHeader* h) 52 { assert(data); data_=data; memcpy(data_, h->data_, getSize()); } 50 GamestateHeader(){ data_=0; } 51 GamestateHeader(uint8_t* data) 52 { assert(data); data_ = data; *(uint32_t*)data_ = Type::Gamestate; } 53 /*GamestateHeader(uint8_t* data, GamestateHeader* h) 54 { assert(data); data_=data; memcpy(data_, h->data_, getSize()); }*/ 55 void setData(uint8_t* data) 56 { assert(data); data_ = data; *(uint32_t*)data_ = Type::Gamestate; } 53 57 static inline uint32_t getSize() 54 { return 21; }58 { return 21; } 55 59 56 60 inline int32_t getID() const 57 { assert(data_); return *(int32_t*)(data_+4); }61 { assert(data_); return *(int32_t*)(data_+4); } 58 62 inline void setID(int32_t id) 59 { assert(data_); *(int32_t*)(data_+4) = id; }63 { assert(data_); *(int32_t*)(data_+4) = id; } 60 64 61 65 inline int32_t getBaseID() const 62 { assert(data_); return *(int32_t*)(data_+8); }66 { assert(data_); return *(int32_t*)(data_+8); } 63 67 inline void setBaseID(int32_t id) 64 { assert(data_); *(int32_t*)(data_+8) = id; }68 { assert(data_); *(int32_t*)(data_+8) = id; } 65 69 66 70 inline uint32_t getDataSize() const 67 { assert(data_); return *(uint32_t*)(data_+12); }71 { assert(data_); return *(uint32_t*)(data_+12); } 68 72 inline void setDataSize(uint32_t size) 69 { assert(data_); *(uint32_t*)(data_+12) = size; }73 { assert(data_); *(uint32_t*)(data_+12) = size; } 70 74 71 75 inline uint32_t getCompSize() const … … 75 79 76 80 inline bool isDiffed() const 77 { assert(data_); return *(int8_t*)(data_+20) & 0x1; }81 { assert(data_); return *(int8_t*)(data_+20) & 0x1; } 78 82 inline void setDiffed(bool b) 79 { assert(data_); *(int8_t*)(data_+20) = (b<<0) | (*(int8_t*)(data_+20) & 0x6 ); }83 { assert(data_); *(int8_t*)(data_+20) = (b<<0) | (*(int8_t*)(data_+20) & 0x6 ); } 80 84 81 85 inline bool isComplete() const 82 { assert(data_); return *(int8_t*)(data_+20) & 0x2; }86 { assert(data_); return *(int8_t*)(data_+20) & 0x2; } 83 87 inline void setComplete(bool b) 84 { assert(data_); *(int8_t*)(data_+20) = (b<<1) | (*(int8_t*)(data_+20) & 0x5 ); }88 { assert(data_); *(int8_t*)(data_+20) = (b<<1) | (*(int8_t*)(data_+20) & 0x5 ); } 85 89 86 90 inline bool isCompressed() const 87 { assert(data_); return *(int8_t*)(data_+20) & 0x4; }91 { assert(data_); return *(int8_t*)(data_+20) & 0x4; } 88 92 inline void setCompressed(bool b) 89 { assert(data_); *(int8_t*)(data_+20) = (b<<2) | (*(int8_t*)(data_+20) & 0x3 ); }93 { assert(data_); *(int8_t*)(data_+20) = (b<<2) | (*(int8_t*)(data_+20) & 0x3 ); } 90 94 91 95 inline void operator=(GamestateHeader& h) 92 { assert(data_); assert(h.data_); memcpy( data_, h.data_, getSize()); }96 { assert(data_); assert(h.data_); memcpy( data_, h.data_, getSize()); } 93 97 private: 94 uint8_t *data_;98 uint8_t* data_; 95 99 96 100 }; … … 110 114 bool collectData(int id, uint8_t mode=0x0); 111 115 bool spreadData( uint8_t mode=0x0); 112 inline int32_t getID() const { return header_ ->getID(); }113 inline bool isDiffed() const { return header_ ->isDiffed(); }114 inline bool isCompressed() const { return header_ ->isCompressed(); }115 inline int32_t getBaseID() const { return header_ ->getBaseID(); }116 inline uint32_t getDataSize() const { return header_ ->getDataSize(); }116 inline int32_t getID() const { return header_.getID(); } 117 inline bool isDiffed() const { return header_.isDiffed(); } 118 inline bool isCompressed() const { return header_.isCompressed(); } 119 inline int32_t getBaseID() const { return header_.getBaseID(); } 120 inline uint32_t getDataSize() const { return header_.getDataSize(); } 117 121 Gamestate* diffVariables(Gamestate *base); 118 Gamestate* diffData(Gamestate *base);119 Gamestate *undiff(Gamestate *base);120 Gamestate* doSelection(unsigned int clientID, unsigned int targetSize);122 // Gamestate* diffData(Gamestate *base); 123 // Gamestate *undiff(Gamestate *base); 124 // Gamestate* doSelection(unsigned int clientID, unsigned int targetSize); 121 125 bool compressData(); 122 126 bool decompressData(); … … 125 129 // Packet functions 126 130 private: 127 void rawDiff( uint8_t* newdata, uint8_t* data, uint8_t* basedata, uint32_t datalength, uint32_t baselength);128 inline uint32_t findObject( const SynchronisableHeader& header, uint8_t* mem, uint32_t dataLength, uint32_t startPosition = 0 );131 // void rawDiff( uint8_t* newdata, uint8_t* data, uint8_t* basedata, uint32_t datalength, uint32_t baselength); 132 // inline uint32_t findObject( const SynchronisableHeader& header, uint8_t* mem, uint32_t dataLength, uint32_t startPosition = 0 ); 129 133 virtual uint32_t getSize() const; 130 134 virtual inline bool process(); 131 135 uint32_t calcGamestateSize(int32_t id, uint8_t mode=0x0); 136 // inline void diffObject( uint8_t*& newData, uint8_t*& origData, uint8_t*& baseData, SynchronisableHeader& objectHeader, std::vector<uint32_t>::iterator& sizes ); 137 // inline void copyObject( uint8_t*& newData, uint8_t*& origData, uint8_t*& baseData, SynchronisableHeader& objectHeader, std::vector<uint32_t>::iterator& sizes ); 132 138 133 139 std::list<obj> dataVector_; 134 GamestateHeader *header_;140 GamestateHeader header_; 135 141 std::vector<uint32_t> sizes_; 136 142 uint32_t nrOfVariables_;
Note: See TracChangeset
for help on using the changeset viewer.