Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 9, 2008, 11:23:40 AM (16 years ago)
Author:
scheusso
Message:

backsync should now work correctly (server can move again ;) )

Location:
code/branches/network/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network/src/network/Server.cc

    r1742 r1748  
    326326    w->setClientID(temp->getID());
    327327    assert(w->send());
     328    packet::Gamestate *g = new packet::Gamestate();
     329    g->setClientID(temp->getID());
     330    assert(g->collectData(0));
     331    assert(g->compressData());
     332    assert(g->send());
    328333    return true;
    329334  }
     
    353358    no->setCamera(std::string("cam_") + convertToString(client->getID()));
    354359    no->create();
    355     no->setBacksync(true);
    356360   
    357361    return true;
  • code/branches/network/src/network/Synchronisable.cc

    r1742 r1748  
    6464    datasize=0;
    6565    objectFrequency_=1;
     66    objectMode_=0x1; // by default do not send data to servere
    6667    objectID=idCounter++;
    6768    syncList = new std::list<synchronisableVariable *>;
     
    8283  }
    8384
     85 
    8486  void Synchronisable::setClient(bool b){
    8587    if(b) // client
     
    314316  }
    315317 
     318  /**
     319   *
     320   * @param id
     321   * @return
     322   */
    316323  bool Synchronisable::isMyTick(unsigned int id){
    317324//     return true;
    318     return id==0 || id%objectFrequency_==objectID%objectFrequency_;
     325    return ( id==0 || id%objectFrequency_==objectID%objectFrequency_ ) && ((objectMode_&state_)!=0);
    319326  }
    320327 
     
    333340  }
    334341 
    335   void Synchronisable::setBacksync(bool sync){
    336     backsync_=sync;
    337   }
    338 
    339   bool Synchronisable::getBacksync(){
    340     return backsync_;
    341   }
     342  void Synchronisable::setObjectMode(int mode){
     343    assert(mode==0x1 || mode==0x2 || mode==0x3);
     344    objectMode_=mode;
     345  }
     346
    342347
    343348}
  • code/branches/network/src/network/Synchronisable.h

    r1742 r1748  
    3434#include <list>
    3535#include "core/OrxonoxClass.h"
     36#include "util/XMLIncludes.h"
    3637#include "NetworkCallback.h"
    3738
     
    6667  class _NetworkExport Synchronisable : virtual public orxonox::OrxonoxClass{
    6768  public:
    68 
     69   
    6970    virtual ~Synchronisable();
    7071    unsigned int objectID;
     
    7677    bool updateData(unsigned char*& mem, int mode=0x0);
    7778    bool isMyData(unsigned char* mem);
    78     void setBacksync(bool sync);
    79     bool getBacksync();
     79    void setObjectMode(int mode);
     80    void setObjectFrequency(unsigned int freq){ objectFrequency_ = freq; }
     81   
    8082    virtual void registerAllVariables()=0;
    8183    virtual bool create();
     
    9395    bool backsync_; // if true the variables with mode > 1 will be synchronised to server (client -> server)
    9496    unsigned int objectFrequency_;
     97    int objectMode_;
    9598  };
    9699}
  • code/branches/network/src/network/packet/Welcome.cc

    r1735 r1748  
    3232#include "Welcome.h"
    3333#include "network/Host.h"
     34#include "network/Synchronisable.h"
    3435#include "core/CoreIncludes.h"
    3536#include <assert.h>
     
    7980  Host::setShipID(shipID);
    8081  COUT(3) << "Welcome set clientId: " << clientID << " shipID: " << shipID << std::endl;
     82  Synchronisable::setClient(true);
    8183  delete this;
    8284  return true;
  • code/branches/network/src/orxonox/objects/Model.cc

    r1627 r1748  
    4545    CreateFactory(Model);
    4646
     47    /**
     48     *
     49     */
    4750    Model::Model()
    4851    {
    4952        RegisterObject(Model);
    5053        registerAllVariables();
     54        if(this->isExactlyA(Class(Model)))
     55           setObjectFrequency(1);
    5156    }
    5257
  • code/branches/network/src/orxonox/objects/SpaceShip.cc

    r1742 r1748  
    166166        if(network::Host::running())
    167167          COUT(3) << "this id: " << this->objectID << " myShipID: " << network::Host::getShipID() << std::endl;
    168         if(network::Host::running() && objectID == network::Host::getShipID())
     168        if(network::Host::running() && objectID == network::Host::getShipID()){
     169          setObjectMode(0x3);
    169170          myShip_=true;
     171        }
    170172        else
    171173          this->setRadarObjectColour(this->getProjectileColour());
     
    360362      if(myShip_){
    361363        COUT(3) << "requesting focus for camera" << std::endl;
    362         this->setBacksync(true);
    363364        //CameraHandler::getInstance()->requestFocus(cam_);
    364365        if(this->isExactlyA(Class(SpaceShip))){
     
    466467            }
    467468
    468             projectile->setBacksync(true);
     469            projectile->setObjectMode(0x3);
    469470            this->timeToReload_ = this->reloadTime_;
    470471        }
Note: See TracChangeset for help on using the changeset viewer.