Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6961


Ignore:
Timestamp:
May 21, 2010, 6:50:07 PM (15 years ago)
Author:
scheusso
Message:

fixed to make everything network-compliant again

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

Legend:

Unmodified
Added
Removed
  • code/branches/presentation3/src/libraries/network/synchronisable/Serialise.h

    r6417 r6961  
    3838#include "util/TypeTraits.h"
    3939#include "core/CorePrereqs.h"
     40#include "core/CoreIncludes.h"
     41#include "core/SmartPtr.h"
    4042
    4143namespace orxonox{
     
    7476            return *(uint32_t*)(mem) == OBJECTID_UNKNOWN;
    7577    }
     78   
     79    // These functions implement loading / saving / etc. for SmartPtr<T>
     80   
     81    /** @brief returns the size of the objectID needed to synchronise the pointer */
     82    template <class T> inline uint32_t returnSize( const SmartPtr<T>& variable )
     83    {
     84        return sizeof(uint32_t);
     85    }
     86   
     87    /** @brief reads the objectID of a pointer out of the bytestream and increases the mem pointer */
     88    template <class T> inline void loadAndIncrease( const SmartPtr<T>& variable, uint8_t*& mem )
     89    {
     90//         *const_cast<typename Loki::TypeTraits<T*>::UnqualifiedType*>(&variable) = dynamic_cast<T*>(variable->getSynchronisable( *(uint32_t*)(mem) ));
     91        *const_cast<typename Loki::TypeTraits<SmartPtr<T> >::UnqualifiedType*>(&variable) = orxonox_cast<T*>(T::getSynchronisable(*(uint32_t*)(mem)));
     92        mem += returnSize( variable );
     93    }
     94   
     95    /** @brief saves the objectID of a pointer into the bytestream and increases the mem pointer */
     96    template <class T> inline void saveAndIncrease( const SmartPtr<T>& variable, uint8_t*& mem )
     97    {
     98        if ( variable.get() )
     99            *(uint32_t*)(mem) = static_cast<uint32_t>(variable->getObjectID());
     100        else
     101            *(uint32_t*)(mem) = OBJECTID_UNKNOWN;
     102        mem += returnSize( variable );
     103    }
     104   
     105    /** @brief checks whether the objectID of the variable is the same as in the bytestream */
     106    template <class T> inline  bool checkEquality( const SmartPtr<T>& variable, uint8_t* mem )
     107    {
     108        if ( variable.get() )
     109            return *(uint32_t*)(mem) == variable->getObjectID();
     110        else
     111            return *(uint32_t*)(mem) == OBJECTID_UNKNOWN;
     112    }
    76113}
    77114
  • code/branches/presentation3/src/libraries/network/synchronisable/Synchronisable.cc

    r6417 r6961  
    177177    no->setClassID(header.getClassID());
    178178    assert(no->creatorID_ == header.getCreatorID());
     179    if( creator )
     180      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)
    179181    //assert(no->classID_ == header.getClassID());
    180182    COUT(4) << "fabricate objectID_: " << no->objectID_ << " classID_: " << no->classID_ << std::endl;
  • code/branches/presentation3/src/orxonox/Level.cc

    r6926 r6961  
    127127        this->objects_.push_back(object);
    128128        object->setGametype(this->getGametype());
    129     object->setLevel(this);
     129        object->setLevel(this);
    130130    }
    131131
  • code/branches/presentation3/src/orxonox/Scene.cc

    r6417 r6961  
    4747#include "Radar.h"
    4848#include "worldentities/WorldEntity.h"
     49#include "Level.h"
    4950
    5051namespace orxonox
     
    133134        registerVariable(this->bHasPhysics_,        VariableDirection::ToClient, new NetworkCallback<Scene>(this, &Scene::networkcallback_hasPhysics));
    134135        registerVariable(this->bShadows_,           VariableDirection::ToClient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applyShadows));
     136        registerVariable(this->getLevel(),          VariableDirection::ToClient, new NetworkCallback<Scene>(this, &Scene::changedLevel));
    135137    }
    136138
  • code/branches/presentation3/src/orxonox/graphics/Model.cc

    r6942 r6961  
    115115                    Level* level_ = this->getLevel();
    116116                   
    117                     MeshLodInformation* lodInfo = level_->getLodInfo(this->meshSrc_);
    118                    
    119                     if(lodInfo!=0)
    120                         setLodLevel(lodInfo->getLodLevel());
     117                    // TODO: make this also working on the client (there is currently no level pointer in the baseobject on the client)
     118                    if( level_ != 0 && level_->getLodInfo(this->meshSrc_)!=0 )
     119                        setLodLevel(level_->getLodInfo(this->meshSrc_)->getLodLevel());
    121120                   
    122121                    COUT(4) << "Setting lodLevel for " << this->meshSrc_<< " with lodLevel_: " << this->lodLevel_ <<" and scale: "<< scaleFactor << ":" << std::endl;
  • code/branches/presentation3/src/orxonox/interfaces/RadarViewable.cc

    r6942 r6961  
    3131#include "util/StringUtils.h"
    3232#include "core/CoreIncludes.h"
     33#include "core/GameMode.h"
    3334#include "worldentities/WorldEntity.h"
    3435#include "Radar.h"
     
    5253
    5354        this->uniqueId_=getUniqueNumberString();
    54         this->radar_ = this->creator_->getScene()->getRadar();
    55         this->radar_->addRadarObject(this);
     55        if( GameMode::showsGraphics() )
     56        {
     57            this->radar_ = this->creator_->getScene()->getRadar();
     58            this->radar_->addRadarObject(this);
     59        }
    5660        this->bInitialized_ = true;
    5761    }
     
    6064    RadarViewable::~RadarViewable()
    6165    {
     66       
    6267        if( this->bInitialized_ )
    63             this->radar_->removeRadarObject(this);
     68        {
     69            if( GameMode::showsGraphics() )
     70            {
     71                this->radar_->removeRadarObject(this);
     72            }
     73        }
    6474    }
    6575
     
    101111    void RadarViewable::settingsChanged()
    102112    {
    103         this->radar_->radarObjectChanged(this);
     113        if( GameMode::showsGraphics() )
     114        {
     115            this->radar_->radarObjectChanged(this);
     116        }
    104117    }
    105118}
Note: See TracChangeset for help on using the changeset viewer.