Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 4, 2008, 5:12:31 PM (16 years ago)
Author:
scheusso
Message:

bidirectional synchronisation works now:
register variables with mode direction::serverMaster or direction::clientMaster
clientMaster: both sides may change the variable but the client is master
serverMaster: both sides may change the variable but the server is master

File:
1 edited

Legend:

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

    r2112 r2132  
    7171}
    7272
    73 bool Gamestate::collectData(int id, int mode)
    74 {
    75   int tempsize=0, currentsize=0;
     73bool Gamestate::collectData(int id, uint8_t mode)
     74{
     75  unsigned int tempsize=0, currentsize=0;
    7676  assert(data_==0);
    77   int size = calcGamestateSize(id, mode);
     77  unsigned int size = calcGamestateSize(id, mode);
    7878
    7979  COUT(4) << "G.ST.Man: producing gamestate with id: " << id << std::endl;
     
    8686  }
    8787
    88 #ifndef NDEBUG
    89   std::list<Synchronisable*> slist;
    90   std::list<Synchronisable*>::iterator iit;
    91 #endif
    9288  //start collect data synchronisable by synchronisable
    9389  uint8_t *mem=data_;
     
    9894
    9995    if(currentsize+tempsize > size){
     96      assert(0); // if we don't use multithreading this part shouldn't be neccessary
    10097      // start allocate additional memory
    10198      COUT(3) << "G.St.Man: need additional memory" << std::endl;
     
    110107    }// stop allocate additional memory
    111108
    112 #ifndef NDEBUG
    113     for(iit=slist.begin(); iit!=slist.end(); iit++)
    114       assert((*iit)!=*it);
    115     slist.push_back(*it);
    116 #endif
    117109
    118110    //if(it->doSelection(id))
     
    127119  //start write gamestate header
    128120  HEADER->packetType = ENUM::Gamestate;
    129   assert( *(ENUM::Type *)(data_) == ENUM::Gamestate);
    130121  HEADER->datasize = currentsize;
    131122  HEADER->id = id;
     
    140131}
    141132
    142 bool Gamestate::spreadData(int mode)
     133bool Gamestate::spreadData(uint8_t mode)
    143134{
    144135  assert(data_);
     
    163154      bool b = s->updateData(mem, mode);
    164155      assert(b);
    165       //if(!s->updateData(mem, mode))
    166         //return false;
    167156    }
    168157  }
     
    367356    assert(it->second->objectID==oldobjectheader->objectID);
    368357    *newobjectheader = *oldobjectheader;
    369     objectOffset=sizeof(uint8_t)+sizeof(bool); //skip the size and the availableData variables in the objectheader
     358    objectOffset=sizeof(synchronisableHeader); //skip the size and the availableData variables in the objectheader
    370359    if(it->second->doSelection(HEADER->id)){
    371360      newobjectheader->dataAvailable=true; //TODO: probably not neccessary
     
    565554
    566555
    567 unsigned int Gamestate::calcGamestateSize(unsigned int id, int mode)
    568 {
    569   int size=0;
     556unsigned int Gamestate::calcGamestateSize(unsigned int id, uint8_t mode)
     557{
     558  unsigned int size=0;
    570559    // get the start of the Synchronisable list
    571560  ObjectList<Synchronisable>::iterator it;
Note: See TracChangeset for help on using the changeset viewer.