Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 927


Ignore:
Timestamp:
Mar 26, 2008, 5:02:14 PM (16 years ago)
Author:
scheusso
Message:

Made various changes to Classes WorldEntity, Model, SpaceShip,
BulletManager and AmmunitionDump in order to make them really
synchronisable.
I hope, that everythings still working now. I only did some small tests
(ie no segfault when running/starting and acting)

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

Legend:

Unmodified
Added
Removed
  • code/branches/network/src/network/Synchronisable.h

    r871 r927  
    5656    int getSize();
    5757    bool updateData(syncData vars);
    58     void registerAllVariables();
     58    virtual void registerAllVariables()=0;
    5959    virtual bool create()=0;
    6060  protected:
  • code/branches/network/src/orxonox/objects/Model.cc

    r871 r927  
    4444    {
    4545        RegisterObject(Model);
     46        registerAllVariables();
    4647    }
    4748
     
    6364    /**
    6465        @brief XML loading and saving.
    65         @param xmlelement The XML-element
     66    @p
     67    aram xmlelement The XML-element
    6668        @param loading Loading (true) or saving (false)
    6769        @return The XML-element
     
    8284
    8385    bool Model::create(){
     86      WorldEntity::create();
    8487      if(meshSrc_.compare("")!=0){
    8588        this->mesh_.setMesh(meshSrc_);
     
    8790        COUT(4) << "Loader: Created model" << std::endl;
    8891      }
    89       registerAllVariables();
    9092      return true;
    9193    }
    9294
    9395    void Model::registerAllVariables(){
    94 //      registerVar(&meshSrc_, meshSrc_.length() + 1, network::STRING);
     96      WorldEntity::registerAllVariables();
     97      registerVar(&meshSrc_, meshSrc_.length() + 1, network::STRING);
    9598    }
    9699}
  • code/branches/network/src/orxonox/objects/Model.h

    r871 r927  
    2222            bool create();
    2323
     24        protected:
     25            void registerAllVariables();
     26           
    2427        private:
    2528            std::string meshSrc_;
    2629            Mesh mesh_;
    27             void registerAllVariables();
    2830    };
    2931}
  • code/branches/network/src/orxonox/objects/SpaceShip.cc

    r919 r927  
    5656    {
    5757        RegisterObject(SpaceShip);
     58        this->registerAllVariables();
    5859
    5960        this->setConfigValues();
     
    125126        this->brakeLoop(loop);
    126127*/
    127         this->init();
    128 
     128//         this->create();
     129
     130       
    129131        COUT(3) << "Info: SpaceShip was loaded" << std::endl;
    130132    }
     
    136138    }
    137139
     140    bool SpaceShip::create(){
     141      if(Model::create())
     142        this->init();
     143      else
     144        return false;
     145      return true;
     146    }
     147   
     148    void SpaceShip::registerAllVariables(){
     149      Model::registerAllVariables();
     150     
     151     
     152     
     153    }
     154   
    138155    void SpaceShip::init()
    139156    {
     
    203220    {
    204221        Model::loadParams(xmlElem);
     222        this->create();
    205223/*
    206224        if (xmlElem->Attribute("forward") && xmlElem->Attribute("rotateupdown") && xmlElem->Attribute("rotaterightleft") && xmlElem->Attribute("looprightleft"))
  • code/branches/network/src/orxonox/objects/SpaceShip.h

    r871 r927  
    2121            SpaceShip();
    2222            ~SpaceShip();
     23            bool create();
     24            void registerAllVariables();
    2325            void init();
    2426            void setConfigValues();
  • code/branches/network/src/orxonox/objects/WorldEntity.cc

    r871 r927  
    4949        RegisterObject(WorldEntity);
    5050
    51         if (Orxonox::getSingleton()->getSceneManager())
    52         {
    53             std::ostringstream name;
    54             name << (WorldEntity::worldEntityCounter_s++);
    55             this->setName("WorldEntity" + name.str());
    56             this->node_ = Orxonox::getSingleton()->getSceneManager()->getRootSceneNode()->createChildSceneNode(this->getName());
    57         }
    58         else
    59         {
    60             this->node_ = 0;
    61         }
     51        //create();
    6252
    6353        this->bStatic_ = true;
     
    6757        this->rotationRate_ = 0;
    6858        this->momentum_ = 0;
     59       
     60        if (Orxonox::getSingleton()->getSceneManager())
     61        {
     62          std::ostringstream name;
     63          name << (WorldEntity::worldEntityCounter_s++);
     64          this->setName("WorldEntity" + name.str());
     65          this->node_ = Orxonox::getSingleton()->getSceneManager()->getRootSceneNode()->createChildSceneNode(this->getName());
     66       
     67          registerAllVariables();
     68        }
     69        else
     70        {
     71          this->node_ = 0;
     72        }
    6973    }
    7074
     
    8993
    9094        BaseObject::loadParams(xmlElem);
     95        create();
    9196/*
    9297        if (xmlElem->Attribute("position"))
     
    185190    }
    186191
    187     bool WorldEntity::create(){
    188       registerAllVariables();
    189       return true;
    190     }
    191192
    192193    void WorldEntity::registerAllVariables()
    193194    {
    194 /*      // register coordinates
     195      // register coordinates
    195196      registerVar( (void*) &(this->getPosition().x), sizeof(this->getPosition().x), network::DATA);
    196197      registerVar( (void*) &(this->getPosition().y), sizeof(this->getPosition().y), network::DATA);
     
    200201      registerVar( (void*) &(this->getOrientation().x), sizeof(this->getOrientation().x), network::DATA);
    201202      registerVar( (void*) &(this->getOrientation().y), sizeof(this->getOrientation().y), network::DATA);
    202       registerVar( (void*) &(this->getOrientation().z), sizeof(this->getOrientation().z), network::DATA);*/
     203      registerVar( (void*) &(this->getOrientation().z), sizeof(this->getOrientation().z), network::DATA);
    203204      // not needed at the moment, because we don't have prediction yet
    204       /*// register velocity_
     205      // register velocity_
    205206      registerVar( (void*) &(this->getVelocity().x), sizeof(this->getVelocity().x), network::DATA);
    206207      registerVar( (void*) &(this->getVelocity().y), sizeof(this->getVelocity().y), network::DATA);
     
    210211      registerVar( (void*) &(this->getRotationAxis().x), sizeof(this->getRotationAxis().x), network::DATA);
    211212      registerVar( (void*) &(this->getRotationAxis().y), sizeof(this->getRotationAxis().y), network::DATA);
    212       registerVar( (void*) &(this->getRotationAxis().z), sizeof(this->getRotationAxis().z), network::DATA);*/
     213      registerVar( (void*) &(this->getRotationAxis().z), sizeof(this->getRotationAxis().z), network::DATA);
    213214    }
    214215
  • code/branches/network/src/orxonox/objects/WorldEntity.h

    r917 r927  
    1717namespace orxonox
    1818{
    19     class _OrxonoxExport WorldEntity : public BaseObject, public Tickable//, public network::Synchronisable
     19    class _OrxonoxExport WorldEntity : public BaseObject, public Tickable, public network::Synchronisable
    2020    {
    2121        public:
     
    2626            virtual void loadParams(TiXmlElement* xmlElem);
    2727            virtual void XMLPort(Element& xmlelement, bool loading);
    28             bool create();
     28            inline bool create(){ return true; }
    2929
    3030            void attachWorldEntity(WorldEntity* entity);
  • code/branches/network/src/orxonox/objects/weapon/AmmunitionDump.cc

    r871 r927  
    4545  {
    4646    RegisterObject(AmmunitionDump);
     47    registerAllVariables();
    4748
    4849    for (int i = 0; i < numberOfAmmos_; i++)
     
    114115    return stock_[id];
    115116  }
     117 
     118  void AmmunitionDump::registerAllVariables(){
     119    registerVar( &numberOfAmmos_, sizeof(int), network::DATA);
     120   
     121    for (int i = 0; i < numberOfAmmos_; i++)
     122    {
     123      registerVar(&stock_[i], sizeof(int), network::DATA);
     124      registerVar(&capacity_[i], sizeof(int), network::DATA);
     125    }
     126  }
    116127}
  • code/branches/network/src/orxonox/objects/weapon/AmmunitionDump.h

    r871 r927  
    6060  protected:
    6161    inline bool create() { return true; }
     62    void registerAllVariables();
    6263
    6364    int numberOfAmmos_;
  • code/branches/network/src/orxonox/objects/weapon/BulletManager.cc

    r871 r927  
    3939  {
    4040    RegisterObject(BulletManager);
     41    registerAllVariables();
    4142    bullets_ = new Bullet*[bulletsSize_];
    4243  }
     
    103104  }
    104105
     106  void BulletManager::registerAllVariables(){
     107    registerVar(&bulletsSize_, sizeof(int), network::DATA);
     108    registerVar(&bulletsIndex_, sizeof(int), network::DATA);
     109    // TODO we got a problem here:
     110    // there is no possibility (so far) to synchronise pointers to objects
     111  }
     112 
    105113}
  • code/branches/network/src/orxonox/objects/weapon/BulletManager.h

    r917 r927  
    6060  protected:
    6161    inline bool create() { return true; }
     62    void registerAllVariables();
    6263
    6364    // Bullet array
Note: See TracChangeset for help on using the changeset viewer.