[Orxonox-commit 2787] r7490 - in code/trunk/src/libraries/network: . packet

scheusso at orxonox.net scheusso at orxonox.net
Sun Sep 26 18:41:20 CEST 2010


Author: scheusso
Date: 2010-09-26 18:41:19 +0200 (Sun, 26 Sep 2010)
New Revision: 7490

Added:
   code/trunk/src/libraries/network/FunctionCall.cc
   code/trunk/src/libraries/network/FunctionCall.h
Modified:
   code/trunk/src/libraries/network/CMakeLists.txt
   code/trunk/src/libraries/network/NetworkPrereqs.h
   code/trunk/src/libraries/network/packet/FunctionCalls.cc
   code/trunk/src/libraries/network/packet/FunctionCalls.h
   code/trunk/src/libraries/network/packet/Packet.h
Log:
cleaning up function calls a bit in order to buffer calls for not (yet) existing objects


Modified: code/trunk/src/libraries/network/CMakeLists.txt
===================================================================
--- code/trunk/src/libraries/network/CMakeLists.txt	2010-09-24 14:01:04 UTC (rev 7489)
+++ code/trunk/src/libraries/network/CMakeLists.txt	2010-09-26 16:41:19 UTC (rev 7490)
@@ -24,6 +24,7 @@
   ClientInformation.cc
   ClientConnectionListener.cc
   Connection.cc
+  FunctionCall.cc
   FunctionCallManager.cc
   GamestateManager.cc
   GamestateClient.cc
@@ -44,6 +45,7 @@
   ClientConnectionListener.h
   ClientInformation.h
   Connection.h
+  FunctionCall.h
   FunctionCallManager.h
   GamestateClient.h
   GamestateHandler.h

