Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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/libraries/network/synchronisable
Files:
2 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;
Note: See TracChangeset for help on using the changeset viewer.