Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 14, 2010, 8:54:00 PM (14 years ago)
Author:
scheusso
Message:

a lot of changes:

  • some fixes (mostly gamestate:diff)
  • FunctionCall buffering (if Gamestate is not recent enough)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network5/src/libraries/network/synchronisable/Synchronisable.h

    r7163 r7759  
    6565    };
    6666  }
    67  
    68   typedef uint8_t VariableID;
    69 
    70   /**
    71    * @brief: stores information about a Synchronisable
    72    *
    73    * This class stores the information about a Synchronisable (objectID_, classID_, creatorID_, dataSize)
    74    * in an emulated bitset.
    75    * Bit 1 to 31 store the size of the Data the synchronisable consumes in the stream
    76    * Bit 32 is a bool and defines whether the variables are stored in diff mode
    77    * Byte 5 to 8: objectID_
    78    * Byte 9 to 12: classID_
    79    * Byte 13 to 16: creatorID_
    80    */
    81   class _NetworkExport SynchronisableHeader{
    82     friend class SynchronisableHeaderLight;
    83     private:
    84       uint8_t* data_;
    85     public:
    86       SynchronisableHeader(uint8_t* data)
    87         { data_ = data; }
    88       inline static uint32_t getSize()
    89         { return 14; }
    90       inline uint16_t getDataSize() const
    91         { return (*(uint16_t*)data_) & 0x7FFF; } //only use the first 15 bits
    92       inline void setDataSize(uint16_t size)
    93         { *(uint16_t*)(data_) = (size & 0x7FFF) | (*(uint16_t*)(data_) & 0x8000 ); }
    94       inline bool isDiffed() const
    95         { return ( (*(uint16_t*)data_) & 0x8000 ) == 0x8000; }
    96       inline void setDiffed( bool b)
    97         { *(uint16_t*)(data_) = (b << 15) | (*(uint16_t*)(data_) & 0x7FFF ); }
    98       inline uint32_t getObjectID() const
    99         { return *(uint32_t*)(data_+2); }
    100       inline void setObjectID(uint32_t objectID_)
    101         { *(uint32_t*)(data_+2) = objectID_; }
    102       inline uint32_t getClassID() const
    103         { return *(uint32_t*)(data_+6); }
    104       inline void setClassID(uint32_t classID_)
    105         { *(uint32_t*)(data_+6) = classID_; }
    106       inline uint32_t getCreatorID() const
    107         { return *(uint32_t*)(data_+10); }
    108       inline void setCreatorID(uint32_t creatorID_)
    109         { *(uint32_t*)(data_+10) = creatorID_; }
    110       inline void operator=(SynchronisableHeader& h)
    111         { memcpy(data_, h.data_, getSize()); }
    112   };
    11367
    11468    /**
     
    12175   * Byte 5 to 8: objectID_
    12276   */
    123   class _NetworkExport SynchronisableHeaderLight{
    124     private:
     77  class _NetworkExport SynchronisableHeaderLight
     78  {
     79    protected:
    12580      uint8_t* data_;
    12681    public:
     
    14196      inline void setObjectID(uint32_t objectID_)
    14297        { *(uint32_t*)(data_+2) = objectID_; }
     98      inline void operator=(SynchronisableHeaderLight& h)
     99        { memcpy(data_, h.data_, SynchronisableHeaderLight::getSize()); }
     100  };
     101 
     102  typedef uint8_t VariableID;
     103 
     104  /**
     105   * @brief: stores information about a Synchronisable
     106   *
     107   * This class stores the information about a Synchronisable (objectID_, classID_, creatorID_, dataSize)
     108   * in an emulated bitset.
     109   * Bit 1 to 31 store the size of the Data the synchronisable consumes in the stream
     110   * Bit 32 is a bool and defines whether the variables are stored in diff mode
     111   * Byte 5 to 8: objectID_
     112   * Byte 9 to 12: classID_
     113   * Byte 13 to 16: creatorID_
     114   */
     115  class _NetworkExport SynchronisableHeader: public SynchronisableHeaderLight
     116  {
     117    public:
     118      SynchronisableHeader(uint8_t* data): SynchronisableHeaderLight(data)
     119        {}
     120      inline static uint32_t getSize()
     121        { return SynchronisableHeaderLight::getSize()+8; }
     122      inline uint32_t getClassID() const
     123        { return *(uint32_t*)(data_+SynchronisableHeaderLight::getSize()); }
     124      inline void setClassID(uint32_t classID_)
     125        { *(uint32_t*)(data_+SynchronisableHeaderLight::getSize()) = classID_; }
     126      inline uint32_t getCreatorID() const
     127        { return *(uint32_t*)(data_+SynchronisableHeaderLight::getSize()+4); }
     128      inline void setCreatorID(uint32_t creatorID_)
     129        { *(uint32_t*)(data_+SynchronisableHeaderLight::getSize()+4) = creatorID_; }
    143130      inline void operator=(SynchronisableHeader& h)
    144131        { memcpy(data_, h.data_, getSize()); }
    145132  };
     133 
     134//   inline void operator=(SynchronisableHeaderLight& h1, SynchronisableHeader& h2)
     135//   {
     136//     memcpy(h1.data_, h2.data_, h1.getSize());
     137//   }
    146138
    147139  /**
Note: See TracChangeset for help on using the changeset viewer.