[Orxonox-commit 536] r3084 - in trunk: . src src/core src/core/input src/network src/network/packet src/network/synchronisable src/orxonox src/orxonox/gamestates src/orxonox/objects src/orxonox/objects/controllers src/orxonox/objects/worldentities src/orxonox/objects/worldentities/pawns src/util

landauf at orxonox.net landauf at orxonox.net
Tue May 26 21:20:58 CEST 2009


Author: landauf
Date: 2009-05-26 21:20:57 +0200 (Tue, 26 May 2009)
New Revision: 3084

Added:
   trunk/src/network/FunctionCallManager.cc
   trunk/src/network/FunctionCallManager.h
   trunk/src/network/NetworkFunction.cc
   trunk/src/network/NetworkFunction.h
   trunk/src/network/packet/FunctionCalls.cc
   trunk/src/network/packet/FunctionCalls.h
   trunk/src/network/packet/FunctionIDs.cc
   trunk/src/network/packet/FunctionIDs.h
   trunk/src/network/synchronisable/SynchronisableVariable.cc
   trunk/src/util/Serialise.h
Removed:
   trunk/src/network/synchronisable/SynchronisableVariable.cc
Modified:
   trunk/
   trunk/src/CMakeLists.txt
   trunk/src/core/Game.cc
   trunk/src/core/Game.h
   trunk/src/core/GameState.cc
   trunk/src/core/GameState.h
   trunk/src/core/input/InputManager.cc
   trunk/src/core/input/InputManager.h
   trunk/src/network/CMakeLists.txt
   trunk/src/network/Client.cc
   trunk/src/network/Client.h
   trunk/src/network/ClientConnection.cc
   trunk/src/network/ClientConnection.h
   trunk/src/network/ConnectionManager.cc
   trunk/src/network/ConnectionManager.h
   trunk/src/network/GamestateManager.cc
   trunk/src/network/GamestateManager.h
   trunk/src/network/Host.h
   trunk/src/network/NetworkPrereqs.h
   trunk/src/network/Server.cc
   trunk/src/network/Server.h
   trunk/src/network/TrafficControl.cc
   trunk/src/network/TrafficControl.h
   trunk/src/network/packet/CMakeLists.txt
   trunk/src/network/packet/ClassID.cc
   trunk/src/network/packet/Gamestate.cc
   trunk/src/network/packet/Gamestate.h
   trunk/src/network/packet/Packet.cc
   trunk/src/network/packet/Packet.h
   trunk/src/network/synchronisable/NetworkCallbackManager.cc
   trunk/src/network/synchronisable/Synchronisable.cc
   trunk/src/network/synchronisable/Synchronisable.h
   trunk/src/network/synchronisable/SynchronisableSpecialisations.cc
   trunk/src/network/synchronisable/SynchronisableVariable.h
   trunk/src/orxonox/OrxonoxPrereqs.h
   trunk/src/orxonox/gamestates/GSGraphics.cc
   trunk/src/orxonox/gamestates/GSGraphics.h
   trunk/src/orxonox/gamestates/GSRoot.cc
   trunk/src/orxonox/gamestates/GSRoot.h
   trunk/src/orxonox/objects/CMakeLists.txt
   trunk/src/orxonox/objects/Test.cc
   trunk/src/orxonox/objects/Test.h
   trunk/src/orxonox/objects/controllers/AIController.cc
   trunk/src/orxonox/objects/worldentities/ControllableEntity.cc
   trunk/src/orxonox/objects/worldentities/MobileEntity.h
   trunk/src/orxonox/objects/worldentities/PongBall.cc
   trunk/src/orxonox/objects/worldentities/PongBall.h
   trunk/src/orxonox/objects/worldentities/PongBat.cc
   trunk/src/orxonox/objects/worldentities/pawns/Pawn.cc
   trunk/src/orxonox/objects/worldentities/pawns/Pawn.h
   trunk/src/util/MultiType.h
   trunk/src/util/MultiTypeValue.h
Log:
merged netp3 branch back to trunk



Property changes on: trunk
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/buildsystem:1875-2277,2279-2401
/branches/buildsystem2:2507-2659
/branches/buildsystem3:2663-2709
/branches/ceguilua:1803-1809
/branches/core3:1573-1740
/branches/gametypes:2827-3032
/branches/gcc43:1581
/branches/gui:1636-1724,2796-2895
/branches/input:1630-1637
/branches/lodfinal:2373-2412
/branches/miniprojects:2755-2825
/branches/network:2357
/branches/network64:2211-2356
/branches/objecthierarchy:1912-2086,2101,2111-2170
/branches/objecthierarchy2:2172-2480
/branches/overlay:2118-2386
/branches/physics:1913-2056,2108-2440
/branches/physics_merge:2437-2458
/branches/pickups:1927-2087,2128,2828-2916
/branches/pickups2:2108-2498,2916-3072
/branches/presentation:2370-2653,2655-2661
/branches/questsystem:1895-2089
/branches/questsystem2:2108-2260
/branches/questsystem5:2777-2906
/branches/script_trigger:1296-1954,1956
/branches/sound:2830-3011
/branches/weapon:1926-2095
/branches/weapon2:2108-2489
/branches/weapons:2898-3052
/branches/weaponsystem:2743-2891
   + /branches/buildsystem:1875-2277,2279-2401
/branches/buildsystem2:2507-2659
/branches/buildsystem3:2663-2709
/branches/ceguilua:1803-1809
/branches/core3:1573-1740
/branches/gametypes:2827-3032
/branches/gcc43:1581
/branches/gui:1636-1724,2796-2895
/branches/input:1630-1637
/branches/lodfinal:2373-2412
/branches/miniprojects:2755-2825
/branches/netp2:2836-2989
/branches/netp3:2989-3083
/branches/network:2357
/branches/network64:2211-2356
/branches/objecthierarchy:1912-2086,2101,2111-2170
/branches/objecthierarchy2:2172-2480
/branches/overlay:2118-2386
/branches/physics:1913-2056,2108-2440
/branches/physics_merge:2437-2458
/branches/pickups:1927-2087,2128,2828-2916
/branches/pickups2:2108-2498,2916-3072
/branches/presentation:2370-2653,2655-2661
/branches/questsystem:1895-2089
/branches/questsystem2:2108-2260
/branches/questsystem5:2777-2906
/branches/script_trigger:1296-1954,1956
/branches/sound:2830-3011
/branches/weapon:1926-2095
/branches/weapon2:2108-2489
/branches/weapons:2898-3052
/branches/weaponsystem:2743-2891

Modified: trunk/src/CMakeLists.txt
===================================================================
--- trunk/src/CMakeLists.txt	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/CMakeLists.txt	2009-05-26 19:20:57 UTC (rev 3084)
@@ -105,6 +105,8 @@
   ${CMAKE_CURRENT_SOURCE_DIR}
   # Bullet headers really need the include directory
   ${CMAKE_CURRENT_SOURCE_DIR}/bullet
+  # OIS headers need the root dir as well
+  ${CMAKE_CURRENT_SOURCE_DIR}/ois
   # Convenience directory
   ${CMAKE_CURRENT_SOURCE_DIR}/orxonox
   # OrxonoxConfig.h

Modified: trunk/src/core/Game.cc
===================================================================
--- trunk/src/core/Game.cc	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/core/Game.cc	2009-05-26 19:20:57 UTC (rev 3084)
@@ -184,8 +184,18 @@
             this->core_->update(*this->gameClock_);
             for (std::vector<GameState*>::const_iterator it = this->activeStates_.begin();
                 it != this->activeStates_.end(); ++it)
