Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 12, 2010, 11:13:01 PM (15 years ago)
Author:
scheusso
Message:

merging network4 into network5 branch

Location:
code/branches/network5
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network5

  • code/branches/network5/src/libraries/network/packet/Gamestate.h

    r7163 r7758  
    4848class _NetworkExport GamestateHeader{
    4949  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; }
    5357    static inline uint32_t getSize()
    54     { return 21; }
     58      { return 21; }
    5559
    5660    inline int32_t getID() const
    57     { assert(data_); return *(int32_t*)(data_+4); }
     61      { assert(data_); return *(int32_t*)(data_+4); }
    5862    inline void setID(int32_t id)
    59     { assert(data_); *(int32_t*)(data_+4) = id; }
     63      { assert(data_); *(int32_t*)(data_+4) = id; }
    6064
    6165    inline int32_t getBaseID() const
    62     { assert(data_); return *(int32_t*)(data_+8); }
     66      { assert(data_); return *(int32_t*)(data_+8); }
    6367    inline void setBaseID(int32_t id)
    64     { assert(data_); *(int32_t*)(data_+8) = id; }
     68      { assert(data_); *(int32_t*)(data_+8) = id; }
    6569
    6670    inline uint32_t getDataSize() const
    67     { assert(data_); return *(uint32_t*)(data_+12); }
     71      { assert(data_); return *(uint32_t*)(data_+12); }
    6872    inline void setDataSize(uint32_t size)
    69     { assert(data_); *(uint32_t*)(data_+12) = size; }
     73      { assert(data_); *(uint32_t*)(data_+12) = size; }
    7074
    7175    inline uint32_t getCompSize() const
     
    7579
    7680    inline bool isDiffed() const
    77     { assert(data_); return *(int8_t*)(data_+20) & 0x1; }
     81      { assert(data_); return *(int8_t*)(data_+20) & 0x1; }
    7882    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 ); }
    8084
    8185    inline bool isComplete() const
    82     { assert(data_); return *(int8_t*)(data_+20) & 0x2; }
     86      { assert(data_); return *(int8_t*)(data_+20) & 0x2; }
    8387    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 ); }
    8589
    8690    inline bool isCompressed() const
    87     { assert(data_); return *(int8_t*)(data_+20) & 0x4; }
     91      { assert(data_); return *(int8_t*)(data_+20) & 0x4; }
    8892    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 ); }
    9094
    9195    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()); }
    9397  private:
    94     uint8_t *data_;
     98    uint8_t* data_;
    9599
    96100};
     
    110114    bool collectData(int id, uint8_t mode=0x0);
    111115    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(); }
    117121    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);
    121125    bool compressData();
    122126    bool decompressData();
     
    125129    // Packet functions
    126130  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 );
    129133    virtual uint32_t getSize() const;
    130134    virtual inline bool process();
    131135    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 );
    132138   
    133139    std::list<obj>          dataVector_;
    134     GamestateHeader*        header_;
     140    GamestateHeader         header_;
    135141    std::vector<uint32_t>   sizes_;
    136142    uint32_t                nrOfVariables_;
Note: See TracChangeset for help on using the changeset viewer.