[Orxonox-commit 307] r2937 - in branches/netp2/src: network network/packet network/synchronisable orxonox orxonox/objects util

scheusso at orxonox.net scheusso at orxonox.net
Wed Apr 29 16:05:36 CEST 2009


Author: scheusso
Date: 2009-04-29 16:05:35 +0200 (Wed, 29 Apr 2009)
New Revision: 2937

Added:
   branches/netp2/src/network/FunctionCallManager.cc
   branches/netp2/src/network/FunctionCallManager.h
   branches/netp2/src/network/NetworkFunction.cc
   branches/netp2/src/network/NetworkFunction.h
   branches/netp2/src/network/packet/FunctionIDs.cc
   branches/netp2/src/network/packet/FunctionIDs.h
Removed:
   branches/netp2/src/network/synchronisable/SynchronisableVariableSpecialisations.h
Modified:
   branches/netp2/src/network/CMakeLists.txt
   branches/netp2/src/network/NetworkPrereqs.h
   branches/netp2/src/network/packet/CMakeLists.txt
   branches/netp2/src/network/packet/ClassID.cc
   branches/netp2/src/network/packet/Packet.cc
   branches/netp2/src/network/packet/Packet.h
   branches/netp2/src/network/synchronisable/Synchronisable.h
   branches/netp2/src/orxonox/OrxonoxPrereqs.h
   branches/netp2/src/orxonox/objects/Test.cc
   branches/netp2/src/orxonox/objects/Test.h
   branches/netp2/src/util/MultiType.h
Log:
commit for testing reasons
- added possibility to transfer function calls over network
- made MultiType serialisable
- put serialise functions from synchronisable to util
- ... (can't remember ^^)


Modified: branches/netp2/src/network/CMakeLists.txt
===================================================================
--- branches/netp2/src/network/CMakeLists.txt	2009-04-27 15:15:04 UTC (rev 2936)
+++ branches/netp2/src/network/CMakeLists.txt	2009-04-29 14:05:35 UTC (rev 2937)
@@ -24,13 +24,15 @@
   ClientInformation.cc
   ClientConnectionListener.cc
   ConnectionManager.cc
+  FunctionCallManager.cc
   GamestateManager.cc
   GamestateClient.cc
   GamestateHandler.cc
+  NetworkFunction.cc
+  Host.cc
   PacketBuffer.cc
   Server.cc
   TrafficControl.cc
-  Host.cc
 )
 ADD_SUBDIRECTORY(packet)
 ADD_SUBDIRECTORY(synchronisable)

Added: branches/netp2/src/network/FunctionCallManager.cc
===================================================================
--- branches/netp2/src/network/FunctionCallManager.cc	                        (rev 0)
+++ branches/netp2/src/network/FunctionCallManager.cc	2009-04-29 14:05:35 UTC (rev 2937)
@@ -0,0 +1,64 @@
+/*
+ *   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>, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "FunctionCallManager.h"
+#include "packet/FunctionCalls.h"
+
+namespace orxonox {
+    
+std::map<uint32_t, packet::FunctionCalls*> FunctionCallManager::clientMap_;
+
+void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, MultiType* mt1, MultiType* mt2, MultiType* mt3, MultiType* mt4, MultiType* mt5)
+{ 
+  if(clientMap_.find(clientID)==clientMap_.end()) 
+  {
+    clientMap_[clientID] = new packet::FunctionCalls; 
+    clientMap_[clientID]->setClientID(clientID); 
+  } 
+  clientMap_[clientID]->addCallStatic(functionID, mt1, mt2, mt3, mt4, mt5);
+}
+
+void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, MultiType* mt1, MultiType* mt2, MultiType* mt3, MultiType* mt4, MultiType* mt5)
+{ 
+  if(clientMap_.find(clientID)==clientMap_.end()) 
+  {
+    clientMap_[clientID] = new packet::FunctionCalls; 
+    clientMap_[clientID]->setClientID(clientID); 
+  } 
+  clientMap_[clientID]->addCallMember(functionID, objectID, mt1, mt2, mt3, mt4, mt5);
+}
+
+void FunctionCallManager::sendCalls()
+{
+  std::map<uint32_t, packet::FunctionCalls*>::iterator it;
+  for (it = FunctionCallManager::clientMap_.begin(); it != FunctionCallManager::clientMap_.end(); it++)
+    it->second->send();
+}
+
+
+} //namespace orxonox

Added: branches/netp2/src/network/FunctionCallManager.h
===================================================================
--- branches/netp2/src/network/FunctionCallManager.h	                        (rev 0)
+++ branches/netp2/src/network/FunctionCallManager.h	2009-04-29 14:05:35 UTC (rev 2937)
@@ -0,0 +1,32 @@
+
+#ifndef NETWORKFUNCTIONCALLMANAGER_H
+#define NETWORKFUNCTIONCALLMANAGER_H
+
+#include "NetworkPrereqs.h"
+#include "packet/FunctionCalls.h"
+#include <map>
+
+
+namespace orxonox {
+/**
+	@author
+*/
+
+class MultiType;
+
+class _NetworkExport FunctionCallManager
+{
+public:
+  static void addCallStatic(uint32_t functionID, uint32_t clientID, MultiType* mt1=0, MultiType* mt2=0, MultiType* mt3=0, MultiType* mt4=0, MultiType* mt5=0);
+  static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, MultiType* mt1=0, MultiType* mt2=0, MultiType* mt3=0, MultiType* mt4=0, MultiType* mt5=0);
+  static void sendCalls();
+  
+  static std::map<uint32_t, packet::FunctionCalls*> clientMap_;
+protected:
+  FunctionCallManager();
+  ~FunctionCallManager();
+};
+
+} //namespace orxonox
+
+#endif