+            {
+                // Add tick time for most of the states
+                uint64_t timeBeforeTick;
+                if ((*it)->getCountTickTime())
+                    timeBeforeTick = this->gameClock_->getRealMicroseconds();
+                
                 (*it)->update(*this->gameClock_);
 
+                if ((*it)->getCountTickTime())
+                    this->addTickTime(this->gameClock_->getRealMicroseconds() - timeBeforeTick);
+            }
+
             // STATISTICS
             if (this->periodTime_ > statisticsRefreshCycle_)
             {

Modified: trunk/src/core/Game.h
===================================================================
--- trunk/src/core/Game.h	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/core/Game.h	2009-05-26 19:20:57 UTC (rev 3084)
@@ -42,8 +42,13 @@
 #include <vector>
 #include "OrxonoxClass.h"
 
-#define AddGameState(classname, name) \
-    static bool MACRO_CONCATENATE(bGameStateDummy_##classname, __LINE__) = orxonox::Game::addGameState(new classname(name))
+/**
+ at def
+    Adds a new GameState to the Game. The second parameter is the name as string
+    and every following paramter is a constructor argument (which is usually non existent)
+*/
+#define AddGameState(classname, ...) \
+    static bool MACRO_CONCATENATE(bGameStateDummy_##classname, __LINE__) = orxonox::Game::addGameState(new classname(__VA_ARGS__))
 
 // tolua_begin
 namespace orxonox

Modified: trunk/src/core/GameState.cc
===================================================================
--- trunk/src/core/GameState.cc	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/core/GameState.cc	2009-05-26 19:20:57 UTC (rev 3084)
@@ -44,8 +44,9 @@
     @brief
         Constructor only initialises variables and sets the name permanently.
     */
-    GameState::GameState(const std::string& name)
+    GameState::GameState(const std::string& name, bool countTickTime)
         : name_(name)
+        , bCountTickTime_(countTickTime)
         , parent_(0)
     {
         this->activity_.activating   = false;

Modified: trunk/src/core/GameState.h
===================================================================
--- trunk/src/core/GameState.h	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/core/GameState.h	2009-05-26 19:20:57 UTC (rev 3084)
@@ -77,13 +77,15 @@
         };
 
     public:
-        GameState(const std::string& name);
+        GameState(const std::string& name, bool countTicktime = true);
         virtual ~GameState();
 
         const std::string& getName() const { return name_; }
-        State getActivity() const    { return this->activity_; }
-        GameState* getParent() const       { return this->parent_; }
+        State getActivity()          const { return this->activity_; }
+        GameState* getParent()       const { return this->parent_; }
 
+        bool getCountTickTime()      const { return this->bCountTickTime_; }
+
         void addChild(GameState* state);
         void removeChild(GameState* state);
 
@@ -101,6 +103,7 @@
 
         const std::string                        name_;
         State                                    activity_;
+        const bool                               bCountTickTime_;
         GameState*                               parent_;
         std::map<std::string, GameState*>        children_;
     };

Modified: trunk/src/core/input/InputManager.cc
===================================================================
--- trunk/src/core/input/InputManager.cc	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/core/input/InputManager.cc	2009-05-26 19:20:57 UTC (rev 3084)
@@ -40,13 +40,18 @@
 
 #include "ois/OISException.h"
 #include "ois/OISInputManager.h"
+#include "core/ConsoleCommand.h"
 
+// HACK
+#ifdef ORXONOX_PLATFORM_LINUX
+#  include "ois/linux/LinuxMouse.h"
+#endif
+
 #include "util/Exception.h"
 #include "core/Clock.h"
 #include "core/CoreIncludes.h"
 #include "core/ConfigValueIncludes.h"
 #include "core/CommandExecutor.h"
-#include "core/ConsoleCommand.h"
 #include "core/CommandLine.h"
 #include "util/Debug.h"
 
@@ -63,6 +68,10 @@
 {
     SetConsoleCommand(InputManager, calibrate, true);
     SetConsoleCommand(InputManager, reload, false);
+#ifdef ORXONOX_PLATFORM_LINUX
+    SetConsoleCommand(InputManager, grabMouse, true);
+    SetConsoleCommand(InputManager, ungrabMouse, true);
+#endif
     SetCommandLineSwitch(keyboard_no_grab);
 
     EmptyHandler InputManager::EMPTY_HANDLER;
@@ -1468,4 +1477,26 @@
     {
         getInstance().reloadInputSystem(joyStickSupport);
     }
+
+
+    // ############################################################
+    // #####                   ugly hacks                     #####
+    // ##########                                        ##########
+    // ############################################################
+
+#ifdef ORXONOX_PLATFORM_LINUX
+    void InputManager::grabMouse()
+    {
+        OIS::LinuxMouse* linuxMouse = dynamic_cast<OIS::LinuxMouse*>(singletonRef_s->mouse_);
+        assert(linuxMouse);
+        linuxMouse->grab(true);
+    }
+
+    void InputManager::ungrabMouse()
+    {
+        OIS::LinuxMouse* linuxMouse = dynamic_cast<OIS::LinuxMouse*>(singletonRef_s->mouse_);
+        assert(linuxMouse);
+        linuxMouse->grab(false);
+    }
+#endif
 }

Modified: trunk/src/core/input/InputManager.h
===================================================================
--- trunk/src/core/input/InputManager.h	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/core/input/InputManager.h	2009-05-26 19:20:57 UTC (rev 3084)
@@ -137,6 +137,12 @@
         bool requestEnterState     (const std::string& name);
         bool requestLeaveState     (const std::string& name);
 
+#ifdef ORXONOX_PLATFORM_LINUX
+        // HACK!
+        static void grabMouse();
+        static void ungrabMouse();
+#endif
+
         void update(const Clock& time);
 
         static InputManager& getInstance()    { assert(singletonRef_s); return *singletonRef_s; }

Modified: trunk/src/network/CMakeLists.txt
===================================================================
--- trunk/src/network/CMakeLists.txt	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/network/CMakeLists.txt	2009-05-26 19:20:57 UTC (rev 3084)
@@ -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)

Modified: trunk/src/network/Client.cc
===================================================================
--- trunk/src/network/Client.cc	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/network/Client.cc	2009-05-26 19:20:57 UTC (rev 3084)
@@ -20,7 +20,7 @@
  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *
  *   Author:
- *      Oliver Scheuss, (C) 2007
+ *      Oliver Scheuss
  *   Co-authors:
  *      ...
  *
@@ -47,6 +47,7 @@
 #include "core/Clock.h"
 #include "core/CoreIncludes.h"
 #include "packet/Packet.h"
+#include "FunctionCallManager.h"
 
 // #include "packet/Acknowledgement.h"
 
@@ -139,17 +140,25 @@
    * @param time
    */
   void Client::update(const Clock& time){
-//     COUT(3) << ".";
-    if(client_connection.isConnected() && isSynched_){
-      COUT(4) << "popping partial gamestate: " << std::endl;
-      packet::Gamestate *gs = gamestate.getGamestate();
-      if(gs){
-        COUT(4) << "client tick: sending gs " << gs << std::endl;
-        if( !gs->send() )
-          COUT(3) << "Problem adding partial gamestate to queue" << std::endl;
+    //this steers our network frequency
+    timeSinceLastUpdate_+=time.getDeltaTime();
+    if(timeSinceLastUpdate_>=NETWORK_PERIOD){
+      timeSinceLastUpdate_ -= static_cast<unsigned int>( timeSinceLastUpdate_ / NETWORK_PERIOD ) * NETWORK_PERIOD;
+      //     COUT(3) << ".";
+      if(client_connection.isConnected() && isSynched_){
+        COUT(4) << "popping partial gamestate: " << std::endl;
+        packet::Gamestate *gs = gamestate.getGamestate();
+        //assert(gs); <--- there might be the case that no data has to be sent, so its commented out now
+        if(gs){
+          COUT(4) << "client tick: sending gs " << gs << std::endl;
+          if( !gs->send() )
+            COUT(3) << "Problem adding partial gamestate to queue" << std::endl;
         // gs gets automatically deleted by enet callback
+        }
+        FunctionCallManager::sendCalls();
       }
     }
+    
     ENetEvent *event;
     // stop if the packet queue is empty
     while(!(client_connection.queueEmpty())){
@@ -166,6 +175,7 @@
         isSynched_=true;
     }
     gamestate.cleanup();
+
     return;
   }
 

Modified: trunk/src/network/Client.h
===================================================================
--- trunk/src/network/Client.h	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/network/Client.h	2009-05-26 19:20:57 UTC (rev 3084)
@@ -20,7 +20,7 @@
  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *
  *   Author:
- *      Oliver Scheuss, (C) 2007
+ *      Oliver Scheuss
  *   Co-authors:
  *      ...
  *
@@ -87,6 +87,7 @@
     bool isSynched_;
 
     bool gameStateFailure_;
+    float timeSinceLastUpdate_;
   };
 
 

Modified: trunk/src/network/ClientConnection.cc
===================================================================
--- trunk/src/network/ClientConnection.cc	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/network/ClientConnection.cc	2009-05-26 19:20:57 UTC (rev 3084)
@@ -20,7 +20,7 @@
  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *
  *   Author:
- *      Oliver Scheuss, (C) 2007
+ *      Oliver Scheuss
  *   Co-authors:
  *      ...
  *
@@ -41,6 +41,7 @@
 
 #include <enet/enet.h>
 #include <iostream>
+#include <cassert>
 // boost.thread library for multithreading support
 #include <boost/thread/thread.hpp>
 #include <boost/bind.hpp>
@@ -56,7 +57,7 @@
   static boost::recursive_mutex enet_mutex_g;
 
   ClientConnection::ClientConnection(int port, const std::string& address) {
-    quit=false;
+    quit_=false;
     server=NULL;
     serverAddress = new ENetAddress();
     enet_address_set_host(serverAddress, address.c_str());
@@ -65,7 +66,7 @@
   }
 
   ClientConnection::ClientConnection(int port, const char *address) {
-    quit=false;
+    quit_=false;
     server=NULL;
     serverAddress = new ENetAddress();
     enet_address_set_host(serverAddress, address);
@@ -105,7 +106,7 @@
   }
 
   bool ClientConnection::closeConnection() {
-    quit=true;
+    quit_=true;
     //network_threads.join_all();
     receiverThread_->join();
     established=false;
@@ -149,24 +150,26 @@
     if(client==NULL) {
       COUT(2) << "ClientConnection: could not create client host" << std::endl;
       // add some error handling here ==========================
-      quit=true;
+      quit_=true;
     }
     //connect to the server
     if(!establishConnection()){
       COUT(2) << "clientConn: receiver thread: could not establishConnection" << std::endl;
-      quit=true;
+      quit_=true;
       return;
     }
     event = new ENetEvent;
     //main loop
-    while(!quit){
+    while(!quit_){
       //std::cout << "connection loop" << std::endl;
       {
         boost::recursive_mutex::scoped_lock lock(enet_mutex_g);
         if(enet_host_service(client, event, NETWORK_CLIENT_WAIT_TIME)<0){
           // we should never reach this point
-          quit=true;
-          continue;
+// 	        assert(0);
+          printf("ClientConnection: ENet returned with an error!\n");
+          quit_=true;
+          break;
           // add some error handling here ========================
         }
         lock.unlock();
@@ -182,7 +185,8 @@
         event = new ENetEvent;
         break;
       case ENET_EVENT_TYPE_DISCONNECT:
-        quit=true;
+        quit_=true;
+        printf("Received disconnect Packet from Server!\n");
         // server closed the connection
         return;
         break;
@@ -203,9 +207,11 @@
 
   bool ClientConnection::disconnectConnection() {
     ENetEvent event;
+    if(this->quit_)
+      return true;
     boost::recursive_mutex::scoped_lock lock(enet_mutex_g);
     enet_peer_disconnect(server, 0);
-    while(enet_host_service(client, &event, NETWORK_CLIENT_WAIT_TIME) > 0){
+    while(enet_host_service(client, &event, NETWORK_CLIENT_WAIT_TIME) >= 0){
       switch (event.type)
       {
       case ENET_EVENT_TYPE_NONE:
@@ -232,7 +238,7 @@
       return false;
     }
     // handshake
-    while(enet_host_service(client, &event, NETWORK_CLIENT_WAIT_TIME)>=0 && !quit){
+    while(enet_host_service(client, &event, NETWORK_CLIENT_WAIT_TIME)>=0 && !quit_){
       if( event.type == ENET_EVENT_TYPE_CONNECT ){
         established=true;
         return true;

Modified: trunk/src/network/ClientConnection.h
===================================================================
--- trunk/src/network/ClientConnection.h	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/network/ClientConnection.h	2009-05-26 19:20:57 UTC (rev 3084)
@@ -20,7 +20,7 @@
  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *
  *   Author:
- *      Oliver Scheuss, (C) 2007
+ *      Oliver Scheuss
  *   Co-authors:
  *      ...
  *
@@ -52,7 +52,7 @@
 
     const int NETWORK_PORT = 55556;
     const int NETWORK_CLIENT_MAX_CONNECTIONS = 5;
-    const int NETWORK_CLIENT_WAIT_TIME = 1;
+    const int NETWORK_CLIENT_WAIT_TIME = 10;
     const int NETWORK_CLIENT_CONNECT_TIMEOUT = 3000; // miliseconds
     const int NETWORK_CLIENT_CHANNELS = 2;
 
@@ -75,7 +75,8 @@
     // send out all queued packets and save result in event
     //bool sendPackets(ENetEvent *event);
     bool waitEstablished(int milisec);
-    bool isConnected(){return established;}
+    inline bool isConnected(){return established;}
+    inline bool checkConnection(){ return !quit_ && isConnected(); }
   private:
     ClientConnection(const ClientConnection& copy); // not used
     bool processData(ENetEvent *event);
@@ -89,7 +90,7 @@
     ENetHost *client;
     ENetAddress *serverAddress;
     // quit-variable (communication with threads)
-    bool quit;
+    bool quit_;
     bool established;
     // clientlist
     ENetPeer *server;

Modified: trunk/src/network/ConnectionManager.cc
===================================================================
--- trunk/src/network/ConnectionManager.cc	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/network/ConnectionManager.cc	2009-05-26 19:20:57 UTC (rev 3084)
@@ -57,10 +57,7 @@
 namespace std
 {
   bool operator< (ENetAddress a, ENetAddress b) {
-    if(a.host <= b.host)
-      return true;
-    else
-      return false;
+    return a.host <= b.host;
   }
 }
 
@@ -74,7 +71,7 @@
   ConnectionManager::ConnectionManager():receiverThread_(0){
     assert(instance_==0);
     instance_=this;
-    quit=false;
+    quit_=false;
     bindAddress = new ENetAddress();
     bindAddress->host = ENET_HOST_ANY;
     bindAddress->port = NETWORK_PORT;
@@ -83,7 +80,7 @@
   ConnectionManager::ConnectionManager(int port){
     assert(instance_==0);
     instance_=this;
-    quit=false;
+    quit_=false;
     bindAddress = new ENetAddress();
     bindAddress->host = ENET_HOST_ANY;
     bindAddress->port = port;
@@ -92,7 +89,7 @@
   ConnectionManager::ConnectionManager(int port, const std::string& address) :receiverThread_(0) {
     assert(instance_==0);
     instance_=this;
-    quit=false;
+    quit_=false;
     bindAddress = new ENetAddress();
     enet_address_set_host (bindAddress, address.c_str());
     bindAddress->port = NETWORK_PORT;
@@ -101,14 +98,14 @@
   ConnectionManager::ConnectionManager(int port, const char *address) : receiverThread_(0) {
     assert(instance_==0);
     instance_=this;
-    quit=false;
+    quit_=false;
     bindAddress = new ENetAddress();
     enet_address_set_host (bindAddress, address);
     bindAddress->port = NETWORK_PORT;
   }
 
   ConnectionManager::~ConnectionManager(){
-    if(!quit)
+    if(!quit_)
       quitListener();
     instance_=0;
     delete bindAddress;
@@ -132,7 +129,7 @@
   }
 
   bool ConnectionManager::quitListener() {
-    quit=true;
+    quit_=true;
     receiverThread_->join();
     return true;
   }
@@ -188,17 +185,20 @@
     }
     if(server==NULL){
       // add some error handling here ==========================
-      quit=true;
+      quit_=true;
       return;
     }
 
     event = new ENetEvent;
-    while(!quit){
+    while(!quit_)
+    {
       { //mutex scope
         boost::recursive_mutex::scoped_lock lock(enet_mutex_g);
         if(enet_host_service(server, event, NETWORK_WAIT_TIMEOUT)<0){
           // we should never reach this point
-          quit=true;
+          printf("ConnectionManager: ENet returned with an error\n");
+          quit_=true;
+          printf("waaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaahhhhhhhhhhhhhhhh\n");
           continue;
           // add some error handling here ========================
         }
@@ -207,6 +207,7 @@
       switch(event->type){
         // log handling ================
         case ENET_EVENT_TYPE_CONNECT:
+//             printf("====================================================================");
         case ENET_EVENT_TYPE_DISCONNECT:
         case ENET_EVENT_TYPE_RECEIVE:
             processData(event);
@@ -214,7 +215,7 @@
           break;
         case ENET_EVENT_TYPE_NONE:
           //receiverThread_->yield();
-          msleep(1);
+          msleep(10);
           break;
       }
 //       usleep(100);
@@ -266,14 +267,7 @@
     return;
   }
 
-  bool ConnectionManager::processData(ENetEvent *event) {
-    // just add packet to the buffer
-    // this can be extended with some preprocessing
-    return buffer.push(event);
-  }
 
-
-
   int ConnectionManager::getClientID(ENetPeer* peer) {
     return getClientID(&(peer->address));
   }

Modified: trunk/src/network/ConnectionManager.h
===================================================================
--- trunk/src/network/ConnectionManager.h	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/network/ConnectionManager.h	2009-05-26 19:20:57 UTC (rev 3084)
@@ -54,7 +54,7 @@
 {
     const int NETWORK_PORT = 55556;
     const int NETWORK_MAX_CONNECTIONS = 50;
-    const int NETWORK_WAIT_TIMEOUT = 1;
+    const int NETWORK_WAIT_TIMEOUT = 10;
     const int NETWORK_DEFAULT_CHANNEL = 0;
 
   struct _NetworkExport ClientList{
@@ -80,10 +80,11 @@
     bool sendPackets();
     void disconnectClient(ClientInformation *client);
     void syncClassid(unsigned int clientID);
+    bool checkReceiverThread(){ return !quit_; }
 
   private:
     ConnectionManager(const ConnectionManager& copy); // not used
-    bool processData(ENetEvent *event);
+    inline bool processData(ENetEvent *event){ return buffer.push(event); }
     void receiverThread();
     void disconnectClients();
     int getClientID(ENetPeer* peer);
@@ -94,7 +95,7 @@
     ENetHost *server;
     ENetAddress *bindAddress;
 
-    bool quit; // quit-variable (communication with threads)
+    bool quit_; // quit-variable (communication with threads)
 
     boost::thread *receiverThread_;
     static ConnectionManager *instance_;

Copied: trunk/src/network/FunctionCallManager.cc (from rev 3083, branches/netp3/src/network/FunctionCallManager.cc)
===================================================================
--- trunk/src/network/FunctionCallManager.cc	                        (rev 0)
+++ trunk/src/network/FunctionCallManager.cc	2009-05-26 19:20:57 UTC (rev 3084)
@@ -0,0 +1,165 @@
+/*
+ *   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_;
+
+// Static calls
+
+void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID)
+{  
+  if(clientMap_.find(clientID)==clientMap_.end()) 
+  {
+    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 
+    FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 
+  } 
+  FunctionCallManager::	clientMap_[clientID]->addCallStatic(functionID);
+}
+void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1)
+{  
+  if(clientMap_.find(clientID)==clientMap_.end()) 
+  {
+    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 
+    FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 
+  } 
+  FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1);
+}
+void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2)
+{  
+  if(clientMap_.find(clientID)==clientMap_.end()) 
+  {
+    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 
+    FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 
+  } 
+  FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2);
+}
+void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)
+{  
+  if(clientMap_.find(clientID)==clientMap_.end()) 
+  {
+    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 
+    FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 
+  } 
+  FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2, &mt3);
+}
+void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)
+{  
+  if(clientMap_.find(clientID)==clientMap_.end()) 
+  {
+    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 
+    FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 
+  } 
+  FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4);
+}
+void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
+{  
+  if(clientMap_.find(clientID)==clientMap_.end()) 
+  {
+    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 
+    FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 
+  } 
+  FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4, &mt5);
+}
+
+
+// MemberCalls
+
+void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID)
+{ 
+  if(clientMap_.find(clientID)==clientMap_.end()) 
+  {
+    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 
+    FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 
+  } 
+  FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID);
+}
+void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1)
+{ 
+  if(clientMap_.find(clientID)==clientMap_.end()) 
+  {
+    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 
+    FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 
+  } 
+  FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID, &mt1);
+}
+void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2)
+{ 
+  if(clientMap_.find(clientID)==clientMap_.end()) 
+  {
+    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 
+    FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 
+  } 
+  FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2);
+}
+void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)
+{ 
+  if(clientMap_.find(clientID)==clientMap_.end()) 
+  {
+    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 
+    FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 
+  } 
+  FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3);
+}
+void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)
+{ 
+  if(clientMap_.find(clientID)==clientMap_.end()) 
+  {
+    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 
+    FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 
+  } 
+  FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4);
+}
+void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
+{ 
+  if(clientMap_.find(clientID)==clientMap_.end()) 
+  {
+    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 
+    FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 
+  } 
+  FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4, &mt5);
+}
+
+// Send calls
+
+void FunctionCallManager::sendCalls()
+{
+  std::map<uint32_t, packet::FunctionCalls*>::iterator it;
+  for (it = FunctionCallManager::clientMap_.begin(); it != FunctionCallManager::clientMap_.end(); it++ )
+  {
+    assert(!FunctionCallManager::clientMap_.empty());
+    it->second->send();
+  }
+  FunctionCallManager::clientMap_.clear();
+}
+
+
+} //namespace orxonox


Property changes on: trunk/src/network/FunctionCallManager.cc
___________________________________________________________________
Added: svn:eol-style
   + native

Copied: trunk/src/network/FunctionCallManager.h (from rev 3083, branches/netp3/src/network/FunctionCallManager.h)
===================================================================
--- trunk/src/network/FunctionCallManager.h	                        (rev 0)
+++ trunk/src/network/FunctionCallManager.h	2009-05-26 19:20:57 UTC (rev 3084)
@@ -0,0 +1,44 @@
+
+#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);
+  static void addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1);
+  static void addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2);
+  static void addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3);
+  static void addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4);
+  static void addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5);
+  
+  static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID);
+  static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1);
+  static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2);
+  static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3);
+  static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4);
+  static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5);
+  
+  static void sendCalls();
+  
+  static std::map<uint32_t, packet::FunctionCalls*> clientMap_;
+protected:
+  FunctionCallManager();
+  ~FunctionCallManager();
+};
+
+} //namespace orxonox
+
+#endif


Property changes on: trunk/src/network/FunctionCallManager.h
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: trunk/src/network/GamestateManager.cc
===================================================================
--- trunk/src/network/GamestateManager.cc	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/network/GamestateManager.cc	2009-05-26 19:20:57 UTC (rev 3084)
@@ -20,7 +20,7 @@
  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *
  *   Author:
- *      Oliver Scheuss, (C) 2007
+ *      Oliver Scheuss
  *   Co-authors:
  *      ...
  *
@@ -131,8 +131,11 @@
     }
     if(client){
 //       COUT(3) << "diffing" << std::endl;
+//       packet::Gamestate* gs1  = gs;
       gs = gs->diff(client);
+//       packet::Gamestate* gs2 = gs->undiff(client);
 //       gs = new packet::Gamestate(*gs);
+//       assert(*gs1==*gs2);
     }
     else{
 //       COUT(3) << "not diffing" << std::endl;
@@ -160,6 +163,7 @@
       std::map<unsigned int, packet::Gamestate*>::iterator it;
       for(it = gamestateMap_[clientID].begin(); it!=gamestateMap_[clientID].end(); ){
         delete it->second;
+
         gamestateMap_[clientID].erase(it++);
       }
       return true;

Modified: trunk/src/network/GamestateManager.h
===================================================================
--- trunk/src/network/GamestateManager.h	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/network/GamestateManager.h	2009-05-26 19:20:57 UTC (rev 3084)
@@ -20,7 +20,7 @@
  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *
  *   Author:
- *      Oliver Scheuss, (C) 2007
+ *      Oliver Scheuss
  *   Co-authors:
  *      ...
  *

Modified: trunk/src/network/Host.h
===================================================================
--- trunk/src/network/Host.h	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/network/Host.h	2009-05-26 19:20:57 UTC (rev 3084)
@@ -35,6 +35,10 @@
 
 namespace orxonox {
 
+  const int CLIENTID_SERVER = 0;
+  const unsigned int NETWORK_FREQUENCY = 30;
+  const float NETWORK_PERIOD = 1.0f/NETWORK_FREQUENCY;
+
 /**
 *       @brief Base class of Server and Client
 *       This is the Base class of the Server and Client classes

Copied: trunk/src/network/NetworkFunction.cc (from rev 3083, branches/netp3/src/network/NetworkFunction.cc)
===================================================================
--- trunk/src/network/NetworkFunction.cc	                        (rev 0)
+++ trunk/src/network/NetworkFunction.cc	2009-05-26 19:20:57 UTC (rev 3084)
@@ -0,0 +1,91 @@
+/*
+ *   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(FunctorStatic* functor, std::string name, const NetworkFunctionPointer& p):
+    NetworkFunctionBase(name)
+  {
+    RegisterObject(NetworkFunctionStatic);
+    
+    this->functor_ = functor;
+    functorMap_[p] = this;
+    idMap_[ this->getNetworkID() ] = this;
+  }
+  
+  NetworkFunctionStatic::~NetworkFunctionStatic()
+  {
+    delete this->functor_;
+  }
+  
+  
+  
+  NetworkMemberFunctionBase::NetworkMemberFunctionBase(std::string name, const NetworkFunctionPointer& p):
+    NetworkFunctionBase(name)
+  {
+    RegisterObject(NetworkMemberFunctionBase);
+    
+    functorMap_[p] = this;
+    idMap_[ this->getNetworkID() ] = this;
+  }
+  
+  NetworkMemberFunctionBase::~NetworkMemberFunctionBase()
+  {
+  }
+  
+
+}


Property changes on: trunk/src/network/NetworkFunction.cc
___________________________________________________________________
Added: svn:eol-style
   + native

Copied: trunk/src/network/NetworkFunction.h (from rev 3083, branches/netp3/src/network/NetworkFunction.h)
===================================================================
--- trunk/src/network/NetworkFunction.h	                        (rev 0)
+++ trunk/src/network/NetworkFunction.h	2009-05-26 19:20:57 UTC (rev 3084)
@@ -0,0 +1,237 @@
+/*
+ *   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 "OrxonoxConfig.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 _NetworkExport 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); }
+    
+  protected:
+    static std::map<uint32_t, bool> isStaticMap_;
+    
+  private:
+    static std::map<std::string, NetworkFunctionBase*> nameMap_;
+    uint32_t networkID_;
+    std::string name_;
+      
+};
+
+
+class _NetworkExport NetworkFunctionStatic: public NetworkFunctionBase {
+  public:
+    NetworkFunctionStatic(FunctorStatic* 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 _NetworkExport 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 NetworkMemberFunction: public NetworkMemberFunctionBase {
+  public:
+    NetworkMemberFunction(FunctorMember<T>* functor, std::string name, const NetworkFunctionPointer& p);
+    ~NetworkMemberFunction();
+    
+    inline void call(uint32_t objectID)
+    { 
+      if ( Synchronisable::getSynchronisable(objectID)!=0 )
+        (*this->functor_)(dynamic_cast<T*>(Synchronisable::getSynchronisable(objectID)));
+    }
+    inline void call(uint32_t objectID, const MultiType& mt1)
+    { 
+      if ( Synchronisable::getSynchronisable(objectID)!=0 )
+        (*this->functor_)(dynamic_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1);
+    }
+    inline void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2)
+    { 
+      if ( Synchronisable::getSynchronisable(objectID)!=0 )
+        (*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)
+    { 
+      if ( Synchronisable::getSynchronisable(objectID)!=0 )
+        (*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)
+    { 
+      if ( Synchronisable::getSynchronisable(objectID)!=0 )
+        (*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)
+    { 
+      if ( Synchronisable::getSynchronisable(objectID)!=0 )
+        (*this->functor_)(dynamic_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2, mt3, mt4, mt5);
+    }
+    
+  private:
+    FunctorMember<T>* functor_;
+};
+
+template <class T> NetworkMemberFunction<T>::NetworkMemberFunction(FunctorMember<T>* functor, std::string name, const NetworkFunctionPointer& p):
+    NetworkMemberFunctionBase(name, p), functor_(functor)
+{
+}
+template <class T> NetworkMemberFunction<T>::~NetworkMemberFunction()
+{
+  delete this->functor_;
+}
+
+template<class T> inline void copyPtr( T ptr, NetworkFunctionPointer& destptr)
+{
+  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, 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>( createFunctor(ptr), name, destptr );
+  return 0;
+}
+
+#define registerStaticNetworkFunction( functionPointer ) \
+  static void* MACRO_CONCATENATE( NETWORK_FUNCTION_, __LINE__ ) = registerStaticNetworkFunctionFct( functionPointer, #functionPointer );
+#define registerMemberNetworkFunction( class, function ) \
+  static void* MACRO_CONCATENATE( NETWORK_FUNCTION_##class, __LINE__ ) = 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


Property changes on: trunk/src/network/NetworkFunction.h
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: trunk/src/network/NetworkPrereqs.h
===================================================================
--- trunk/src/network/NetworkPrereqs.h	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/network/NetworkPrereqs.h	2009-05-26 19:20:57 UTC (rev 3084)
@@ -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: trunk/src/network/Server.cc
===================================================================
--- trunk/src/network/Server.cc	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/network/Server.cc	2009-05-26 19:20:57 UTC (rev 3084)
@@ -20,7 +20,7 @@
  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *
  *   Author:
- *      Oliver Scheuss, (C) 2007
+ *      Oliver Scheuss
  *   Co-authors:
  *      ...
  *
@@ -60,7 +60,10 @@
 #include "packet/DeleteObjects.h"
 #include "util/Convert.h"
 #include "ChatListener.h"
+#include "FunctionCallManager.h"
+#include "packet/FunctionIDs.h"
 
+
 namespace orxonox
 {
   const unsigned int MAX_FAILURES = 20;
@@ -151,12 +154,13 @@
   */
   void Server::update(const Clock& time) {
     processQueue();
+    gamestates_->processGamestates();
     //this steers our network frequency
     timeSinceLastUpdate_+=time.getDeltaTime();
     if(timeSinceLastUpdate_>=NETWORK_PERIOD){
       timeSinceLastUpdate_ -= static_cast<unsigned int>( timeSinceLastUpdate_ / NETWORK_PERIOD ) * NETWORK_PERIOD;
-      gamestates_->processGamestates();
       updateGamestate();
+      FunctionCallManager::sendCalls();
     }
   }
 
@@ -340,13 +344,22 @@
       COUT(2) << "Conn.Man. could not create client with id: " << clientID << std::endl;
       return false;
     }
-    COUT(4) << "Con.Man: creating client id: " << temp->getID() << std::endl;
+    COUT(5) << "Con.Man: creating client id: " << temp->getID() << std::endl;
+    
+    // synchronise class ids
     connection->syncClassid(temp->getID());
+    
+    // now synchronise functionIDs
+    packet::FunctionIDs *fIDs = new packet::FunctionIDs();
+    fIDs->setClientID(clientID);
+    bool b = fIDs->send();
+    assert(b);
+    
     temp->setSynched(true);
-    COUT(3) << "sending welcome" << std::endl;
+    COUT(4) << "sending welcome" << std::endl;
     packet::Welcome *w = new packet::Welcome(temp->getID(), temp->getShipID());
     w->setClientID(temp->getID());
-    bool b = w->send();
+    b = w->send();
     assert(b);
     packet::Gamestate *g = new packet::Gamestate();
     g->setClientID(temp->getID());

Modified: trunk/src/network/Server.h
===================================================================
--- trunk/src/network/Server.h	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/network/Server.h	2009-05-26 19:20:57 UTC (rev 3084)
@@ -20,24 +20,12 @@
  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *
  *   Author:
- *      Oliver Scheuss, (C) 2007
+ *      Oliver Scheuss
  *   Co-authors:
  *      ...
  *
  */
 
-//
-// C++ Interface: Server
-//
-// Description:
-//
-//
-// Author:  Oliver Scheuss, (C) 2007
-//
-// Copyright: See COPYING file that comes with this distribution
-//
-//
-
 #ifndef _Server_H__
 #define _Server_H__
 
@@ -50,9 +38,6 @@
 
 namespace orxonox
 {
-  const int CLIENTID_SERVER = 0;
-  const unsigned int NETWORK_FREQUENCY = 25;
-  const float NETWORK_PERIOD = 1.f/NETWORK_FREQUENCY;
 
   /**
   * This class is the root class of the network module for a server.

Modified: trunk/src/network/TrafficControl.cc
===================================================================
--- trunk/src/network/TrafficControl.cc	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/network/TrafficControl.cc	2009-05-26 19:20:57 UTC (rev 3084)
@@ -20,7 +20,7 @@
  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *
  *   Author:
- *      Oliver Scheuss <scheusso [at] ee.ethz.ch>, (C) 2008
+ *      Oliver Scheuss <scheusso [at] ee.ethz.ch>
  *   Co-authors:
  *      ...
  *
@@ -90,8 +90,8 @@
 
   void TrafficControl::setConfigValues()
   {
-    SetConfigValue ( bActive_, true );
-    SetConfigValue ( targetSize, 5000 );
+    SetConfigValue ( bActive_, false );
+    SetConfigValue ( targetSize, 10000 );
   }
 
   /**
@@ -120,9 +120,8 @@
 
 
 
-	void TrafficControl::processObjectList(unsigned int clientID, unsigned int gamestateID, std::list<obj> *list)
+	void TrafficControl::processObjectList(unsigned int clientID, unsigned int gamestateID, std::list<obj>& list)
 	{
-// 	  copiedVector = *list;
 	  currentClientID=clientID;
 	  currentGamestateID=gamestateID;
 	  evaluateList(clientID, list);
@@ -142,26 +141,30 @@
     //assertions to make sure the maps already exist
     assert(clientListTemp_.find(clientID) != clientListTemp_.end() );
     assert(clientListPerm_.find(clientID) != clientListPerm_.end() );
-	  assert( clientListTemp_[clientID].find(gamestateID) != clientListTemp_[clientID].end() );
+    assert( clientListTemp_[clientID].find(gamestateID) != clientListTemp_[clientID].end() );
+    
+    // shortcut for maps
+    std::map<unsigned int, objInfo >& objectListPerm = clientListPerm_[clientID];
+    std::map<unsigned int, std::list<obj> >& objectListTemp = clientListTemp_[clientID];
 
-    for(itvec = clientListTemp_[clientID][gamestateID].begin(); itvec != clientListTemp_[clientID][gamestateID].end(); itvec++)
+    for(itvec = objectListTemp[gamestateID].begin(); itvec != objectListTemp[gamestateID].end(); itvec++)
 	  {
-      if(clientListPerm_[clientID].find((*itvec).objID) != clientListPerm_[clientID].end()) // check whether the obj already exists in our lists
+      if(objectListPerm.find((*itvec).objID) != objectListPerm.end()) // check whether the obj already exists in our lists
       {
-        clientListPerm_[clientID][(*itvec).objID].objCurGS = gamestateID;
-        clientListPerm_[clientID][(*itvec).objID].objValueSched = 0; //set scheduling value back
+        objectListPerm[(*itvec).objID].objCurGS = gamestateID;
+        objectListPerm[(*itvec).objID].objValueSched = 0; //set scheduling value back
       }
       else
       {
         assert(0);
-        clientListPerm_[clientID][(*itvec).objID].objCurGS = gamestateID;
-        clientListPerm_[clientID][(*itvec).objID].objID = (*itvec).objID;
-        clientListPerm_[clientID][(*itvec).objID].objCreatorID = (*itvec).objCreatorID;
-        clientListPerm_[clientID][(*itvec).objID].objSize = (*itvec).objSize;
+        objectListPerm[(*itvec).objID].objCurGS = gamestateID;
+        objectListPerm[(*itvec).objID].objID = (*itvec).objID;
+        objectListPerm[(*itvec).objID].objCreatorID = (*itvec).objCreatorID;
+        objectListPerm[(*itvec).objID].objSize = (*itvec).objSize;
       }
 	  }
 	   // remove temporary list (with acked objects) from the map
-    clientListTemp_[clientID].erase( clientListTemp_[clientID].find(gamestateID) );
+    objectListTemp.erase( objectListTemp.find(gamestateID) );
 	}
 
 /**
@@ -175,33 +178,29 @@
 	void TrafficControl::insertinClientListPerm(unsigned int clientID, obj objinf)
 	{
 	  std::map<unsigned int,std::map<unsigned int, objInfo> >::iterator itperm;//iterator clientListPerm over clientIDs
-// 	  itperm = (clientListPerm_).find(clientID);
-// 	  assert(itperm != clientListPerm_.end() );
     unsigned int gsid=GAMESTATEID_INITIAL, gsdiff=currentGamestateID, prioperm=Synchronisable::getSynchronisable(objinf.objID)->getPriority(), priomom=0;
     clientListPerm_[clientID][objinf.objID] = objInfo(objinf.objID, objinf.objCreatorID,gsid,gsdiff, objinf.objSize,prioperm,priomom);
-// 	  itperm->second.insert(std::pair<unsigned int, objInfo>(objid,objinf));
-//     permObjPrio_.insert(objid, objinf.objValuePerm);
 	}
 
   /**
   * updateClientListTemp
   * takes the shortened list which will be sent to the gsmanager and puts the *info into clientListTemp
   */
-  void TrafficControl::updateClientListTemp(std::list<obj> *list)
+  void TrafficControl::updateClientListTemp(std::list<obj>& list)
   {
-    clientListTemp_[currentClientID][currentGamestateID] = std::list<obj>(*list);
+    clientListTemp_[currentClientID][currentGamestateID] = std::list<obj>(list);
   }
 
   /**
   *cut
   *takes the current list that has to be returned to the gsmanager and shortens it in criteria of bandwidth of clientID(XY)
   */
-  void TrafficControl::cut(std::list<obj> *list, unsigned int targetsize)
+  void TrafficControl::cut(std::list<obj>& list, unsigned int targetsize)
   {
     unsigned int size=0;
     std::list<obj>::iterator itvec, ittemp;
-    assert(!list->empty());
-    for(itvec = list->begin(); itvec != list->end();)
+    assert(!list.empty());
+    for(itvec = list.begin(); itvec != list.end();)
     {
       assert( (*itvec).objSize < 1000);
       if ( ( size + (*itvec).objSize ) < targetsize )
@@ -212,18 +211,19 @@
       else
       {
         clientListPerm_[currentClientID][(*itvec).objID].objValueSched += SCHED_PRIORITY_OFFSET; // NOTE: SCHED_PRIORITY_OFFSET is negative
-        list->erase(itvec++);
+        list.erase(itvec, list.end());
+        break;
       }
 //       printList(list, currentClientID);
     }
-    assert(!list->empty());
+    assert(!list.empty());
   }
 
 
 	/**
 	*evaluateList evaluates whether new obj are there, whether there are things to be updatet and manipulates all this.
 	*/
-	void TrafficControl::evaluateList(unsigned int clientID, std::list<obj> *list)
+	void TrafficControl::evaluateList(unsigned int clientID, std::list<obj>& list)
 	{
 
 	  //now the sorting
@@ -231,13 +231,16 @@
 	  //compare listToProcess vs clientListPerm
     //if listToProcess contains new Objects, add them to clientListPerm
     std::list<obj>::iterator itvec;
-	  for( itvec=list->begin(); itvec != list->end(); itvec++)
+    
+    std::map<unsigned int, objInfo >& objectListPerm = clientListPerm_[clientID];
+    
+	  for( itvec=list.begin(); itvec != list.end(); itvec++)
 	  {
-	    if ( clientListPerm_[clientID].find( (*itvec).objID) != clientListPerm_[clientID].end() )
+	    if ( objectListPerm.find( (*itvec).objID) != objectListPerm.end() )
       {
         // we already have the object in our map
         //obj bleibt in liste und permanente prio wird berechnet
-        clientListPerm_[clientID][(*itvec).objID].objDiffGS = currentGamestateID - clientListPerm_[clientID][(*itvec).objID].objCurGS;
+        objectListPerm[(*itvec).objID].objDiffGS = currentGamestateID - objectListPerm[(*itvec).objID].objCurGS;
         continue;//check next objId
       }
       else
@@ -253,11 +256,14 @@
     {
       //sort copied list according to priorities
       // use boost bind here because we need to pass a memberfunction to stl sort
-      list->sort(boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) );
+//       sort( list.begin(), list.end(), boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) );
+      list.sort( boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) );
+      
+//       list.sort(boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) );
 
       //now we check, that the creator of an object always exists on a client
       std::list<obj>::iterator itcreator;
-      for(itvec = list->begin(); itvec != list->end(); itvec++)
+      for(itvec = list.begin(); itvec != list.end(); itvec++)
       {
         fixCreatorDependencies(itvec, list, clientID);
       }
@@ -265,36 +271,36 @@
       //now the cutting, work the same obj out in processobjectlist and copiedlist, compression rate muss noch festgelegt werden.
 //       printList(list, clientID);
       cut(list, targetSize);
-
       //now sort again after objDataOffset
-      list->sort(boost::bind(&TrafficControl::dataSort, this, _1, _2) );
+//       sort(list.begin(), list.end(), boost::bind(&TrafficControl::dataSort, this, _1, _2) );
+      list.sort( boost::bind(&TrafficControl::dataSort, this, _1, _2) );
     }
     //diese Funktion updateClientList muss noch gemacht werden
     updateClientListTemp(list);
     //end of sorting
   }
 
-  void TrafficControl::printList(std::list<obj> *list, unsigned int clientID)
+  void TrafficControl::printList(std::list<obj>& list, unsigned int clientID)
   {
     std::list<obj>::iterator it;
     COUT(0) << "=========== Objectlist ===========" << endl;
-    for( it=list->begin(); it!=list->end(); it++)
+    for( it=list.begin(); it!=list.end(); it++)
       COUT(0) << "ObjectID: " << (*it).objID << " creatorID: " << (*it).objCreatorID << " Priority: " << clientListPerm_[clientID][(*it).objID].objValuePerm + clientListPerm_[clientID][(*it).objID].objValueSched << " size: " << (*it).objSize << endl;
   }
 
-  void TrafficControl::fixCreatorDependencies(std::list<obj>::iterator it1, std::list<obj> *list, unsigned int clientID)
+  void TrafficControl::fixCreatorDependencies(std::list<obj>::iterator it1, std::list<obj>& list, unsigned int clientID)
   {
     if ( (*it1).objCreatorID == OBJECTID_UNKNOWN )
       return;
     if( clientListPerm_[clientID][(*it1).objCreatorID].objCurGS != GAMESTATEID_INITIAL )
       return;
     std::list<obj>::iterator it2, it3=it1;
-    for( it2 = ++it3; it2 != list->end(); it2++ )
+    for( it2 = ++it3; it2 != list.end(); it2++ )
     {
       if( (*it2).objID == (*it1).objCreatorID )
       {
-        it3 = list->insert(it1, *it2); //insert creator before it1
-        list->erase(it2);
+        it3 = list.insert(it1, *it2); //insert creator before it1
+        list.erase(it2);
 //         printList(list, clientID);
         fixCreatorDependencies( it3, list, clientID );
         break;

Modified: trunk/src/network/TrafficControl.h
===================================================================
--- trunk/src/network/TrafficControl.h	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/network/TrafficControl.h	2009-05-26 19:20:57 UTC (rev 3084)
@@ -20,7 +20,7 @@
  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *
  *   Author:
- *      Oliver Scheuss <scheusso [at] ee.ethz.ch>, (C) 2008
+ *      Oliver Scheuss <scheusso [at] ee.ethz.ch>
  *   Co-authors:
  *      ...
  *
@@ -82,20 +82,6 @@
   private:
 
     /**
-    *Lists that will be used:
-    *listToProcess
-    *clientListPerm
-    *clientListTemp
-    *referenceList
-    *permObjPrio list
-    *schedObjPrio
-    */
-    //start: lists to be used
-    /**
-    *creates list (typ map) that contains objids, struct with info concerning object(objid)
-    */
-//     std::map<unsigned int, objInfo> listToProcess_;//copy of argument, when traffic control tool is being called, the original of this must be returned later on, eg the list given by GS
-    /**
     *permanent client list: contains client ids, object ids and objectInfos (in this order)
     */
     std::map<unsigned int, std::map<unsigned int, objInfo > > clientListPerm_;
@@ -105,15 +91,6 @@
     *temporary client list: contains client ids, gamestate ids and object ids (in this order)
     */
     std::map<unsigned int, std::map<unsigned int, std::list<obj> > > clientListTemp_;
-    /**
-    *static priority list: contains obj id, basic priority (in this order)
-    */
-//     std::map<unsigned int, unsigned int> permObjPrio_;
-    /**
-    *dynamic priority list: contains obj id, dynamic priority (eg scheduled) (in this order)
-    */
-//     std::map<unsigned int, unsigned int> schedObjPrio_;
-    //end: lists to be used
 
     /**updateReferenceList
     *currentGamestateID and currentClientID will be defined as soon as TrafficControl is being called by Server
@@ -122,24 +99,15 @@
     unsigned int currentClientID;
     unsigned int targetSize;
     bool         bActive_;
-    /**
-    *copiedVector is a copy of the given Vector by the GSmanager, on this list all manipulations are performed
-    */
-//     std::list<obj> copiedVector;
-
-//     void updateReferenceList(std::map<unsigned int, objInfo> *list);//done
-    void insertinClientListPerm(unsigned int clientID, obj objinf);//done
-    /**
-    *creates listToProcess, which can be easialy compared with other lists
-    */
-//     void copyList(std::list<obj> *list);//done
     
-    void cut(std::list<obj> *list, unsigned int targetsize);
-    void updateClientListTemp(std::list<obj> *list);//done
+    void insertinClientListPerm(unsigned int clientID, obj objinf);
+    
+    void cut(std::list<obj>& list, unsigned int targetsize);
+    void updateClientListTemp(std::list<obj>& list);//done
     /**
     *evaluates Data given (list) and produces result(->Data to be updated)
     */
-    void evaluateList(unsigned int clientID, std::list<obj> *list);//done    
+    void evaluateList(unsigned int clientID, std::list<obj>& list);//done    
     void ack(unsigned int clientID, unsigned int gamestateID);  // this function gets called when the server receives an ack from the client
     
     //ClientConnectionListener functions
@@ -161,17 +129,15 @@
     */
     void setConfigValues();
     static TrafficControl *getInstance();
-    void processObjectList(unsigned int clientID, unsigned int gamestateID, std::list<obj>* list); //gets a pointer to the list (containing objectIDs) and sorts it
-    //done
+    void processObjectList(unsigned int clientID, unsigned int gamestateID, std::list<obj>& list); //gets a pointer to the list (containing objectIDs) and sorts it
     static void processAck(unsigned int clientID, unsigned int gamestateID)
     { return instance_->ack(clientID, gamestateID); }
-    //done
     void deleteObject(unsigned int objectID);				// this function gets called when an object has been deleted (in order to clean up lists and maps)
     
     bool prioritySort(uint32_t clientID, obj i, obj j);
     bool dataSort(obj i, obj j);
-    void printList(std::list<obj> *list, unsigned int clientID);
-    void fixCreatorDependencies(std::list<obj>::iterator it, std::list<obj> *list, unsigned int clientID);
+    void printList(std::list<obj>& list, unsigned int clientID);
+    void fixCreatorDependencies(std::list<obj>::iterator it, std::list<obj>& list, unsigned int clientID);
 };
 
 }

Modified: trunk/src/network/packet/CMakeLists.txt
===================================================================
--- trunk/src/network/packet/CMakeLists.txt	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/network/packet/CMakeLists.txt	2009-05-26 19:20:57 UTC (rev 3084)
@@ -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: trunk/src/network/packet/ClassID.cc
===================================================================
--- trunk/src/network/packet/ClassID.cc	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/network/packet/ClassID.cc	2009-05-26 19:20:57 UTC (rev 3084)
@@ -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;
   
 }
 

Copied: trunk/src/network/packet/FunctionCalls.cc (from rev 3083, branches/netp3/src/network/packet/FunctionCalls.cc)
===================================================================
--- trunk/src/network/packet/FunctionCalls.cc	                        (rev 0)
+++ trunk/src/network/packet/FunctionCalls.cc	2009-05-26 19:20:57 UTC (rev 3084)
@@ -0,0 +1,323 @@
+/*
+ *   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 "FunctionCalls.h"
+
+#include <enet/enet.h>
+#include <cassert>
+#include <cstring>
+#include "network/Host.h"
+#include "network/NetworkFunction.h"
+#include "util/MultiType.h"
+
+namespace orxonox {
+namespace packet {
+  
+#define   PACKET_FLAGS_FUNCTIONCALLS ENET_PACKET_FLAG_RELIABLE
+#define   _PACKETID         0
+const unsigned int FUNCTIONCALLS_MEM_ALLOCATION = 1000;
+    
+FunctionCalls::FunctionCalls()
+ : Packet()
+{
+  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 ];
+  *(ENUM::Type *)(data_ + _PACKETID ) = ENUM::FunctionCalls;
+  *(uint32_t*)(data_+sizeof(uint32_t)) = 0; // set nrOfCalls to 0
+}
+
+FunctionCalls::FunctionCalls( uint8_t* data, unsigned int clientID )
+  : Packet(data, clientID)
+{
+}
+
+FunctionCalls::~FunctionCalls()
+{
+}
+
+
+bool FunctionCalls::process(){
+  assert(isDataENetAllocated());
+  uint8_t* temp = data_+sizeof(uint32_t); //skip packetid
+  this->nrOfCalls_ = *(uint32_t*)temp;
+  temp += sizeof(uint32_t);
+  for( unsigned int i = 0; i<this->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;
+      }
+    }
+  }
+  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_;
+  
+}
+
+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());
+  
+  // 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)
+  {
+    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
+  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;
+  
+}
+
+
+} //namespace packet
+} //namespace orxonox


Property changes on: trunk/src/network/packet/FunctionCalls.cc
___________________________________________________________________
Added: svn:eol-style
   + native

Copied: trunk/src/network/packet/FunctionCalls.h (from rev 3083, branches/netp3/src/network/packet/FunctionCalls.h)
===================================================================
--- trunk/src/network/packet/FunctionCalls.h	                        (rev 0)
+++ trunk/src/network/packet/FunctionCalls.h	2009-05-26 19:20:57 UTC (rev 3084)
@@ -0,0 +1,46 @@
+
+#ifndef NETWORKFUNCTIONCALLS_H
+#define NETWORKFUNCTIONCALLS_H
+
+#include "../NetworkPrereqs.h"
+
+#include <string>
+#include <cstring>
+
+#include "Packet.h"
+#include <cassert>
+
+namespace orxonox {
+
+class MultiType;
+
+namespace packet {
+/**
+	@author
+*/
+
+
+class _NetworkExport FunctionCalls : public Packet
+{
+public:
+  FunctionCalls();
+  FunctionCalls( uint8_t* data, unsigned int clientID );
+  ~FunctionCalls();
+
+  inline unsigned int getSize() const
+    { assert(!this->isDataENetAllocated()); return currentSize_; }
+  bool process();
+
+  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);
+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
+};
+
+} //namespace packet
+} //namespace orxonox
+
+#endif


Property changes on: trunk/src/network/packet/FunctionCalls.h
___________________________________________________________________
Added: svn:eol-style
   + native

Copied: trunk/src/network/packet/FunctionIDs.cc (from rev 3083, branches/netp3/src/network/packet/FunctionIDs.cc)
===================================================================
--- trunk/src/network/packet/FunctionIDs.cc	                        (rev 0)
+++ trunk/src/network/packet/FunctionIDs.cc	2009-05-26 19:20:57 UTC (rev 3084)
@@ -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


Property changes on: trunk/src/network/packet/FunctionIDs.cc
___________________________________________________________________
Added: svn:eol-style
   + native

Copied: trunk/src/network/packet/FunctionIDs.h (from rev 3083, branches/netp3/src/network/packet/FunctionIDs.h)
===================================================================
--- trunk/src/network/packet/FunctionIDs.h	                        (rev 0)
+++ trunk/src/network/packet/FunctionIDs.h	2009-05-26 19:20:57 UTC (rev 3084)
@@ -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


Property changes on: trunk/src/network/packet/FunctionIDs.h
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: trunk/src/network/packet/Gamestate.cc
===================================================================
--- trunk/src/network/packet/Gamestate.cc	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/network/packet/Gamestate.cc	2009-05-26 19:20:57 UTC (rev 3084)
@@ -20,7 +20,7 @@
  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *
  *   Author:
- *      Oliver Scheuss, (C) 2008
+ *      Oliver Scheuss
  *   Co-authors:
  *      ...
  *
@@ -106,7 +106,12 @@
   ObjectList<Synchronisable>::iterator it;
   for(it = ObjectList<Synchronisable>::begin(); it; ++it){
     
-    tempsize=it->getSize(id, mode);
+//     tempsize=it->getSize(id, mode);
+
+    tempsize = it->getData(mem, id, mode);
+    if ( tempsize != 0 )
+      dataVector_.push_back( obj(it->getObjectID(), it->getCreatorID(), tempsize, mem-data_) );
+    
 #ifndef NDEBUG
     if(currentsize+tempsize > size){
       assert(0); // if we don't use multithreading this part shouldn't be neccessary
@@ -122,11 +127,8 @@
       size = currentsize+addsize;
     }// stop allocate additional memory
 #endif
-
-    if ( it->doSync( id, mode ) )
-      dataMap_.push_back( obj(it->getObjectID(), it->getCreatorID(), tempsize, mem-data_) );
-    if(!it->getData(mem, id, mode))
-      return false; // mem pointer gets automatically increased because of call by reference
+//     if(!it->getData(mem, id, mode))
+//       return false; // mem pointer gets automatically increased because of call by reference
     // increase size counter by size of current synchronisable
     currentsize+=tempsize;
   }
@@ -176,28 +178,31 @@
       assert(b);
     }
   }
-
    // In debug mode, check first, whether there are no duplicate objectIDs
 #ifndef NDEBUG
-  ObjectList<Synchronisable>::iterator it;
-  for (it = ObjectList<Synchronisable>::begin(); it != ObjectList<Synchronisable>::end(); ++it) {
-    if (it->getObjectID() == OBJECTID_UNKNOWN) {
-      if (it->objectMode_ != 0x0) {
-        COUT(0) << "Found object with OBJECTID_UNKNOWN on the client with objectMode != 0x0!" << std::endl;
-        COUT(0) << "Possible reason for this error: Client created a synchronized object without the Server's approval." << std::endl;
-        COUT(0) << "Objects class: " << it->getIdentifier()->getName() << std::endl;
-        assert(false);
+  if(this->getID()%1000==0){
+    std::list<uint32_t> v1;
+    ObjectList<Synchronisable>::iterator it;
+    for (it = ObjectList<Synchronisable>::begin(); it != ObjectList<Synchronisable>::end(); ++it) {
+      if (it->getObjectID() == OBJECTID_UNKNOWN) {
+        if (it->objectMode_ != 0x0) {
+          COUT(0) << "Found object with OBJECTID_UNKNOWN on the client with objectMode != 0x0!" << std::endl;
+          COUT(0) << "Possible reason for this error: Client created a synchronized object without the Server's approval." << std::endl;
+          COUT(0) << "Objects class: " << it->getIdentifier()->getName() << std::endl;
+          assert(false);
+        }
       }
-    }
-    else {
-      ObjectList<Synchronisable>::iterator it2;
-      for (it2 = ObjectList<Synchronisable>::begin(); it2 != ObjectList<Synchronisable>::end(); ++it2) {
-        if (it->getObjectID() == it2->getObjectID() && *it != *it2) {
-           COUT(0) << "Found duplicate objectIDs on the client!" << std::endl
-                   << "Are you sure you don't create a Sychnronisable objcect with 'new' \
-                       that doesn't have objectMode = 0x0?" << std::endl;
-           assert(false);
+      else {
+        std::list<uint32_t>::iterator it2;
+        for (it2 = v1.begin(); it2 != v1.end(); ++it2) {
+          if (it->getObjectID() == *it2) {
+            COUT(0) << "Found duplicate objectIDs on the client!" << std::endl
+                    << "Are you sure you don't create a Sychnronisable objcect with 'new' \
+                        that doesn't have objectMode = 0x0?" << std::endl;
+            assert(false);
+          }
         }
+        v1.push_back(it->getObjectID());
       }
     }
   }
@@ -220,16 +225,12 @@
 bool Gamestate::operator==(packet::Gamestate gs){
   uint8_t *d1 = data_+GamestateHeader::getSize();
   uint8_t *d2 = gs.data_+GamestateHeader::getSize();
+  GamestateHeader* h1 = new GamestateHeader(data_);
+  GamestateHeader* h2 = new GamestateHeader(gs.data_);
+  assert(h1->getDataSize() == h2->getDataSize());
   assert(!isCompressed());
   assert(!gs.isCompressed());
-  while(d1<data_+header_->getDataSize())
-  {
-    if(*d1!=*d2)
-      return false;
-    d1++;
-    d2++;
-  }
-  return true;
+  return memcmp(d1, d2, h1->getDataSize())==0;
 }
 
 bool Gamestate::process()
@@ -356,6 +357,58 @@
   return g;
 }
 
+// Gamestate *Gamestate::diff(Gamestate *base)
+// {
+//   assert(data_);
+//   assert(!header_->isCompressed());
+//   assert(!header_->isDiffed());
+//   GamestateHeader diffHeader(base->data_);
+//   uint8_t *basep = GAMESTATE_START(base->data_), *gs = GAMESTATE_START(this->data_);
+//   uint32_t of=0; // pointers offset
+//   uint32_t dest_length=0;
+//   dest_length=header_->getDataSize();
+//   if(dest_length==0)
+//     return NULL;
+//   uint8_t *ndata = new uint8_t[dest_length*sizeof(uint8_t)+GamestateHeader::getSize()];
+//   uint8_t *dest = ndata + GamestateHeader::getSize();
+//   
+//   
+//   // LOOP-UNROLLED DIFFING
+//   uint32_t *dest32 = (uint32_t*)dest, *base32 = (uint32_t*)basep, *gs32 = (uint32_t*)gs;
+//   // diff in 4-byte steps
+//   while( of < (uint32_t)(header_->getDataSize())/4 ){
+//     if( of < (uint32_t)(diffHeader.getDataSize())/4 )
+//     {
+//       *(dest32+of)=*(base32+of) ^ *(gs32+of); // do the xor
+//       ++of;
+//     }
+//     else
+//     {
+//       *(dest32+of)=*(gs32+of); // same as 0 ^ *(gs32+of)
+//       ++of;
+//     }
+//   }
+//   for( unsigned int of2 = 0; of2 < header_->getDataSize()%4; ++of2 )
+//   {
+//     if( of*4+of2 < diffHeader.getDataSize() )
+//     {
+//       *(dest+4*of+of2)=*(basep+4*of+of2) ^ *(gs+4*of+of2); // do the xor
+//     }
+//     else
+//     {
+//       *(dest+4*of+of2)=*(gs+4*of+of2); // same as 0 ^ *(gs32+of)
+//     }
+//   }
+// 
+//   Gamestate *g = new Gamestate(ndata, getClientID());
+//   *(g->header_) = *header_;
+//   g->header_->setDiffed( true );
+//   g->header_->setBaseID( base->getID() );
+//   g->flags_=flags_;
+//   g->packetDirection_ = packetDirection_;
+//   return g;
+// }
+
 Gamestate* Gamestate::doSelection(unsigned int clientID, unsigned int targetSize){
   assert(data_);
   std::list<obj>::iterator it;
@@ -377,10 +430,15 @@
   //Synchronisable *object;
 
   //call TrafficControl
-  TrafficControl::getInstance()->processObjectList( clientID, header_->getID(), &dataMap_ );
+  TrafficControl::getInstance()->processObjectList( clientID, header_->getID(), dataVector_ );
 
   //copy in the zeros
-  for(it=dataMap_.begin(); it!=dataMap_.end();){
+//   std::list<obj>::iterator itt;
+//   COUT(0) << "myvector contains:";
+//   for ( itt=dataVector_.begin() ; itt!=dataVector_.end(); itt++ )
+//     COUT(0) << " " << (*itt).objID;
+//   COUT(0) << endl;
+  for(it=dataVector_.begin(); it!=dataVector_.end();){
     SynchronisableHeader oldobjectheader(origdata);
     SynchronisableHeader newobjectheader(newdata);
     if ( (*it).objSize == 0 )

Modified: trunk/src/network/packet/Gamestate.h
===================================================================
--- trunk/src/network/packet/Gamestate.h	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/network/packet/Gamestate.h	2009-05-26 19:20:57 UTC (rev 3084)
@@ -20,7 +20,7 @@
  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *
  *   Author:
- *      Oliver Scheuss, (C) 2008
+ *      Oliver Scheuss
  *   Co-authors:
  *      ...
  *
@@ -36,7 +36,7 @@
 #include "network/TrafficControl.h"
 #include <string.h>
 #include <map>
-#include <list>
+#include <vector>
 #include <cassert>
 #ifndef NDEBUG
 #include "util/CRC32.h"
@@ -119,16 +119,16 @@
     Gamestate* doSelection(unsigned int clientID, unsigned int targetSize);
     bool compressData();
     bool decompressData();
+    bool operator ==(packet::Gamestate gs);
 
     // Packet functions
   private:
     virtual uint32_t getSize() const;
     virtual inline bool process();
 
-    bool operator ==(packet::Gamestate gs);
   private:
     uint32_t calcGamestateSize(int32_t id, uint8_t mode=0x0);
-    std::list<obj> dataMap_;
+    std::list<obj> dataVector_;
     GamestateHeader* header_;
 };
 

Modified: trunk/src/network/packet/Packet.cc
===================================================================
--- trunk/src/network/packet/Packet.cc	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/network/packet/Packet.cc	2009-05-26 19:20:57 UTC (rev 3084)
@@ -38,11 +38,13 @@
 #include "network/ClientInformation.h"
 
 #include "Acknowledgement.h"
+#include "DeleteObjects.h"
 #include "Chat.h"
 #include "ClassID.h"
+#include "FunctionCalls.h"
+#include "FunctionIDs.h"
 #include "Gamestate.h"
 #include "Welcome.h"
-#include "DeleteObjects.h"
 #include "network/Host.h"
 #include "core/CoreIncludes.h"
 
@@ -152,6 +154,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
@@ -169,34 +173,42 @@
   assert(ClientInformation::findClient(&peer->address)->getID() != (unsigned int)-2 || !Host::isServer());
   unsigned int clientID = ClientInformation::findClient(&peer->address)->getID();
   Packet *p = 0;
-  COUT(5) << "packet type: " << *(ENUM::Type *)&data[_PACKETID] << std::endl;
+  COUT(6) << "packet type: " << *(ENUM::Type *)&data[_PACKETID] << std::endl;
   switch( *(ENUM::Type *)(data + _PACKETID) )
   {
     case ENUM::Acknowledgement:
-      COUT(4) << "ack" << std::endl;
+      COUT(5) << "ack" << std::endl;
       p = new Acknowledgement( data, clientID );
       break;
     case ENUM::Chat:
-      COUT(4) << "chat" << std::endl;
+      COUT(5) << "chat" << std::endl;
       p = new Chat( data, clientID );
       break;
     case ENUM::ClassID:
-      COUT(4) << "classid" << std::endl;
+      COUT(5) << "classid" << std::endl;
       p = new ClassID( data, clientID );
       break;
     case ENUM::Gamestate:
-      COUT(4) << "gamestate" << std::endl;
+      COUT(5) << "gamestate" << std::endl;
       // TODO: remove brackets
       p = new Gamestate( data, clientID );
       break;
     case ENUM::Welcome:
-      COUT(4) << "welcome" << std::endl;
+      COUT(5) << "welcome" << std::endl;
       p = new Welcome( data, clientID );
       break;
     case ENUM::DeleteObjects:
-      COUT(4) << "deleteobjects" << std::endl;
+      COUT(5) << "deleteobjects" << std::endl;
       p = new DeleteObjects( data, clientID );
       break;
+    case ENUM::FunctionCalls:
+      COUT(5) << "functionCalls" << std::endl;
+      p = new FunctionCalls( data, clientID );
+      break;
+    case ENUM::FunctionIDs:
+      COUT(5) << "functionIDs" << std::endl;
+      p = new FunctionIDs( data, clientID );
+      break;
     default:
       assert(0); //TODO: repair this
       break;

Modified: trunk/src/network/packet/Packet.h
===================================================================
--- trunk/src/network/packet/Packet.h	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/network/packet/Packet.h	2009-05-26 19:20:57 UTC (rev 3084)
@@ -44,11 +44,13 @@
   };
   enum Type{
     Acknowledgement,
+    Chat,
+    ClassID,
+    DeleteObjects,
+    FunctionIDs,
+    FunctionCalls,
     Gamestate,
-    ClassID,
-    Chat,
-    Welcome,
-    DeleteObjects
+    Welcome
   };
 }
 
@@ -65,11 +67,11 @@
     virtual unsigned char *getData(){ return data_; };
     virtual unsigned int getSize() const =0;
     virtual bool process()=0;
-    uint32_t getFlags()
+    inline uint32_t getFlags()
       { return flags_; }
-    int getClientID()
+    inline int getClientID()
       { return clientID_; }
-    void setClientID( int id )
+    inline void setClientID( int id )
       { clientID_ = id; }
 
     bool send();
@@ -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: trunk/src/network/synchronisable/NetworkCallbackManager.cc
===================================================================
--- trunk/src/network/synchronisable/NetworkCallbackManager.cc	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/network/synchronisable/NetworkCallbackManager.cc	2009-05-26 19:20:57 UTC (rev 3084)
@@ -31,7 +31,7 @@
 #include "NetworkCallback.h"
 
 namespace orxonox{
-
+  
   std::set<NetworkCallbackBase*> NetworkCallbackManager::callbackSet_;
   std::queue<NetworkCallbackBase*> NetworkCallbackManager::triggeredCallbacks_;
   
@@ -59,7 +59,9 @@
   {
     while( triggeredCallbacks_.empty()==false )
     {
-      triggeredCallbacks_.front()->call();
+      //make sure callback hasn't been deleted before
+      if ( callbackSet_.find(triggeredCallbacks_.front()) != callbackSet_.end() )
+        triggeredCallbacks_.front()->call();
       triggeredCallbacks_.pop();
     }
   }

Modified: trunk/src/network/synchronisable/Synchronisable.cc
===================================================================
--- trunk/src/network/synchronisable/Synchronisable.cc	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/network/synchronisable/Synchronisable.cc	2009-05-26 19:20:57 UTC (rev 3084)
@@ -65,7 +65,9 @@
     else
       objectID=OBJECTID_UNKNOWN;
     classID = static_cast<uint32_t>(-1);
-
+    
+    // set dataSize to 0
+    this->dataSize_ = 0;
     // set standard priority
     this->setPriority( priority::normal );
 
@@ -95,7 +97,7 @@
   Synchronisable::~Synchronisable(){
     // delete callback function objects
     if(!Identifier::isCreatingHierarchy()){
-      for(std::list<SynchronisableVariableBase*>::iterator it = syncList.begin(); it!=syncList.end(); it++)
+      for(std::vector<SynchronisableVariableBase*>::iterator it = syncList.begin(); it!=syncList.end(); it++)
         delete (*it);
       if (this->objectMode_ != 0x0 && (Host::running() && Host::isServer()))
         deletedObjects_.push(objectID);
@@ -235,12 +237,12 @@
    *             0x3: bidirectional
    * @return true: if !doSync or if everything was successfully saved
    */
-  bool Synchronisable::getData(uint8_t*& mem, int32_t id, uint8_t mode){
+  uint32_t Synchronisable::getData(uint8_t*& mem, int32_t id, uint8_t mode){
     if(mode==0x0)
       mode=state_;
     //if this tick is we dont synchronise, then abort now
     if(!doSync(id, mode))
-      return true;
+      return 0;
     uint32_t tempsize = 0;
     if (this->classID==0)
       COUT(3) << "classid 0 " << this->getIdentifier()->getName() << std::endl;
@@ -249,30 +251,34 @@
         this->classID = this->getIdentifier()->getNetworkID();
 
     assert(this->classID==this->getIdentifier()->getNetworkID());
-    std::list<SynchronisableVariableBase*>::iterator i;
-    uint32_t size;
-    size=getSize(id, mode);
+    std::vector<SynchronisableVariableBase*>::iterator i;
 
     // start copy header
     SynchronisableHeader header(mem);
-    header.setDataSize( size );
-    header.setObjectID( this->objectID );
-    header.setCreatorID( this->creatorID );
-    header.setClassID( this->classID );
-    header.setDataAvailable( true );
-    tempsize += SynchronisableHeader::getSize();
     mem += SynchronisableHeader::getSize();
     // end copy header
 
 
-    COUT(5) << "Synchronisable getting data from objectID: " << objectID << " classID: " << classID << " length: " << size << std::endl;
+    COUT(5) << "Synchronisable getting data from objectID: " << objectID << " classID: " << classID << std::endl;
     // copy to location
     for(i=syncList.begin(); i!=syncList.end(); ++i){
-      (*i)->getData( mem, mode );
-      tempsize += (*i)->getSize( mode );
+      tempsize += (*i)->getData( mem, mode );
+      //tempsize += (*i)->getSize( mode );
     }
+    
+    tempsize += SynchronisableHeader::getSize();
+    header.setObjectID( this->objectID );
+    header.setCreatorID( this->creatorID );
+    header.setClassID( this->classID );
+    header.setDataAvailable( true );
+    header.setDataSize( tempsize );
+    
+#ifndef NDEBUG
+    uint32_t size;
+    size=getSize(id, mode);
     assert(tempsize==size);
-    return true;
+#endif
+    return tempsize;
   }
 
 
@@ -285,7 +291,7 @@
   bool Synchronisable::updateData(uint8_t*& mem, uint8_t mode, bool forceCallback){
     if(mode==0x0)
       mode=state_;
-    std::list<SynchronisableVariableBase *>::iterator i;
+    std::vector<SynchronisableVariableBase *>::iterator i;
     if(syncList.empty()){
       assert(0);
       COUT(4) << "Synchronisable::updateData syncList is empty" << std::endl;
@@ -324,12 +330,14 @@
   */
   uint32_t Synchronisable::getSize(int32_t id, uint8_t mode){
     int tsize=SynchronisableHeader::getSize();
-    if(mode==0x0)
+    if (mode==0x0)
       mode=state_;
-    if(!doSync(id, mode))
+    if (!doSync(id, mode))
       return 0;
-    std::list<SynchronisableVariableBase*>::iterator i;
-    for(i=syncList.begin(); i!=syncList.end(); i++){
+    assert( mode==state_ );
+    tsize += this->dataSize_;
+    std::vector<SynchronisableVariableBase*>::iterator i;
+    for(i=stringList.begin(); i!=stringList.end(); ++i){
       tsize += (*i)->getSize( mode );
     }
     return tsize;

Modified: trunk/src/network/synchronisable/Synchronisable.h
===================================================================
--- trunk/src/network/synchronisable/Synchronisable.h	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/network/synchronisable/Synchronisable.h	2009-05-26 19:20:57 UTC (rev 3084)
@@ -32,9 +32,11 @@
 #include "network/NetworkPrereqs.h"
 
 #include <list>
+#include <vector>
 #include <map>
 #include <queue>
 #include <cassert>
+#include <string>
 #include "util/Math.h"
 #include "util/mbool.h"
 #include "core/OrxonoxClass.h"
@@ -119,7 +121,6 @@
   class _NetworkExport Synchronisable : virtual public OrxonoxClass{
   public:
     friend class packet::Gamestate;
-//     friend class Server;
     virtual ~Synchronisable();
 
     static void setClient(bool b);
@@ -138,13 +139,13 @@
   protected:
     Synchronisable(BaseObject* creator);
     template <class T> void registerVariable(T& variable, uint8_t mode=0x1, NetworkCallbackBase *cb=0, bool bidirectional=false);
-    template <class T> void unregisterVariable(T& var);
+    //template <class T> void unregisterVariable(T& var);
     void setObjectMode(uint8_t mode);
     void setPriority(unsigned int freq){ objectFrequency_ = freq; }
 
 
   private:
-    bool getData(uint8_t*& men, int32_t id, uint8_t mode=0x0);
+    uint32_t getData(uint8_t*& men, int32_t id, uint8_t mode=0x0);
     uint32_t getSize(int32_t id, uint8_t mode=0x0);
     bool updateData(uint8_t*& mem, uint8_t mode=0x0, bool forceCallback=false);
     bool isMyData(uint8_t* mem);
@@ -154,7 +155,9 @@
     uint32_t creatorID;
     uint32_t classID;
 
-    std::list<SynchronisableVariableBase*> syncList;
+    std::vector<SynchronisableVariableBase*> syncList;
+    std::vector<SynchronisableVariableBase*> stringList;
+    uint32_t dataSize_; //size of all variables except strings
     static uint8_t state_; // detemines wheter we are server (default) or client
     bool backsync_; // if true the variables with mode > 1 will be synchronised to server (client -> server)
     unsigned int objectFrequency_;
@@ -163,31 +166,10 @@
     static std::queue<uint32_t> deletedObjects_;
   };
 
-  template <class T> void Synchronisable::registerVariable(T& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
-  {
-    if (bidirectional)
-      syncList.push_back(new SynchronisableVariableBidirectional<const T>(variable, mode, cb));
-    else
-      syncList.push_back(new SynchronisableVariable<const T>(variable, mode, cb));
-  }
-
-  template <class T> void Synchronisable::unregisterVariable(T& var){
-    std::list<SynchronisableVariableBase*>::iterator it = syncList.begin();
-    while(it!=syncList.end()){
-      if( ((*it)->getReference()) == &var ){
-        delete (*it);
-        syncList.erase(it);
-        return;
-      }
-      else
-        it++;
-    }
-    bool unregistered_nonexistent_variable = false;
-    assert(unregistered_nonexistent_variable); //if we reach this point something went wrong:
-    // the variable has not been registered before
-  }
-
   // ================= Specialisation declarations
+  
+//   template <> _NetworkExport void Synchronisable::registerVariable( const std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional);
+  template <> _NetworkExport void Synchronisable::registerVariable( std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional);
   template <> _NetworkExport void Synchronisable::registerVariable( const ColourValue& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
   template <> _NetworkExport void Synchronisable::registerVariable( ColourValue& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
   template <> _NetworkExport void Synchronisable::registerVariable( const Vector2& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
@@ -199,6 +181,41 @@
   template <> _NetworkExport void Synchronisable::registerVariable( mbool& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
   template <> _NetworkExport void Synchronisable::registerVariable( const Quaternion& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
   template <> _NetworkExport void Synchronisable::registerVariable( Quaternion& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
+  
+  template <class T> void Synchronisable::registerVariable(T& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
+  {
+    if (bidirectional)
+    {
+      syncList.push_back(new SynchronisableVariableBidirectional<const T>(variable, mode, cb));
+      this->dataSize_ += syncList.back()->getSize(state_);
+    }
+    else
+    {
+      syncList.push_back(new SynchronisableVariable<const T>(variable, mode, cb));
+      if ( this->state_ == mode )
+        this->dataSize_ += syncList.back()->getSize(state_);
+    }
+  }
+  
+
+
+//   template <class T> void Synchronisable::unregisterVariable(T& var){
+//     std::vector<SynchronisableVariableBase*>::iterator it = syncList.begin();
+//     while(it!=syncList.end()){
+//       if( ((*it)->getReference()) == &var ){
+//         delete (*it);
+//         syncList.erase(it);
+//         return;
+//       }
+//       else
+//         it++;
+//     }
+//     bool unregistered_nonexistent_variable = false;
+//     assert(unregistered_nonexistent_variable); //if we reach this point something went wrong:
+//     // the variable has not been registered before
+//   }
+
+  
 }
 
 #endif /* _Synchronisable_H__ */

Modified: trunk/src/network/synchronisable/SynchronisableSpecialisations.cc
===================================================================
--- trunk/src/network/synchronisable/SynchronisableSpecialisations.cc	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/network/synchronisable/SynchronisableSpecialisations.cc	2009-05-26 19:20:57 UTC (rev 3084)
@@ -28,12 +28,31 @@
  */
 
 #include "network/synchronisable/Synchronisable.h"
+#include <string>
 
 // ================ template spezialisation
   
   
 namespace orxonox{
   
+//   template <> void Synchronisable::registerVariable( const std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
+//   {
+//     if (bidirectional)
+//       syncList.push_back(new SynchronisableVariableBidirectional<const std::string>(variable, mode, cb));
+//     else
+//       syncList.push_back(new SynchronisableVariable<const std::string>(variable, mode, cb));
+//     stringList.push_back(syncList.back());
+//   }
+  
+  template <> void Synchronisable::registerVariable( std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
+  {
+    if (bidirectional)
+      syncList.push_back(new SynchronisableVariableBidirectional<const std::string>(variable, mode, cb));
+    else
+      syncList.push_back(new SynchronisableVariable<const std::string>(variable, mode, cb));
+    stringList.push_back(syncList.back());
+  }
+  
   template <> void Synchronisable::registerVariable( const ColourValue& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
   {
     registerVariable(variable.r, mode, cb, bidirectional);
@@ -51,10 +70,10 @@
     registerVariable(variable.x, mode, cb, bidirectional);
     registerVariable(variable.y, mode, cb, bidirectional);
   }
-  template <> void Synchronisable::registerVariable( Vector2& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
-  {
-    registerVariable( (const ColourValue&)variable, mode, cb, bidirectional);
-  }
+//   template <> void Synchronisable::registerVariable( Vector2& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
+//   {
+//     registerVariable( (const ColourValue&)variable, mode, cb, bidirectional);
+//   }
   
   template <> void Synchronisable::registerVariable( const Vector3& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
   {

Deleted: trunk/src/network/synchronisable/SynchronisableVariable.cc
===================================================================
--- trunk/src/network/synchronisable/SynchronisableVariable.cc	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/network/synchronisable/SynchronisableVariable.cc	2009-05-26 19:20:57 UTC (rev 3084)
@@ -1,441 +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 "SynchronisableVariable.h"
-#include <cstring>
-#include "util/Math.h"
-#include "core/GameMode.h"
-
-
-namespace orxonox{
-
-uint8_t SynchronisableVariableBase::state_ = 0;
-
-/*static*/ void SynchronisableVariableBase::setState()
-{
-  if ( state_ == 0x0 )
-  {
-    state_ = GameMode::isMaster() ? 0x1 : 0x2;  // set the appropriate mode here
-  }
-}
-
-
-// =================== Template specialisation stuff =============
-
-// =========== bool
-
-template <> uint32_t SynchronisableVariable<const bool>::returnSize()
-{
-  return sizeof(uint8_t);
-}
-
-template <> void SynchronisableVariable<const bool>::setAndIncrease( uint8_t*& mem )
-{
-  *(uint8_t*)(&this->variable_) = *static_cast<uint8_t*>(mem);
-  mem += SynchronisableVariable<const bool>::returnSize();
-}
-
-template <> void SynchronisableVariable<const bool>::getAndIncrease( uint8_t*& mem )
-{
-  *static_cast<uint8_t*>(mem) = *(uint8_t*)(&this->variable_);
-  mem += SynchronisableVariable<const bool>::returnSize();
-}
-
-template <> bool SynchronisableVariable<const bool>::checkEquality( uint8_t* mem )
-{
-  return *static_cast<uint8_t*>(mem) == *(uint8_t*)(&this->variable_);
-}
-
-// =========== char
-
-template <> uint32_t SynchronisableVariable<const char>::returnSize()
-{
-  return sizeof(uint8_t);
-}
-
-template <> void SynchronisableVariable<const char>::setAndIncrease( uint8_t*& mem )
-{
-  *(uint8_t*)(&this->variable_) = *static_cast<uint8_t*>(mem);
-  mem += SynchronisableVariable<const char>::returnSize();
-}
-
-template <> void SynchronisableVariable<const char>::getAndIncrease( uint8_t*& mem )
-{
-  *static_cast<uint8_t*>(mem) = *(uint8_t*)(&this->variable_);
-  mem += SynchronisableVariable<const char>::returnSize();
-}
-
-template <> bool SynchronisableVariable<const char>::checkEquality( uint8_t* mem )
-{
-  return *static_cast<uint8_t*>(mem) == *(uint8_t*)(&this->variable_);
-}
-
-// =========== unsigned char
-
-template <> uint32_t SynchronisableVariable<const unsigned char>::returnSize()
-{
-  return sizeof(uint8_t);
-}
-
-template <> 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 <> 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 <> bool SynchronisableVariable<const unsigned char>::checkEquality( uint8_t* mem )
-{
-  return *static_cast<uint8_t*>(mem) == *(uint8_t*)(&this->variable_);
-}
-
-// =========== short
-
-template <> uint32_t SynchronisableVariable<const short>::returnSize()
-{
-  return sizeof(int16_t);
-}
-
-template <> void SynchronisableVariable<const short>::setAndIncrease( uint8_t*& mem )
-{
-  *(short*)(&this->variable_) = *(int16_t*)(mem);
-  mem += SynchronisableVariable<const short>::returnSize();
-}
-
-template <> void SynchronisableVariable<const short>::getAndIncrease( uint8_t*& mem )
-{
-  *(int16_t*)(mem) = this->variable_;
-  mem += SynchronisableVariable<const short>::returnSize();
-}
-
-template <> bool SynchronisableVariable<const short>::checkEquality( uint8_t* mem )
-{
-  return *(int16_t*)(mem) == static_cast<int16_t>(this->variable_);
-}
-
-// =========== unsigned short
-
-template <> uint32_t SynchronisableVariable<const unsigned short>::returnSize()
-{
-  return sizeof(uint16_t);
-}
-
-template <> void SynchronisableVariable<const unsigned short>::setAndIncrease( uint8_t*& mem )
-{
-  *(unsigned short*)(&this->variable_) = *(uint16_t*)(mem);
-  mem += SynchronisableVariable<const unsigned short>::returnSize();
-}
-
-template <> void SynchronisableVariable<const unsigned short>::getAndIncrease( uint8_t*& mem )
-{
-  *(uint16_t*)(mem) = this->variable_;
-  mem += SynchronisableVariable<const unsigned short>::returnSize();
-}
-
-template <> bool SynchronisableVariable<const unsigned short>::checkEquality( uint8_t* mem )
-{
-  return *(uint16_t*)(mem) == this->variable_;
-}
-
-// =========== int
-
-template <> uint32_t SynchronisableVariable<const int>::returnSize()
-{
-  return sizeof(int32_t);
-}
-
-template <> void SynchronisableVariable<const int>::setAndIncrease( uint8_t*& mem )
-{
-  *(int *)(&this->variable_) = *(int32_t*)(mem);
-  mem += SynchronisableVariable<const int>::returnSize();
-}
-
-template <> void SynchronisableVariable<const int>::getAndIncrease( uint8_t*& mem )
-{
-  *(int32_t*)(mem) = this->variable_;
-  mem += SynchronisableVariable<const int>::returnSize();
-}
-
-template <> bool SynchronisableVariable<const int>::checkEquality( uint8_t* mem )
-{
-  return *(int32_t*)(mem) == this->variable_;
-}
-
-// =========== unsigned int
-
-template <> uint32_t SynchronisableVariable<const unsigned int>::returnSize()
-{
-  return sizeof(uint32_t);
-}
-    
-template <> void SynchronisableVariable<const unsigned int>::setAndIncrease( uint8_t*& mem )
-{
-  *(unsigned int*)(&this->variable_) = *(uint32_t*)(mem);
-  mem += SynchronisableVariable<const unsigned int>::returnSize();
-}
-
-template <> void SynchronisableVariable<const unsigned int>::getAndIncrease( uint8_t*& mem )
-{
-  *(uint32_t*)(mem) = this->variable_;
-  mem += SynchronisableVariable<const unsigned int>::returnSize();
-}
-
-template <> bool SynchronisableVariable<const unsigned int>::checkEquality( uint8_t* mem )
-{
-  return *(uint32_t*)(mem) == this->variable_;
-}
-
-// =========== long
-
-template <> uint32_t SynchronisableVariable<const long>::returnSize()
-{
-  return sizeof(int32_t);
-}
-
-template <> void SynchronisableVariable<const long>::setAndIncrease( uint8_t*& mem )
-{
-  *(long*)(&this->variable_) = *(int32_t*)(mem);
-  mem += SynchronisableVariable<const long>::returnSize();
-}
-
-template <> void SynchronisableVariable<const long>::getAndIncrease( uint8_t*& mem )
-{
-  *(int32_t*)(mem) = this->variable_;
-  mem += SynchronisableVariable<const long>::returnSize();
-}
-
-template <> bool SynchronisableVariable<const long>::checkEquality( uint8_t* mem )
-{
-  return *(int32_t*)(mem) == this->variable_;
-}
-
-// =========== unsigned long
-
-template <> uint32_t SynchronisableVariable<const unsigned long>::returnSize()
-{
-  return sizeof(uint32_t);
-}
-
-template <> void SynchronisableVariable<const unsigned long>::setAndIncrease( uint8_t*& mem )
-{
-  *(unsigned long*)(&this->variable_) = *(uint32_t*)(mem);
-  mem += SynchronisableVariable<const unsigned long>::returnSize();
-}
-
-template <> void SynchronisableVariable<const unsigned long>::getAndIncrease( uint8_t*& mem )
-{
-  *(uint32_t*)(mem) = this->variable_;
-  mem += SynchronisableVariable<const unsigned long>::returnSize();
-}
-
-template <> bool SynchronisableVariable<const unsigned long>::checkEquality( uint8_t* mem )
-{
-  return *(uint32_t*)(mem) == this->variable_;
-}
-
-// =========== long long
-
-template <> uint32_t SynchronisableVariable<const long long>::returnSize()
-{
-  return sizeof(int64_t);
-}
-
-template <> void SynchronisableVariable<const long long>::setAndIncrease( uint8_t*& mem )
-{
-  *(long long*)(&this->variable_) = *(int64_t*)(mem);
-  mem += SynchronisableVariable<const long long>::returnSize();
-}
-
-template <> void SynchronisableVariable<const long long>::getAndIncrease( uint8_t*& mem )
-{
-  *(int64_t*)(mem) = this->variable_;
-  mem += SynchronisableVariable<const long long>::returnSize();
-}
-
-template <> bool SynchronisableVariable<const long long>::checkEquality( uint8_t* mem )
-{
-  return *(int64_t*)(mem) == this->variable_;
-}
-
-// =========== unsigned long long
-
-template <> uint32_t SynchronisableVariable<const unsigned long long>::returnSize()
-{
-  return sizeof(uint64_t);
-}
-
-template <> 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 <> void SynchronisableVariable<const unsigned long long>::getAndIncrease( uint8_t*& mem )
-{
-  *(uint64_t*)(mem) = this->variable_;
-  mem += SynchronisableVariable<const unsigned long long>::returnSize();
-}
-
-template <> bool SynchronisableVariable<const unsigned long long>::checkEquality( uint8_t* mem )
-{
-  return *(uint64_t*)(mem) == this->variable_;
-}
-
-// =========== float
-
-template <> uint32_t SynchronisableVariable<const float>::returnSize()
-{
-  return sizeof(uint32_t);
-}
-
-template <> void SynchronisableVariable<const float>::setAndIncrease( uint8_t*& mem )
-{
-  *(uint32_t*)(&this->variable_) = *(uint32_t*)(mem);
-  mem += SynchronisableVariable<const float>::returnSize();
-}
-
-template <> void SynchronisableVariable<const float>::getAndIncrease( uint8_t*& mem )
-{
-  *(uint32_t*)(mem) = *(uint32_t*)(&this->variable_);
-  mem += SynchronisableVariable<const float>::returnSize();
-}
-
-template <> bool SynchronisableVariable<const float>::checkEquality( uint8_t* mem )
-{
-  return *(uint32_t*)(mem) == *(uint32_t*)(&this->variable_);
-}
-
-// =========== double
-
-template <> uint32_t SynchronisableVariable<const double>::returnSize()
-{
-  return sizeof(uint64_t);
-}
-
-template <> void SynchronisableVariable<const double>::setAndIncrease( uint8_t*& mem )
-{
-  *(uint64_t*)(&this->variable_) = *(uint64_t*)(mem);
-  mem += SynchronisableVariable<const double>::returnSize();
-}
-
-template <> void SynchronisableVariable<const double>::getAndIncrease( uint8_t*& mem )
-{
-  *(uint64_t*)(mem) = *(uint64_t*)(&this->variable_);
-  mem += SynchronisableVariable<const double>::returnSize();
-}
-
-template <> bool SynchronisableVariable<const double>::checkEquality( uint8_t* mem )
-{
-  return *(uint64_t*)(mem) == *(uint64_t*)(&this->variable_);
-}
-
-// =========== long double
-
-template <> uint32_t SynchronisableVariable<const long double>::returnSize()
-{
-  return sizeof(uint64_t);
-}
-
-template <> 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 <> 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 <> 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 <> uint32_t SynchronisableVariable<const std::string>::returnSize()
-{
-  return variable_.length()+1;
-}
-
-template <> 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 <> void SynchronisableVariable<const std::string>::setAndIncrease( uint8_t*& mem )
-{
-  *(std::string*)(&this->variable_) = std::string((const char *)mem);
-  mem += this->variable_.length()+1;
-}
-
-template <> bool SynchronisableVariable<const std::string>::checkEquality( uint8_t* mem )
-{
-  return std::string((const char*)mem)==this->variable_;
-}
-
-// =========== Degree
-
-template <> uint32_t SynchronisableVariable<const Degree>::returnSize()
-{
-  return sizeof(Ogre::Real);
-}
-
-template <> void SynchronisableVariable<const Degree>::getAndIncrease( uint8_t*& mem )
-{
-  Ogre::Real r = this->variable_.valueDegrees();
-  memcpy(mem, &r, returnSize());
-  mem += returnSize();
-}
-
-template <> void SynchronisableVariable<const Degree>::setAndIncrease( uint8_t*& mem )
-{
-  Ogre::Real* r = (Ogre::Real*)mem;
-  (Degree&)this->variable_ = *r;
-  mem += returnSize();
-}
-
-template <> bool SynchronisableVariable<const Degree>::checkEquality( uint8_t* mem )
-{
-  Ogre::Real* r = (Ogre::Real*)mem;
-  return this->variable_==Degree(*r);
-}
-
-}

Copied: trunk/src/network/synchronisable/SynchronisableVariable.cc (from rev 3083, branches/netp3/src/network/synchronisable/SynchronisableVariable.cc)
===================================================================
--- trunk/src/network/synchronisable/SynchronisableVariable.cc	                        (rev 0)
+++ trunk/src/network/synchronisable/SynchronisableVariable.cc	2009-05-26 19:20:57 UTC (rev 3084)
@@ -0,0 +1,37 @@
+/*
+ *   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 "SynchronisableVariable.h"
+
+
+namespace orxonox{
+
+uint8_t SynchronisableVariableBase::state_ = 0;
+
+
+} //namespace


Property changes on: trunk/src/network/synchronisable/SynchronisableVariable.cc
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: trunk/src/network/synchronisable/SynchronisableVariable.h
===================================================================
--- trunk/src/network/synchronisable/SynchronisableVariable.h	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/network/synchronisable/SynchronisableVariable.h	2009-05-26 19:20:57 UTC (rev 3084)
@@ -20,7 +20,7 @@
  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *
  *   Author:
- *      Oliver Scheuss, (C) 2008
+ *      Oliver Scheuss
  *   Co-authors:
  *      ...
  *
@@ -34,7 +34,10 @@
 
 #include <string>
 #include <cassert>
-#include "util/Math.h"
+#include "util/Serialise.h"
+#include "core/Core.h"
+#include "core/CoreIncludes.h"
+#include "core/GameMode.h"
 #include "network/synchronisable/NetworkCallback.h"
 #include "network/synchronisable/NetworkCallbackManager.h"
 
@@ -54,14 +57,13 @@
   class _NetworkExport SynchronisableVariableBase
   {
     public:
-      virtual void getData(uint8_t*& mem, uint8_t mode)=0;
+      virtual uint32_t getData(uint8_t*& mem, uint8_t mode)=0;
       virtual void putData(uint8_t*& mem, uint8_t mode, bool forceCallback = false)=0;
       virtual uint32_t getSize(uint8_t mode)=0;
       virtual void* getReference()=0;
       virtual uint8_t getMode()=0;
       virtual ~SynchronisableVariableBase() {}
     protected:
-      static void setState();
       static uint8_t state_;
   };
 
@@ -73,15 +75,11 @@
       virtual ~SynchronisableVariable();
 
       virtual inline uint8_t getMode(){ return mode_; }
-      virtual inline void getData(uint8_t*& mem, uint8_t mode);
+      virtual inline uint32_t getData(uint8_t*& mem, uint8_t mode);
       virtual inline void putData(uint8_t*& mem, uint8_t mode, bool forceCallback = false);
       virtual inline uint32_t getSize(uint8_t mode);
       virtual inline void* getReference(){ return (void *)&this->variable_; }
     protected:
-      bool checkEquality(uint8_t* mem);
-      void setAndIncrease(uint8_t*& mem);
-      void getAndIncrease(uint8_t*& mem);
-      uint32_t returnSize();
       
       T& variable_;
       uint8_t mode_;
@@ -96,9 +94,9 @@
       virtual ~SynchronisableVariableBidirectional();
       
       virtual inline uint8_t getMode(){ return 0x3; } //this basically is a hack ^^
-      virtual void getData(uint8_t*& mem, uint8_t mode);
+      virtual inline uint32_t getData(uint8_t*& mem, uint8_t mode);
       virtual void putData(uint8_t*& mem, uint8_t mode, bool forceCallback = false);
-      virtual uint32_t getSize(uint8_t mode);
+      virtual inline uint32_t getSize(uint8_t mode);
     private:
       T varBuffer_;
       uint8_t varReference_;
@@ -109,7 +107,10 @@
   template <class T> SynchronisableVariable<T>::SynchronisableVariable(T& variable, uint8_t syncDirection, NetworkCallbackBase *cb):
       variable_( variable ), mode_( syncDirection ), callback_( cb )
   {
-      setState();
+    if ( state_ == 0x0 )
+    {
+      state_ = GameMode::isMaster() ? 0x1 : 0x2;  // set the appropriate mode here
+    }
   }
   
   template <class T> SynchronisableVariable<T>::~SynchronisableVariable()
@@ -118,11 +119,15 @@
       NetworkCallbackManager::deleteCallback(this->callback_); //safe call for deletion
   }
 
-  template <class T> void SynchronisableVariable<T>::getData(uint8_t*& mem, uint8_t mode)
+  template <class T> inline uint32_t SynchronisableVariable<T>::getData(uint8_t*& mem, uint8_t mode)
   {
     if ( state_ == this->mode_ )
-      getAndIncrease( mem );
-//   mem += SynchronisableVariable<T>::getSize();
+    {
+      saveAndIncrease( this->variable_, mem );
+      return returnSize( this->variable_ );
+    }
+    else
+      return 0;
   }
 
   template <class T> void SynchronisableVariable<T>::putData(uint8_t*& mem, uint8_t mode, bool forceCallback)
@@ -134,86 +139,24 @@
   // check whether we need to consider a callback
     if ( this->callback_ != 0 )
     {
-      if( forceCallback || !checkEquality( mem ) )
+      if( forceCallback || !checkEquality( this->variable_, mem ) )
         callback = true;
     }
   // write the data
-    setAndIncrease( mem );
-//   mem += SynchronisableVariable<T>::getSize();
+    loadAndIncrease( this->variable_, mem );
   // now do a callback if neccessary
     if ( callback )
       NetworkCallbackManager::triggerCallback( this->callback_ );
-      //this->callback_->call();
   }
 
-  template <class T> uint32_t SynchronisableVariable<T>::getSize(uint8_t mode)
+  template <class T> inline uint32_t SynchronisableVariable<T>::getSize(uint8_t mode)
   {
     if ( mode == this->mode_ )
-      return returnSize();
+      return returnSize( this->variable_ );
     else
       return 0;
   }
 
-  template <> _NetworkExport uint32_t SynchronisableVariable<const bool>::returnSize();
-  template <> _NetworkExport void     SynchronisableVariable<const bool>::setAndIncrease(uint8_t*& mem);
-  template <> _NetworkExport void     SynchronisableVariable<const bool>::getAndIncrease(uint8_t*& mem);
-  template <> _NetworkExport bool     SynchronisableVariable<const bool>::checkEquality(uint8_t* mem);
-  template <> _NetworkExport uint32_t SynchronisableVariable<const unsigned char>::returnSize();
-  template <> _NetworkExport void     SynchronisableVariable<const unsigned char>::setAndIncrease(uint8_t*& mem);
-  template <> _NetworkExport void     SynchronisableVariable<const unsigned char>::getAndIncrease(uint8_t*& mem);
-  template <> _NetworkExport bool     SynchronisableVariable<const unsigned char>::checkEquality(uint8_t* mem);
-  template <> _NetworkExport uint32_t SynchronisableVariable<const short>::returnSize();
-  template <> _NetworkExport void     SynchronisableVariable<const short>::setAndIncrease(uint8_t*& mem);
-  template <> _NetworkExport void     SynchronisableVariable<const short>::getAndIncrease(uint8_t*& mem);
-  template <> _NetworkExport bool     SynchronisableVariable<const short>::checkEquality(uint8_t* mem);
-  template <> _NetworkExport uint32_t SynchronisableVariable<const unsigned short>::returnSize();
-  template <> _NetworkExport void     SynchronisableVariable<const unsigned short>::setAndIncrease(uint8_t*& mem);
-  template <> _NetworkExport void     SynchronisableVariable<const unsigned short>::getAndIncrease(uint8_t*& mem);
-  template <> _NetworkExport bool     SynchronisableVariable<const unsigned short>::checkEquality(uint8_t* mem);
-  template <> _NetworkExport uint32_t SynchronisableVariable<const int>::returnSize();
-  template <> _NetworkExport void     SynchronisableVariable<const int>::setAndIncrease(uint8_t*& mem);
-  template <> _NetworkExport void     SynchronisableVariable<const int>::getAndIncrease(uint8_t*& mem);
-  template <> _NetworkExport bool     SynchronisableVariable<const int>::checkEquality(uint8_t* mem);
-  template <> _NetworkExport uint32_t SynchronisableVariable<const unsigned int>::returnSize();
-  template <> _NetworkExport void     SynchronisableVariable<const unsigned int>::setAndIncrease(uint8_t*& mem);
-  template <> _NetworkExport void     SynchronisableVariable<const unsigned int>::getAndIncrease(uint8_t*& mem);
-  template <> _NetworkExport bool     SynchronisableVariable<const unsigned int>::checkEquality(uint8_t* mem);
-  template <> _NetworkExport uint32_t SynchronisableVariable<const long>::returnSize();
-  template <> _NetworkExport void     SynchronisableVariable<const long>::setAndIncrease(uint8_t*& mem);
-  template <> _NetworkExport void     SynchronisableVariable<const long>::getAndIncrease(uint8_t*& mem);
-  template <> _NetworkExport bool     SynchronisableVariable<const long>::checkEquality(uint8_t* mem);
-  template <> _NetworkExport uint32_t SynchronisableVariable<const unsigned long>::returnSize();
-  template <> _NetworkExport void     SynchronisableVariable<const unsigned long>::setAndIncrease(uint8_t*& mem);
-  template <> _NetworkExport void     SynchronisableVariable<const unsigned long>::getAndIncrease(uint8_t*& mem);
-  template <> _NetworkExport bool     SynchronisableVariable<const unsigned long>::checkEquality(uint8_t* mem);
-  template <> _NetworkExport uint32_t SynchronisableVariable<const long long>::returnSize();
-  template <> _NetworkExport void     SynchronisableVariable<const long long>::setAndIncrease(uint8_t*& mem);
-  template <> _NetworkExport void     SynchronisableVariable<const long long>::getAndIncrease(uint8_t*& mem);
-  template <> _NetworkExport bool     SynchronisableVariable<const long long>::checkEquality(uint8_t* mem);
-  template <> _NetworkExport uint32_t SynchronisableVariable<const unsigned long long>::returnSize();
-  template <> _NetworkExport void     SynchronisableVariable<const unsigned long long>::setAndIncrease(uint8_t*& mem);
-  template <> _NetworkExport void     SynchronisableVariable<const unsigned long long>::getAndIncrease(uint8_t*& mem);
-  template <> _NetworkExport bool     SynchronisableVariable<const unsigned long long>::checkEquality(uint8_t* mem);
-  template <> _NetworkExport uint32_t SynchronisableVariable<const float>::returnSize();
-  template <> _NetworkExport void     SynchronisableVariable<const float>::setAndIncrease(uint8_t*& mem);
-  template <> _NetworkExport void     SynchronisableVariable<const float>::getAndIncrease(uint8_t*& mem);
-  template <> _NetworkExport bool     SynchronisableVariable<const float>::checkEquality(uint8_t* mem);
-  template <> _NetworkExport uint32_t SynchronisableVariable<const double>::returnSize();
-  template <> _NetworkExport void     SynchronisableVariable<const double>::setAndIncrease(uint8_t*& mem);
-  template <> _NetworkExport void     SynchronisableVariable<const double>::getAndIncrease(uint8_t*& mem);
-  template <> _NetworkExport bool     SynchronisableVariable<const double>::checkEquality(uint8_t* mem);
-  template <> _NetworkExport uint32_t SynchronisableVariable<const long double>::returnSize();
-  template <> _NetworkExport void     SynchronisableVariable<const long double>::setAndIncrease(uint8_t*& mem);
-  template <> _NetworkExport void     SynchronisableVariable<const long double>::getAndIncrease(uint8_t*& mem);
-  template <> _NetworkExport bool     SynchronisableVariable<const long double>::checkEquality(uint8_t* mem);
-  template <> _NetworkExport uint32_t SynchronisableVariable<const std::string>::returnSize();
-  template <> _NetworkExport void     SynchronisableVariable<const std::string>::setAndIncrease(uint8_t*& mem);
-  template <> _NetworkExport void     SynchronisableVariable<const std::string>::getAndIncrease(uint8_t*& mem);
-  template <> _NetworkExport bool     SynchronisableVariable<const std::string>::checkEquality(uint8_t* mem);
-  template <> _NetworkExport uint32_t SynchronisableVariable<const Degree>::returnSize();
-  template <> _NetworkExport void     SynchronisableVariable<const Degree>::setAndIncrease(uint8_t*& mem);
-  template <> _NetworkExport void     SynchronisableVariable<const Degree>::getAndIncrease(uint8_t*& mem);
-  template <> _NetworkExport bool     SynchronisableVariable<const Degree>::checkEquality(uint8_t* mem);
 
 
 
@@ -228,7 +171,7 @@
     {
     }
 
-    template <class T> void SynchronisableVariableBidirectional<T>::getData(uint8_t*& mem, uint8_t mode)
+    template <class T> uint32_t SynchronisableVariableBidirectional<T>::getData(uint8_t*& mem, uint8_t mode)
     {
       if ( this->mode_ == mode )
       {   // we are master for this variable and have to check whether to change the varReference
@@ -242,8 +185,8 @@
       *static_cast<uint8_t*>(mem) = varReference_;
       mem += sizeof(this->varReference_);
   // now write the content
-      SynchronisableVariable<T>::getAndIncrease( mem );
-//   mem += SynchronisableVariable<T>::getSize();
+      saveAndIncrease( this->variable_, mem );
+      return SynchronisableVariableBidirectional::getSize(mode);
     }
 
     template <class T> void SynchronisableVariableBidirectional<T>::putData(uint8_t*& mem, uint8_t mode, bool forceCallback)
@@ -254,19 +197,20 @@
         // check that the client (source of the data) has a recent version of this variable
         if ( *static_cast<uint8_t*>(mem) != this->varReference_ )
         { // wrong reference number, so discard the data
+//           COUT(0) << "discharding data" << endl;
           mem += getSize( mode ); // SynchronisableVariableBidirectional::getSize returns size of variable + reference
           return;
         }
         else{
           // apply data
-          mem += sizeof(varReference_);
-          if ( SynchronisableVariableBidirectional<T>::checkEquality( mem )==true )
+          if ( checkEquality( this->variable_, mem+sizeof(varReference_) )==true )
           {
-            mem += SynchronisableVariable<T>::getSize( mode );
+            mem += getSize( mode );
             return;
           }
           else
           {
+            mem += sizeof(varReference_);
             memcpy((void*)&this->varBuffer_, &this->variable_, sizeof(T));
             if ( this->callback_ != 0 )
               callback = true;
@@ -284,7 +228,7 @@
         {
           this->varReference_ = *static_cast<uint8_t*>(mem);
           mem += sizeof(varReference_);
-          if ( SynchronisableVariable<T>::checkEquality( mem ) == false )
+          if ( checkEquality( this->variable_, mem ) == false )
           {
             // value changed so remark for callback
             if ( this->callback_ != 0 )
@@ -293,16 +237,15 @@
         }
       }
   // now write the data
-      SynchronisableVariable<T>::setAndIncrease(mem);
+      loadAndIncrease(this->variable_, mem);
   // now do a callback if neccessary
       if ( callback )
         NetworkCallbackManager::triggerCallback( this->callback_ );
-        //this->callback_->call();
     }
 
-    template <class T> uint32_t SynchronisableVariableBidirectional<T>::getSize(uint8_t mode)
+    template <class T> inline uint32_t SynchronisableVariableBidirectional<T>::getSize(uint8_t mode)
     {
-      return SynchronisableVariable<T>::returnSize() + sizeof(varReference_);
+      return returnSize( this->variable_ ) + sizeof(varReference_);
     }
   
 

Modified: trunk/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- trunk/src/orxonox/OrxonoxPrereqs.h	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/orxonox/OrxonoxPrereqs.h	2009-05-26 19:20:57 UTC (rev 3084)
@@ -139,6 +139,7 @@
     class CameraPosition;
     class SpawnPoint;
     class TeamSpawnPoint;
+    class Test;
 
     class Spectator;
     class Pawn;

Modified: trunk/src/orxonox/gamestates/GSGraphics.cc
===================================================================
--- trunk/src/orxonox/gamestates/GSGraphics.cc	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/orxonox/gamestates/GSGraphics.cc	2009-05-26 19:20:57 UTC (rev 3084)
@@ -56,10 +56,10 @@
 
 namespace orxonox
 {
-    AddGameState(GSGraphics, "graphics");
+    AddGameState(GSGraphics, "graphics", false);
 
-    GSGraphics::GSGraphics(const std::string& name)
-        : GameState(name)
+    GSGraphics::GSGraphics(const std::string& name, bool countTickTime)
+        : GameState(name, countTickTime)
         , inputManager_(0)
         , console_(0)
         , guiManager_(0)
@@ -212,15 +212,16 @@
 
         uint64_t timeBeforeTick = time.getRealMicroseconds();
 
-        this->inputManager_->update(time);        // tick console
+        this->inputManager_->update(time);
         this->console_->update(time);
-        this->guiManager_->update(time);
 
         uint64_t timeAfterTick = time.getRealMicroseconds();
 
         // Also add our tick time
         Game::getInstance().addTickTime(timeAfterTick - timeBeforeTick);
 
+        // Process gui events
+        this->guiManager_->update(time);
         // Render
         this->graphicsManager_->update(time);
     }

Modified: trunk/src/orxonox/gamestates/GSGraphics.h
===================================================================
--- trunk/src/orxonox/gamestates/GSGraphics.h	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/orxonox/gamestates/GSGraphics.h	2009-05-26 19:20:57 UTC (rev 3084)
@@ -50,7 +50,7 @@
     class _OrxonoxExport GSGraphics : public GameState, public WindowEventListener
     {
     public:
-        GSGraphics(const std::string& name);
+        GSGraphics(const std::string& name, bool countTickTime);
         ~GSGraphics();
         void setConfigValues();
 

Modified: trunk/src/orxonox/gamestates/GSRoot.cc
===================================================================
--- trunk/src/orxonox/gamestates/GSRoot.cc	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/orxonox/gamestates/GSRoot.cc	2009-05-26 19:20:57 UTC (rev 3084)
@@ -42,7 +42,7 @@
 
 namespace orxonox
 {
-    AddGameState(GSRoot, "root");
+    AddGameState(GSRoot, "root", false);
     SetCommandLineSwitch(console);
     // Shortcuts for easy direct loading
     SetCommandLineSwitch(server);
@@ -50,8 +50,8 @@
     SetCommandLineSwitch(dedicated);
     SetCommandLineSwitch(standalone);
 
-    GSRoot::GSRoot(const std::string& name)
-        : GameState(name)
+    GSRoot::GSRoot(const std::string& name, bool countTickTime)
+        : GameState(name, countTickTime)
         , timeFactor_(1.0f)
         , bPaused_(false)
         , timeFactorPauseBackup_(1.0f)

Modified: trunk/src/orxonox/gamestates/GSRoot.h
===================================================================
--- trunk/src/orxonox/gamestates/GSRoot.h	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/orxonox/gamestates/GSRoot.h	2009-05-26 19:20:57 UTC (rev 3084)
@@ -38,7 +38,7 @@
     class _OrxonoxExport GSRoot : public GameState
     {
     public:
-        GSRoot(const std::string& name);
+        GSRoot(const std::string& name, bool countTickTime);
         ~GSRoot();
 
         void activate();

Modified: trunk/src/orxonox/objects/CMakeLists.txt
===================================================================
--- trunk/src/orxonox/objects/CMakeLists.txt	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/orxonox/objects/CMakeLists.txt	2009-05-26 19:20:57 UTC (rev 3084)
@@ -9,7 +9,6 @@
   RadarViewable.cc
   Teamcolourable.cc
   Tickable.cc
-  Test.cc
   Scene.cc
   Script.cc
 )

Modified: trunk/src/orxonox/objects/Test.cc
===================================================================
--- trunk/src/orxonox/objects/Test.cc	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/orxonox/objects/Test.cc	2009-05-26 19:20:57 UTC (rev 3084)
@@ -30,7 +30,9 @@
 #include "core/CoreIncludes.h"
 #include "core/ConfigValueIncludes.h"
 #include "core/ConsoleCommand.h"
+#include "network/NetworkFunction.h"
 #include "Test.h"
+#include "util/MultiType.h"
 
 namespace orxonox
 {
@@ -40,7 +42,18 @@
   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);
+  SetConsoleCommand(Test, call2, 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 );
+  registerMemberNetworkFunction( Test, checkU1 );
+  registerMemberNetworkFunction( Test, printBlaBla );
+  
   Test* Test::instance_ = 0;
 
 	Test::Test(BaseObject* creator) : BaseObject(creator), Synchronisable(creator)
@@ -72,19 +85,54 @@
 	}
 
 
-	void Test::registerVariables()
-	{
-		registerVariable ( u1, variableDirection::toclient, new NetworkCallback<Test> ( this, &Test::checkU1 ));
+  void Test::registerVariables()
+  {
+    registerVariable ( u1, variableDirection::toclient, new NetworkCallback<Test> ( this, &Test::checkU1 ));
     registerVariable ( u2, variableDirection::toserver, new NetworkCallback<Test> ( this, &Test::checkU2 ));
-		registerVariable ( u3, variableDirection::serverMaster, new NetworkCallback<Test> ( this, &Test::checkU3 ), true );
+    registerVariable ( u3, variableDirection::serverMaster, new NetworkCallback<Test> ( this, &Test::checkU3 ), true );
     registerVariable ( u4, variableDirection::clientMaster, new NetworkCallback<Test> ( this, &Test::checkU4 ), true );
     
     registerVariable ( s1, variableDirection::toclient, new NetworkCallback<Test> ( this, &Test::checkS1 ));
     registerVariable ( s2, variableDirection::toserver, new NetworkCallback<Test> ( this, &Test::checkS2 ));
     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 );
+    callStaticNetworkFunction( &Test::printV1, clientID );
+  }
+  
+  void Test::call2(unsigned int clientID, std::string s1, std::string s2, std::string s3, std::string s4)
+  {
+    callMemberNetworkFunction( Test, printBlaBla, this->getObjectID(), clientID, s1, s2, s3, s4, s4 );
+  }
+  
+  void Test::tick(float dt)
+  {
+//     std::string str1 = "blub";
+//     //MultiType mt1(std::string("blub"));
+//     MultiType mt1(str1);
+//     uint8_t* mem = new uint8_t[mt1.getNetworkSize()];
+//     uint8_t* temp = mem;
+//     mt1.exportData( temp );
+//     assert( temp-mem == mt1.getNetworkSize() );
+//     MultiType mt2;
+//     temp = mem;
+//     mt2.importData( temp );
+//     assert( temp-mem == mt1.getNetworkSize() );
+//     COUT(0) << mt2 << endl;
+    if(!Core::isMaster())
+      call2(0, "bal", "a", "n", "ce");
+//       callMemberNetworkFunction( Test, checkU1, this->getObjectID(), 0 );
+  }
+  
+  void Test::printBlaBla(std::string s1, std::string s2, std::string s3, std::string s4, std::string s5)
+  {
+    COUT(0) << s1 << s2 << s3 << s4 << s5 << endl;
+  }
+  
   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: trunk/src/orxonox/objects/Test.h
===================================================================
--- trunk/src/orxonox/objects/Test.h	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/orxonox/objects/Test.h	2009-05-26 19:20:57 UTC (rev 3084)
@@ -32,6 +32,7 @@
 #include "OrxonoxPrereqs.h"
 #include "core/BaseObject.h"
 #include "network/synchronisable/Synchronisable.h"
+#include "Tickable.h"
 
 
 typedef int TYPE;
@@ -40,7 +41,7 @@
 
 namespace orxonox
 {
-  class _OrxonoxExport Test: public BaseObject, public Synchronisable
+  class _OrxonoxExport Test: public BaseObject, public Synchronisable, public Tickable
   {
     public:
       Test(BaseObject* creator);
@@ -48,6 +49,10 @@
 
       void setConfigValues();
       void registerVariables();
+      
+      static void call(unsigned int clientID);
+      void call2(unsigned int clientID, std::string s1, std::string s2, std::string s3, std::string s4);
+      virtual void tick(float dt);
 
 
       //unsigned functions
@@ -74,6 +79,8 @@
       static void printV2(){ instance_->checkU2(); }
       static void printV3(){ instance_->checkU3(); }
       static void printV4(){ instance_->checkU4(); }
+      
+      void printBlaBla(std::string s1, std::string s2, std::string s3, std::string s4, std::string s5);
 
     private:
       UTYPE u1;

Modified: trunk/src/orxonox/objects/controllers/AIController.cc
===================================================================
--- trunk/src/orxonox/objects/controllers/AIController.cc	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/orxonox/objects/controllers/AIController.cc	2009-05-26 19:20:57 UTC (rev 3084)
@@ -29,7 +29,6 @@
 #include "OrxonoxStableHeaders.h"
 #include "AIController.h"
 
-#include "core/GameMode.h"
 #include "core/CoreIncludes.h"
 #include "core/Executor.h"
 #include "objects/worldentities/ControllableEntity.h"
@@ -44,8 +43,7 @@
     {
         RegisterObject(AIController);
 
-        if (GameMode::isMaster())
-            this->actionTimer_.setTimer(ACTION_INTERVAL, true, this, createExecutor(createFunctor(&AIController::action)));
+        this->actionTimer_.setTimer(ACTION_INTERVAL, true, this, createExecutor(createFunctor(&AIController::action)));
     }
 
     AIController::~AIController()

Modified: trunk/src/orxonox/objects/worldentities/ControllableEntity.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/ControllableEntity.cc	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/orxonox/objects/worldentities/ControllableEntity.cc	2009-05-26 19:20:57 UTC (rev 3084)
@@ -378,6 +378,7 @@
         registerVariable(this->client_linear_velocity_,  variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientLinearVelocity));
         registerVariable(this->client_orientation_,      variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientOrientation));
         registerVariable(this->client_angular_velocity_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientAngularVelocity));
+        
 
         registerVariable(this->playerID_,                variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedplayerID));
     }

Modified: trunk/src/orxonox/objects/worldentities/MobileEntity.h
===================================================================
--- trunk/src/orxonox/objects/worldentities/MobileEntity.h	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/orxonox/objects/worldentities/MobileEntity.h	2009-05-26 19:20:57 UTC (rev 3084)
@@ -60,7 +60,7 @@
             inline void setAngularVelocity(float x, float y, float z)
                 { this->setAngularVelocity(Vector3(x, y, z)); }
             inline const Vector3& getAngularVelocity() const
-                { return this->linearAcceleration_; }
+                { return this->angularVelocity_; }
 
             void setAcceleration(const Vector3& acceleration);
             inline void setAcceleration(float x, float y, float z)

Modified: trunk/src/orxonox/objects/worldentities/PongBall.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/PongBall.cc	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/orxonox/objects/worldentities/PongBall.cc	2009-05-26 19:20:57 UTC (rev 3084)
@@ -31,7 +31,6 @@
 
 #include "core/CoreIncludes.h"
 #include "core/GameMode.h"
-#include "objects/worldentities/PongBat.h"
 #include "objects/gametypes/Gametype.h"
 
 namespace orxonox
@@ -46,8 +45,24 @@
 
         this->speed_ = 0;
         this->bat_ = 0;
+        this->batID_ = new unsigned int[2];
+        this->batID_[0] = OBJECTID_UNKNOWN;
+        this->batID_[1] = OBJECTID_UNKNOWN;
         this->relMercyOffset_ = 0.05;
+        
+        this->registerVariables();
     }
+    
+    void PongBall::registerVariables()
+    {
+        registerVariable( this->fieldWidth_ );
+        registerVariable( this->fieldHeight_ );
+        registerVariable( this->batlength_ );
+        registerVariable( this->speed_ );
+        registerVariable( this->relMercyOffset_ );
+        registerVariable( this->batID_[0] );
+        registerVariable( this->batID_[1], variableDirection::toclient, new NetworkCallback<PongBall>( this, &PongBall::applyBats) );
+    }
 
     void PongBall::tick(float dt)
     {
@@ -118,6 +133,55 @@
             if (position != this->getPosition())
                 this->setPosition(position);
         }
+        else
+        {
+          Vector3 position = this->getPosition();
+          Vector3 velocity = this->getVelocity();
+
+          if (position.z > this->fieldHeight_ / 2 || position.z < -this->fieldHeight_ / 2)
+          {
+            velocity.z = -velocity.z;
+
+            if (position.z > this->fieldHeight_ / 2)
+              position.z = this->fieldHeight_ / 2;
+            if (position.z < -this->fieldHeight_ / 2)
+              position.z = -this->fieldHeight_ / 2;
+          }
+
+          if (position.x > this->fieldWidth_ / 2 || position.x < -this->fieldWidth_ / 2)
+          {
+            float distance = 0;
+
+            if (this->bat_)
+            {
+              if (position.x > this->fieldWidth_ / 2 && this->bat_[1])
+              {
+                distance = (position.z - this->bat_[1]->getPosition().z) / (this->fieldHeight_ * (this->batlength_ * 1.10) / 2);
+                if (fabs(distance) <= 1)
+                {
+                  position.x = this->fieldWidth_ / 2;
+                  velocity.x = -velocity.x;
+                  velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_;
+                }
+              }
+              if (position.x < -this->fieldWidth_ / 2 && this->bat_[0])
+              {
+                distance = (position.z - this->bat_[0]->getPosition().z) / (this->fieldHeight_ * (this->batlength_ * 1.10) / 2);
+                if (fabs(distance) <= 1)
+                {
+                  position.x = -this->fieldWidth_ / 2;
+                  velocity.x = -velocity.x;
+                  velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_;
+                }
+              }
+            }
+          }
+
+          if (velocity != this->getVelocity())
+            this->setVelocity(velocity);
+          if (position != this->getPosition())
+            this->setPosition(position);
+        }
     }
 
     void PongBall::setSpeed(float speed)

Modified: trunk/src/orxonox/objects/worldentities/PongBall.h
===================================================================
--- trunk/src/orxonox/objects/worldentities/PongBall.h	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/orxonox/objects/worldentities/PongBall.h	2009-05-26 19:20:57 UTC (rev 3084)
@@ -32,6 +32,7 @@
 #include "OrxonoxPrereqs.h"
 
 #include "objects/worldentities/MovableEntity.h"
+#include "objects/worldentities/PongBat.h"
 
 namespace orxonox
 {
@@ -42,6 +43,8 @@
             virtual ~PongBall() {}
 
             virtual void tick(float dt);
+            
+            void registerVariables();
 
             void setFieldDimension(float width, float height)
                 { this->fieldWidth_ = width; this->fieldHeight_ = height; }
@@ -60,7 +63,10 @@
                 { return this->batlength_; }
 
             void setBats(PongBat** bats)
-                { this->bat_ = bats; }
+            { this->bat_ = bats; this->batID_[0] = this->bat_[0]->getObjectID(); this->batID_[1] = this->bat_[1]->getObjectID(); }
+            
+            void applyBats()
+            { if(!this->bat_) this->bat_ = new PongBat*[2]; if(this->batID_[0] != OBJECTID_UNKNOWN) this->bat_[0] = dynamic_cast<PongBat*>(Synchronisable::getSynchronisable(this->batID_[0])); if(this->batID_[1] != OBJECTID_UNKNOWN) this->bat_[1] = dynamic_cast<PongBat*>(Synchronisable::getSynchronisable(this->batID_[1])); }
 
             static const float MAX_REL_Z_VELOCITY;
 
@@ -70,6 +76,7 @@
             float speed_;
             float batlength_;
             PongBat** bat_;
+            unsigned int* batID_;
             float relMercyOffset_;
     };
 }

Modified: trunk/src/orxonox/objects/worldentities/PongBat.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/PongBat.cc	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/orxonox/objects/worldentities/PongBat.cc	2009-05-26 19:20:57 UTC (rev 3084)
@@ -53,8 +53,8 @@
     void PongBat::registerVariables()
     {
         registerVariable(this->speed_);
-        registerVariable(this->speed_);
-        registerVariable(this->speed_);
+        registerVariable(this->fieldHeight_);
+        registerVariable(this->length_);
     }
 
     void PongBat::tick(float dt)
@@ -90,13 +90,16 @@
         if (position.z < -this->fieldHeight_ / 2 + this->fieldHeight_ * this->length_ / 2)
             position.z = -this->fieldHeight_ / 2 + this->fieldHeight_ * this->length_ / 2;
         if (position != this->getPosition())
+        {
             this->setPosition(position);
+            this->setVelocity( Vector3::ZERO );
+        }
     }
 
     void PongBat::moveFrontBack(const Vector2& value)
     {
         this->bMoveLocal_ = false;
-        this->movement_ -= value.x;
+        this->movement_ = -value.x;
     }
 
     void PongBat::moveRightLeft(const Vector2& value)

Modified: trunk/src/orxonox/objects/worldentities/pawns/Pawn.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/pawns/Pawn.cc	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/orxonox/objects/worldentities/pawns/Pawn.cc	2009-05-26 19:20:57 UTC (rev 3084)
@@ -38,15 +38,20 @@
 #include "objects/gametypes/Gametype.h"
 #include "objects/worldentities/ParticleSpawner.h"
 #include "objects/worldentities/ExplosionChunk.h"
+
 #include "objects/weaponsystem/WeaponSystem.h"
 #include "objects/weaponsystem/WeaponSlot.h"
 #include "objects/weaponsystem/WeaponPack.h"
 #include "objects/weaponsystem/WeaponSet.h"
 
+#include "network/NetworkFunction.h"
+
 namespace orxonox
 {
     CreateFactory(Pawn);
 
+    registerMemberNetworkFunction( Pawn, doFire );
+
     Pawn::Pawn(BaseObject* creator) : ControllableEntity(creator)
     {
         RegisterObject(Pawn);
@@ -122,21 +127,22 @@
     {
         SUPER(Pawn, tick, dt);
 
-        if (this->weaponSystem_ && GameMode::isMaster())
-        {
-            for (unsigned int firemode = 0; firemode < WeaponSystem::MAX_FIRE_MODES; firemode++)
-                if (this->fire_ & WeaponSystem::getFiremodeMask(firemode))
-                    this->weaponSystem_->fire(firemode);
-
-            if (this->bReload_)
-                this->weaponSystem_->reload();
-        }
-
-        this->fire_ = this->firehack_;
-        this->firehack_ = 0x0;
+//        if (this->weaponSystem_ && GameMode::isMaster())
+//        {
+//            for (unsigned int firemode = 0; firemode < WeaponSystem::MAX_FIRE_MODES; firemode++)
+//                if (this->fire_ & WeaponSystem::getFiremodeMask(firemode))
+//                    this->weaponSystem_->fire(firemode);
+//
+//            if (this->bReload_)
+//                this->weaponSystem_->reload();
+//        }
+//
+//        this->fire_ = this->firehack_;
+//        this->firehack_ = 0x0;
         this->bReload_ = false;
 
-        if (this->health_ <= 0)
+        if (GameMode::isMaster())
+          if (this->health_ <= 0)
             this->death();
     }
 
@@ -262,9 +268,24 @@
 
     void Pawn::fire(unsigned int firemode)
     {
-        this->firehack_ |= WeaponSystem::getFiremodeMask(firemode);
+        this->doFire(firemode);
     }
 
+    void Pawn::doFire(uint8_t firemode)
+    {
+        if(GameMode::isMaster())
+        {
+            if (this->weaponSystem_)
+                this->weaponSystem_->fire(firemode);
+        }
+        else
+        {
+            callMemberNetworkFunction(Pawn, doFire, this->getObjectID(), 0, ((uint8_t)firemode));
+            if (this->weaponSystem_)
+                this->weaponSystem_->fire(firemode);
+        }
+    }
+
     void Pawn::reload()
     {
         this->bReload_ = true;

Modified: trunk/src/orxonox/objects/worldentities/pawns/Pawn.h
===================================================================
--- trunk/src/orxonox/objects/worldentities/pawns/Pawn.h	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/orxonox/objects/worldentities/pawns/Pawn.h	2009-05-26 19:20:57 UTC (rev 3084)
@@ -78,6 +78,7 @@
 
             virtual void fire(unsigned int firemode);
             virtual void reload();
+            virtual void doFire(uint8_t firemode);
             virtual void postSpawn();
 
             void addWeaponSlot(WeaponSlot * wSlot);

Modified: trunk/src/util/MultiType.h
===================================================================
--- trunk/src/util/MultiType.h	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/util/MultiType.h	2009-05-26 19:20:57 UTC (rev 3084)
@@ -79,30 +79,30 @@
     */
     enum MT_Type
     {
-        MT_null,
-        MT_char,
-        MT_uchar,
-        MT_short,
-        MT_ushort,
-        MT_int,
-        MT_uint,
-        MT_long,
-        MT_ulong,
-        MT_longlong,
-        MT_ulonglong,
-        MT_float,
-        MT_double,
-        MT_longdouble,
-        MT_bool,
-        MT_void,
-        MT_string,
-        MT_vector2,
-        MT_vector3,
-        MT_vector4,
-        MT_colourvalue,
-        MT_quaternion,
-        MT_radian,
-        MT_degree
+        MT_null=0,
+        MT_char=1,
+        MT_uchar=2,
+        MT_short=3,
+        MT_ushort=4,
+        MT_int=5,
+        MT_uint=6,
+        MT_long=7,
+        MT_ulong=8,
+        MT_longlong=9,
+        MT_ulonglong=10,
+        MT_float=11,
+        MT_double=12,
+        MT_longdouble=13,
+        MT_bool=14,
+        MT_void=15,
+        MT_string=16,
+        MT_vector2=17,
+        MT_vector3=18,
+        MT_vector4=19,
+        MT_colourvalue=20,
+        MT_quaternion=21,
+        MT_radian=22,
+        MT_degree=23
     };
 
     /**
@@ -222,6 +222,10 @@
             virtual operator orxonox::Degree()      const = 0;
 
             virtual void toString(std::ostream& outstream) const = 0;
+            
+            virtual void importData( uint8_t*& mem )=0;
+            virtual void exportData( uint8_t*& mem ) const=0;
+            virtual uint8_t getSize() const=0;
 
             MT_Type type_;          //!< The type of the current value
             bool bHasDefaultValue_; //!< True if the last conversion wasn't successful
@@ -319,6 +323,16 @@
             /** @brief Returns true if the current type is T. */
             template <typename T> inline bool isType()                  const { return false; } // Only works for specialized values - see below
             std::string                       getTypename()             const;
+            
+            /** @brief Saves the value of the MT to a bytestream (pointed at by mem) and increases mem pointer by size of MT */
+            inline void                       exportData(uint8_t*& mem) const { assert(sizeof(MT_Type)<=8); *(uint8_t*)(mem) = this->getType(); mem+=sizeof(uint8_t); this->value_->exportData(mem); }
+            /** @brief Loads the value of the MT from a bytestream (pointed at by mem) and increases mem pointer by size of MT */
+            inline void                       importData(uint8_t*& mem) { assert(sizeof(MT_Type)<=8); this->setType(static_cast<MT_Type>(*(uint8_t*)mem)); mem+=sizeof(uint8_t); this->value_->importData(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; }
+            /** @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) const { exportData(mem); }
+            inline uint32_t                   getNetworkSize() const { 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(); }

Modified: trunk/src/util/MultiTypeValue.h
===================================================================
--- trunk/src/util/MultiTypeValue.h	2009-05-26 18:11:37 UTC (rev 3083)
+++ trunk/src/util/MultiTypeValue.h	2009-05-26 19:20:57 UTC (rev 3084)
@@ -39,6 +39,8 @@
 #include "UtilPrereqs.h"
 #include "MathConvert.h"
 #include "MultiType.h"
+#include "Serialise.h"
+#include <cassert>
 
 namespace orxonox
 {
@@ -146,9 +148,118 @@
 
         /** @brief Puts the current value on the stream */
         inline void toString(std::ostream& outstream) const { outstream << this->value_; }
+        
+        /** @brief loads data from the bytestream (mem) into the MT and increases the bytestream pointer by the size of the data */
+        inline void importData( uint8_t*& mem )         { loadAndIncrease( /*(const T&)*/this->value_, mem ); }
+        /** @brief saves data from the MT into the bytestream (mem) and increases the bytestream pointer by the size of the data */
+        inline void exportData( uint8_t*& mem ) const   { saveAndIncrease( /*(const T&)*/this->value_, mem ); }
+        /** @brief returns the size of the data that would be saved by exportData */
+        inline uint8_t getSize() const { return returnSize( this->value_ ); }
 
         T value_; //!< The stored value
     };
+    
+    // Import / Export specialisation
+    // ColourValue
+    template <> inline void MT_Value<ColourValue>::importData( uint8_t*& mem )
+    {
+        loadAndIncrease( this->value_.r, mem );
+        loadAndIncrease( this->value_.g, mem );
+        loadAndIncrease( this->value_.b, mem );
+        loadAndIncrease( this->value_.a, mem );
+    }
+    template <> inline void MT_Value<ColourValue>::exportData( uint8_t*& mem ) const
+    {
+        saveAndIncrease( this->value_.r, mem );
+        saveAndIncrease( this->value_.g, mem );
+        saveAndIncrease( this->value_.b, mem );
+        saveAndIncrease( this->value_.a, mem );
+    }
+    template <> inline uint8_t MT_Value<ColourValue>::getSize() const
+    {
+        return 4*returnSize(this->value_.r);
+    }
+    // Ogre::Quaternion
+    template <> inline void MT_Value<Ogre::Quaternion>::importData( uint8_t*& mem )
+    {
+        loadAndIncrease( this->value_.x, mem );
+        loadAndIncrease( this->value_.y, mem );
+        loadAndIncrease( this->value_.z, mem );
+        loadAndIncrease( this->value_.w, mem );
+    }
+    template <> inline void MT_Value<Ogre::Quaternion>::exportData( uint8_t*& mem ) const
+    {
+        saveAndIncrease( this->value_.x, mem );
+        saveAndIncrease( this->value_.y, mem );
+        saveAndIncrease( this->value_.z, mem );
+        saveAndIncrease( this->value_.w, mem );
+    }template <> inline uint8_t MT_Value<Ogre::Quaternion>::getSize() const
+    {
+        return 4*returnSize(this->value_.x);
+    }
+    // Ogre::Vector2
+    template <> inline void MT_Value<Ogre::Vector2>::importData( uint8_t*& mem )
+    {
+        loadAndIncrease( this->value_.x, mem );
+        loadAndIncrease( this->value_.y, mem );
+    }
+    template <> inline void MT_Value<Ogre::Vector2>::exportData( uint8_t*& mem ) const
+    {
+        saveAndIncrease( this->value_.x, mem );
+        saveAndIncrease( this->value_.y, mem );
+    }
+    template <> inline uint8_t MT_Value<Ogre::Vector2>::getSize() const
+    {
+        return 2*returnSize(this->value_.x);
+    }
+    // Ogre::Vector3
+    template <> inline void MT_Value<Ogre::Vector3>::importData( uint8_t*& mem )
+    {
+        loadAndIncrease( this->value_.x, mem );
+        loadAndIncrease( this->value_.y, mem );
+        loadAndIncrease( this->value_.z, mem );
+    }
+    template <> inline void MT_Value<Ogre::Vector3>::exportData( uint8_t*& mem ) const
+    {
+        saveAndIncrease( this->value_.x, mem );
+        saveAndIncrease( this->value_.y, mem );
+        saveAndIncrease( this->value_.z, mem );
+    }
+    template <> inline uint8_t MT_Value<Ogre::Vector3>::getSize() const
+    {
+        return 3*returnSize(this->value_.x);
+    }
+    // Ogre::Vector4
+    template <> inline void MT_Value<Ogre::Vector4>::importData( uint8_t*& mem )
+    {
+        loadAndIncrease( this->value_.x, mem );
+        loadAndIncrease( this->value_.y, mem );
+        loadAndIncrease( this->value_.z, mem );
+        loadAndIncrease( this->value_.w, mem );
+    }
+    template <> inline void MT_Value<Ogre::Vector4>::exportData( uint8_t*& mem ) const
+    {
+        saveAndIncrease( this->value_.x, mem );
+        saveAndIncrease( this->value_.y, mem );
+        saveAndIncrease( this->value_.z, mem );
+        saveAndIncrease( this->value_.w, mem );
+    }
+    template <> inline uint8_t MT_Value<Ogre::Vector4>::getSize() const
+    {
+        return 4*returnSize(this->value_.x);
+    }
+    template <> inline void MT_Value<void*>::importData( uint8_t*& mem )
+    {
+        assert(0);
+    }
+    template <> inline void MT_Value<void*>::exportData( uint8_t*& mem ) const
+    {
+        assert(0);
+    }
+    template <> inline uint8_t MT_Value<void*>::getSize() const
+    {
+        assert(0); return 0;
+    }
 }
 
 #endif /* _MultiTypeValue_H__ */

Copied: trunk/src/util/Serialise.h (from rev 3083, branches/netp3/src/util/Serialise.h)
===================================================================
--- trunk/src/util/Serialise.h	                        (rev 0)
+++ trunk/src/util/Serialise.h	2009-05-26 19:20:57 UTC (rev 3084)
@@ -0,0 +1,477 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @brief Functions to serialise most of the types/classed used in Orxonox
+*/
+
+#ifndef _Serialise_H__
+#define _Serialise_H__
+
+#include <cstring>
+#include "util/Math.h"
+
+namespace orxonox{
+    
+// general template declaration
+    
+    /** @brief returns the size of the variable in a datastream */
+    template <class T> inline uint32_t returnSize( const T& );
+    /** @brief loads the value of a variable out of the bytestream and increases the mem pointer */
+    template <class T> inline void loadAndIncrease( const T&, uint8_t*& );
+    /** @brief saves the value of a variable into the bytestream and increases the mem pointer */
+    template <class T> inline void saveAndIncrease( const T&, uint8_t*& );
+    /** @brief checks whether the variable of type T is the same as in the bytestream */
+    template <class T> inline  bool checkEquality( const T&, uint8_t* );
+
+// =================== Template specialisation stuff =============
+
+// =========== bool
+
+    template <> inline uint32_t returnSize( const bool& variable )
+    {
+        return sizeof(uint8_t);
+    }
+
+    template <> inline void loadAndIncrease( const bool& variable, uint8_t*& mem )
+    {
+        *(uint8_t*)( &variable ) = *static_cast<uint8_t*>(mem);
+        mem += returnSize( variable );
+    }
+
+    template <> inline void saveAndIncrease( const bool& variable, uint8_t*& mem )
+    {
+        *static_cast<uint8_t*>(mem) = *(uint8_t*)( &variable );
+        mem += returnSize( variable );
+    }
+
+    template <> inline bool checkEquality( const bool& variable, uint8_t* mem )
+    {
+        return *static_cast<uint8_t*>(mem) == *(uint8_t*)( &variable );
+    }
+
+// =========== char
+
+    template <> inline uint32_t returnSize( const char& variable )
+    {
+        return sizeof(uint8_t);
+    }
+
+    template <> inline void loadAndIncrease( const char& variable, uint8_t*& mem )
+    {
+        *(uint8_t*)( &variable ) = *static_cast<uint8_t*>(mem);
+        mem += returnSize( variable );
+    }
+
+    template <> inline void saveAndIncrease( const char& variable, uint8_t*& mem )
+    {
+        *static_cast<uint8_t*>(mem) = *(uint8_t*)( &variable );
+        mem += returnSize( variable );
+    }
+
+    template <> inline bool checkEquality( const char& variable, uint8_t* mem )
+    {
+        return *static_cast<uint8_t*>(mem) == *(uint8_t*)( &variable );
+    }
+
+// =========== unsigned char
+
+    template <> inline uint32_t returnSize( const unsigned char& variable )
+    {
+        return sizeof(uint8_t);
+    }
+
+    template <> inline void loadAndIncrease( const unsigned char& variable, uint8_t*& mem )
+    {
+        *(uint8_t*)( &variable ) = *static_cast<uint8_t*>(mem);
+        mem += returnSize( variable );
+    }
+
+    template <> inline void saveAndIncrease( const unsigned char& variable, uint8_t*& mem )
+    {
+        *static_cast<uint8_t*>(mem) = *(uint8_t*)( &variable );
+        mem += returnSize( variable );
+    }
+
+    template <> inline bool checkEquality( const unsigned char& variable, uint8_t* mem )
+    {
+        return *static_cast<uint8_t*>(mem) == *(uint8_t*)( &variable );
+    }
+
+// =========== short
+
+    template <> inline uint32_t returnSize( const short& variable )
+    {
+        return sizeof(int16_t);
+    }
+
+    template <> inline void loadAndIncrease( const short& variable, uint8_t*& mem )
+    {
+        *(short*)( &variable ) = *(int16_t*)(mem);
+        mem += returnSize( variable );
+    }
+
+    template <> inline void saveAndIncrease( const short& variable, uint8_t*& mem )
+    {
+        *(int16_t*)(mem) = variable;
+        mem += returnSize( variable );
+    }
+
+    template <> inline bool checkEquality( const short& variable, uint8_t* mem )
+    {
+        return *(int16_t*)(mem) == static_cast<int16_t>(variable);
+    }
+
+// =========== unsigned short
+
+    template <> inline uint32_t returnSize( const unsigned short& variable )
+    {
+        return sizeof(uint16_t);
+    }
+
+    template <> inline void loadAndIncrease( const unsigned short& variable, uint8_t*& mem )
+    {
+        *(unsigned short*)( &variable ) = *(uint16_t*)(mem);
+        mem += returnSize( variable );
+    }
+
+    template <> inline void saveAndIncrease( const unsigned short& variable, uint8_t*& mem )
+    {
+        *(uint16_t*)(mem) = variable;
+        mem += returnSize( variable );
+    }
+
+    template <> inline bool checkEquality( const unsigned short& variable, uint8_t* mem )
+    {
+        return *(uint16_t*)(mem) == variable;
+    }
+
+// =========== int
+
+    template <> inline uint32_t returnSize( const int& variable )
+    {
+        return sizeof(int32_t);
+    }
+
+    template <> inline void loadAndIncrease( const int& variable, uint8_t*& mem )
+    {
+        *(int *)( &variable ) = *(int32_t*)(mem);
+        mem += returnSize( variable );
+    }
+
+    template <> inline void saveAndIncrease( const int& variable, uint8_t*& mem )
+    {
+        *(int32_t*)(mem) = variable;
+        mem += returnSize( variable );
+    }
+
+    template <> inline bool checkEquality( const int& variable, uint8_t* mem )
+    {
+        return *(int32_t*)(mem) == variable;
+    }
+
+// =========== unsigned int
+
+    template <> inline uint32_t returnSize( const unsigned int& variable )
+    {
+        return sizeof(uint32_t);
+    }
+    
+    template <> inline void loadAndIncrease( const unsigned int& variable, uint8_t*& mem )
+    {
+        *(unsigned int*)( &variable ) = *(uint32_t*)(mem);
+        mem += returnSize( variable );
+    }
+
+    template <> inline void saveAndIncrease( const unsigned int& variable, uint8_t*& mem )
+    {
+        *(uint32_t*)(mem) = variable;
+        mem += returnSize( variable );
+    }
+
+    template <> inline bool checkEquality( const unsigned int& variable, uint8_t* mem )
+    {
+        return *(uint32_t*)(mem) == variable;
+    }
+
+// =========== long
+
+    template <> inline uint32_t returnSize( const long& variable )
+    {
+        return sizeof(int32_t);
+    }
+
+    template <> inline void loadAndIncrease( const long& variable, uint8_t*& mem )
+    {
+        *(long*)( &variable ) = *(int32_t*)(mem);
+        mem += returnSize( variable );
+    }
+
+    template <> inline void saveAndIncrease( const long& variable, uint8_t*& mem )
+    {
+        *(int32_t*)(mem) = variable;
+        mem += returnSize( variable );
+    }
+
+    template <> inline bool checkEquality( const long& variable, uint8_t* mem )
+    {
+        return *(int32_t*)(mem) == variable;
+    }
+
+// =========== unsigned long
+
+    template <> inline uint32_t returnSize( const unsigned long& variable )
+    {
+        return sizeof(uint32_t);
+    }
+
+    template <> inline void loadAndIncrease( const unsigned long& variable, uint8_t*& mem )
+    {
+        *(unsigned long*)( &variable ) = *(uint32_t*)(mem);
+        mem += returnSize( variable );
+    }
+
+    template <> inline void saveAndIncrease( const unsigned long& variable, uint8_t*& mem )
+    {
+        *(uint32_t*)(mem) = variable;
+        mem += returnSize( variable );
+    }
+
+    template <> inline bool checkEquality( const unsigned long& variable, uint8_t* mem )
+    {
+        return *(uint32_t*)(mem) == variable;
+    }
+
+// =========== long long
+
+    template <> inline uint32_t returnSize( const long long& variable )
+    {
+        return sizeof(int64_t);
+    }
+
+    template <> inline void loadAndIncrease( const long long& variable, uint8_t*& mem )
+    {
+        *(long long*)( &variable ) = *(int64_t*)(mem);
+        mem += returnSize( variable );
+    }
+
+    template <> inline void saveAndIncrease( const long long& variable, uint8_t*& mem )
+    {
+        *(int64_t*)(mem) = variable;
+        mem += returnSize( variable );
+    }
+
+    template <> inline bool checkEquality( const long long& variable, uint8_t* mem )
+    {
+        return *(int64_t*)(mem) == variable;
+    }
+
+// =========== unsigned long long
+
+    template <> inline uint32_t returnSize( const unsigned long long& variable )
+    {
+        return sizeof(uint64_t);
+    }
+
+    template <> inline void loadAndIncrease( const unsigned long long& variable, uint8_t*& mem )
+    {
+        *(unsigned long long*)( &variable ) = *(uint64_t*)(mem);
+        mem += returnSize( variable );
+    }
+
+    template <> inline void saveAndIncrease( const unsigned long long& variable, uint8_t*& mem )
+    {
+        *(uint64_t*)(mem) = variable;
+        mem += returnSize( variable );
+    }
+
+    template <> inline bool checkEquality( const unsigned long long& variable, uint8_t* mem )
+    {
+        return *(uint64_t*)(mem) == variable;
+    }
+
+// =========== float
+
+    template <> inline uint32_t returnSize( const float& variable )
+    {
+        return sizeof(uint32_t);
+    }
+
+    template <> inline void loadAndIncrease( const float& variable, uint8_t*& mem )
+    {
+        *(uint32_t*)( &variable ) = *(uint32_t*)(mem);
+        mem += returnSize( variable );
+    }
+
+    template <> inline void saveAndIncrease( const float& variable, uint8_t*& mem )
+    {
+        *(uint32_t*)(mem) = *(uint32_t*)( &variable );
+        mem += returnSize( variable );
+    }
+
+    template <> inline bool checkEquality( const float& variable, uint8_t* mem )
+    {
+        return *(uint32_t*)(mem) == *(uint32_t*)( &variable );
+    }
+
+// =========== double
+
+    template <> inline uint32_t returnSize( const double& variable )
+    {
+        return sizeof(uint64_t);
+    }
+
+    template <> inline void loadAndIncrease( const double& variable, uint8_t*& mem )
+    {
+        *(uint64_t*)( &variable ) = *(uint64_t*)(mem);
+        mem += returnSize( variable );
+    }
+
+    template <> inline void saveAndIncrease( const double& variable, uint8_t*& mem )
+    {
+        *(uint64_t*)(mem) = *(uint64_t*)( &variable );
+        mem += returnSize( variable );
+    }
+
+    template <> inline bool checkEquality( const double& variable, uint8_t* mem )
+    {
+        return *(uint64_t*)(mem) == *(uint64_t*)( &variable );
+    }
+
+// =========== long double
+
+    template <> inline uint32_t returnSize( const long double& variable )
+    {
+        return sizeof(uint64_t);
+    }
+
+    template <> inline void loadAndIncrease( const long double& variable, uint8_t*& mem )
+    {
+        double temp;
+        memcpy(&temp, mem, sizeof(uint64_t));
+        *(long double*)( &variable ) = static_cast<const long double>(temp);
+        mem += returnSize( variable );
+    }
+
+    template <> inline void saveAndIncrease( const long double& variable, uint8_t*& mem )
+    {
+        double temp = static_cast<double>(variable);
+        memcpy(mem, &temp, sizeof(uint64_t));
+        mem += returnSize( variable );
+    }
+
+    template <> inline bool checkEquality( const long double& variable, uint8_t* mem )
+    {
+        double temp = static_cast<double>(variable);
+        return memcmp(&temp, mem, sizeof(uint64_t))==0;
+    }
+
+// =========== string
+
+    template <> inline uint32_t returnSize( const std::string& variable )
+    {
+        return variable.length()+1;
+    }
+
+    template <> inline void saveAndIncrease( const std::string& variable, uint8_t*& mem )
+    {
+        memcpy(mem, variable.c_str(), variable.length()+1);
+        mem += variable.length()+1;
+    }
+
+    template <> inline void loadAndIncrease( const std::string& variable, uint8_t*& mem )
+    {
+        *(std::string*)( &variable ) = std::string((const char *)mem);
+        mem += variable.length()+1;
+    }
+
+    template <> inline bool checkEquality( const std::string& variable, uint8_t* mem )
+    {
+        return std::string((const char*)mem)==variable;
+    }
+
+// =========== Degree
+
+    template <> inline uint32_t returnSize( const Degree& variable )
+    {
+        return sizeof(Ogre::Real);
+    }
+
+    template <> inline void saveAndIncrease( const Degree& variable, uint8_t*& mem )
+    {
+        Ogre::Real r = variable.valueDegrees();
+        memcpy(mem, &r, returnSize( variable ));
+        mem += returnSize( variable );
+    }
+
+    template <> inline void loadAndIncrease( const Degree& variable, uint8_t*& mem )
+    {
+        Ogre::Real* r = (Ogre::Real*)mem;
+        (Degree&)variable = *r;
+        mem += returnSize( variable );
+    }
+
+     template <> inline bool checkEquality( const Degree& variable, uint8_t* mem )
+    {
+        Ogre::Real* r = (Ogre::Real*)mem;
+        return variable==Degree(*r);
+    }
+
+// =========== Radian
+
+    template <> inline uint32_t returnSize( const Radian& variable )
+    {
+        return sizeof(Ogre::Real);
+    }
+
+    template <> inline void saveAndIncrease( const Radian& variable, uint8_t*& mem )
+    {
+        Ogre::Real r = variable.valueRadians();
+        memcpy(mem, &r, returnSize( variable ));
+        mem += returnSize( variable );
+    }
+
+    template <> inline void loadAndIncrease( const Radian& variable, uint8_t*& mem )
+    {
+        Ogre::Real* r = (Ogre::Real*)mem;
+        (Radian&)variable = *r;
+        mem += returnSize( variable );
+    }
+
+    template <> inline bool checkEquality( const Radian& variable, uint8_t* mem )
+    {
+        Ogre::Real* r = (Ogre::Real*)mem;
+        return variable==Degree(*r);
+    }
+    
+    
+}
+
+
+#endif


Property changes on: trunk/src/util/Serialise.h
___________________________________________________________________
Added: svn:eol-style
   + native




More information about the Orxonox-commit mailing list