[Orxonox-commit 3644] r8329 - in code/trunk/src: libraries/network/synchronisable orxonox/worldentities/pawns

scheusso at orxonox.net scheusso at orxonox.net
Tue Apr 26 00:31:32 CEST 2011


Author: scheusso
Date: 2011-04-26 00:31:32 +0200 (Tue, 26 Apr 2011)
New Revision: 8329

Modified:
   code/trunk/src/libraries/network/synchronisable/Synchronisable.cc
   code/trunk/src/libraries/network/synchronisable/Synchronisable.h
   code/trunk/src/orxonox/worldentities/pawns/Pawn.cc
Log:
preparing countermeasures against clients sending unwanted data


Modified: code/trunk/src/libraries/network/synchronisable/Synchronisable.cc
===================================================================
--- code/trunk/src/libraries/network/synchronisable/Synchronisable.cc	2011-04-25 18:49:59 UTC (rev 8328)
+++ code/trunk/src/libraries/network/synchronisable/Synchronisable.cc	2011-04-25 22:31:32 UTC (rev 8329)
@@ -235,7 +235,7 @@
     if(mode==0x0)
       mode=state_;
     //if this tick is we dont synchronise, then abort now
-    if(!doSync(id, mode))
+    if(!doSync(/*id,*/ mode))
       return 0;
     uint32_t tempsize = 0;
 #ifndef NDEBUG
@@ -301,6 +301,7 @@
   {
     if(mode==0x0)
       mode=state_;
+    
     if(syncList_.empty())
     {
       assert(0);
@@ -312,6 +313,17 @@
     // start extract header
     SynchronisableHeaderLight syncHeaderLight(mem);
     assert(syncHeaderLight.getObjectID()==this->getObjectID());
+    
+    if( !this->doReceive(mode) )
+    {
+      uint32_t headerSize;
+      if( syncHeaderLight.isDiffed() )
+        headerSize = SynchronisableHeaderLight::getSize();
+      else
+        headerSize = SynchronisableHeader::getSize();
+      mem += syncHeaderLight.getDataSize() + headerSize;
+      return true;
+    }
 
     //COUT(5) << "Synchronisable: objectID_ " << syncHeader.getObjectID() << ", classID_ " << syncHeader.getClassID() << " size: " << syncHeader.getDataSize() << " synchronising data" << std::endl;
     if( !syncHeaderLight.isDiffed() )
@@ -356,7 +368,7 @@
     uint32_t tsize=SynchronisableHeader::getSize();
     if (mode==0x0)
       mode=state_;
-    if (!doSync(id, mode))
+    if (!doSync(/*id, */mode))
       return 0;
     assert( mode==state_ );
     tsize += this->dataSize_;
@@ -374,13 +386,25 @@
    * @param mode Synchronisation mode (toclient, toserver or bidirectional)
    * @return true/false
    */
-  bool Synchronisable::doSync(int32_t id, uint8_t mode)
+  bool Synchronisable::doSync(/*int32_t id,*/ uint8_t mode)
   {
 //     if(mode==0x0)
 //       mode=state_;
     assert(mode!=0x0);
     return ( (this->objectMode_ & mode)!=0 && (!syncList_.empty() ) );
   }
+  
+  /**
+   * This function determines, wheter the object should accept data from the bytestream (according to its syncmode/direction)
+   * @param id gamestate id
+   * @param mode Synchronisation mode (toclient, toserver or bidirectional)
+   * @return true/false
+   */
+  bool Synchronisable::doReceive( uint8_t mode)
+  {
+    //return mode != this->objectMode_ || this->objectMode_ == ObjectDirection::Bidirectional;
+    return true;
+  }
 
   /**
    * This function sets the synchronisation mode of the object

Modified: code/trunk/src/libraries/network/synchronisable/Synchronisable.h
===================================================================
--- code/trunk/src/libraries/network/synchronisable/Synchronisable.h	2011-04-25 18:49:59 UTC (rev 8328)
+++ code/trunk/src/libraries/network/synchronisable/Synchronisable.h	2011-04-25 22:31:32 UTC (rev 8329)
@@ -179,7 +179,8 @@
     uint32_t getData(uint8_t*& mem, std::vector<uint32_t>& sizes, int32_t id, uint8_t mode);
     uint32_t getSize(int32_t id, uint8_t mode=0x0);
     bool updateData(uint8_t*& mem, uint8_t mode=0x0, bool forceCallback=false);
-    bool doSync(int32_t id, uint8_t mode=0x0);
+    bool doSync(/*int32_t id,*/ uint8_t mode=0x0);
+    bool doReceive( uint8_t mode );
 
     inline void setObjectID(uint32_t id){ this->objectID_ = id; objectMap_[this->objectID_] = this; }
     inline void setClassID(uint32_t id){ this->classID_ = id; }

Modified: code/trunk/src/orxonox/worldentities/pawns/Pawn.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/pawns/Pawn.cc	2011-04-25 18:49:59 UTC (rev 8328)
+++ code/trunk/src/orxonox/worldentities/pawns/Pawn.cc	2011-04-25 22:31:32 UTC (rev 8329)
@@ -88,6 +88,8 @@
         this->registerVariables();
 
         this->isHumanShip_ = this->hasLocalController();
+        
+        this->setSyncMode(ObjectDirection::Bidirectional); // needed to synchronise e.g. aimposition
     }
 
     Pawn::~Pawn()




More information about the Orxonox-commit mailing list