Added: branches/netp2/src/network/NetworkFunction.cc
===================================================================
--- branches/netp2/src/network/NetworkFunction.cc	                        (rev 0)
+++ branches/netp2/src/network/NetworkFunction.cc	2009-04-29 14:05:35 UTC (rev 2937)
@@ -0,0 +1,89 @@
+/*
+ *   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
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "NetworkFunction.h"
+#include <string>
+#include "synchronisable/Synchronisable.h"
+
+namespace orxonox
+{
+  std::map<std::string, NetworkFunctionBase*> NetworkFunctionBase::nameMap_;
+  std::map<uint32_t, bool> NetworkFunctionBase::isStaticMap_;
+  
+  std::map<NetworkFunctionPointer, NetworkFunctionStatic*> NetworkFunctionStatic::functorMap_;
+  std::map<uint32_t, NetworkFunctionStatic*> NetworkFunctionStatic::idMap_;
+      
+  std::map<NetworkFunctionPointer, NetworkMemberFunctionBase*> NetworkMemberFunctionBase::functorMap_;
+  std::map<uint32_t, NetworkMemberFunctionBase*> NetworkMemberFunctionBase::idMap_;
+
+  NetworkFunctionBase::NetworkFunctionBase(std::string name)
+  {
+    RegisterRootObject(NetworkFunctionBase);
+    
+    static uint32_t networkID = 0;
+    this->networkID_ = networkID++;
+    
+    this->name_ = name;
+    nameMap_[name] = this;
+  }
+  NetworkFunctionBase::~NetworkFunctionBase()
+  {
+  }
+  
+  
+  
+  NetworkFunctionStatic::NetworkFunctionStatic(Functor* functor, std::string name, const NetworkFunctionPointer& p):
+    NetworkFunctionBase(name)
+  {
+    RegisterObject(NetworkFunctionStatic);
+    
+    functorMap_[p] = this;
+    idMap_[ this->getNetworkID() ] = this;
+  }
+  
+  NetworkFunctionStatic::~NetworkFunctionStatic()
+  {
+  }
+  
+  
+  
+  NetworkMemberFunctionBase::NetworkMemberFunctionBase(std::string name, const NetworkFunctionPointer& p):
+    NetworkFunctionBase(name)
+  {
+    RegisterObject(NetworkMemberFunctionBase);
+    
+    functorMap_[p] = this;
+    idMap_[ this->getNetworkID() ] = this;
+  }
+  
+  NetworkMemberFunctionBase::~NetworkMemberFunctionBase()
+  {
+  }
+  
+
+}

Added: branches/netp2/src/network/NetworkFunction.h
===================================================================
--- branches/netp2/src/network/NetworkFunction.h	                        (rev 0)
+++ branches/netp2/src/network/NetworkFunction.h	2009-04-29 14:05:35 UTC (rev 2937)
@@ -0,0 +1,201 @@
+/*
+ *   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
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef NETWORKFUNCTION_H
+#define NETWORKFUNCTION_H
+
+#include "NetworkPrereqs.h"
+#include "core/OrxonoxClass.h"
+
+#include <string>
+#include <map>
+#include <cassert>
+#include "util/MultiType.h"
+#include "synchronisable/Synchronisable.h"
+#include "FunctionCallManager.h"
+
+
+namespace orxonox
+{
+
+#ifdef ORXONOX_COMPILER_GCC
+static const unsigned int MAX_FUNCTION_POINTER_SIZE = 8;
+#else //ORXONOX_COMPILER_GCC
+static const unsigned int MAX_FUNCTION_POINTER_SIZE = 16;
+#endif //ORXONOX_COMPILER_GCC
+static const unsigned int MAX_FUNCTION_POINTER_INTS = (MAX_FUNCTION_POINTER_SIZE-1)/4+1;
+
+struct _NetworkExport NetworkFunctionPointer {
+  uint32_t pointer[MAX_FUNCTION_POINTER_INTS];
+  bool operator<(const NetworkFunctionPointer& b) const
+  {
+#ifdef ORXONOX_COMPILER_GCC
+    return pointer[0]<b.pointer[0] ? true : pointer[1]<b.pointer[1];
+#else //ORXONOX_COMPILER_GCC
+    return pointer[0]<b.pointer[0] ? true : ( pointer[1]<b.pointer[1] ? true : ( pointer[2]<b.pointer[2] ? true : pointer[3]<b.pointer[3] ) );
+#endif //ORXONOX_COMPILER_GCC
+  }
+};
+
+
+
+
+
+class NetworkFunctionBase: virtual public OrxonoxClass {
+  public:
+    NetworkFunctionBase(std::string name);
+    ~NetworkFunctionBase();
+    
+    inline void         setNetworkID(uint32_t id)       { this->networkID_ = id; }
+    inline uint32_t     getNetworkID() const            { return this->networkID_; }
+    inline std::string  getName() const                 { return name_; }
+    static inline bool  isStatic( uint32_t networkID )  { return isStaticMap_[networkID]; }
+    
+    
+    static inline void setNetworkID(std::string name, uint32_t id){ assert( nameMap_.find(name)!=nameMap_.end() ); nameMap_[name]->setNetworkID(id); }
+    
+  private:
+    static std::map<std::string, NetworkFunctionBase*> nameMap_;
+    static std::map<uint32_t, bool> isStaticMap_;
+    uint32_t networkID_;
+    std::string name_;
+      
+};
+
+
+class _NetworkExport NetworkFunctionStatic: public NetworkFunctionBase {
+  public:
+    NetworkFunctionStatic(Functor* functor, std::string name, const NetworkFunctionPointer& p);
+    ~NetworkFunctionStatic();
+    
+    inline void call(){ (*this->functor_)(); }
+    inline void call(const MultiType& mt1){ (*this->functor_)(mt1); }
+    inline void call(const MultiType& mt1, const MultiType& mt2){ (*this->functor_)(mt1, mt2); }
+    inline void call(const MultiType& mt1, const MultiType& mt2, const MultiType& mt3){ (*this->functor_)(mt1, mt2, mt3); }
+    inline void call(const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4){ (*this->functor_)(mt1, mt2, mt3, mt4); }
+    inline void call(const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5){ (*this->functor_)(mt1, mt2, mt3, mt4, mt5); }
+    
+    static inline NetworkFunctionStatic* getNetworkFunction( uint32_t id){ assert( idMap_.find(id)!=idMap_.end() ); return idMap_[id]; }
+    static NetworkFunctionStatic* getFunction( uint32_t id ){ assert( idMap_.find(id) != idMap_.end() ); return idMap_[id]; }
+    static NetworkFunctionStatic* getFunction( const NetworkFunctionPointer& p ){ assert( functorMap_.find(p) != functorMap_.end() ); return functorMap_[p]; }
+    
+  private:
+    static std::map<NetworkFunctionPointer, NetworkFunctionStatic*> functorMap_;
+    static std::map<uint32_t, NetworkFunctionStatic*> idMap_;
+    
+    FunctorStatic* functor_;
+    
+};
+
+
+class NetworkMemberFunctionBase: public NetworkFunctionBase {
+  public:
+    NetworkMemberFunctionBase(std::string name, const NetworkFunctionPointer& p);
+    ~NetworkMemberFunctionBase();
+    
+    static inline NetworkMemberFunctionBase* getNetworkFunction( uint32_t id){ assert( idMap_.find(id)!=idMap_.end() ); return idMap_[id]; }
+    static NetworkMemberFunctionBase* getFunction( uint32_t id ){ assert( idMap_.find(id) != idMap_.end() ); return idMap_[id]; }
+    static NetworkMemberFunctionBase* getFunction( const NetworkFunctionPointer& p ){ assert( functorMap_.find(p) != functorMap_.end() ); return functorMap_[p]; }
+    
+    // 
+    virtual void call(uint32_t objectID)=0;
+    virtual void call(uint32_t objectID, const MultiType& mt1)=0;
+    virtual void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2)=0;
+    virtual void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)=0;
+    virtual void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)=0;
+    virtual void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)=0;
+    
+  private:
+    static std::map<NetworkFunctionPointer, NetworkMemberFunctionBase*> functorMap_;
+    static std::map<uint32_t, NetworkMemberFunctionBase*> idMap_;
+};
+
+
+template <class T> class _NetworkExport NetworkMemberFunction: public NetworkMemberFunctionBase {
+  public:
+    NetworkMemberFunction(FunctorMember<T>* functor, std::string name, const NetworkFunctionPointer& p);
+    ~NetworkMemberFunction();
+    
+    inline void call(uint32_t objectID){ (*this->functor_)(dynamic_cast<T*>(Synchronisable::getSynchronisable(objectID))); }
+    inline void call(uint32_t objectID, const MultiType& mt1){ (*this->functor_)(dynamic_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1); }
+    inline void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2){ (*this->functor_)(dynamic_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2); }
+    inline void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3){ (*this->functor_)(dynamic_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2, mt3); }
+    inline void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4){ (*this->functor_)(dynamic_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2, mt3, mt4); }
+    inline void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5){ (*this->functor_)(dynamic_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2, mt3, mt4, mt5); }
+    
+  private:
+    FunctorMember<T>* functor_;
+};
+
+
+template<class T> inline void copyPtr( T ptr, NetworkFunctionPointer& destptr)
+{
+  memset(&destptr, 0, sizeof(ptr));
+  T p2 = ptr;
+  memcpy( &destptr, &p2, sizeof(T) );
+//   for(unsigned int i=0; i<(sizeof(T)-1/4)+1; i++)
+//     *((uint32_t*)destptr+i) = p2>>32*i;
+}
+
+template<class T> inline void* registerStaticNetworkFunctionFct( T ptr, std::string name )
+{
+  NetworkFunctionPointer destptr;
+  copyPtr( ptr, destptr );
+  new NetworkFunctionStatic( createFunctor(ptr), name, destptr );
+  return 0;
+}
+
+template<class T, class PT> inline void* registerMemberNetworkFunctionFct( PT ptr, std::string name )
+{
+  NetworkFunctionPointer destptr;
+  copyPtr( ptr, destptr );
+  new NetworkMemberFunction<T>( new FunctorMember<T>(ptr), name, destptr );
+  return 0;
+}
+
+#define registerStaticNetworkFunction( functionPointer, name ) \
+  void* NETWORK_FUNCTION_name##a = registerStaticNetworkFunctionFct( functionPointer, name );
+#define registerMemberNetworkFunction( functionPointer, class, name ) \
+  void* NETWORK_FUNCTION_class##name##a = registerMemberNetworkFunction<class>( functionPointer, name );
+#define callStaticNetworkFunction( functionPointer, ...) \
+  { \
+    NetworkFunctionPointer p1; \
+    copyPtr( functionPointer, p1 ); \
+    FunctionCallManager::addCallStatic(NetworkMemberFunctionBase::getFunction(p1)->getNetworkID(), __VA_ARGS__); \
+  }
+#define callMemberNetworkFunction( functionPointer, objectID, ...) \
+  { \
+    NetworkFunctionPointer p1; \
+    copyPtr( functionPointer, p1 ); \
+    FunctionCallManager::addCallMember(NetworkMemberFunctionBase::getFunction(p1)->getNetworkID(), objectID, __VA_ARGS__) \
+  }
+
+
+}
+
+#endif

Modified: branches/netp2/src/network/NetworkPrereqs.h
===================================================================
--- branches/netp2/src/network/NetworkPrereqs.h	2009-04-27 15:15:04 UTC (rev 2936)
+++ branches/netp2/src/network/NetworkPrereqs.h	2009-04-29 14:05:35 UTC (rev 2937)
@@ -89,12 +89,18 @@
   class ClientFrameListener;
   class ClientInformation;
   class ConnectionManager;
+  class FunctionCallManager;
   class GamestateClient;
   class GamestateManager;
   class GamestateHandler;
   class NetworkCallbackBase;
   template <class T> class NetworkCallback;
   class NetworkCallbackManager;
+  class NetworkFunctionBase;
+  class NetworkFunctionStatic;
+  class NetworkMemberFunctionBase;
+  template <class T> class NetworkMemeberFunction;
+  struct NetworkFunctionPointer;
   class PacketBuffer;
   class Server;
   class ServerFrameListener;
@@ -111,12 +117,15 @@
 
   namespace packet
   {
+    class Acknowledgement;
+    class Chat;
+    class ClassID;
+    class FunctionCalls;
+    class FunctionIDs;
     class Gamestate;
+    class NetworkIDs;
     class Packet;
-    class Acknowledgement;
-    class ClassID;
     class Welcome;
-    class Chat;
   }
 }
 

Modified: branches/netp2/src/network/packet/CMakeLists.txt
===================================================================
--- branches/netp2/src/network/packet/CMakeLists.txt	2009-04-27 15:15:04 UTC (rev 2936)
+++ branches/netp2/src/network/packet/CMakeLists.txt	2009-04-29 14:05:35 UTC (rev 2937)
@@ -1,9 +1,11 @@
 ADD_SOURCE_FILES(NETWORK_SRC_FILES
   Packet.cc
+  Acknowledgement.cc
   Chat.cc
   ClassID.cc
-  Acknowledgement.cc
+  DeleteObjects.cc
+  FunctionIDs.cc
+  FunctionCalls.cc
   Gamestate.cc
   Welcome.cc
-  DeleteObjects.cc
 )

Modified: branches/netp2/src/network/packet/ClassID.cc
===================================================================
--- branches/netp2/src/network/packet/ClassID.cc	2009-04-27 15:15:04 UTC (rev 2936)
+++ branches/netp2/src/network/packet/ClassID.cc	2009-04-29 14:05:35 UTC (rev 2937)
@@ -92,7 +92,7 @@
     temp+=2*sizeof(uint32_t)+tempPair.second.size()+1;
   }
   
-  COUT(0) << "classid packetSize is " << packetSize << endl;
+  COUT(5) << "classid packetSize is " << packetSize << endl;
   
 }
 

Added: branches/netp2/src/network/packet/FunctionIDs.cc
===================================================================
--- branches/netp2/src/network/packet/FunctionIDs.cc	                        (rev 0)
+++ branches/netp2/src/network/packet/FunctionIDs.cc	2009-04-29 14:05:35 UTC (rev 2937)
@@ -0,0 +1,143 @@
+/*
+ *   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
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+
+
+#include "FunctionIDs.h"
+#include "network/NetworkFunction.h"
+#include <enet/enet.h>
+#include "core/CoreIncludes.h"
+#include <string>
+#include <cassert>
+#include <queue>
+
+namespace orxonox {
+namespace packet {
+
+
+#define PACKET_FLAGS_FUNCTIONIDS  ENET_PACKET_FLAG_RELIABLE
+#define _PACKETID                 0
+
+
+FunctionIDs::FunctionIDs( ) : Packet(){
+  std::string functionname;
+  unsigned int nrOfFunctions=0; 
+  unsigned int packetSize=2*sizeof(uint32_t); //space for the packetID and for the nroffunctions
+  uint32_t networkID;
+  flags_ = flags_ | PACKET_FLAGS_FUNCTIONIDS;
+  std::queue<std::pair<uint32_t, std::string> > tempQueue;
+  
+  //calculate total needed size (for all strings and integers)
+  ObjectList<NetworkFunctionBase>::iterator it;
+  for(it = ObjectList<NetworkFunctionBase>::begin(); it; ++it){
+    functionname = it->getName();
+    networkID = it->getNetworkID();
+    // now push the network id and the classname to the stack
+    tempQueue.push( std::pair<unsigned int, std::string>(networkID, functionname) );
+    ++nrOfFunctions;
+    packetSize += (functionname.size()+1)+sizeof(uint32_t)+sizeof(uint32_t); // reserver size for the functionname string, the functionname length and the networkID
+  }
+  
+  this->data_=new uint8_t[ packetSize ];
+  //set the appropriate packet id
+  assert(this->data_);
+  *(ENUM::Type *)(this->data_ + _PACKETID ) = ENUM::FunctionIDs;
+  
+  uint8_t *temp=data_+sizeof(uint32_t);
+  // save the number of all classes
+  *(uint32_t*)temp = nrOfFunctions;
+  temp += sizeof(uint32_t);
+  
+  // now save all classids and classnames
+  std::pair<uint32_t, std::string> tempPair;
+  while( !tempQueue.empty() ){
+    tempPair = tempQueue.front();
+    tempQueue.pop();
+    *(uint32_t*)temp = tempPair.first;
+    *(uint32_t*)(temp+sizeof(uint32_t)) = tempPair.second.size()+1;
+    memcpy(temp+2*sizeof(uint32_t), tempPair.second.c_str(), tempPair.second.size()+1);
+    temp+=2*sizeof(uint32_t)+tempPair.second.size()+1;
+  }
+  
+  COUT(5) << "FunctionIDs packetSize is " << packetSize << endl;
+  
+}
+
+FunctionIDs::FunctionIDs( uint8_t* data, unsigned int clientID )
+  : Packet(data, clientID)
+{
+}
+
+FunctionIDs::~FunctionIDs()
+{
+}
+
+uint32_t FunctionIDs::getSize() const{
+  assert(this->data_);
+  uint8_t *temp = data_+sizeof(uint32_t); // packet identification
+  uint32_t totalsize = sizeof(uint32_t); // data size
+  uint32_t nrOfFunctions = *(uint32_t*)temp;
+  temp += sizeof(uint32_t);
+  totalsize += sizeof(uint32_t); // storage size for nr of all classes
+  
+  for(unsigned int i=0; i<nrOfFunctions; i++){
+    totalsize += 2*sizeof(uint32_t) + *(uint32_t*)(temp + sizeof(uint32_t)); // for each network function add size for id, sizeof(string) and length of string itself to totalsize
+    temp += 2*sizeof(uint32_t) + *(uint32_t*)(temp + sizeof(uint32_t));
+  }
+  return totalsize;
+}
+
+
+bool FunctionIDs::process(){
+  int nrOfFunctions;
+  uint8_t *temp = data_+sizeof(uint32_t); //skip the packetid
+  uint32_t networkID;
+  uint32_t stringsize;
+  unsigned char *functionname;
+  
+  COUT(4) << "=== processing functionids: " << endl;
+  std::pair<uint32_t, std::string> tempPair;
+  // read the total number of classes
+  nrOfFunctions = *(uint32_t*)temp;
+  temp += sizeof(uint32_t);
+  
+  for( int i=0; i<nrOfFunctions; i++){
+    networkID = *(uint32_t*)temp;
+    stringsize = *(uint32_t*)(temp+sizeof(uint32_t));
+    functionname = temp+2*sizeof(uint32_t);
+    COUT(0) << "processing functionid: " << networkID << " name: " << functionname << std::endl;
+    NetworkFunctionBase::setNetworkID((const char*)functionname, networkID);
+    temp += 2*sizeof(uint32_t) + stringsize;
+  }
+  delete this;
+  return true;
+}
+
+
+} //namespace packet
+}//namespace orxonox

Added: branches/netp2/src/network/packet/FunctionIDs.h
===================================================================
--- branches/netp2/src/network/packet/FunctionIDs.h	                        (rev 0)
+++ branches/netp2/src/network/packet/FunctionIDs.h	2009-04-29 14:05:35 UTC (rev 2937)
@@ -0,0 +1,60 @@
+/*
+ *   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 NETWORKFUNCTIONIDS_H
+#define NETWORKFUNCTIONIDS_H
+
+#include "../NetworkPrereqs.h"
+
+#include <string>
+
+#include "Packet.h"
+
+namespace orxonox {
+namespace packet {
+
+  
+/**
+	@author
+*/
+class _NetworkExport FunctionIDs : public Packet
+{
+public:
+  FunctionIDs( );
+  FunctionIDs( uint8_t* data, unsigned int clientID );
+  ~FunctionIDs();
+
+  uint32_t getSize() const;
+  bool process();
+
+private:
+};
+
+} //namespace packet
+} //namespace orxonox
+
+#endif