Copied: code/trunk/src/libraries/network/FunctionCall.cc (from rev 7489, code/trunk/src/libraries/network/packet/FunctionCalls.cc)
===================================================================
--- code/trunk/src/libraries/network/FunctionCall.cc	                        (rev 0)
+++ code/trunk/src/libraries/network/FunctionCall.cc	2010-09-26 16:41:19 UTC (rev 7490)
@@ -0,0 +1,232 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss <scheusso [at] orxonox.net>, (C) 2010
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "FunctionCall.h"
+
+#include <cassert>
+#include "util/MultiType.h"
+#include "NetworkFunction.h"
+
+namespace orxonox {
+
+FunctionCall::FunctionCall()
+ : nrOfArguments_(-1), objectID_(OBJECTID_UNKNOWN), size_(0)
+{
+}
+
+FunctionCall::~FunctionCall()
+{
+}
+
+
+bool FunctionCall::execute(){
+  if( this->bIsStatic_ )
+  {
+    NetworkFunctionStatic *fct = NetworkFunctionStatic::getFunction( this->functionID_ );
+    assert( this->nrOfArguments_==this->arguments_.size() );
+    switch(this->nrOfArguments_)
+    {
+      case 0:
+        fct->call();
+        break;
+      case 1:
+        fct->call(this->arguments_[0]);
+        break;
+      case 2:
+        fct->call(this->arguments_[0], this->arguments_[1]);
+        break;
+      case 3:
+        fct->call(this->arguments_[0], this->arguments_[1], this->arguments_[2]);
+        break;
+      case 4:
+        fct->call(this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3]);
+        break;
+      case 5:
+        fct->call(this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3], this->arguments_[4]);
+        break;
+      default:
+        assert(0);
+    }
+  }
+  else // not a static function, so also handle with the objectID
+  {
+    NetworkMemberFunctionBase *fct = NetworkMemberFunctionBase::getFunction( this->functionID_ );
+    switch(this->nrOfArguments_)
+    {
+      case 0:
+        fct->call(this->objectID_);
+        break;
+      case 1:
+        fct->call(this->objectID_, this->arguments_[0]);
+        break;
+      case 2:
+        fct->call(this->objectID_, this->arguments_[0], this->arguments_[1]);
+        break;
+      case 3:
+        fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2]);
+        break;
+      case 4:
+        fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3]);
+        break;
+      case 5:
+        fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3], this->arguments_[4]);
+        break;
+      default:
+        assert(0);
+    }
+  }
+  return true;
+}
+
+void FunctionCall::setCallStatic( uint32_t networkID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5){
+
+  // first determine the size that has to be reserved for this call
+  uint32_t callsize = 2*sizeof(uint32_t)+sizeof(uint8_t); //size for network-function-id and nrOfArguments and for bool isStatic
+  uint32_t nrOfArguments = 0;
+  if(mt1)
+  {
+    nrOfArguments++;
+    callsize += mt1->getNetworkSize();
+    this->arguments_.push_back(*mt1);
+    if(mt2)
+    {
+      nrOfArguments++;
+      callsize += mt2->getNetworkSize();
+      this->arguments_.push_back(*mt2);
+      if(mt3)
+      {
+        nrOfArguments++;
+        callsize += mt3->getNetworkSize();
+        this->arguments_.push_back(*mt3);
+        if(mt4)
+        {
+          nrOfArguments++;
+          callsize += mt4->getNetworkSize();
+          this->arguments_.push_back(*mt4);
+          if(mt5)
+          {
+            nrOfArguments++;
+            callsize += mt5->getNetworkSize();
+            this->arguments_.push_back(*mt5);
+          }
+        }
+      }
+    }
+  }
+  this->nrOfArguments_ = nrOfArguments;
+  this->size_ = callsize;
+  this->bIsStatic_ = true;
+  this->functionID_ = networkID;
+}
+
+void FunctionCall::setCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5){
+
+  // first determine the size that has to be reserved for this call
+  uint32_t callsize = 3*sizeof(uint32_t)+sizeof(uint8_t); //size for network-function-id and nrOfArguments and the objectID and bIsStatic
+  uint32_t nrOfArguments = 0;
+  if(mt1)
+  {
+    nrOfArguments++;
+    callsize += mt1->getNetworkSize();
+    this->arguments_.push_back(*mt1);
+    if(mt2)
+    {
+      nrOfArguments++;
+      callsize += mt2->getNetworkSize();
+      this->arguments_.push_back(*mt2);
+      if(mt3)
+      {
+        nrOfArguments++;
+        callsize += mt3->getNetworkSize();
+        this->arguments_.push_back(*mt3);
+        if(mt4)
+        {
+          nrOfArguments++;
+          callsize += mt4->getNetworkSize();
+          this->arguments_.push_back(*mt4);
+          if(mt5)
+          {
+            nrOfArguments++;
+            callsize += mt5->getNetworkSize();
+            this->arguments_.push_back(*mt5);
+          }
+        }
+      }
+    }
+  }
+  this->nrOfArguments_ = nrOfArguments;
+  this->bIsStatic_ = false;
+  this->functionID_ = networkID;
+  this->size_ = callsize;
+  this->objectID_ = objectID;
+}
+
+void FunctionCall::loadData(uint8_t*& mem)
+{
+  this->functionID_ = *(uint32_t*)mem;
+  this->bIsStatic_ = *(uint8_t*)(mem+sizeof(uint32_t));
+  this->nrOfArguments_ = *(uint32_t*)(mem+sizeof(uint32_t)+sizeof(uint8_t));
+  if( this->bIsStatic_ )
+  {
+    mem += 2*sizeof(uint32_t)+sizeof(uint8_t);
+  }
+  else
+  {
+    this->objectID_ = *(uint32_t*)(mem+2*sizeof(uint32_t)+sizeof(uint8_t));
+    mem += 3*sizeof(uint32_t)+sizeof(uint8_t);
+  }
+  for( unsigned int i=0; i<this->nrOfArguments_; ++i )
+  {
+    this->arguments_.push_back(MultiType());
+    this->arguments_.back().importData(mem);
+  }
+}
+
+void FunctionCall::saveData(uint8_t*& mem)
+{
+  // now serialise the mt values and copy the function id and isStatic
+  *(uint32_t*)mem = this->functionID_;
+  *(uint8_t*)(mem+sizeof(uint32_t)) = this->bIsStatic_;
+  *(uint32_t*)(mem+sizeof(uint32_t)+sizeof(uint8_t)) = this->nrOfArguments_;
+  if( this->bIsStatic_ )
+  {
+    mem += 2*sizeof(uint32_t)+sizeof(uint8_t);
+  }
+  {
+    *(uint32_t*)(mem+2*sizeof(uint32_t)+sizeof(uint8_t)) = this->objectID_;
+    mem += 3*sizeof(uint32_t)+sizeof(uint8_t);
+  }
+  for( std::vector<MultiType>::iterator it = this->arguments_.begin(); it!=this->arguments_.end(); ++it )
+  {
+    it->exportData( mem );
+  }
+}
+
+
+
+} //namespace orxonox

