Changeset 10624 for code/trunk/src/libraries/network/synchronisable
- Timestamp:
- Oct 4, 2015, 9:12:21 PM (9 years ago)
- Location:
- code/trunk
- Files:
-
- 1 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
-
code/trunk/src/libraries/network/synchronisable/CMakeLists.txt
r7314 r10624 2 2 NetworkCallbackManager.cc 3 3 Synchronisable.cc 4 SynchronisableVariable.cc5 4 ) 6 5 -
code/trunk/src/libraries/network/synchronisable/Serialise.h
r9667 r10624 78 78 } 79 79 80 // These functions implement loading / saving / etc. for S martPtr<T>80 // These functions implement loading / saving / etc. for StrongPtr<T> 81 81 82 82 /** @brief returns the size of the objectID needed to synchronise the pointer */ 83 template <class T> inline uint32_t returnSize( const S martPtr<T>& )83 template <class T> inline uint32_t returnSize( const StrongPtr<T>& ) 84 84 { 85 85 return sizeof(uint32_t); … … 87 87 88 88 /** @brief reads the objectID of a pointer out of the bytestream and increases the mem pointer */ 89 template <class T> inline void loadAndIncrease( const S martPtr<T>& variable, uint8_t*& mem )89 template <class T> inline void loadAndIncrease( const StrongPtr<T>& variable, uint8_t*& mem ) 90 90 { 91 91 // *const_cast<typename Loki::TypeTraits<T*>::UnqualifiedType*>(&variable) = dynamic_cast<T*>(variable->getSynchronisable( *(uint32_t*)(mem) )); 92 *const_cast<typename Loki::TypeTraits<S martPtr<T> >::UnqualifiedType*>(&variable) = orxonox_cast<T*>(T::getSynchronisable(*(uint32_t*)(mem)));92 *const_cast<typename Loki::TypeTraits<StrongPtr<T> >::UnqualifiedType*>(&variable) = orxonox_cast<T*>(T::getSynchronisable(*(uint32_t*)(mem))); 93 93 mem += returnSize( variable ); 94 94 } 95 95 96 96 /** @brief saves the objectID of a pointer into the bytestream and increases the mem pointer */ 97 template <class T> inline void saveAndIncrease( const S martPtr<T>& variable, uint8_t*& mem )97 template <class T> inline void saveAndIncrease( const StrongPtr<T>& variable, uint8_t*& mem ) 98 98 { 99 99 if ( variable.get() ) … … 105 105 106 106 /** @brief checks whether the objectID of the variable is the same as in the bytestream */ 107 template <class T> inline bool checkEquality( const S martPtr<T>& variable, uint8_t* mem )107 template <class T> inline bool checkEquality( const StrongPtr<T>& variable, uint8_t* mem ) 108 108 { 109 109 if ( variable.get() ) … … 125 125 { 126 126 // *const_cast<typename Loki::TypeTraits<T*>::UnqualifiedType*>(&variable) = dynamic_cast<T*>(variable->getSynchronisable( *(uint32_t*)(mem) )); 127 *const_cast<typename Loki::TypeTraits< SmartPtr<T> >::UnqualifiedType*>(&variable) = orxonox_cast<T*>(T::getSynchronisable(*(uint32_t*)(mem)));127 *const_cast<typename Loki::TypeTraits<WeakPtr<T> >::UnqualifiedType*>(&variable) = orxonox_cast<T*>(T::getSynchronisable(*(uint32_t*)(mem))); 128 128 mem += returnSize( variable ); 129 129 } -
code/trunk/src/libraries/network/synchronisable/Synchronisable.cc
r9667 r10624 45 45 uint8_t Synchronisable::state_=0x1; // detemines wheter we are server (default) or client 46 46 47 RegisterAbstractClass(Synchronisable).inheritsFrom (Class(OrxonoxInterface));47 RegisterAbstractClass(Synchronisable).inheritsFrom<OrxonoxInterface>(); 48 48 49 49 /** … … 151 151 for(int i = 0; i<160; i++) 152 152 orxout(user_error, context::network) << "classid: " << i << " identifier: " << ClassByID(i) << endl; 153 orxout(user_error, context::network) << "Assertion failed: id"<< endl;153 orxout(user_error, context::network) << "Assertion failed: Could not find Identifier for ClassID " << header.getClassID() << endl; 154 154 orxout(user_error, context::network) << "Possible reason for this error: Client received a synchronizable object whose class has no factory." << endl; 155 155 abort(); … … 182 182 no->setClassID(header.getClassID()); 183 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 }190 184 //assert(no->classID_ == header.getClassID()); 191 185 orxout(verbose, context::network) << "fabricate objectID_: " << no->objectID_ << " classID_: " << no->classID_ << endl; -
code/trunk/src/libraries/network/synchronisable/SynchronisableVariable.h
r8858 r10624 65 65 virtual uint8_t getMode()=0; 66 66 virtual ~SynchronisableVariableBase() {} 67 protected:68 static uint8_t state_;69 67 }; 70 68 … … 108 106 variable_( variable ), mode_( syncDirection ), callback_( cb ) 109 107 { 110 if ( state_ == 0x0 )111 {112 state_ = GameMode::isMaster() ? 0x1 : 0x2; // set the appropriate mode here113 }114 108 } 115 109
Note: See TracChangeset
for help on using the changeset viewer.