Modified: branches/netp2/src/network/packet/Packet.cc
===================================================================
--- branches/netp2/src/network/packet/Packet.cc	2009-04-27 15:15:04 UTC (rev 2936)
+++ branches/netp2/src/network/packet/Packet.cc	2009-04-29 14:05:35 UTC (rev 2937)
@@ -152,6 +152,8 @@
     case ENUM::Gamestate:
     case ENUM::Welcome:
     case ENUM::DeleteObjects:
+    case ENUM::FunctionIDs:
+    case ENUM::FunctionCalls:
       break;
     default:
       assert(0); //there was some error, if this is the case

Modified: branches/netp2/src/network/packet/Packet.h
===================================================================
--- branches/netp2/src/network/packet/Packet.h	2009-04-27 15:15:04 UTC (rev 2936)
+++ branches/netp2/src/network/packet/Packet.h	2009-04-29 14:05:35 UTC (rev 2937)
@@ -44,11 +44,13 @@
   };
   enum Type{
     Acknowledgement,
+    Chat,
+    ClassID,
+    DeleteObjects,
+    FunctionIDs,
+    FunctionCalls,
     Gamestate,
-    ClassID,
-    Chat,
-    Welcome,
-    DeleteObjects
+    Welcome
   };
 }
 
@@ -77,6 +79,9 @@
     Packet();
     Packet(uint8_t *data, unsigned int clientID);
 //    Packet(ENetPacket *packet, ENetPeer *peer);
