Index: code/trunk/src/libraries/network/NetworkFunction.h
===================================================================
--- code/trunk/src/libraries/network/NetworkFunction.h	(revision 9667)
+++ code/trunk/src/libraries/network/NetworkFunction.h	(revision 10624)
@@ -36,9 +36,5 @@
 #include <map>
 #include <string>
-#include <boost/preprocessor/cat.hpp>
-#include <boost/static_assert.hpp>
-
-#include "core/object/Listable.h"
-#include "core/class/Identifier.h"
+
 #include "core/command/Functor.h"
 #include "FunctionCallManager.h"
@@ -60,8 +56,22 @@
   {
 #if defined(ORXONOX_COMPILER_GCC) && defined(ORXONOX_ARCH_32)
-    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
+    if (pointer[0] != b.pointer[0])
+        return pointer[0] < b.pointer[0];
+    else if (pointer[1] != b.pointer[1])
+        return pointer[1] < b.pointer[1];
+    else
+        return false;
+#else
+    if (pointer[0] != b.pointer[0])
+        return pointer[0] < b.pointer[0];
+    else if (pointer[1] != b.pointer[1])
+        return pointer[1] < b.pointer[1];
+    else if (pointer[2] != b.pointer[2])
+        return pointer[2] < b.pointer[2];
+    else if (pointer[3] != b.pointer[3])
+        return pointer[3] < b.pointer[3];
+    else
+        return false;
+#endif
   }
 };
@@ -71,73 +81,14 @@
 
 
-class _NetworkExport NetworkFunctionBase: virtual public Listable {
-  public:
-    NetworkFunctionBase(const std::string& name);
-    ~NetworkFunctionBase();
-
-    virtual void        setNetworkID(uint32_t id)       { this->networkID_ = id; }
-    inline uint32_t     getNetworkID() const            { return this->networkID_; }
-    inline const std::string& getName() const           { return name_; }
-    static inline bool  isStatic( uint32_t networkID )  { return isStaticMap_[networkID]; }
-
-    static inline void setNetworkID(const std::string& name, uint32_t id)
-    {
-        std::map<std::string, NetworkFunctionBase*>& map = NetworkFunctionBase::getNameMap();
-        assert( map.find(name)!=map.end() );
-        map[name]->setNetworkID(id);
-    }
-
-    static void destroyAllNetworkFunctions();
-
-  protected:
-    static std::map<uint32_t, bool> isStaticMap_;
-
-  private:
-    static std::map<std::string, NetworkFunctionBase*>& getNameMap();
-    uint32_t networkID_;
-    std::string name_;
-
-};
-
-
-class _NetworkExport NetworkFunctionStatic: public NetworkFunctionBase {
-  public:
-    NetworkFunctionStatic(const FunctorStaticPtr& functor, const std::string& name, const NetworkFunctionPointer& p);
-
-    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); }
-
-    virtual void setNetworkID( uint32_t id )
-        { NetworkFunctionBase::setNetworkID( id ); NetworkFunctionStatic::getIdMap()[id] = this; }
-    static inline NetworkFunctionStatic* getNetworkFunction( uint32_t id)
-        { assert( NetworkFunctionStatic::getIdMap().find(id)!=NetworkFunctionStatic::getIdMap().end() ); return NetworkFunctionStatic::getIdMap()[id]; }
-    static NetworkFunctionStatic* getFunction( uint32_t id )
-        { assert( NetworkFunctionStatic::getIdMap().find(id) != NetworkFunctionStatic::getIdMap().end() ); return NetworkFunctionStatic::getIdMap()[id]; }
-    static NetworkFunctionStatic* getFunction( const NetworkFunctionPointer& p )
-        { assert( NetworkFunctionStatic::getFunctorMap().find(p) != NetworkFunctionStatic::getFunctorMap().end() ); return NetworkFunctionStatic::getFunctorMap()[p]; }
-
-  private:
-    static std::map<NetworkFunctionPointer, NetworkFunctionStatic*>& getFunctorMap();
-    static std::map<uint32_t, NetworkFunctionStatic*>& getIdMap();
-    FunctorStaticPtr functor_;
-
-};
-
-
-class _NetworkExport NetworkMemberFunctionBase: public NetworkFunctionBase {
-  public:
-    NetworkMemberFunctionBase(const std::string& name, const NetworkFunctionPointer& p);
-    ~NetworkMemberFunctionBase();
-
-    virtual void setNetworkID( uint32_t id ){ NetworkFunctionBase::setNetworkID( id ); idMap_[id] = this; }
-    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]; }
-
-    //
+class _NetworkExport NetworkFunctionBase {
+  public:
+    NetworkFunctionBase(const std::string& name, const NetworkFunctionPointer& pointer);
+    virtual ~NetworkFunctionBase() {}
+
+    void setNetworkID(uint32_t id);
+    inline uint32_t     getNetworkID() const                { return this->networkID_; }
+    inline const std::string& getName() const               { return this->name_; }
+    inline const NetworkFunctionPointer& getPointer() const { return this->pointer_; }
+
     virtual bool call(uint32_t objectID)=0;
     virtual bool call(uint32_t objectID, const MultiType& mt1)=0;
@@ -148,6 +99,37 @@
 
   private:
-    static std::map<NetworkFunctionPointer, NetworkMemberFunctionBase*> functorMap_;
-    static std::map<uint32_t, NetworkMemberFunctionBase*> idMap_;
+    uint32_t networkID_;
+    std::string name_;
+    NetworkFunctionPointer pointer_;
+
+};
+
+
+class _NetworkExport NetworkFunctionStatic: public NetworkFunctionBase {
+  public:
+    NetworkFunctionStatic(const FunctorStaticPtr& functor, const std::string& name, const NetworkFunctionPointer& p)
+        : NetworkFunctionBase(name, p)
+        , functor_(functor)
+    { }
+
+    // ignore the objectID because its a static function
+    virtual bool call(uint32_t objectID){ (*this->functor_)(); return true; }
+    virtual bool call(uint32_t objectID, const MultiType& mt1){ (*this->functor_)(mt1); return true; }
+    virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2){ (*this->functor_)(mt1, mt2); return true; }
+    virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3){ (*this->functor_)(mt1, mt2, mt3); return true; }
+    virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4){ (*this->functor_)(mt1, mt2, mt3, mt4); return true; }
+    virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5){ (*this->functor_)(mt1, mt2, mt3, mt4, mt5); return true; }
+
+  private:
+    FunctorStaticPtr functor_;
+
+};
+
+
+class _NetworkExport NetworkMemberFunctionBase: public NetworkFunctionBase {
+  public:
+    NetworkMemberFunctionBase(const std::string& name, const NetworkFunctionPointer& p)
+        : NetworkFunctionBase(name, p)
+    { }
 };
 
