Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 14, 2009, 6:01:05 PM (16 years ago)
Author:
scheusso
Message:

fixed a problem with gamestate caching and diffing

Location:
code/branches/presentation/src/network/packet
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation/src/network/packet/Acknowledgement.cc

    r2171 r2660  
    6464
    6565bool Acknowledgement::process(){
     66COUT(0) << "processing ACK with ID: " << getAckID() << endl;
    6667  bool b = GamestateHandler::ackGamestate(getAckID(), clientID_);
    6768  delete this;
  • code/branches/presentation/src/network/packet/Gamestate.cc

    r2655 r2660  
    7070  flags_ = flags_ | PACKET_FLAG_GAMESTATE;
    7171  data_=data;
     72  header_ = new GamestateHeader(data_);
     73}
     74
     75Gamestate::Gamestate(const Gamestate& g) :
     76    Packet( *(Packet*)&g )
     77{
     78  flags_ = flags_ | PACKET_FLAG_GAMESTATE;
    7279  header_ = new GamestateHeader(data_);
    7380}
     
    146153bool Gamestate::spreadData(uint8_t mode)
    147154{
     155  COUT(4) << "processing gamestate with id " << header_->getID() << endl;
    148156  assert(data_);
    149157  assert(!header_->isCompressed());
  • code/branches/presentation/src/network/packet/Gamestate.h

    r2655 r2660  
    4848class _NetworkExport GamestateHeader{
    4949  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; }
    5151    GamestateHeader(uint8_t *data, GamestateHeader* h)
    52       { data_=data; memcpy(data_, h->data_, getSize()); }
     52    { assert(data); data_=data; memcpy(data_, h->data_, getSize()); }
    5353    static inline uint32_t getSize()
    54       { return 21; }
     54    { return 21; }
    5555
    5656    inline int32_t getID() const
    57       { return *(int32_t*)(data_+4); }
     57    { assert(data_); return *(int32_t*)(data_+4); }
    5858    inline void setID(int32_t id)
    59       { *(int32_t*)(data_+4) = id; }
     59    { assert(data_); *(int32_t*)(data_+4) = id; }
    6060
    6161    inline int32_t getBaseID() const
    62       { return *(int32_t*)(data_+8); }
     62    { assert(data_); return *(int32_t*)(data_+8); }
    6363    inline void setBaseID(int32_t id)
    64       { *(int32_t*)(data_+8) = id; }
     64    { assert(data_); *(int32_t*)(data_+8) = id; }
    6565
    6666    inline uint32_t getDataSize() const
    67       { return *(uint32_t*)(data_+12); }
     67    { assert(data_); return *(uint32_t*)(data_+12); }
    6868    inline void setDataSize(uint32_t size)
    69       { *(uint32_t*)(data_+12) = size; }
     69    { assert(data_); *(uint32_t*)(data_+12) = size; }
    7070
    7171    inline uint32_t getCompSize() const
    72       { return *(uint32_t*)(data_+16); }
     72    { assert(data_); return *(uint32_t*)(data_+16); }
    7373    inline void setCompSize(uint32_t size)
    74       { *(uint32_t*)(data_+16) = size; }
     74    { assert(data_); *(uint32_t*)(data_+16) = size; }
    7575
    7676    inline bool isDiffed() const
    77       { return *(int8_t*)(data_+20) & 0x1; }
     77    { assert(data_); return *(int8_t*)(data_+20) & 0x1; }
    7878    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 ); }
    8080
    8181    inline bool isComplete() const
    82       { return *(int8_t*)(data_+20) & 0x2; }
     82    { assert(data_); return *(int8_t*)(data_+20) & 0x2; }
    8383    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 ); }
    8585
    8686    inline bool isCompressed() const
    87       { return *(int8_t*)(data_+20) & 0x4; }
     87    { assert(data_); return *(int8_t*)(data_+20) & 0x4; }
    8888    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 ); }
    9090
    9191    inline void operator=(GamestateHeader& h)
    92       { memcpy( data_, h.data_, getSize()); }
     92    { assert(data_); assert(h.data_); memcpy( data_, h.data_, getSize()); }
    9393  private:
    9494    uint8_t *data_;
     
    107107    Gamestate(uint8_t *data, unsigned int clientID);
    108108    Gamestate(uint8_t *data);
     109    Gamestate(const Gamestate& g);
    109110
    110111    ~Gamestate();
Note: See TracChangeset for help on using the changeset viewer.