[Orxonox-commit 2248] r6964 - in code/branches/presentation3/src: libraries/network/packet libraries/network/synchronisable modules/weapons/projectiles orxonox/graphics

scheusso at orxonox.net scheusso at orxonox.net
Sat May 22 20:43:39 CEST 2010


Author: scheusso
Date: 2010-05-22 20:43:39 +0200 (Sat, 22 May 2010)
New Revision: 6964

Modified:
   code/branches/presentation3/src/libraries/network/packet/ClassID.cc
   code/branches/presentation3/src/libraries/network/synchronisable/Serialise.h
   code/branches/presentation3/src/modules/weapons/projectiles/Rocket.cc
   code/branches/presentation3/src/orxonox/graphics/Model.cc
Log:
fix in ClassID (thanks reto)
fix in Rocket
small improvements in model
weakptr synchronisable


Modified: code/branches/presentation3/src/libraries/network/packet/ClassID.cc
===================================================================
--- code/branches/presentation3/src/libraries/network/packet/ClassID.cc	2010-05-22 17:26:52 UTC (rev 6963)
+++ code/branches/presentation3/src/libraries/network/packet/ClassID.cc	2010-05-22 18:43:39 UTC (rev 6964)
@@ -89,7 +89,7 @@
     temp+=2*sizeof(uint32_t)+tempPair.second.size()+1;
     tempsize+=2*sizeof(uint32_t)+tempPair.second.size()+1;
   }
-  assert(tempsize=packetSize);
+  assert(tempsize==packetSize);
 
   COUT(5) << "classid packetSize is " << packetSize << endl;
 

Modified: code/branches/presentation3/src/libraries/network/synchronisable/Serialise.h
===================================================================
--- code/branches/presentation3/src/libraries/network/synchronisable/Serialise.h	2010-05-22 17:26:52 UTC (rev 6963)
+++ code/branches/presentation3/src/libraries/network/synchronisable/Serialise.h	2010-05-22 18:43:39 UTC (rev 6964)
@@ -110,6 +110,41 @@
         else
             return *(uint32_t*)(mem) == OBJECTID_UNKNOWN;
     }
+    
+    // These functions implement loading / saving / etc. for WeakPtr<T>
+    
+    /** @brief returns the size of the objectID needed to synchronise the pointer */
+    template <class T> inline uint32_t returnSize( const WeakPtr<T>& variable )
+    {
+        return sizeof(uint32_t);
+    }
+    
+    /** @brief reads the objectID of a pointer out of the bytestream and increases the mem pointer */
+    template <class T> inline void loadAndIncrease( const WeakPtr<T>& variable, uint8_t*& mem )
+    {
+        //         *const_cast<typename Loki::TypeTraits<T*>::UnqualifiedType*>(&variable) = dynamic_cast<T*>(variable->getSynchronisable( *(uint32_t*)(mem) ));
+        *const_cast<typename Loki::TypeTraits<SmartPtr<T> >::UnqualifiedType*>(&variable) = orxonox_cast<T*>(T::getSynchronisable(*(uint32_t*)(mem)));
+        mem += returnSize( variable );
+    }
+    
+    /** @brief saves the objectID of a pointer into the bytestream and increases the mem pointer */
+    template <class T> inline void saveAndIncrease( const WeakPtr<T>& variable, uint8_t*& mem )
+    {
+        if ( variable.get() )
+            *(uint32_t*)(mem) = static_cast<uint32_t>(variable->getObjectID());
+        else
+            *(uint32_t*)(mem) = OBJECTID_UNKNOWN;
+        mem += returnSize( variable );
+    }
+    
+    /** @brief checks whether the objectID of the variable is the same as in the bytestream */
+    template <class T> inline  bool checkEquality( const WeakPtr<T>& variable, uint8_t* mem )
+    {
+        if ( variable.get() )
+            return *(uint32_t*)(mem) == variable->getObjectID();
+        else
+            return *(uint32_t*)(mem) == OBJECTID_UNKNOWN;
+    }
 }
 
 

Modified: code/branches/presentation3/src/modules/weapons/projectiles/Rocket.cc
===================================================================
--- code/branches/presentation3/src/modules/weapons/projectiles/Rocket.cc	2010-05-22 17:26:52 UTC (rev 6963)
+++ code/branches/presentation3/src/modules/weapons/projectiles/Rocket.cc	2010-05-22 18:43:39 UTC (rev 6964)
@@ -163,9 +163,13 @@
             this->setAngularVelocity(this->getOrientation() * this->localAngularVelocity_);
             this->setVelocity( this->getOrientation()*WorldEntity::FRONT*this->getVelocity().length() );
             this->localAngularVelocity_ = 0;
-
+        }
+        
+        if( GameMode::isMaster() )
+        {
             if( this->bDestroy_ )
                 this->destroy();
+            
         }
     }
 

Modified: code/branches/presentation3/src/orxonox/graphics/Model.cc
===================================================================
--- code/branches/presentation3/src/orxonox/graphics/Model.cc	2010-05-22 17:26:52 UTC (rev 6963)
+++ code/branches/presentation3/src/orxonox/graphics/Model.cc	2010-05-22 18:43:39 UTC (rev 6964)
@@ -112,11 +112,11 @@
                         creatorPtr = creatorPtr->getCreator();
                     }
                     
-                    Level* level_ = this->getLevel();
+                    Level* level = this->getLevel();
                     
-                    // TODO: make this also working on the client (there is currently no level pointer in the baseobject on the client)
-                    if( level_ != 0 && level_->getLodInfo(this->meshSrc_)!=0 )
-                        setLodLevel(level_->getLodInfo(this->meshSrc_)->getLodLevel());
+                    assert( level != 0 );
+                    if( level->getLodInfo(this->meshSrc_)!=0 )
+                        setLodLevel(level->getLodInfo(this->meshSrc_)->getLodLevel());
                     
                     COUT(4) << "Setting lodLevel for " << this->meshSrc_<< " with lodLevel_: " << this->lodLevel_ <<" and scale: "<< scaleFactor << ":" << std::endl;
 




More information about the Orxonox-commit mailing list