Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 25, 2013, 9:08:42 PM (11 years ago)
Author:
landauf
Message:

merged core6 back to trunk

Location:
code/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/network/synchronisable/Serialise.h

    r8706 r9667  
    4141#include "util/Serialise.h"
    4242#include "core/CorePrereqs.h"
    43 #include "core/CoreIncludes.h"
    44 #include "core/BaseObject.h" // remove this if circular dependencies in BaseObject/SmartPtr are fixed
    45 //#include "core/SmartPtr.h"
    4643
    4744namespace orxonox{
  • code/trunk/src/libraries/network/synchronisable/Synchronisable.cc

    r8858 r9667  
    4545  uint8_t Synchronisable::state_=0x1; // detemines wheter we are server (default) or client
    4646
     47  RegisterAbstractClass(Synchronisable).inheritsFrom(Class(OrxonoxInterface));
     48
    4749  /**
    4850  * Constructor:
    4951  * Initializes all Variables and sets the right objectID_
    5052  */
    51   Synchronisable::Synchronisable(BaseObject* creator )
    52   {
    53     RegisterRootObject(Synchronisable);
     53  Synchronisable::Synchronisable(Context* context)
     54  {
     55      RegisterObject(Synchronisable);
    5456    static uint32_t idCounter=0;
    5557    objectMode_=0x1; // by default do not send data to server
     
    6971    this->setPriority( Priority::Normal );
    7072
    71     // get creator id
    72     if( creator )
    73       this->creatorID_ = creator->getSceneID();
    74     else
    75       this->creatorID_ = OBJECTID_UNKNOWN;
     73    // get context id
     74    this->contextID_ = this->findContextID(context);
    7675  }
    7776
     
    8382  {
    8483    // delete callback function objects
    85     if(!Identifier::isCreatingHierarchy()){
     84    if(!IdentifierManager::getInstance().isCreatingHierarchy()){
    8685      // remove object from the static objectMap
    8786      if (this->objectMode_ != 0x0 && (Host::running() && Host::isServer()))
     
    10099  }
    101100
     101  /**
     102   * @brief Returns the id of the context.
     103   * If the context is not Synchronisable, it moves on to its parent, recursively.
     104   */
     105  uint32_t Synchronisable::findContextID(Context* context)
     106  {
     107      if (context == NULL)
     108          return OBJECTID_UNKNOWN;
     109
     110      Synchronisable* synchronisableContext = orxonox_cast<Synchronisable*>(context);
     111      if (synchronisableContext != NULL)
     112          return synchronisableContext->getObjectID();
     113      else
     114          return this->findContextID(context->getParentContext());
     115  }
    102116
    103117  /**
     
    142156    }
    143157    assert(id);
    144     BaseObject* creator = 0;
    145     if (header.getCreatorID() != OBJECTID_UNKNOWN)
    146     {
    147       Synchronisable* synchronisable_creator = Synchronisable::getSynchronisable(header.getCreatorID());
    148       if (!synchronisable_creator)
     158    Context* context = 0;
     159    if (header.getContextID() != OBJECTID_UNKNOWN)
     160    {
     161      Synchronisable* synchronisable_context = Synchronisable::getSynchronisable(header.getContextID());
     162      if (!synchronisable_context)
    149163      {
    150164        mem += header.getDataSize()+SynchronisableHeader::getSize(); //.TODO: this suckz.... remove size from header
     
    153167      }
    154168      else
    155         creator = orxonox_cast<BaseObject*>(synchronisable_creator);
    156     }
     169        context = orxonox_cast<Context*>(synchronisable_context);
     170    }
     171    else
     172      context = Context::getRootContext();
     173
    157174    assert(getSynchronisable(header.getObjectID())==0);   //make sure no object with this id exists
    158     BaseObject *bo = id->fabricate(creator);
     175    BaseObject *bo = orxonox_cast<BaseObject*>(id->fabricate(context));
    159176    assert(bo);
    160177    Synchronisable *no = orxonox_cast<Synchronisable*>(bo);
     
    162179    assert( Synchronisable::objectMap_.find(header.getObjectID()) == Synchronisable::objectMap_.end() );
    163180    no->setObjectID(header.getObjectID());
    164     //no->creatorID=header.getCreatorID(); //TODO: remove this
     181    //no->contextID=header.getContextID(); //TODO: remove this
    165182    no->setClassID(header.getClassID());
    166     assert(no->creatorID_ == header.getCreatorID());
    167     if( creator )
    168       bo->setLevel(creator->getLevel());          // Note: this ensures that the level is known on the client for child objects of the scene (and the scene itself)
     183    assert(no->contextID_ == header.getContextID());
     184    if( context )
     185    {
     186      BaseObject* boContext = orxonox_cast<BaseObject*>(context);
     187      if (boContext)
     188          bo->setLevel(boContext->getLevel()); // Note: this ensures that the level is known on the client for child objects of the scene (and the scene itself)
     189    }
    169190    //assert(no->classID_ == header.getClassID());
    170191    orxout(verbose, context::network) << "fabricate objectID_: " << no->objectID_ << " classID_: " << no->classID_ << endl;
     
    274295
    275296    header.setObjectID( this->objectID_ );
    276     header.setCreatorID( this->creatorID_ );
     297    header.setContextID( this->contextID_ );
    277298    header.setClassID( this->classID_ );
    278299    header.setDataSize( tempsize );
     
    331352      SynchronisableHeader syncHeader2(mem);
    332353      assert( this->getClassID() == syncHeader2.getClassID() );
    333       assert( this->getCreatorID() == syncHeader2.getCreatorID() );
     354      assert( this->getContextID() == syncHeader2.getContextID() );
    334355      mem += SynchronisableHeader::getSize();
    335356      std::vector<SynchronisableVariableBase *>::iterator i;
  • code/trunk/src/libraries/network/synchronisable/Synchronisable.h

    r8858 r9667  
    4040
    4141#include "util/mbool.h"
    42 #include "core/OrxonoxClass.h"
     42#include "util/Output.h"
     43#include "core/class/OrxonoxInterface.h"
    4344#include "SynchronisableVariable.h"
    4445#include "NetworkCallback.h"
     
    106107   * @brief: stores information about a Synchronisable
    107108   *
    108    * This class stores the information about a Synchronisable (objectID_, classID_, creatorID_, dataSize)
     109   * This class stores the information about a Synchronisable (objectID_, classID_, contextID_, dataSize)
    109110   * in an emulated bitset.
    110111   * Bit 1 to 31 store the size of the Data the synchronisable consumes in the stream
     
    112113   * Byte 5 to 8: objectID_
    113114   * Byte 9 to 12: classID_
    114    * Byte 13 to 16: creatorID_
     115   * Byte 13 to 16: contextID_
    115116   */
    116117  class _NetworkExport SynchronisableHeader: public SynchronisableHeaderLight
     
    125126      inline void setClassID(uint32_t classID_)
    126127        { *(uint32_t*)(data_+SynchronisableHeaderLight::getSize()) = classID_; }
    127       inline uint32_t getCreatorID() const
     128      inline uint32_t getContextID() const
    128129        { return *(uint32_t*)(data_+SynchronisableHeaderLight::getSize()+4); }
    129       inline void setCreatorID(uint32_t creatorID_)
    130         { *(uint32_t*)(data_+SynchronisableHeaderLight::getSize()+4) = creatorID_; }
     130      inline void setContextID(uint32_t contextID_)
     131        { *(uint32_t*)(data_+SynchronisableHeaderLight::getSize()+4) = contextID_; }
    131132      inline void operator=(SynchronisableHeader& h)
    132133        { memcpy(data_, h.data_, getSize()); }
     
    143144  * @author Oliver Scheuss
    144145  */
    145   class _NetworkExport Synchronisable : virtual public OrxonoxClass{
     146  class _NetworkExport Synchronisable : virtual public OrxonoxInterface {
    146147  public:
    147148    friend class packet::Gamestate;
     
    157158
    158159    inline uint32_t getObjectID() const {return this->objectID_;}
    159     inline unsigned int getCreatorID() const {return this->creatorID_;}
     160    inline unsigned int getContextID() const {return this->contextID_;}
    160161    inline uint32_t getClassID() const {return this->classID_;}
    161162    inline unsigned int getPriority() const { return this->objectFrequency_;}
     
    169170
    170171  protected:
    171     Synchronisable(BaseObject* creator);
     172    Synchronisable(Context* context);
    172173    template <class T> void registerVariable(T& variable, uint8_t mode=0x1, NetworkCallbackBase *cb=0, bool bidirectional=false);
    173174    template <class T> void registerVariable(std::set<T>& variable, uint8_t mode=0x1, NetworkCallbackBase *cb=0, bool bidirectional=false);
     
    175176
    176177    void setPriority(unsigned int freq){ objectFrequency_ = freq; }
    177 
     178    uint32_t findContextID(Context* context);
    178179
    179180  private:
     
    188189
    189190    uint32_t objectID_;
    190     uint32_t creatorID_;
     191    uint32_t contextID_;
    191192    uint32_t classID_;
    192193
Note: See TracChangeset for help on using the changeset viewer.