+    inline bool isDataENetAllocated() const
+      { return bDataENetAllocated_; }
+
     uint32_t flags_;
     unsigned int clientID_;
     ENUM::Direction packetDirection_;

Modified: branches/netp2/src/network/synchronisable/Synchronisable.h
===================================================================
--- branches/netp2/src/network/synchronisable/Synchronisable.h	2009-04-27 15:15:04 UTC (rev 2936)
+++ branches/netp2/src/network/synchronisable/Synchronisable.h	2009-04-29 14:05:35 UTC (rev 2937)
@@ -121,7 +121,6 @@
   class _NetworkExport Synchronisable : virtual public OrxonoxClass{
   public:
     friend class packet::Gamestate;
-//     friend class Server;
     virtual ~Synchronisable();
 
     static void setClient(bool b);

Deleted: branches/netp2/src/network/synchronisable/SynchronisableVariableSpecialisations.h
===================================================================
--- branches/netp2/src/network/synchronisable/SynchronisableVariableSpecialisations.h	2009-04-27 15:15:04 UTC (rev 2936)
+++ branches/netp2/src/network/synchronisable/SynchronisableVariableSpecialisations.h	2009-04-29 14:05:35 UTC (rev 2937)
@@ -1,435 +0,0 @@
-/*
- *   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, (C) 2008
- *   Co-authors:
- *      ...
- *
- */
-
-#include <cstring>
-#include "util/Math.h"
-
-#ifndef _NETWORK_SYNCHRONISABLEVARIABLESPECIALISATIONS__
-#define _NETWORK_SYNCHRONISABLEVARIABLESPECIALISATIONS__
-
-namespace orxonox{
-
-
-
-// =================== Template specialisation stuff =============
-
-// =========== bool
-
-template <> inline uint32_t SynchronisableVariable<const bool>::returnSize()
-{
-  return sizeof(uint8_t);
-}
-
-template <> inline void SynchronisableVariable<const bool>::setAndIncrease( uint8_t*& mem )
-{
-  *(uint8_t*)(&this->variable_) = *static_cast<uint8_t*>(mem);
-  mem += SynchronisableVariable<const bool>::returnSize();
-}
-
-template <> inline void SynchronisableVariable<const bool>::getAndIncrease( uint8_t*& mem )
-{
-  *static_cast<uint8_t*>(mem) = *(uint8_t*)(&this->variable_);
-  mem += SynchronisableVariable<const bool>::returnSize();
-}
-
-template <> inline bool SynchronisableVariable<const bool>::checkEquality( uint8_t* mem )
-{
-  return *static_cast<uint8_t*>(mem) == *(uint8_t*)(&this->variable_);
-}
-
-// =========== char
-
-template <> inline uint32_t SynchronisableVariable<const char>::returnSize()
-{
-  return sizeof(uint8_t);
-}
-
-template <> inline void SynchronisableVariable<const char>::setAndIncrease( uint8_t*& mem )
-{
-  *(uint8_t*)(&this->variable_) = *static_cast<uint8_t*>(mem);
-  mem += SynchronisableVariable<const char>::returnSize();
-}
-
-template <> inline void SynchronisableVariable<const char>::getAndIncrease( uint8_t*& mem )
-{
-  *static_cast<uint8_t*>(mem) = *(uint8_t*)(&this->variable_);
-  mem += SynchronisableVariable<const char>::returnSize();
-}
-
-template <> inline bool SynchronisableVariable<const char>::checkEquality( uint8_t* mem )
-{
-  return *static_cast<uint8_t*>(mem) == *(uint8_t*)(&this->variable_);
-}
-
-// =========== unsigned char
-
-template <> inline uint32_t SynchronisableVariable<const unsigned char>::returnSize()
-{
-  return sizeof(uint8_t);
-}
-
-template <> inline void SynchronisableVariable<const unsigned char>::setAndIncrease( uint8_t*& mem )
-{
-  *(uint8_t*)(&this->variable_) = *static_cast<uint8_t*>(mem);
-  mem += SynchronisableVariable<const unsigned char>::returnSize();
-}
-
-template <> inline void SynchronisableVariable<const unsigned char>::getAndIncrease( uint8_t*& mem )
-{
-  *static_cast<uint8_t*>(mem) = *(uint8_t*)(&this->variable_);
-  mem += SynchronisableVariable<const unsigned char>::returnSize();
-}
-
-template <> inline bool SynchronisableVariable<const unsigned char>::checkEquality( uint8_t* mem )
-{
-  return *static_cast<uint8_t*>(mem) == *(uint8_t*)(&this->variable_);
-}
-
-// =========== short
-
-template <> inline uint32_t SynchronisableVariable<const short>::returnSize()
-{
-  return sizeof(int16_t);
-}
-
-template <> inline void SynchronisableVariable<const short>::setAndIncrease( uint8_t*& mem )
-{
-  *(short*)(&this->variable_) = *(int16_t*)(mem);
-  mem += SynchronisableVariable<const short>::returnSize();
-}
-
-template <> inline void SynchronisableVariable<const short>::getAndIncrease( uint8_t*& mem )
-{
-  *(int16_t*)(mem) = this->variable_;
-  mem += SynchronisableVariable<const short>::returnSize();
-}
-
-template <> inline bool SynchronisableVariable<const short>::checkEquality( uint8_t* mem )
-{
-  return *(int16_t*)(mem) == static_cast<int16_t>(this->variable_);
-}
-
-// =========== unsigned short
-
-template <> inline uint32_t SynchronisableVariable<const unsigned short>::returnSize()
-{
-  return sizeof(uint16_t);
-}
-
-template <> inline void SynchronisableVariable<const unsigned short>::setAndIncrease( uint8_t*& mem )
-{
-  *(unsigned short*)(&this->variable_) = *(uint16_t*)(mem);
-  mem += SynchronisableVariable<const unsigned short>::returnSize();
-}
-
-template <> inline void SynchronisableVariable<const unsigned short>::getAndIncrease( uint8_t*& mem )
-{
-  *(uint16_t*)(mem) = this->variable_;
-  mem += SynchronisableVariable<const unsigned short>::returnSize();
-}
-
-template <> inline bool SynchronisableVariable<const unsigned short>::checkEquality( uint8_t* mem )
-{
-  return *(uint16_t*)(mem) == this->variable_;
-}
-
-// =========== int
-
-template <> inline uint32_t SynchronisableVariable<const int>::returnSize()
-{
-  return sizeof(int32_t);
-}
-
-template <> inline void SynchronisableVariable<const int>::setAndIncrease( uint8_t*& mem )
-{
-  *(int *)(&this->variable_) = *(int32_t*)(mem);
-  mem += SynchronisableVariable<const int>::returnSize();
-}
-
-template <> inline void SynchronisableVariable<const int>::getAndIncrease( uint8_t*& mem )
-{
-  *(int32_t*)(mem) = this->variable_;
-  mem += SynchronisableVariable<const int>::returnSize();
-}
-
-template <> inline bool SynchronisableVariable<const int>::checkEquality( uint8_t* mem )
-{
-  return *(int32_t*)(mem) == this->variable_;
-}
-
-// =========== unsigned int
-
-template <> inline uint32_t SynchronisableVariable<const unsigned int>::returnSize()
-{
-  return sizeof(uint32_t);
-}
-    
-template <> inline void SynchronisableVariable<const unsigned int>::setAndIncrease( uint8_t*& mem )
-{
-  *(unsigned int*)(&this->variable_) = *(uint32_t*)(mem);
-  mem += SynchronisableVariable<const unsigned int>::returnSize();
-}
-
-template <> inline void SynchronisableVariable<const unsigned int>::getAndIncrease( uint8_t*& mem )
-{
-  *(uint32_t*)(mem) = this->variable_;
-  mem += SynchronisableVariable<const unsigned int>::returnSize();
-}
-
-template <> inline bool SynchronisableVariable<const unsigned int>::checkEquality( uint8_t* mem )
-{
-  return *(uint32_t*)(mem) == this->variable_;
-}
-
-// =========== long
-
-template <> inline uint32_t SynchronisableVariable<const long>::returnSize()
-{
-  return sizeof(int32_t);
-}
-
-template <> inline void SynchronisableVariable<const long>::setAndIncrease( uint8_t*& mem )
-{
-  *(long*)(&this->variable_) = *(int32_t*)(mem);
-  mem += SynchronisableVariable<const long>::returnSize();
-}
-
-template <> inline void SynchronisableVariable<const long>::getAndIncrease( uint8_t*& mem )
-{
-  *(int32_t*)(mem) = this->variable_;
-  mem += SynchronisableVariable<const long>::returnSize();
-}
-
-template <> inline bool SynchronisableVariable<const long>::checkEquality( uint8_t* mem )
-{
-  return *(int32_t*)(mem) == this->variable_;
-}
-
-// =========== unsigned long
-
-template <> inline uint32_t SynchronisableVariable<const unsigned long>::returnSize()
-{
-  return sizeof(uint32_t);
-}
-
-template <> inline void SynchronisableVariable<const unsigned long>::setAndIncrease( uint8_t*& mem )
-{
-  *(unsigned long*)(&this->variable_) = *(uint32_t*)(mem);
-  mem += SynchronisableVariable<const unsigned long>::returnSize();
-}
-
-template <> inline void SynchronisableVariable<const unsigned long>::getAndIncrease( uint8_t*& mem )
-{
-  *(uint32_t*)(mem) = this->variable_;
-  mem += SynchronisableVariable<const unsigned long>::returnSize();
-}
-
-template <> inline bool SynchronisableVariable<const unsigned long>::checkEquality( uint8_t* mem )
-{
-  return *(uint32_t*)(mem) == this->variable_;
-}
-
-// =========== long long
-
-template <> inline uint32_t SynchronisableVariable<const long long>::returnSize()
-{
-  return sizeof(int64_t);
-}
-
-template <> inline void SynchronisableVariable<const long long>::setAndIncrease( uint8_t*& mem )
-{
-  *(long long*)(&this->variable_) = *(int64_t*)(mem);
-  mem += SynchronisableVariable<const long long>::returnSize();
-}
-
-template <> inline void SynchronisableVariable<const long long>::getAndIncrease( uint8_t*& mem )
-{
-  *(int64_t*)(mem) = this->variable_;
-  mem += SynchronisableVariable<const long long>::returnSize();
-}
-
-template <> inline bool SynchronisableVariable<const long long>::checkEquality( uint8_t* mem )
-{
-  return *(int64_t*)(mem) == this->variable_;
-}
-
-// =========== unsigned long long
-
-template <> inline uint32_t SynchronisableVariable<const unsigned long long>::returnSize()
-{
-  return sizeof(uint64_t);
-}
-
-template <> inline void SynchronisableVariable<const unsigned long long>::setAndIncrease( uint8_t*& mem )
-{
-  *(unsigned long long*)(&this->variable_) = *(uint64_t*)(mem);
-  mem += SynchronisableVariable<const unsigned long long>::returnSize();
-}
-
-template <> inline void SynchronisableVariable<const unsigned long long>::getAndIncrease( uint8_t*& mem )
-{
-  *(uint64_t*)(mem) = this->variable_;
-  mem += SynchronisableVariable<const unsigned long long>::returnSize();
-}
-
-template <> inline bool SynchronisableVariable<const unsigned long long>::checkEquality( uint8_t* mem )
-{
-  return *(uint64_t*)(mem) == this->variable_;
-}
-
-// =========== float
-
-template <> inline uint32_t SynchronisableVariable<const float>::returnSize()
-{
-  return sizeof(uint32_t);
-}
-
-template <> inline void SynchronisableVariable<const float>::setAndIncrease( uint8_t*& mem )
-{
-  *(uint32_t*)(&this->variable_) = *(uint32_t*)(mem);
-  mem += SynchronisableVariable<const float>::returnSize();
-}
-
-template <> inline void SynchronisableVariable<const float>::getAndIncrease( uint8_t*& mem )
-{
-  *(uint32_t*)(mem) = *(uint32_t*)(&this->variable_);
-  mem += SynchronisableVariable<const float>::returnSize();
-}
-
-template <> inline bool SynchronisableVariable<const float>::checkEquality( uint8_t* mem )
-{
-  return *(uint32_t*)(mem) == *(uint32_t*)(&this->variable_);
-}
-
-// =========== double
-
-template <> inline uint32_t SynchronisableVariable<const double>::returnSize()
-{
-  return sizeof(uint64_t);
-}
-
-template <> inline void SynchronisableVariable<const double>::setAndIncrease( uint8_t*& mem )
-{
-  *(uint64_t*)(&this->variable_) = *(uint64_t*)(mem);
-  mem += SynchronisableVariable<const double>::returnSize();
-}
-
-template <> inline void SynchronisableVariable<const double>::getAndIncrease( uint8_t*& mem )
-{
-  *(uint64_t*)(mem) = *(uint64_t*)(&this->variable_);
-  mem += SynchronisableVariable<const double>::returnSize();
-}
-
-template <> inline bool SynchronisableVariable<const double>::checkEquality( uint8_t* mem )
-{
-  return *(uint64_t*)(mem) == *(uint64_t*)(&this->variable_);
-}
-
-// =========== long double
-
-template <> inline uint32_t SynchronisableVariable<const long double>::returnSize()
-{
-  return sizeof(uint64_t);
-}
-
-template <> inline void SynchronisableVariable<const long double>::setAndIncrease( uint8_t*& mem )
-{
-  double temp;
-  memcpy(&temp, mem, sizeof(uint64_t));
-  *(long double*)(&this->variable_) = static_cast<const long double>(temp);
-  mem += SynchronisableVariable<const long double>::returnSize();
-}
-
-template <> inline void SynchronisableVariable<const long double>::getAndIncrease( uint8_t*& mem )
-{
-  double temp = static_cast<double>(this->variable_);
-  memcpy(mem, &temp, sizeof(uint64_t));
-  mem += SynchronisableVariable<const long double>::returnSize();
-}
-
-template <> inline bool SynchronisableVariable<const long double>::checkEquality( uint8_t* mem )
-{
-  double temp = static_cast<double>(this->variable_);
-  return memcmp(&temp, mem, sizeof(uint64_t))==0;
-}
-
-// =========== string
-
-template <> inline uint32_t SynchronisableVariable<const std::string>::returnSize()
-{
-  return variable_.length()+1;
-}
-
-template <> inline void SynchronisableVariable<const std::string>::getAndIncrease( uint8_t*& mem )
-{
-  memcpy(mem, this->variable_.c_str(), this->variable_.length()+1);
-  mem += this->variable_.length()+1;
-}
-
-template <> inline void SynchronisableVariable<const std::string>::setAndIncrease( uint8_t*& mem )
-{
-  *(std::string*)(&this->variable_) = std::string((const char *)mem);
-  mem += this->variable_.length()+1;
-}
-
-template <> inline bool SynchronisableVariable<const std::string>::checkEquality( uint8_t* mem )
-{
-  return std::string((const char*)mem)==this->variable_;
-}
-
-// =========== Degree
-
-template <> inline uint32_t SynchronisableVariable<const Degree>::returnSize()
-{
-  return sizeof(Ogre::Real);
-}
-
-template <> inline void SynchronisableVariable<const Degree>::getAndIncrease( uint8_t*& mem )
-{
-  Ogre::Real r = this->variable_.valueDegrees();
-  memcpy(mem, &r, returnSize());
-  mem += returnSize();
-}
-
-template <> inline void SynchronisableVariable<const Degree>::setAndIncrease( uint8_t*& mem )
-{
-  Ogre::Real* r = (Ogre::Real*)mem;
-  (Degree&)this->variable_ = *r;
-  mem += returnSize();
-}
-
-template <> inline bool SynchronisableVariable<const Degree>::checkEquality( uint8_t* mem )
-{
-  Ogre::Real* r = (Ogre::Real*)mem;
-  return this->variable_==Degree(*r);
-}
-
-}
-
-
-#endif

Modified: branches/netp2/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- branches/netp2/src/orxonox/OrxonoxPrereqs.h	2009-04-27 15:15:04 UTC (rev 2936)
+++ branches/netp2/src/orxonox/OrxonoxPrereqs.h	2009-04-29 14:05:35 UTC (rev 2937)
@@ -158,6 +158,7 @@
     class CameraPosition;
     class SpawnPoint;
     class TeamSpawnPoint;
+    class Test;
 
     class Spectator;
     class Pawn;

Modified: branches/netp2/src/orxonox/objects/Test.cc
===================================================================
--- branches/netp2/src/orxonox/objects/Test.cc	2009-04-27 15:15:04 UTC (rev 2936)
+++ branches/netp2/src/orxonox/objects/Test.cc	2009-04-29 14:05:35 UTC (rev 2937)
@@ -30,6 +30,7 @@
 #include "core/CoreIncludes.h"
 #include "core/ConfigValueIncludes.h"
 #include "core/ConsoleCommand.h"
+#include "network/NetworkFunction.h"
 #include "Test.h"
 
 namespace orxonox
@@ -40,7 +41,15 @@
   SetConsoleCommand(Test, printV2, true).accessLevel(AccessLevel::User);
   SetConsoleCommand(Test, printV3, true).accessLevel(AccessLevel::User);
   SetConsoleCommand(Test, printV4, true).accessLevel(AccessLevel::User);
+  SetConsoleCommand(Test, call, true).accessLevel(AccessLevel::User);
   
+  
+  //void=* aaaaa = copyPtr<sizeof(&Test::printV1)>( &NETWORK_FUNCTION_POINTER, &Test::printV1 );
+  //void* NETWORK_FUNCTION_TEST_B = memcpy(&NETWORK_FUNCTION_POINTER, &a, sizeof(a));
+//   NetworkFunctionBase* NETWORK_FUNCTION_TEST_C = new NetworkFunctionStatic( createFunctor(&Test::printV1), "bla", NETWORK_FUNCTION_POINTER );
+  
+  registerStaticNetworkFunction( &Test::printV1, "printV1" );
+  
   Test* Test::instance_ = 0;
 
 	Test::Test(BaseObject* creator) : BaseObject(creator), Synchronisable(creator)
@@ -84,7 +93,12 @@
     registerVariable ( s3, variableDirection::serverMaster, new NetworkCallback<Test> ( this, &Test::checkS3 ), true );
     registerVariable ( s4, variableDirection::clientMaster, new NetworkCallback<Test> ( this, &Test::checkS4 ), true );
 	}