Copied: code/trunk/src/libraries/network/FunctionCall.h (from rev 7489, code/trunk/src/libraries/network/packet/FunctionCalls.h)
===================================================================
--- code/trunk/src/libraries/network/FunctionCall.h	                        (rev 0)
+++ code/trunk/src/libraries/network/FunctionCall.h	2010-09-26 16:41:19 UTC (rev 7490)
@@ -0,0 +1,69 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss <scheusso [at] ee.ethz.ch>
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _FunctionCall_H__
+#define _FunctionCall_H__
+
+#include "network/NetworkPrereqs.h"
+#include "util/UtilPrereqs.h"
+
+#include <cassert>
+#include <vector>
+
+namespace orxonox {
+/**
+    @author
+*/
+
+
+class _NetworkExport FunctionCall
+{
+public:
+  FunctionCall();
+  ~FunctionCall();
+
+  inline unsigned int getSize() const { return this->size_; }
+  bool execute();
+
+  void setCallStatic( uint32_t networkID, const MultiType* mt1=0, const MultiType* mt2=0, const MultiType* mt3=0, const MultiType* mt4=0, const MultiType* mt5=0);
+  void setCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1=0, const MultiType* mt2=0, const MultiType* mt3=0, const MultiType* mt4=0, const MultiType* mt5=0);
+  
+  void saveData( uint8_t*& mem );
+  void loadData( uint8_t*& mem );
+private:
+  uint32_t                  nrOfArguments_;
+  bool                      bIsStatic_;
+  uint32_t                  functionID_;
+  uint32_t                  objectID_;
+  uint32_t                  size_;
+  std::vector<MultiType>    arguments_;
+};
+
+} //namespace orxonox
+
+#endif /* _FunctionCalls_H__ */

Modified: code/trunk/src/libraries/network/NetworkPrereqs.h
===================================================================
--- code/trunk/src/libraries/network/NetworkPrereqs.h	2010-09-24 14:01:04 UTC (rev 7489)
+++ code/trunk/src/libraries/network/NetworkPrereqs.h	2010-09-26 16:41:19 UTC (rev 7490)
@@ -114,6 +114,7 @@
   class ClientConnectionListener;
   class ClientInformation;
   class Connection;
+  class FunctionCall;
   class FunctionCallManager;
   class GamestateClient;
   class GamestateHandler;

Modified: code/trunk/src/libraries/network/packet/FunctionCalls.cc
===================================================================
--- code/trunk/src/libraries/network/packet/FunctionCalls.cc	2010-09-24 14:01:04 UTC (rev 7489)
+++ code/trunk/src/libraries/network/packet/FunctionCalls.cc	2010-09-26 16:41:19 UTC (rev 7490)
@@ -29,9 +29,7 @@
 #include "FunctionCalls.h"
 
 #include <cassert>
