Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 2, 2008, 9:10:00 PM (16 years ago)
Author:
scheusso
Message:

made some adjustments mostly to the networkid (classid) in order to have it platform independent

Location:
code/branches/network64/src/network/packet
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network64/src/network/packet/Gamestate.cc

    r2171 r2309  
    7373bool Gamestate::collectData(int id, uint8_t mode)
    7474{
    75   unsigned int tempsize=0, currentsize=0;
     75  uint32_t tempsize=0, currentsize=0;
    7676  assert(data_==0);
    77   unsigned int size = calcGamestateSize(id, mode);
     77  uint32_t size = calcGamestateSize(id, mode);
    7878
    7979  COUT(4) << "G.ST.Man: producing gamestate with id: " << id << std::endl;
     
    166166}
    167167
    168 unsigned int Gamestate::getSize() const
     168uint32_t Gamestate::getSize() const
    169169{
    170170  assert(data_);
     
    251251  assert(HEADER->compressed);
    252252  COUT(4) << "GameStateClient: uncompressing gamestate. id: " << HEADER->id << ", baseid: " << HEADER->base_id << ", datasize: " << HEADER->datasize << ", compsize: " << HEADER->compsize << std::endl;
    253   unsigned int datasize = HEADER->datasize;
    254   unsigned int compsize = HEADER->compsize;
    255   unsigned int bufsize;
     253  uint32_t datasize = HEADER->datasize;
     254  uint32_t compsize = HEADER->compsize;
     255  uint32_t bufsize;
    256256//  assert(compsize<=datasize);
    257257  bufsize = datasize;
     
    302302  //unsigned char *basep = base->getGs()/*, *gs = getGs()*/;
    303303  uint8_t *basep = GAMESTATE_START(base->data_), *gs = GAMESTATE_START(this->data_);
    304   unsigned int of=0; // pointers offset
    305   unsigned int dest_length=0;
     304  uint32_t of=0; // pointers offset
     305  uint32_t dest_length=0;
    306306  dest_length=HEADER->datasize;
    307307  if(dest_length==0)
     
    334334Gamestate* Gamestate::doSelection(unsigned int clientID){
    335335  assert(data_);
    336   std::map<unsigned int, Synchronisable *>::iterator it;
     336  std::map<uint32_t, Synchronisable *>::iterator it;
    337337
    338338  // allocate memory for new data
     
    347347
    348348  synchronisableHeader *oldobjectheader, *newobjectheader;
    349   unsigned int objectOffset;
     349  uint32_t objectOffset;
    350350
    351351  //copy in the zeros
     
    353353    oldobjectheader = (synchronisableHeader*)origdata;
    354354    newobjectheader = (synchronisableHeader*)newdata;
    355     unsigned int objectsize = oldobjectheader->size;
     355    uint32_t objectsize = oldobjectheader->size;
    356356    assert(it->second->objectID==oldobjectheader->objectID);
    357357    *newobjectheader = *oldobjectheader;
     
    382382
    383383  //preparations
    384   std::map<unsigned int, Synchronisable *>::iterator it;
     384  std::map<uint32_t, Synchronisable *>::iterator it;
    385385  uint8_t *origdata, *basedata, *destdata, *ndata;
    386   unsigned int objectOffset, streamOffset=0;    //data offset
    387   unsigned int minsize = (HEADER->datasize < GAMESTATE_HEADER(base->data_)->datasize) ? HEADER->datasize : GAMESTATE_HEADER(base->data_)->datasize;
     386  uint32_t objectOffset, streamOffset=0;    //data offset
     387  uint32_t minsize = (HEADER->datasize < GAMESTATE_HEADER(base->data_)->datasize) ? HEADER->datasize : GAMESTATE_HEADER(base->data_)->datasize;
    388388  synchronisableHeader *origheader;
    389389  synchronisableHeader *destheader;
     
    402402
    403403    //copy and partially diff the object header
    404     assert(sizeof(synchronisableHeader)==3*sizeof(unsigned int)+sizeof(bool));
     404    assert(sizeof(synchronisableHeader)==3*sizeof(uint32_t)+sizeof(bool));
    405405    *(uint32_t*)destdata = *(uint32_t*)origdata; //size (do not diff)
    406406    *(bool*)(destdata+sizeof(uint32_t)) = sendData;
     
    450450
    451451  //preparations
    452   std::map<unsigned int, Synchronisable *>::iterator it;
     452  std::map<uint32_t, Synchronisable *>::iterator it;
    453453  uint8_t *origdata, *basedata, *destdata, *ndata;
    454   unsigned int objectOffset, streamOffset=0;    //data offset
    455   unsigned int minsize = (HEADER->datasize < GAMESTATE_HEADER(base->data_)->datasize) ? HEADER->datasize : GAMESTATE_HEADER(base->data_)->datasize;
     454  uint32_t objectOffset, streamOffset=0;    //data offset
     455  uint32_t minsize = (HEADER->datasize < GAMESTATE_HEADER(base->data_)->datasize) ? HEADER->datasize : GAMESTATE_HEADER(base->data_)->datasize;
    456456  synchronisableHeader *origheader;
    457457  synchronisableHeader *destheader;
     
    470470
    471471    //copy and partially diff the object header
    472     assert(sizeof(synchronisableHeader)==3*sizeof(unsigned int)+sizeof(bool));
    473     *(unsigned int*)destdata = *(unsigned int*)origdata; //size (do not diff)
    474     *(bool*)(destdata+sizeof(unsigned int)) = *(bool*)(origdata+sizeof(unsigned int));
    475     sendData = *(bool*)(origdata+sizeof(unsigned int));
     472    assert(sizeof(synchronisableHeader)==3*sizeof(uint32_t)+sizeof(bool));
     473    *(uint32_t*)destdata = *(uint32_t*)origdata; //size (do not diff)
     474    *(bool*)(destdata+sizeof(uint32_t)) = *(bool*)(origdata+sizeof(uint32_t));
     475    sendData = *(bool*)(origdata+sizeof(uint32_t));
    476476    if(sendData){
    477       *(unsigned int*)(destdata+sizeof(unsigned int)+sizeof(bool)) = *(unsigned int*)(basedata+sizeof(unsigned int)+sizeof(bool)) ^ *(unsigned int*)(origdata+sizeof(unsigned int)+sizeof(bool)); //objectid (diff it)
    478       *(unsigned int*)(destdata+2*sizeof(unsigned int)+sizeof(bool)) = *(unsigned int*)(basedata+2*sizeof(unsigned int)+sizeof(bool)) ^ *(unsigned int*)(origdata+2*sizeof(unsigned int)+sizeof(bool)); //classid (diff it)
     477      *(uint32_t*)(destdata+sizeof(uint32_t)+sizeof(bool)) = *(uint32_t*)(basedata+sizeof(uint32_t)+sizeof(bool)) ^ *(uint32_t*)(origdata+sizeof(uint32_t)+sizeof(bool)); //objectid (diff it)
     478      *(uint32_t*)(destdata+2*sizeof(uint32_t)+sizeof(bool)) = *(uint32_t*)(basedata+2*sizeof(uint32_t)+sizeof(bool)) ^ *(uint32_t*)(origdata+2*sizeof(uint32_t)+sizeof(bool)); //classid (diff it)
    479479    }else{
    480       *(unsigned int*)(destdata+sizeof(unsigned int)+sizeof(bool)) = 0;
    481       *(unsigned int*)(destdata+2*sizeof(unsigned int)+sizeof(bool)) = 0;
     480      *(uint32_t*)(destdata+sizeof(uint32_t)+sizeof(bool)) = 0;
     481      *(uint32_t*)(destdata+2*sizeof(uint32_t)+sizeof(bool)) = 0;
    482482    }
    483483    objectOffset=sizeof(synchronisableHeader);
     
    517517  uint8_t *basep = GAMESTATE_START(base->data_);
    518518  uint8_t *gs = GAMESTATE_START(this->data_);
    519   unsigned int of=0; // pointers offset
    520   unsigned int dest_length=0;
     519  uint32_t of=0; // pointers offset
     520  uint32_t dest_length=0;
    521521  dest_length=HEADER->datasize;
    522522  if(dest_length==0)
     
    548548
    549549
    550 unsigned int Gamestate::calcGamestateSize(unsigned int id, uint8_t mode)
    551 {
    552   unsigned int size=0;
     550uint32_t Gamestate::calcGamestateSize(int32_t id, uint8_t mode)
     551{
     552  uint32_t size=0;
    553553    // get the start of the Synchronisable list
    554554  ObjectList<Synchronisable>::iterator it;
  • code/branches/network64/src/network/packet/Gamestate.h

    r2211 r2309  
    8585    // Packet functions
    8686  private:
    87     virtual unsigned int getSize() const;
     87    virtual uint32_t getSize() const;
    8888    virtual bool process();
    8989
    9090    bool operator ==(packet::Gamestate gs);
    9191  private:
    92     unsigned int calcGamestateSize(unsigned int id, uint8_t mode=0x0);
     92    uint32_t calcGamestateSize(int32_t id, uint8_t mode=0x0);
    9393    void removeObject(ObjectListIterator<Synchronisable> &it);
    94     std::map<unsigned int, Synchronisable*> dataMap_;
     94    std::map<uint32_t, Synchronisable*> dataMap_;
    9595};
    9696
Note: See TracChangeset for help on using the changeset viewer.