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

Location:
code/branches/objecthierarchy/src/orxonox/objects
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy/src/orxonox/objects/Test.cc

    r2112 r2132  
    3030#include "core/CoreIncludes.h"
    3131#include "core/ConfigValueIncludes.h"
     32#include "core/ConsoleCommand.h"
    3233#include "Test.h"
    3334
     
    3536{
    3637        CreateFactory ( Test );
     38 
     39  SetConsoleCommand(Test, printV1, true).accessLevel(AccessLevel::User);
     40  SetConsoleCommand(Test, printV2, true).accessLevel(AccessLevel::User);
     41  SetConsoleCommand(Test, printV3, true).accessLevel(AccessLevel::User);
     42  SetConsoleCommand(Test, printV4, true).accessLevel(AccessLevel::User);
     43 
     44  Test* Test::instance_ = 0;
    3745
    3846        Test::Test(BaseObject* creator) : BaseObject(creator), Synchronisable(creator)
    3947        {
     48    assert(instance_==0);
     49    instance_=this;
    4050                RegisterObject ( Test );
    41                 setConfigValues();
    42                 registerVariables();
     51    setConfigValues();
     52    registerVariables();
    4353                setObjectMode(0x3);
    4454        }
     
    4656        Test::~Test()
    4757        {
    48 
     58    instance_=0;
    4959        }
    5060
    5161        void Test::setConfigValues()
    5262        {
    53                 SetConfigValue ( v1, 1 ).callback ( this, &Test::checkV1 );
    54                 SetConfigValue ( v2, 2 ).callback ( this, &Test::checkV2 );
    55                 SetConfigValue ( v3, 3 ).callback ( this, &Test::checkV3 );
     63                SetConfigValue ( v1, 1 )/*.callback ( this, &Test::checkV1 )*/;
     64    SetConfigValue ( v2, 2 )/*.callback ( this, &Test::checkV2 )*/;
     65    SetConfigValue ( v3, 3 )/*.callback ( this, &Test::checkV3 )*/;
     66    SetConfigValue ( v4, 4 )/*.callback ( this, &Test::checkV4 )*/;
    5667        }
    5768
     
    6071        {
    6172                REGISTERDATA ( v1,direction::toclient, new NetworkCallback<Test> ( this, &Test::checkV1 ) );
    62                 REGISTERDATA ( v2,direction::toserver, new NetworkCallback<Test> ( this, &Test::checkV2 ) );
    63                 REGISTERDATA ( v3,direction::bidirectional, new NetworkCallback<Test> ( this, &Test::checkV3 ) );
     73    REGISTERDATA ( v2,direction::toserver, new NetworkCallback<Test> ( this, &Test::checkV2 ) );
     74                REGISTERDATA ( v3,direction::serverMaster, new NetworkCallback<Test> ( this, &Test::checkV3 ) );
     75    REGISTERDATA ( v4,direction::clientMaster, new NetworkCallback<Test> ( this, &Test::checkV4 ) );
    6476        }
    6577
    66         void Test::checkV1(){
    67                 COUT(1) << "V1 changed: " << v1 << std::endl;
    68         }
     78  void Test::checkV1(){
     79    COUT(1) << "V1 changed: " << v1 << std::endl;
     80  }
    6981
    70         void Test::checkV2(){
    71                 COUT(1) << "V2 changed: " << v2 << std::endl;
    72         }
     82  void Test::checkV2(){
     83    COUT(1) << "V2 changed: " << v2 << std::endl;
     84  }
    7385
    74         void Test::checkV3(){
    75                 COUT(1) << "V3 changed: " << v3 << std::endl;
    76         }
     86  void Test::checkV3(){
     87    COUT(1) << "V3 changed: " << v3 << std::endl;
     88  }
     89 
     90  void Test::checkV4(){
     91    COUT(1) << "V4 changed: " << v4 << std::endl;
     92  }
    7793
    7894
  • code/branches/objecthierarchy/src/orxonox/objects/Test.h

    r2112 r2132  
    4848      void setV2(unsigned int value){ v2 = value; }
    4949      void setV3(unsigned int value){ v3 = value; }
     50      void setV4(unsigned int value){ v4 = value; }
    5051
    5152      void checkV1();
    5253      void checkV2();
    5354      void checkV3();
     55      void checkV4();
     56     
     57      void printV1(){ instance_->checkV1(); }
     58      void printV2(){ instance_->checkV2(); }
     59      void printV3(){ instance_->checkV3(); }
     60      void printV4(){ instance_->checkV4(); }
    5461
    5562    private:
     
    5764      unsigned int v2;
    5865      unsigned int v3;
     66      unsigned int v4;
     67     
     68      static Test* instance_;
    5969  };
    6070}
  • code/branches/objecthierarchy/src/orxonox/objects/worldentities/ControllableEntity.cc

    r2112 r2132  
    250250        REGISTERSTRING(this->cameraPositionTemplate_, direction::toclient);
    251251
     252        REGISTERDATA(this->server_overwrite_,   direction::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processOverwrite));
     253        REGISTERDATA(this->client_overwrite_,   direction::toserver);
     254       
    252255        REGISTERDATA(this->server_position_,    direction::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition));
    253256        REGISTERDATA(this->server_velocity_,    direction::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerVelocity));
    254257        REGISTERDATA(this->server_orientation_, direction::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerOrientation));
    255258
    256         REGISTERDATA(this->server_overwrite_,   direction::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processOverwrite));
    257         REGISTERDATA(this->client_overwrite_,   direction::toserver);
    258 
    259259        REGISTERDATA(this->client_position_,    direction::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientPosition));
    260260        REGISTERDATA(this->client_velocity_,    direction::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientVelocity));
Note: See TracChangeset for help on using the changeset viewer.