-#include <cstring>
-#include "util/MultiType.h"
-#include "network/NetworkFunction.h"
+#include "network/FunctionCall.h"
 
 namespace orxonox {
 namespace packet {
@@ -45,11 +43,6 @@
 {
   flags_ = flags_ | PACKET_FLAGS_FUNCTIONCALLS;
   currentSize_ = 2*sizeof(uint32_t); // for packetid and nrOfCalls
-  nrOfCalls_ = 0;
-  currentMemBlocks_ = 1;
-  data_=new uint8_t[ FUNCTIONCALLS_MEM_ALLOCATION ];
-  *(Type::Value *)(data_ + _PACKETID ) = Type::FunctionCalls;
-  *(uint32_t*)(data_+sizeof(uint32_t)) = 0; // set nrOfCalls to 0
 }
 
 FunctionCalls::FunctionCalls( uint8_t* data, unsigned int clientID )
@@ -64,258 +57,58 @@
 
 bool FunctionCalls::process(){
   assert(isDataENetAllocated());
+  
   uint8_t* temp = data_+sizeof(uint32_t); //skip packetid
-  this->nrOfCalls_ = *(uint32_t*)temp;
+  uint32_t nrOfCalls = *(uint32_t*)temp;
   temp += sizeof(uint32_t);
-  for( unsigned int i = 0; i<this->nrOfCalls_; i++ )
+  for( unsigned int i = 0; i<nrOfCalls; i++ )
   {
-    uint32_t functionID = *(uint32_t*)temp;
-    bool isStatic = *(uint8_t*)(temp+sizeof(uint32_t));
-    if( isStatic )
-    {
-      MultiType mt1, mt2, mt3, mt4, mt5;
-      NetworkFunctionStatic *fct = NetworkFunctionStatic::getFunction( functionID );
-      uint32_t nrOfArguments = *(uint32_t*)(temp+sizeof(uint32_t)+sizeof(uint8_t));
-      temp+=2*sizeof(uint32_t)+sizeof(uint8_t);
-      switch(nrOfArguments)
-      {
-        case 0:
-          fct->call();
-          break;
-        case 1:
-          mt1.importData(temp);
-          fct->call(mt1);
-          break;
-        case 2:
-          mt1.importData(temp);
-          mt2.importData(temp);
-          fct->call(mt1, mt2);
-          break;
-        case 3:
-          mt1.importData(temp);
-          mt2.importData(temp);
-          mt3.importData(temp);
-          fct->call(mt1, mt2, mt3);
-          break;
-        case 4:
-          mt1.importData(temp);
-          mt2.importData(temp);
-          mt3.importData(temp);
-          mt4.importData(temp);
-          fct->call(mt1, mt2, mt3, mt4);
-          break;
-        case 5:
-          mt1.importData(temp);
-          mt2.importData(temp);
-          mt3.importData(temp);
-          mt4.importData(temp);
-          mt5.importData(temp);
-          fct->call(mt1, mt2, mt3, mt4, mt5);
-          break;
-        default:
-          assert(0);
-      }
-    }
-    else // not a static function, so also handle the objectID
-    {
-      MultiType mt1, mt2, mt3, mt4, mt5;
-      NetworkMemberFunctionBase *fct = NetworkMemberFunctionBase::getFunction( functionID );
-      uint32_t nrOfArguments = *(uint32_t*)(temp+sizeof(uint32_t)+sizeof(uint8_t));
-      uint32_t objectID = *(uint32_t*)(temp+2*sizeof(uint32_t)+sizeof(uint8_t));
-      temp+=3*sizeof(uint32_t)+sizeof(uint8_t);
-      switch(nrOfArguments)
-      {
-        case 0:
-          fct->call(objectID);
-          break;
-        case 1:
-          mt1.importData(temp);
-          fct->call(objectID, mt1);
-          break;
-        case 2:
-          mt1.importData(temp);
-          mt2.importData(temp);
-          fct->call(objectID, mt1, mt2);
-          break;
-        case 3:
-          mt1.importData(temp);
-          mt2.importData(temp);
-          mt3.importData(temp);
-          fct->call(objectID, mt1, mt2, mt3);
-          break;
-        case 4:
-          mt1.importData(temp);
-          mt2.importData(temp);
-          mt3.importData(temp);
-          mt4.importData(temp);
-          fct->call(objectID, mt1, mt2, mt3, mt4);
-          break;
-        case 5:
-          mt1.importData(temp);
-          mt2.importData(temp);
-          mt3.importData(temp);
-          mt4.importData(temp);
-          mt5.importData(temp);
-          fct->call(objectID, mt1, mt2, mt3, mt4, mt5);
-          break;
-        default:
-          assert(0);
-          break;
-      }
-    }
+    FunctionCall fctCall;
+    fctCall.loadData(temp);
+    fctCall.execute();
   }
+  
   delete this;
   return true;
 }
 
 void FunctionCalls::addCallStatic( uint32_t networkID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5){
   assert(!isDataENetAllocated());
-
-  // first determine the size that has to be reserved for this call
-  uint32_t callsize = 2*sizeof(uint32_t)+sizeof(uint8_t); //size for network-function-id and nrOfArguments and for bool isStatic
-  uint32_t nrOfArguments = 0;
-  if(mt1)
-  {
-    nrOfArguments++;
-    callsize += mt1->getNetworkSize();
-    if(mt2)
-    {
-      nrOfArguments++;
-      callsize += mt2->getNetworkSize();
-      if(mt3)
-      {
-        nrOfArguments++;
-        callsize += mt3->getNetworkSize();
-        if(mt4)
-        {
-          nrOfArguments++;
-          callsize += mt4->getNetworkSize();
-          if(mt5)
-          {
-            nrOfArguments++;
-            callsize += mt5->getNetworkSize();
-          }
-        }
-      }
-    }
-  }
-
-  // now allocated mem if neccessary
-  if( currentSize_ + callsize > currentMemBlocks_*FUNCTIONCALLS_MEM_ALLOCATION )
-  {
-    currentMemBlocks_ = (currentSize_ + callsize)%FUNCTIONCALLS_MEM_ALLOCATION+1;
-    uint8_t *temp = new uint8_t[currentMemBlocks_*FUNCTIONCALLS_MEM_ALLOCATION];
-    memcpy( temp, data_, currentSize_ );
-    delete[] data_;
-    data_ = temp;
-  }
-
-  // now serialise the mt values and copy the function id and isStatic
-  uint8_t* temp = data_+currentSize_;
-  *(uint32_t*)(data_+sizeof(uint32_t)) = *(uint32_t*)(data_+sizeof(uint32_t))+1; // increase number of calls
-  *(uint32_t*)temp = networkID;
-  *(uint8_t*)(temp+sizeof(uint32_t)) = true;
-  *(uint32_t*)(temp+sizeof(uint32_t)+sizeof(uint8_t)) = nrOfArguments;
-  temp += 2*sizeof(uint32_t)+sizeof(uint8_t);
-  if(mt1)
-  {
-    mt1->exportData( temp ); //temp gets automatically increased
-    if(mt2)
-    {
-      mt2->exportData( temp ); //temp gets automatically increased
-      if(mt3)
-      {
-        mt3->exportData( temp ); //temp gets automatically increased
-        if(mt4)
-        {
-          mt4->exportData( temp ); //temp gets automatically increased
-          if(mt5)
-          {
-            mt5->exportData( temp ); //temp gets automatically increased
-          }
-        }
-      }
-    }
-  }
-  //currentSize_ += callsize;
-  currentSize_ = temp-data_;
-
+  
+  this->functionCalls_.push(orxonox::FunctionCall());
+  this->functionCalls_.back().setCallStatic( networkID, mt1, mt2, mt3, mt4, mt5 );
+  this->currentSize_ += this->functionCalls_.back().getSize();
 }
 
 void FunctionCalls::addCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5){
   assert(!isDataENetAllocated());
+  
+  this->functionCalls_.push(orxonox::FunctionCall());
+  this->functionCalls_.back().setCallMember( networkID, objectID, mt1, mt2, mt3, mt4, mt5 );
+  this->currentSize_ += this->functionCalls_.back().getSize();
+}
 
-  // first determine the size that has to be reserved for this call
-  uint32_t callsize = 3*sizeof(uint32_t)+sizeof(uint8_t); //size for network-function-id and nrOfArguments and the objectID
-  uint32_t nrOfArguments = 0;
-  if(mt1)
+bool FunctionCalls::send()
+{
+  assert(this->functionCalls_.size());
+  data_=new uint8_t[ currentSize_ ];
+  *(Type::Value *)(data_ + _PACKETID ) = Type::FunctionCalls; // Set the Packet ID
+  *(uint32_t*)(data_+sizeof(uint32_t)) = this->functionCalls_.size(); // set nrOfCalls to 0
+  uint8_t* temp = data_+2*sizeof(uint32_t);
+  
+  while( this->functionCalls_.size() )
   {
-    nrOfArguments++;
-    callsize += mt1->getNetworkSize();
-    if(mt2)
-    {
-      nrOfArguments++;
-      callsize += mt2->getNetworkSize();
-      if(mt3)
-      {
-        nrOfArguments++;
-        callsize += mt3->getNetworkSize();
-        if(mt4)
-        {
-          nrOfArguments++;
-          callsize += mt4->getNetworkSize();
-          if(mt5)
-          {
-            nrOfArguments++;
-            callsize += mt5->getNetworkSize();
-          }
-        }
-      }
-    }
+    this->functionCalls_.front().saveData( temp );
+    this->functionCalls_.pop();
   }
-
-  // now allocated mem if neccessary
-  if( currentSize_ + callsize > currentMemBlocks_*FUNCTIONCALLS_MEM_ALLOCATION )
-  {
-    currentMemBlocks_ = (currentSize_ + callsize)%FUNCTIONCALLS_MEM_ALLOCATION+1;
-    uint8_t *temp = new uint8_t[currentMemBlocks_*FUNCTIONCALLS_MEM_ALLOCATION];
-    memcpy( temp, data_, currentSize_ );
-    delete[] data_;
-    data_ = temp;
-  }
-
-  // now serialise the mt values and copy the function id
-  uint8_t* temp = data_+currentSize_;
-  *(uint32_t*)(data_+sizeof(uint32_t)) = *(uint32_t*)(data_+sizeof(uint32_t))+1; // increase number of calls
-  *(uint32_t*)temp = networkID;
-  *(uint8_t*)(temp+sizeof(uint32_t)) = false;
-  *(uint32_t*)(temp+sizeof(uint32_t)+sizeof(uint8_t)) = nrOfArguments;
-  *(uint32_t*)(temp+2*sizeof(uint32_t)+sizeof(uint8_t)) = objectID;
-  temp += 3*sizeof(uint32_t)+sizeof(uint8_t);
-  if(mt1)
-  {
-    mt1->exportData( temp ); //temp gets automatically increased
-    if(mt2)
-    {
-      mt2->exportData( temp ); //temp gets automatically increased
-      if(mt3)
-      {
-        mt3->exportData( temp ); //temp gets automatically increased
-        if(mt4)
-        {
-          mt4->exportData( temp ); //temp gets automatically increased
-          if(mt5)
-          {
-            mt5->exportData( temp ); //temp gets automatically increased
-          }
-        }
-      }
-    }
-  }
-  currentSize_ += callsize;
-
+  
+  assert( temp==data_+currentSize_ );
+  
+  Packet::send();
+  return true;
 }
 
 
+
 } //namespace packet
 } //namespace orxonox

