Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 5, 2008, 1:19:22 AM (16 years ago)
Author:
scheusso
Message:

a lot of changes in order to make it possible to have mulpiple clients with each one a new ship
camera changes
object changes
synchronisable: backsyncronisation should be possible now
gamestatemanager/gamestateclient: functions for backsyncronisation
some changes in order to get the input system (the old one) on the client working
TODO something with the camera position is wrong at the moment (clientside)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network3/src/network/Synchronisable.cc

    r1199 r1232  
    4848namespace network
    4949{
     50 
     51 
     52  int Synchronisable::state_=1; // detemines wheter we are server (default) or client
     53 
    5054  /**
    5155  * Constructor:
     
    6367  Synchronisable::~Synchronisable(){
    6468  }
     69 
     70  void Synchronisable::setClient(bool b){
     71    if(b) // client
     72      state_=0x2;
     73    else  // server
     74      state_=0x1;
     75  }
    6576
    6677  /**
     
    7081  * @param size size of the datatype the variable consists of
    7182  */
    72   void Synchronisable::registerVar(void *var, int size, variableType t){
     83  void Synchronisable::registerVar(void *var, int size, variableType t, int mode){
    7384    // create temporary synch.Var struct
    7485    synchronisableVariable *temp = new synchronisableVariable;
    7586    temp->size = size;
    7687    temp->var = var;
     88    temp->mode = mode;
    7789    temp->type = t;
    7890    COUT(5) << "Syncronisable::registering var with size: " << temp->size << " and type: " << temp->type << std::endl;
     
    153165    for(i=syncList->begin(); n<datasize && i!=syncList->end(); ++i){
    154166      //(std::memcpy(retVal.data+n, (const void*)(&(i->size)), sizeof(int));
     167      if( ((*i)->mode & state_) == 0 )
     168        continue;  // this variable should only be received
    155169      switch((*i)->type){
    156170      case DATA:
     
    185199    COUT(5) << "Synchronisable: objectID " << vars.objectID << ", classID " << vars.classID << " size: " << vars.length << " synchronising data" << std::endl;
    186200    for(i=syncList->begin(); i!=syncList->end(); i++){
     201      if( ((*i)->mode ^ state_) == 0 )
     202        continue;  // this variable should only be sent
    187203      COUT(5) << "Synchronisable: element size: " << (*i)->size << " type: " << (*i)->type << std::endl;
    188204      switch((*i)->type){
     
    212228    std::list<synchronisableVariable *>::iterator i;
    213229    for(i=syncList->begin(); i!=syncList->end(); i++){
     230      if( ((*i)->mode & state_) == 0 )
     231        continue;  // this variable should only be received, so dont add its size to the send-size
    214232      switch((*i)->type){
    215233      case DATA:
     
    226244    return tsize;
    227245  }
    228 
     246 
     247  void Synchronisable::setBacksync(bool sync){
     248    backsync_=sync;
     249  }
     250
     251  bool Synchronisable::getBacksync(){
     252    return backsync_;
     253  }
     254 
    229255}
Note: See TracChangeset for help on using the changeset viewer.