@@ -155,5 +137,8 @@
 template <class T> class NetworkMemberFunction: public NetworkMemberFunctionBase {
   public:
-    NetworkMemberFunction(const FunctorMemberPtr<T>& functor, const std::string& name, const NetworkFunctionPointer& p);
+    NetworkMemberFunction(const FunctorMemberPtr<T>& functor, const std::string& name, const NetworkFunctionPointer& p)
+        : NetworkMemberFunctionBase(name, p)
+        , functor_(functor)
+    { }
 
     inline bool call(uint32_t objectID)
@@ -222,58 +207,5 @@
 };
 
-template <class T> NetworkMemberFunction<T>::NetworkMemberFunction(const FunctorMemberPtr<T>& functor, const std::string& name, const NetworkFunctionPointer& p):
-    NetworkMemberFunctionBase(name, p), functor_(functor)
-{
 }
 
-template<class T> inline void copyPtr( T ptr, NetworkFunctionPointer& destptr)
-{
-  if( sizeof(NetworkFunctionPointer)-sizeof(T) > 0)
-    memset((uint8_t*)&destptr + sizeof(T), 0, sizeof(NetworkFunctionPointer)-sizeof(T));
-  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, const std::string& name )
-{
-  BOOST_STATIC_ASSERT( sizeof(T)<=sizeof(NetworkFunctionPointer) ); // if this fails your compiler uses bigger pointers for static functions than defined above
-  NetworkFunctionPointer destptr;
-  copyPtr( ptr, destptr );
-  new NetworkFunctionStatic( createFunctor(ptr), name, destptr );
-  return 0;
-}
-
-template<class T, class PT> inline void* registerMemberNetworkFunctionFct( PT ptr, const std::string& name )
-{
-  BOOST_STATIC_ASSERT( sizeof(PT)<=sizeof(NetworkFunctionPointer) ); // if this fails your compiler uses bigger pointers for a specific kind of member functions than defined above
-  NetworkFunctionPointer destptr;
-  copyPtr( ptr, destptr );
-  new NetworkMemberFunction<T>( createFunctor(ptr), name, destptr );
-  return 0;
-}
-
-#define registerStaticNetworkFunction( functionPointer ) \
-  static void* BOOST_PP_CAT( NETWORK_FUNCTION_, __UNIQUE_NUMBER__ ) = registerStaticNetworkFunctionFct( functionPointer, #functionPointer );
-#define registerMemberNetworkFunction( class, function ) \
-  static void* BOOST_PP_CAT( NETWORK_FUNCTION_##class, __UNIQUE_NUMBER__ ) = registerMemberNetworkFunctionFct<class>( &class::function, #class "_" #function);
-  // call it with functionPointer, clientID, args
-#define callStaticNetworkFunction( functionPointer, ...) \
-  { \
-    NetworkFunctionPointer p1; \
-    copyPtr( functionPointer, p1 ); \
-    FunctionCallManager::addCallStatic(NetworkFunctionStatic::getFunction(p1)->getNetworkID(), __VA_ARGS__); \
-  }
-  // call it with class, function, objectID, clientID, args
-#define callMemberNetworkFunction( class, function, objectID, ...) \
-  { \
-    NetworkFunctionPointer p1; \
-    copyPtr( &class::function, p1 ); \
-    FunctionCallManager::addCallMember(NetworkMemberFunctionBase::getFunction(p1)->getNetworkID(), objectID, __VA_ARGS__); \
-  }
-
-
-}
-
 #endif /* _NetworkFunction_H__ */