Modified: code/trunk/src/libraries/network/packet/FunctionCalls.h
===================================================================
--- code/trunk/src/libraries/network/packet/FunctionCalls.h	2010-09-24 14:01:04 UTC (rev 7489)
+++ code/trunk/src/libraries/network/packet/FunctionCalls.h	2010-09-26 16:41:19 UTC (rev 7490)
@@ -32,8 +32,9 @@
 #include "network/NetworkPrereqs.h"
 
 #include <cassert>
-#include "util/UtilPrereqs.h"
+#include <queue>
 #include "Packet.h"
+#include "network/FunctionCall.h"
 
 namespace orxonox {
 
@@ -56,11 +57,11 @@
 
   void addCallStatic( uint32_t networkID, const MultiType* mt1=0, const MultiType* mt2=0, const MultiType* mt3=0, const MultiType* mt4=0, const MultiType* mt5=0);
   void addCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1=0, const MultiType* mt2=0, const MultiType* mt3=0, const MultiType* mt4=0, const MultiType* mt5=0);
+  virtual bool send();
 private:
-  uint32_t nrOfCalls_;
-  unsigned int clientID_;
-  uint32_t currentSize_;
-  uint32_t currentMemBlocks_; // this saves the number of memory blocks (of size FUNCTIONCALLS_MEM_ALLOCATION) allocated
+  std::queue<orxonox::FunctionCall> functionCalls_;
+  unsigned int                      clientID_;
+  uint32_t                          currentSize_;
 };
 
 } //namespace packet

Modified: code/trunk/src/libraries/network/packet/Packet.h
===================================================================
--- code/trunk/src/libraries/network/packet/Packet.h	2010-09-24 14:01:04 UTC (rev 7489)
+++ code/trunk/src/libraries/network/packet/Packet.h	2010-09-26 16:41:19 UTC (rev 7490)
@@ -75,7 +75,7 @@
     inline void setClientID( int id )
       { clientID_ = id; }
 
-    bool send();
+    virtual bool send();
   protected:
     Packet();
     Packet(uint8_t *data, unsigned int clientID);




More information about the Orxonox-commit mailing list