-
+  
+  void Test::call(unsigned int clientID)
+  {
+    callStaticNetworkFunction( &Test::printV1, clientID );
+  }
+  
   void Test::checkU1(){ COUT(1) << "U1 changed: " << u1 << std::endl; }
   void Test::checkU2(){ COUT(1) << "U2 changed: " << u2 << std::endl; }
   void Test::checkU3(){ COUT(1) << "U3 changed: " << u3 << std::endl; }

Modified: branches/netp2/src/orxonox/objects/Test.h
===================================================================
--- branches/netp2/src/orxonox/objects/Test.h	2009-04-27 15:15:04 UTC (rev 2936)
+++ branches/netp2/src/orxonox/objects/Test.h	2009-04-29 14:05:35 UTC (rev 2937)
@@ -48,6 +48,8 @@
 
       void setConfigValues();
       void registerVariables();
+      
+      void call(unsigned int clientID);
 
 
       //unsigned functions

Modified: branches/netp2/src/util/MultiType.h
===================================================================
--- branches/netp2/src/util/MultiType.h	2009-04-27 15:15:04 UTC (rev 2936)
+++ branches/netp2/src/util/MultiType.h	2009-04-29 14:05:35 UTC (rev 2937)
@@ -329,9 +329,10 @@
             /** @brief Loads the value of the MT from a bytestream (pointed at by mem) and increases mem pointer by size of MT */
             inline void                       exportData(uint8_t*& mem) { assert(sizeof(MT_Type)<=8); this->setType(*(uint8_t*)mem); mem+=sizeof(uint8_t); this->value_->exportData(mem); }
             /** @brief Saves the value of the MT to a bytestream and increases pointer to bytestream by size of MT */
-            inline uint8_t*& operator << (uint8_t*& mem) { importData(mem); return mem; }
+            inline uint8_t*&                  operator << (uint8_t*& mem) { importData(mem); return mem; }
             /** @brief Loads the value of the MT to a bytestream and increases pointer to bytestream by size of MT */
-            inline void operator >> (uint8_t*& mem) { exportData(mem); }
+            inline void                       operator >> (uint8_t*& mem) { exportData(mem); }
+            inline uint32_t                   getNetworkSize() { assert(this->value_); return this->value_->getSize() + sizeof(uint8_t); }
 
             /** @brief Checks whether the value is a default one. */
             bool                              hasDefaultValue()         const { return this->value_->hasDefaultValue(); }




More information about the Orxonox-commit mailing list