Index: /branches/network/src/defs/globals.h
===================================================================
--- /branches/network/src/defs/globals.h	(revision 5828)
+++ /branches/network/src/defs/globals.h	(revision 5829)
@@ -84,12 +84,21 @@
 
 #define  ORXONOX_LICENSE_SHORT \
-"orxonox - the future of 3D-vertical-scrollers\n" \
-"\n" \
-"Copyright (C) 2004 orx\n" \
-"\n" \
-"This program is free software; you can redistribute it and/or modify\n" \
-"it under the terms of the GNU General Public License as published by\n" \
-"the Free Software Foundation; either version 2, or (at your option)\n" \
-"any later version.\n"
+    "Orxonox - The Future of 3D-Action-Game\n" \
+    "\n" \
+    "Copyright (C) 2004 orx\n" \
+    "\n" \
+    "This program is free software; you can redistribute it and/or modify\n" \
+    "it under the terms of the GNU General Public License as published by\n" \
+    "the Free Software Foundation; either version 2, or (at your option)\n" \
+    "any later version.\n" \
+    "\n" \
+    "This program is distributed in the hope that it will be useful,\n" \
+    "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"  \
+    "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"   \
+    "GNU General Public License for more details.\n" \
+    "\n" \
+    "You should have received a copy of the GNU General Public License\n" \
+    "along with this program; if not, write to the Free Software Foundation,\n" \
+    "Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n"
 
 
Index: /branches/network/src/lib/network/network_manager.cc
===================================================================
--- /branches/network/src/lib/network/network_manager.cc	(revision 5828)
+++ /branches/network/src/lib/network/network_manager.cc	(revision 5829)
@@ -35,36 +35,5 @@
 
 
-/************************************
-  What you will see here are the function definitions from the header file (network_manager.h) with doxygen documentation. Here is an example:
-
-
- In file network_manager.h
-
- class NetworkManager
- {
-   int doSomeStuff(float argument, float* pointer);
- }
-
- will be implemented in the source file as follows:
-
- In file network_manager.cc
-
- / **
-  *  this is the short description for this function: it just does some stuff
-  * @param argument: this is the first argument, stuff...
-  * @param pointer:  this is the pointer to nowhereland
-  * return: whatever the function returns: for example an index, number, etc.
-  * /
- int NetworkManager::doSomeStuff(float argument, float* pointer)
- {
-   // whaterver you want to do
- }
-
-
- if you want to make automake compile your files: you will want to add the file names to the local Makefile.am
-
- ************************************/
-
-
+NetworkManager* NetworkManager::singletonRef = NULL;
 
 /**
@@ -79,4 +48,5 @@
   this->netStreamList = NULL;
   this->syncList = NULL;
+  this->tmpStream = NULL;
 
   PRINTF(0)("NetworkManager created\n");
@@ -114,8 +84,29 @@
  *  creates a connection from one object to a host
  * @param hostName: the name of the destination host
- * @param synchronizeable: reference to the sync object
  */
-NetworkStream& establishConnection(const char& hostName, const Synchronizeable& sync)
-{}
+int NetworkManager::establishConnection(const char* name, unsigned int port)
+{
+  IPaddress ipAddress;
+  int error = SDLNet_ResolveHost(&ipAddress, name, port);
+  if( error == -1) {
+    printf("\n\nerror on address resolution, program inconsistency\n\n");
+    return -1;
+  }
+
+  this->tmpStream = new NetworkStream(ipAddress, NET_CLIENT);
+  return 1;
+}
+
+
+/**
+ *  creates a new NetworkStream of server type
+ * @param port: number of the TCP port
+ */
+int NetworkManager::createServer(unsigned int port)
+{
+  this->tmpStream = new NetworkStream(port, NET_SERVER);
+  SDL_Delay(20);
+  return 1;
+}
 
 
@@ -127,8 +118,8 @@
 NetworkStream& NetworkManager::establishConnection(IPaddress& address, Synchronizeable& sync)
 {
-  printf("Establish connection to server %s, on port %u\n", SDLNet_ResolveIP(&address), address.port);
   /* creating a new network stream, it will register itself automaticaly to the class list */
-  NetworkStream* netStream = new NetworkStream(address, sync, NET_CLIENT);
+  this->tmpStream = new NetworkStream(address, sync, NET_CLIENT);
 }
+
 
 /**
@@ -140,5 +131,5 @@
   PRINTF(0)("Create a new server socket\n");
   /* creating a new network stream, it will register itself automaticaly to the class list */
-  NetworkStream* netStream = new NetworkStream(port, sync, NET_SERVER);
+  this->tmpStream = new NetworkStream(port, sync, NET_SERVER);
 }
 
@@ -153,4 +144,9 @@
 
 
+void NetworkManager::connectSynchronizeable(Synchronizeable& sync)
+{
+  this->tmpStream->connectSynchronizeable(sync);
+}
+
 
 /**
@@ -161,7 +157,18 @@
   if (this->netStreamList != NULL || (this->netStreamList = ClassList::getList(CL_NETWORK_STREAM)) != NULL)
   {
+//     tIterator<BaseObject>* iterator = this->netStreamList->getIterator();
+//     NetworkStream* stream = (NetworkStream*)(iterator->firstElement());
+//     while( stream)
+//     {
+//       if(stream->isActive())
+//         stream->processData();
+//       stream = (NetworkStream*)(iterator->nextElement());
+//     }
+//     delete iterator;
     std::list<BaseObject*>::iterator stream;
     for (stream = this->netStreamList->begin(); stream != this->netStreamList->end(); ++stream)
-      static_cast<NetworkStream*>(*stream)->processData();
+      if( static_cast<NetworkStream*>(*stream)->isActive())
+        static_cast<NetworkStream*>(*stream)->processData();
+
   }
 
Index: /branches/network/src/lib/network/network_manager.h
===================================================================
--- /branches/network/src/lib/network/network_manager.h	(revision 5828)
+++ /branches/network/src/lib/network/network_manager.h	(revision 5829)
@@ -19,5 +19,6 @@
 class NetworkStream;
 class Synchronizeable;
-template<typename> class tList;
+template<typename>
+class tList;
 
 /* and here is the class itsself*/
@@ -25,22 +26,33 @@
 {
 
-public:
+  public:
 
-  NetworkManager();
-  ~NetworkManager();
+    inline static NetworkManager* getInstance() { if (!NetworkManager::singletonRef) NetworkManager::singletonRef = new NetworkManager();
+      return NetworkManager::singletonRef; }
+    ~NetworkManager();
 
-  void initialize();
-  void shutdown();
+    void initialize();
+    void shutdown();
 
-  NetworkStream& establishConnection(IPaddress& address, Synchronizeable& sync);
-  NetworkStream& establishConnection(const char& hostName, const Synchronizeable& sync);
-  NetworkStream& createServer(Synchronizeable& sync, unsigned int port);
-  void shutdownConnection();
+    int establishConnection(const char* name, unsigned int port);
+    int createServer(unsigned int port);
 
-  void synchronize();
+    NetworkStream& establishConnection(IPaddress& address, Synchronizeable& sync);
+    NetworkStream& createServer(Synchronizeable& sync, unsigned int port);
+    void shutdownConnection();
 
-private:
-  std::list<BaseObject*>*    netStreamList;            // list with refs to all network streams
-  std::list<BaseObject*>*    syncList;                 // list of synchronizeables
+    void connectSynchronizeable(Synchronizeable& sync);
+
+    void synchronize();
+
+  private:
+    NetworkManager();
+
+
+  private:
+    std::list<BaseObject*>*    netStreamList;            // list with refs to all network streams
+    std::list<BaseObject*>*    syncList;                 // list of synchronizeables
+    static NetworkManager* singletonRef;           //!< Pointer to the only instance of this Class
+    NetworkStream*         tmpStream;              //!< FIXME: this is only for testing purposes
 
 };
Index: /branches/network/src/lib/network/network_socket.cc
===================================================================
--- /branches/network/src/lib/network/network_socket.cc	(revision 5828)
+++ /branches/network/src/lib/network/network_socket.cc	(revision 5829)
@@ -313,5 +313,8 @@
 
   while (!tempsocket && !self->terminateThread)
+  {
     tempsocket = SDLNet_TCP_Accept(self->tcpSocket);
+    SDL_Delay(_MSECONDS_SLEEP_LISTEN);
+  }
 
   SDL_mutexP(self->socketMutex);
Index: /branches/network/src/lib/network/network_socket.h
===================================================================
--- /branches/network/src/lib/network/network_socket.h	(revision 5828)
+++ /branches/network/src/lib/network/network_socket.h	(revision 5829)
@@ -18,4 +18,6 @@
 //sleep if outgoing buffer is empty
 #define _MSECONDS_SLEEP_EMPTY_BUFFER 10
+//sleep when waiting for connections
+#define _MSECONDS_SLEEP_LISTEN 100
 
 /* contains memmove and memcpy */
Index: /branches/network/src/lib/network/network_stream.cc
===================================================================
--- /branches/network/src/lib/network/network_stream.cc	(revision 5828)
+++ /branches/network/src/lib/network/network_stream.cc	(revision 5829)
@@ -40,5 +40,5 @@
 
 NetworkStream::NetworkStream()
-  : DataStream()
+    : DataStream()
 {
   this->init();
@@ -50,7 +50,27 @@
 }
 
+NetworkStream::NetworkStream(IPaddress& address, NodeType type)
+{
+  this->init();
+  this->networkSocket = new NetworkSocket(address);
+  this->networkProtocol = new NetworkProtocol();
+  this->synchronizeables = NULL;
+  this->connectionMonitor = new ConnectionMonitor();
+}
+
+
+NetworkStream::NetworkStream(unsigned int port, NodeType type)
+{
+  this->init();
+  this->networkSocket = new NetworkSocket();
+  this->networkSocket->listen(port);
+  this->networkProtocol = new NetworkProtocol();
+  this->synchronizeables = NULL;
+  this->connectionMonitor = new ConnectionMonitor();
+}
+
 
 NetworkStream::NetworkStream(IPaddress& address, Synchronizeable& sync, NodeType type)
-  : DataStream()
+    : DataStream()
 {
   this->init();
@@ -59,9 +79,10 @@
   this->synchronizeables = &sync;
   this->connectionMonitor = new ConnectionMonitor();
+  this->bActive = true;
 }
 
 
 NetworkStream::NetworkStream(unsigned int port, Synchronizeable& sync, NodeType type)
-  : DataStream()
+    : DataStream()
 {
   this->init();
@@ -71,4 +92,5 @@
   this->synchronizeables = &sync;
   this->connectionMonitor = new ConnectionMonitor();
+  this->bActive = true;
 }
 
@@ -79,4 +101,5 @@
   this->setClassID(CL_NETWORK_STREAM, "NetworkStream");
   this->state = NET_REC_HEADER;
+  this->bActive = false;
 }
 
@@ -85,12 +108,21 @@
 {
 
- networkSocket->disconnectServer();
+  networkSocket->disconnectServer();
 
- if( this->networkSocket)
-   delete networkSocket;
+  if( this->networkSocket)
+    delete networkSocket;
 
- delete connectionMonitor;
- delete networkProtocol;
+  delete connectionMonitor;
+  delete networkProtocol;
 }
+
+
+void NetworkStream::connectSynchronizeable(Synchronizeable& sync)
+{
+  this->synchronizeables = &sync;
+  if( this->networkSocket != NULL)
+    this->bActive = true;
+}
+
 
 void NetworkStream::processData()
@@ -102,17 +134,23 @@
   PRINT(0)("============= DOWNSTREAM:===============\n");
   /* first of all read the synchronizeable's data: */
+  //if(this->isServer())
   dataLength = this->synchronizeables->readBytes((byte*)downBuffer);
 
-  /* send the received data to connectionMonitor */
-  this->connectionMonitor->processPacket((byte*)downBuffer, dataLength);
+  if( dataLength > 0)
+  {
+    /* send the received data to connectionMonitor */
+    this->connectionMonitor->processPacket((byte*)downBuffer, dataLength);
 
-  dataLength = this->networkProtocol->createHeader((byte*)downBuffer, dataLength, DATA_STREAM_BUFFER_SIZE,
-      *(this->synchronizeables), 12/* some random number (no real id)*/);
+    dataLength = this->networkProtocol->createHeader((byte*)downBuffer, dataLength, DATA_STREAM_BUFFER_SIZE,
+                 *(this->synchronizeables), 12/* some random number (no real id)*/);
 
-  /* pass the data to the network socket */
-  dataLength = this->networkSocket->writeBytes((byte*)downBuffer, dataLength);
-  /* check if there was an error */
-  if( dataLength == -1) { PRINTF(0)("Error in writing data to the NetworkSocket\n");}
-
+    /* pass the data to the network socket */
+    dataLength = this->networkSocket->writeBytes((byte*)downBuffer, dataLength);
+    /* check if there was an error */
+    if( dataLength == -1)
+    {
+      PRINTF(0)("Error in writing data to the NetworkSocket\n");
+    }
+  }
 
 
@@ -147,4 +185,5 @@
       this->connectionMonitor->processPacket((byte*)upBuffer, this->packetHeader.length);
       /* now pass the data to the sync object */
+      //if(!this->isServer())
       this->synchronizeables->writeBytes((byte*)upBuffer, this->packetHeader.length);
 
Index: /branches/network/src/lib/network/network_stream.h
===================================================================
--- /branches/network/src/lib/network/network_stream.h	(revision 5828)
+++ /branches/network/src/lib/network/network_stream.h	(revision 5829)
@@ -28,26 +28,30 @@
 {
 
-public:
-  NetworkStream();
-  NetworkStream(IPaddress& address, Synchronizeable& sync, NodeType type);
-  NetworkStream(unsigned int port, Synchronizeable& sync, NodeType type);
-  ~NetworkStream();
+  public:
+    NetworkStream();
+    NetworkStream(IPaddress& address, NodeType type);
+    NetworkStream(unsigned int port, NodeType type);
 
-  void init();
+    NetworkStream(IPaddress& address, Synchronizeable& sync, NodeType type);
+    NetworkStream(unsigned int port, Synchronizeable& sync, NodeType type);
+    ~NetworkStream();
+    void init();
 
-  inline bool isServer() { return (this->type == NET_SERVER)? true:false; }
-  virtual void processData();
+    void connectSynchronizeable(Synchronizeable& sync);
 
-private:
-   NetworkProtocol* networkProtocol;
-   //NetworkSocket*       networkSockets;
-   ConnectionMonitor*      connectionMonitor;
-   // tList<Synchronizeable>* synchronizeables;
-   Synchronizeable*         synchronizeables;
-   NetworkSocket* networkSocket;
-   int                    type;
-   int                    state;
-   Header                 packetHeader;
+    inline bool isServer() const { return (this->type == NET_SERVER)? true:false; }
+    inline bool isActive() const { return this->bActive; }
+
+    virtual void processData();
+
+  private:
+    NetworkProtocol*       networkProtocol;
+    ConnectionMonitor*     connectionMonitor;
+    Synchronizeable*       synchronizeables;
+    NetworkSocket*         networkSocket;
+    int                    type;
+    int                    state;
+    Header                 packetHeader;
+    bool                   bActive;
 };
 #endif /* _NETWORK_STREAM */
-
Index: /branches/network/src/lib/network/synchronizeable.cc
===================================================================
--- /branches/network/src/lib/network/synchronizeable.cc	(revision 5828)
+++ /branches/network/src/lib/network/synchronizeable.cc	(revision 5829)
@@ -18,4 +18,11 @@
 #include "netdefs.h"
 
+
+/**
+ *  default constructor
+ */
+Synchronizeable::Synchronizeable()
+{}
+
 /**
  *  default constructor
@@ -25,4 +32,5 @@
   this->setName(name);
 }
+
 
 /**
@@ -41,5 +49,5 @@
  *  read data from NetworkStream
  */
-int Synchronizeable::readBytes(byte* data) const
+int Synchronizeable::readBytes(byte* data)
 {}
 
Index: /branches/network/src/lib/network/synchronizeable.h
===================================================================
--- /branches/network/src/lib/network/synchronizeable.h	(revision 5828)
+++ /branches/network/src/lib/network/synchronizeable.h	(revision 5829)
@@ -15,8 +15,9 @@
 
     Synchronizeable(const char* name);
+    Synchronizeable();
     ~Synchronizeable();
 
     virtual void      writeBytes(const byte* data, int length);
-    virtual int       readBytes(byte* data) const;
+    virtual int       readBytes(byte* data);
     virtual void      writeDebug() const;
     virtual void      readDebug() const;
Index: /branches/network/src/orxonox.cc
===================================================================
--- /branches/network/src/orxonox.cc	(revision 5828)
+++ /branches/network/src/orxonox.cc	(revision 5829)
@@ -57,4 +57,6 @@
 #include "load_param_description.h"
 
+#include "network_manager.h"
+
 #include <string.h>
 
@@ -79,4 +81,8 @@
   this->argc = 0;
   this->argv = NULL;
+
+  /* this way, there is no network enabled: */
+  this->clientName = NULL;
+  this->port = -1;
 
   this->configFileName = NULL;
@@ -118,11 +124,11 @@
 
   PRINT(3)
-      (
-      "===================================================\n" \
-      "Thanks for playing orxonox.\n" \
-      "visit: http://www.orxonox.net for new versions.\n" \
-      "===================================================\n" \
-      ORXONOX_LICENSE_SHORT
-      );
+  (
+    "===================================================\n" \
+    "Thanks for playing orxonox.\n" \
+    "visit: http://www.orxonox.net for new versions.\n" \
+    "===================================================\n" \
+    ORXONOX_LICENSE_SHORT
+  );
 
   Orxonox::singletonRef = NULL;
@@ -137,21 +143,21 @@
 void Orxonox::restart()
 {
-//   int argc = this->argc;
-//   char** argv = this->argv;
-//
-//   Orxonox *orx = Orxonox::getInstance();
-//
-//   delete orx;
-//
-//   orx = Orxonox::getInstance();
-//
-//   if((*orx).init(argc, argv) == -1)
-//   {
-//     PRINTF(1)("! Orxonox initialization failed\n");
-//     return;
-//   }
-//
-//   printf("finished inizialisation\n");
-//   orx->start();
+  //   int argc = this->argc;
+  //   char** argv = this->argv;
+  //
+  //   Orxonox *orx = Orxonox::getInstance();
+  //
+  //   delete orx;
+  //
+  //   orx = Orxonox::getInstance();
+  //
+  //   if((*orx).init(argc, argv) == -1)
+  //   {
+  //     PRINTF(1)("! Orxonox initialization failed\n");
+  //     return;
+  //   }
+  //
+  //   printf("finished inizialisation\n");
+  //   orx->start();
 }
 
@@ -179,16 +185,15 @@
  * initialize Orxonox with command line
  */
-int Orxonox::init (int argc, char** argv)
+int Orxonox::init (int argc, char** argv, const char* name, int port)
 {
   this->argc = argc;
   this->argv = argv;
-  // parse command line
-  // config file
+
+  this->clientName = name;
+  this->port = port;
 
   // initialize the Config-file
   this->getConfigFile();
 
-  // initialize everything
-  SDL_Init(SDL_INIT_TIMER);
   // windows must not write into stdout.txt and stderr.txt
 #ifdef __WIN32__
@@ -197,17 +202,26 @@
 #endif
 
-  if( initResources () == -1) return -1;
-  if( initVideo() == -1) return -1;
-  if( initSound() == -1) return -1;
-  if( initInput() == -1) return -1;
-  if( initNetworking () == -1) return -1;
-  if( initMisc () == -1) return -1;
-
-  return 0;
-}
+  // initialize everything
+  SDL_Init(SDL_INIT_TIMER);
+  if( initResources () == -1)
+    return -1;
+  if( initVideo() == -1)
+    return -1;
+  if( initSound() == -1)
+    return -1;
+  if( initInput() == -1)
+    return -1;
+  if( initNetworking () == -1)
+    return -1;
+  if( initMisc () == -1)
+    return -1;
+
+  return 0;
+}
+
 
 /**
  * initializes SDL and OpenGL
-*/
+ */
 int Orxonox::initVideo()
 {
@@ -226,4 +240,5 @@
   return 0;
 }
+
 
 /**
@@ -262,5 +277,11 @@
   PRINT(3)("> Initializing networking\n");
 
-  printf("  ---Not yet implemented-FIXME--\n");
+  NetworkManager::getInstance();
+
+  if( this->clientName != NULL) // we are a client
+    NetworkManager::getInstance()->establishConnection(this->clientName, port);
+  else if( this->port > 0)      // we are a server
+    NetworkManager::getInstance()->createServer(port);
+
   return 0;
 }
@@ -281,5 +302,5 @@
   {
     if (!ResourceManager::getInstance()->setDataDir(dataPath) &&
-         !ResourceManager::getInstance()->verifyDataDir(DEFAULT_DATA_DIR_CHECKFILE))
+        !ResourceManager::getInstance()->verifyDataDir(DEFAULT_DATA_DIR_CHECKFILE))
     {
       PRINTF(1)("Data Could not be located in %s\n", dataPath);
@@ -300,5 +321,5 @@
     exit(-1);
   }
-   //! @todo this is a hack and should be loadable
+  //! @todo this is a hack and should be loadable
   char* imageDir = ResourceManager::getInstance()->getFullName("maps");
   ResourceManager::getInstance()->addImageDir(imageDir);
@@ -374,31 +395,94 @@
 int main(int argc, char** argv)
 {
-  // here the pre-arguments are loaded, these are needed to go either to orxonx itself, Help, or Benchmark.
   int i;
   for(i = 1; i < argc; ++i)
+  {
+    if(     !strcmp( "--help", argv[i])     || !strcmp("-h", argv[i]))
+      return showHelp(argc, argv);
+    else if(!strcmp( "--gui", argv[i])      || !strcmp("-g", argv[i]))
+      showGui = true;
+    else if(!strcmp( "--client", argv[i])   || !strcmp("-c", argv[i]))
+      return startNetworkOrxonox(argc, argv);
+    else if(!strcmp( "--server", argv[i])   || !strcmp("-s", argv[i]))
+      return startNetworkOrxonox(argc, argv);
+    else if(!strcmp( "--license", argv[i])  || !strcmp("-s", argv[i]))
+      return PRINT(0)(ORXONOX_LICENSE_SHORT);
+  }
+
+  return startOrxonox(argc, argv, NULL, -1);
+}
+
+
+
+int showHelp(int argc, char** argv)
+{
+  PRINT(0)("Orxonox Version %s\n", PACKAGE_VERSION);
+  PRINT(0)(" Starts Orxonox - The most furious 3D Action Game :)\n");
+  PRINT(0)("\n");
+  PRINT(0)("Common options:\n");
+  PRINT(0)(" -g, --gui                        starts the orxonox with the configuration GUI \n");
+  PRINT(0)(" -h, --help                       shows this help\n");
+  PRINT(0)("\n");
+  PRINT(0)("Network options:\n");
+  PRINT(0)(" -s, --server [port]              starts Orxonox and listens on the [port] for players\n");
+  PRINT(0)(" -c, --client [hostname] [port]   starts Orxonox as a Client\n");
+  PRINT(0)(" -c, --client [ip address] [port] starts Orxonox as a Client\n");
+  PRINT(0)("\n");
+  PRINT(0)("Other options:\n");
+  PRINT(0)("     --license     prints the licence and exit\n\n");
+  PRINT(0)("\n");
+
+  //   {
+  //     Gui* gui = new Gui(argc, argv);
+  //     gui->printHelp();
+  //     delete gui;
+  //   }
+}
+
+
+
+
+/**
+ * starts orxonox in network mode
+ * @param argc parameters count given to orxonox
+ * @param argv parameters given to orxonox
+ */
+int startNetworkOrxonox(int argc, char** argv)
+{
+
+  int i;
+  for(i = 0; i < argc; ++i )
+  {
+    if( !strcmp( "--client", argv[i]) || !strcmp("-c", argv[i]))
     {
-      if(! strcmp( "--help", argv[i]) || !strcmp("-h", argv[i])) return startHelp(argc, argv);
-//      else if(!strcmp( "--benchmark", argv[i]) || !strcmp("-b", argv[i])) return startBenchmarks();
-      else if(!strcmp( "--gui", argv[i]) || !strcmp("-g", argv[i])) showGui = true;
-      //      else PRINTF(2)("Orxonox does not understand the arguments %s\n", argv[i]);
+      if( argc <= (i+2))
+      {
+        printf(" Wrong arguments try following notations:\n");
+        printf("   --client [server ip address] [port number]\n");
+        printf("   --client [dns name] [port number]\n");
+        return 0;
+      }
+
+      const char* name = argv[i+1];
+      int port = atoi(argv[i+2]);
+      printf("Starting Orxonox as client: connecting to %s, on port %i\n", name, port);
+
+      startOrxonox(argc, argv, name, port);
     }
-
-  return startOrxonox(argc, argv);
-}
-
-
-
-int startHelp(int argc, char** argv)
-{
-  PRINT(0)("orxonox: starts the orxonox game - rules\n");
-  PRINT(0)("usage: orxonox [arg [arg...]]\n\n");
-  PRINT(0)("valid options:\n");
-  {
-    Gui* gui = new Gui(argc, argv);
-    gui->printHelp();
-    delete gui;
-  }
-  PRINT(0)(" -b|--benchmark:\t\tstarts the orxonox benchmark\n");
-  PRINT(0)(" -h|--help:\t\t\tshows this help\n");
+    else if( !strcmp( "--server", argv[i]) || !strcmp("-s", argv[i]))
+    {
+      if( argc <= (i+1))
+      {
+        printf(" Wrong arguments try following notations:\n");
+        printf("   --server [port number]\n");
+        return 0;
+      }
+
+      int port = atoi(argv[i+1]);
+      printf("Starting Orxonox as server, listening on port %i\n", port);
+
+      startOrxonox(argc, argv, NULL, port);
+    }
+  }
 }
 
@@ -410,26 +494,26 @@
  * @param argv parameters given to orxonox
  */
-int startOrxonox(int argc, char** argv)
+int startOrxonox(int argc, char** argv, const char* name, int port)
 {
   // checking for existence of the configuration-files, or if the lock file is still used
   if (showGui || (!ResourceManager::isFile("./orxonox.conf") &&
-      !ResourceManager::isFile(DEFAULT_CONFIG_FILE))
+                  !ResourceManager::isFile(DEFAULT_CONFIG_FILE))
 #if DEBUG < 3 // developers do not need to see the GUI, when orxonox fails
-       || ResourceManager::isFile(DEFAULT_LOCK_FILE)
+      || ResourceManager::isFile(DEFAULT_LOCK_FILE)
 #endif
      )
-    {
-      if (ResourceManager::isFile(DEFAULT_LOCK_FILE))
-        ResourceManager::deleteFile(DEFAULT_LOCK_FILE);
-
-      // starting the GUI
-      Gui* gui = new Gui(argc, argv);
-      gui->startGui();
-
-      if (! gui->startOrxonox)
-        return 0;
-
-      delete gui;
-    }
+  {
+    if (ResourceManager::isFile(DEFAULT_LOCK_FILE))
+      ResourceManager::deleteFile(DEFAULT_LOCK_FILE);
+
+    // starting the GUI
+    Gui* gui = new Gui(argc, argv);
+    gui->startGui();
+
+    if (! gui->startOrxonox)
+      return 0;
+
+    delete gui;
+  }
 
   PRINT(0)(">>> Starting Orxonox <<<\n");
@@ -439,11 +523,11 @@
   Orxonox *orx = Orxonox::getInstance();
 
-  if(orx->init(argc, argv) == -1)
-    {
-      PRINTF(1)("! Orxonox initialization failed\n");
-      return -1;
-    }
-
-    printf("finished inizialisation\n");
+  if( orx->init(argc, argv, name, port) == -1)
+  {
+    PRINTF(1)("! Orxonox initialization failed\n");
+    return -1;
+  }
+
+  printf("finished inizialisation\n");
   orx->start();
 
Index: /branches/network/src/orxonox.h
===================================================================
--- /branches/network/src/orxonox.h	(revision 5828)
+++ /branches/network/src/orxonox.h	(revision 5829)
@@ -23,11 +23,9 @@
   inline static Orxonox* getInstance() { if (!singletonRef) singletonRef = new Orxonox();  return singletonRef; };
 
-  int init (int argc, char** argv);
+  int init(int argc, char** argv, const char* name, int port);
 
   void restart();
 
   void start();
-
-  //void graphicsHandler (SDL_Event* event);
 
  private:
@@ -43,5 +41,4 @@
   int initMisc ();
 
-
   const char* getConfigFile ();
 
@@ -55,4 +52,7 @@
   unsigned int      argc;                    //!< Count of Arguments of orxonox
   char**            argv;                    //!< Values of th Arguments of orxonox.
+
+  const char*       clientName;              //!< Name of the Orxonox client if == NULL -> server
+  int               port;                    //!< number of the network port of the server/client if == -1 no network
 };
 
@@ -61,6 +61,8 @@
 // Start-up functions //
 ////////////////////////
-int startHelp(int argc, char** argv);
-int startOrxonox(int argc, char** argv);
+int showHelp(int argc, char** argv);
+int showLicense();
+int startNetworkOrxonox(int argc, char** argv);
+int startOrxonox(int argc, char** argv, const char* clientName, int port);
 
 #endif /* _ORXONOX_H */
Index: /branches/network/src/story_entities/world.cc
===================================================================
--- /branches/network/src/story_entities/world.cc	(revision 5828)
+++ /branches/network/src/story_entities/world.cc	(revision 5829)
@@ -73,4 +73,6 @@
 #include "shader.h"
 
+#include "network_manager.h"
+
 SHELL_COMMAND(speed, World, setSpeed);
 SHELL_COMMAND(togglePNodeVisibility, World, togglePNodeVisibility);
@@ -321,4 +323,5 @@
             localPlayer = (Player*) created;
             CDEngine::getInstance()->setPlayer(localPlayer);
+            NetworkManager::getInstance()->connectSynchronizeable(*(Synchronizeable*)this->localPlayer);
           }
           if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox")) sky = (SkyBox*) created;
@@ -827,4 +830,5 @@
   // Get remote input
   // Update synchronizables
+  NetworkManager::getInstance()->synchronize();
 }
 
Index: /branches/network/src/subprojects/network/Makefile.am
===================================================================
--- /branches/network/src/subprojects/network/Makefile.am	(revision 5828)
+++ /branches/network/src/subprojects/network/Makefile.am	(revision 5829)
@@ -15,4 +15,6 @@
 network_SOURCES=  network_unit_test.cc \
                   simple_sync.cc \
+		  read_sync.cc \
+		  write_sync.cc \
                   \
                   \
@@ -26,4 +28,6 @@
 
 noinst_HEADERS  =  network_unit_test.h \
-                   simple_sync.h
+                   simple_sync.h \
+		   read_sync.h \
+		   write_sync.h
 
Index: /branches/network/src/subprojects/network/Makefile.in
===================================================================
--- /branches/network/src/subprojects/network/Makefile.in	(revision 5828)
+++ /branches/network/src/subprojects/network/Makefile.in	(revision 5829)
@@ -54,5 +54,6 @@
 PROGRAMS = $(bin_PROGRAMS)
 am_network_OBJECTS = network-network_unit_test.$(OBJEXT) \
-	network-simple_sync.$(OBJEXT) network-base_object.$(OBJEXT) \
+	network-simple_sync.$(OBJEXT) network-read_sync.$(OBJEXT) \
+	network-write_sync.$(OBJEXT) network-base_object.$(OBJEXT) \
 	network-class_list.$(OBJEXT) network-load_param.$(OBJEXT) \
 	network-substring.$(OBJEXT) network-helper_functions.$(OBJEXT)
@@ -193,4 +194,6 @@
 network_SOURCES = network_unit_test.cc \
                   simple_sync.cc \
+		  read_sync.cc \
+		  write_sync.cc \
                   \
                   \
@@ -202,5 +205,7 @@
 
 noinst_HEADERS = network_unit_test.h \
-                   simple_sync.h
+                   simple_sync.h \
+		   read_sync.h \
+		   write_sync.h
 
 all: all-am
@@ -275,6 +280,8 @@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/network-load_param.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/network-network_unit_test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/network-read_sync.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/network-simple_sync.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/network-substring.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/network-write_sync.Po@am__quote@
 
 .cc.o:
@@ -319,4 +326,32 @@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(network_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o network-simple_sync.obj `if test -f 'simple_sync.cc'; then $(CYGPATH_W) 'simple_sync.cc'; else $(CYGPATH_W) '$(srcdir)/simple_sync.cc'; fi`
+
+network-read_sync.o: read_sync.cc
+@am__fastdepCXX_TRUE@	if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(network_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT network-read_sync.o -MD -MP -MF "$(DEPDIR)/network-read_sync.Tpo" -c -o network-read_sync.o `test -f 'read_sync.cc' || echo '$(srcdir)/'`read_sync.cc; \
+@am__fastdepCXX_TRUE@	then mv -f "$(DEPDIR)/network-read_sync.Tpo" "$(DEPDIR)/network-read_sync.Po"; else rm -f "$(DEPDIR)/network-read_sync.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='read_sync.cc' object='network-read_sync.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(network_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o network-read_sync.o `test -f 'read_sync.cc' || echo '$(srcdir)/'`read_sync.cc
+
+network-read_sync.obj: read_sync.cc
+@am__fastdepCXX_TRUE@	if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(network_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT network-read_sync.obj -MD -MP -MF "$(DEPDIR)/network-read_sync.Tpo" -c -o network-read_sync.obj `if test -f 'read_sync.cc'; then $(CYGPATH_W) 'read_sync.cc'; else $(CYGPATH_W) '$(srcdir)/read_sync.cc'; fi`; \
+@am__fastdepCXX_TRUE@	then mv -f "$(DEPDIR)/network-read_sync.Tpo" "$(DEPDIR)/network-read_sync.Po"; else rm -f "$(DEPDIR)/network-read_sync.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='read_sync.cc' object='network-read_sync.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(network_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o network-read_sync.obj `if test -f 'read_sync.cc'; then $(CYGPATH_W) 'read_sync.cc'; else $(CYGPATH_W) '$(srcdir)/read_sync.cc'; fi`
+
+network-write_sync.o: write_sync.cc
+@am__fastdepCXX_TRUE@	if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(network_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT network-write_sync.o -MD -MP -MF "$(DEPDIR)/network-write_sync.Tpo" -c -o network-write_sync.o `test -f 'write_sync.cc' || echo '$(srcdir)/'`write_sync.cc; \
+@am__fastdepCXX_TRUE@	then mv -f "$(DEPDIR)/network-write_sync.Tpo" "$(DEPDIR)/network-write_sync.Po"; else rm -f "$(DEPDIR)/network-write_sync.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='write_sync.cc' object='network-write_sync.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(network_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o network-write_sync.o `test -f 'write_sync.cc' || echo '$(srcdir)/'`write_sync.cc
+
+network-write_sync.obj: write_sync.cc
+@am__fastdepCXX_TRUE@	if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(network_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT network-write_sync.obj -MD -MP -MF "$(DEPDIR)/network-write_sync.Tpo" -c -o network-write_sync.obj `if test -f 'write_sync.cc'; then $(CYGPATH_W) 'write_sync.cc'; else $(CYGPATH_W) '$(srcdir)/write_sync.cc'; fi`; \
+@am__fastdepCXX_TRUE@	then mv -f "$(DEPDIR)/network-write_sync.Tpo" "$(DEPDIR)/network-write_sync.Po"; else rm -f "$(DEPDIR)/network-write_sync.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='write_sync.cc' object='network-write_sync.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(network_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o network-write_sync.obj `if test -f 'write_sync.cc'; then $(CYGPATH_W) 'write_sync.cc'; else $(CYGPATH_W) '$(srcdir)/write_sync.cc'; fi`
 
 network-base_object.o: $(MAINSRCDIR)/lib/lang/base_object.cc
Index: /branches/network/src/subprojects/network/network_unit_test.cc
===================================================================
--- /branches/network/src/subprojects/network/network_unit_test.cc	(revision 5828)
+++ /branches/network/src/subprojects/network/network_unit_test.cc	(revision 5829)
@@ -12,4 +12,5 @@
 
 #include "simple_sync.h"
+#include "read_sync.h"
 
 int verbose = 4;
@@ -25,4 +26,5 @@
   printf(" --server [port number]     creates a test server\n");
   printf(" --client [address] [port]  connects to a server\n");
+  printf(" --listen [address] [port]  just listens to this connection");
   printf("\n");
 }
@@ -76,4 +78,5 @@
 
 #define _N_ELEMENTS 212994
+
   char sendbuf[_N_ELEMENTS+1];
   char recvbuf[_N_ELEMENTS+1];
@@ -131,5 +134,5 @@
 
   /* create the network manager */
-  NetworkManager* nm = new NetworkManager();
+  NetworkManager* nm = NetworkManager::getInstance();
 
   /* initialize the network manager */
@@ -143,5 +146,6 @@
   int error = SDLNet_ResolveHost(&ip, "127.0.0.1", port);
   //SDLNet_ResolveHost(&ip, "localhost", port);
-  if(error == -1) printf("\n\nerror on address resolution, program inconsistancy\n\n");
+  if(error == -1)
+    printf("\n\nerror on address resolution, program inconsistancy\n\n");
   nm->establishConnection(ip, *clientSync);
   /* adding some break for connection setup */
@@ -149,5 +153,6 @@
 
   /* synchronize the data 1 time (increment for longer tests) */
-  for( int i = 0; i < 3; i++) {
+  for( int i = 0; i < 3; i++)
+  {
     nm->synchronize();
     /* simulate the network delay */
@@ -177,5 +182,6 @@
 int startServer(int argc, char** argv)
 {
-  if( argc <= 2) {
+  if( argc <= 2)
+  {
     printf(" Wrong arguments try following notations:\n");
     printf("   --server [port number]\n");
@@ -186,15 +192,20 @@
   printf("Starting Server on port %i\n", port);
 
-  NetworkManager* netMan = new NetworkManager();
+  NetworkManager* netMan = NetworkManager::getInstance();
   Synchronizeable* ss = new SimpleSync("Server\0");
 
-  //NetworkStream* server = new NetworkStream(port, ss, NET_SERVER);
   netMan->createServer(*ss, port);
   SDL_Delay(20);
 
-  for(;;) {
+  for(;;)
+  {
     netMan->synchronize();
     SDL_Delay(500);
   }
+
+  delete netMan;
+  delete ss;
+
+
   return 0;
 }
@@ -203,8 +214,9 @@
 int startClient(int argc, char** argv)
 {
-  if( argc < 3) {
+  if( argc < 3)
+  {
     printf(" Wrong arguments try following notations:\n");
     printf("   --client [server ip] [port number]\n");
-    printf("   --server [server name] [port number]\n");
+    printf("   --client [server name] [port number]\n");
     return 0;
   }
@@ -216,18 +228,56 @@
   IPaddress ip;
   int error = SDLNet_ResolveHost(&ip, name, port);
-  //SDLNet_ResolveHost(&ip, "localhost", port);
-  if(error == -1) printf("\n\nerror on address resolution, program inconsistancy\n\n");
-
-  NetworkManager* netMan = new NetworkManager();
+  if(error == -1)
+    printf("\n\nerror on address resolution, program inconsistancy\n\n");
+
+  NetworkManager* netMan = NetworkManager::getInstance();
   Synchronizeable* ss = new SimpleSync("Client\0");
 
   netMan->establishConnection(ip, *ss);
 
-  for(;;) {
+  for(;;)
+  {
     netMan->synchronize();
     SDL_Delay(500);
   }
 
-  //NetworkStream* client = new NetworkStream(ip, ss, NET_CLIENT);
+
+  delete netMan;
+  delete ss;
+
+  return 0;
+}
+
+
+
+int startListen(int argc, char** argv)
+{
+  if( argc < 3)
+  {
+    printf(" Wrong arguments try following notations:\n");
+    printf("   --listen [server ip] [port number]\n");
+    printf("   --listen [server name] [port number]\n");
+    return 0;
+  }
+
+  char* name = argv[2];
+  int port = atoi(argv[3]);
+  printf("Connecting to %s, on port %i\n", name, port);
+
+  IPaddress ip;
+  int error = SDLNet_ResolveHost(&ip, name, port);
+  if(error == -1)
+    printf("\n\nerror on address resolution, program inconsistancy\n\n");
+
+  NetworkManager* netMan = NetworkManager::getInstance();
+  Synchronizeable* ss = new ReadSync("WriteSync\0");
+
+  netMan->establishConnection(ip, *ss);
+
+  for(;;)
+  {
+    netMan->synchronize();
+    SDL_Delay(10);
+  }
 
 
@@ -253,8 +303,14 @@
   {
     //else if(!strcmp( "--gui", argv[i]) || !strcmp("-g", argv[i])) showGui = true;
-    if (! strcmp( "--sockettest", argv[i]) || !strcmp("-st", argv[i])) return testSocket(argc, argv);
-    else if (! strcmp( "--frameworktest", argv[i]) || !strcmp("-ft", argv[i])) return testFramework(argc, argv);
-    else if (! strcmp( "--server", argv[i]) || !strcmp("-s", argv[i])) return startServer(argc, argv);
-    else if (! strcmp( "--client", argv[i]) || !strcmp("-c", argv[i])) return startClient(argc, argv);
+    if (! strcmp( "--sockettest", argv[i]) || !strcmp("-st", argv[i]))
+      return testSocket(argc, argv);
+    else if (! strcmp( "--frameworktest", argv[i]) || !strcmp("-ft", argv[i]))
+      return testFramework(argc, argv);
+    else if (! strcmp( "--server", argv[i]) || !strcmp("-s", argv[i]))
+      return startServer(argc, argv);
+    else if (! strcmp( "--client", argv[i]) || !strcmp("-c", argv[i]))
+      return startClient(argc, argv);
+    else if (! strcmp( "--listen", argv[i]) || !strcmp("-l", argv[i]))
+      return startListen(argc, argv);
   }
 
Index: /branches/network/src/subprojects/network/read_sync.cc
===================================================================
--- /branches/network/src/subprojects/network/read_sync.cc	(revision 5829)
+++ /branches/network/src/subprojects/network/read_sync.cc	(revision 5829)
@@ -0,0 +1,100 @@
+/*
+  orxonox - the future of 3D-vertical-scrollers
+
+  Copyright (C) 2004 orx
+
+  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, or (at your option)
+      any later version.
+
+### File Specific:
+    main-programmer: Patrick Boenzli
+    co-programmer:
+*/
+
+
+/* this is for debug output. It just says, that all calls to PRINT() belong to the DEBUG_MODULE_NETWORK module
+          For more information refere to https://www.orxonox.net/cgi-bin/trac.cgi/wiki/DebugOutput
+*/
+#define DEBUG_MODULE_NETWORK
+
+#include "read_sync.h"
+
+#include "debug.h"
+
+
+/**
+ *  default constructor
+ */
+ReadSync::ReadSync(const char* name)
+  : Synchronizeable(name)
+{
+  /* define the local buffer size */
+
+  this->inLength = 100;
+  this->recLength = 0;
+  this->inData = new byte[this->inLength];
+
+  /* init the buffer data */
+  for( int i = 0; i < this->inLength; i++)
+  {
+    this->inData[i] = 0;
+  }
+
+}
+
+
+/**
+ *  default destructor deletes all unneded stuff
+ */
+ReadSync::~ReadSync()
+{
+
+  if( this->inData)
+    delete[] this->inData;
+}
+
+
+/**
+ *  write data to Synchronizeable
+ */
+void ReadSync::writeBytes(const byte* data, int length)
+{
+  PRINTF(0)("ReadSync: got %i bytes of data\n", length);
+  this->recLength = length;
+  if(this->inLength < length)
+    PRINTF(0)("ERROR: local buffer is smaller than the data to receive.\n");
+
+  /* copy the data localy */
+  for( int i = 0; i < length; i++)
+  {
+    this->inData[i] = data[i];
+  }
+  /* and debug output */
+  this->writeDebug();
+}
+
+
+/**
+ *  read data from Synchronizeable
+ */
+int ReadSync::readBytes(byte* data)
+{
+  return 0;
+}
+
+
+void ReadSync::writeDebug() const
+{
+  PRINTF(0)("Write in bytes: \t(0 <-) |");
+  for(int i = 0; i < this->recLength; i++)
+  {
+    PRINT(0)(" [%u] ",this->inData[i]);
+  }
+  PRINT(0)("|\n");
+}
+
+
+void ReadSync::readDebug() const
+{}
Index: /branches/network/src/subprojects/network/read_sync.h
===================================================================
--- /branches/network/src/subprojects/network/read_sync.h	(revision 5829)
+++ /branches/network/src/subprojects/network/read_sync.h	(revision 5829)
@@ -0,0 +1,33 @@
+/*!
+ * @file simple_sync.h
+ *  implementation of a network sync test
+ */
+
+#ifndef _READ_SYNC
+#define _READ_SYNC
+
+#include "synchronizeable.h"
+
+
+class ReadSync : public Synchronizeable
+  {
+  public:
+    ReadSync(const char* name);
+    ~ReadSync();
+
+    virtual void writeBytes(const byte* data, int length);
+    virtual int readBytes(byte* data);
+
+
+  private:
+    virtual void writeDebug() const;
+    virtual void readDebug() const;
+
+
+  private:
+    byte* inData;
+    int   inLength;
+    int   recLength;
+  };
+
+#endif /* _READ_SYNC */
Index: /branches/network/src/subprojects/network/simple_sync.cc
===================================================================
--- /branches/network/src/subprojects/network/simple_sync.cc	(revision 5828)
+++ /branches/network/src/subprojects/network/simple_sync.cc	(revision 5829)
@@ -86,5 +86,5 @@
  *  read data from Synchronizeable
  */
-int SimpleSync::readBytes(byte* data) const
+int SimpleSync::readBytes(byte* data)
 {
   PRINTF(0)("SimpleSync: sent %i bytes of data\n", this->outLength);
Index: /branches/network/src/subprojects/network/simple_sync.h
===================================================================
--- /branches/network/src/subprojects/network/simple_sync.h	(revision 5828)
+++ /branches/network/src/subprojects/network/simple_sync.h	(revision 5829)
@@ -17,5 +17,5 @@
 
     virtual void writeBytes(const byte* data, int length);
-    virtual int readBytes(byte* data) const;
+    virtual int readBytes(byte* data);
 
 
Index: /branches/network/src/subprojects/network/write_sync.cc
===================================================================
--- /branches/network/src/subprojects/network/write_sync.cc	(revision 5829)
+++ /branches/network/src/subprojects/network/write_sync.cc	(revision 5829)
@@ -0,0 +1,123 @@
+/*
+  orxonox - the future of 3D-vertical-scrollers
+
+  Copyright (C) 2004 orx
+
+  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, or (at your option)
+      any later version.
+
+### File Specific:
+    main-programmer: Patrick Boenzli
+    co-programmer:
+*/
+
+
+/* this is for debug output. It just says, that all calls to PRINT() belong to the DEBUG_MODULE_NETWORK module
+          For more information refere to https://www.orxonox.net/cgi-bin/trac.cgi/wiki/DebugOutput
+*/
+#define DEBUG_MODULE_NETWORK
+
+#include "write_sync.h"
+
+#include "debug.h"
+
+
+/**
+ *  default constructor
+ */
+WriteSync::WriteSync(const char* name)
+  : Synchronizeable(name)
+{
+  /* define the local buffer size */
+  this->outLength = 10;
+  this->recLength = 0;
+  this->inLength = 40;
+  this->outData = new byte[this->outLength];
+  this->inData = new byte[this->inLength];
+
+  /* init the buffer data */
+  for( int i = 0; i < this->outLength; i++)
+  {
+    this->outData[i] = i;
+  }
+  for( int i = 0; i < this->inLength; i++)
+  {
+    this->inData[i] = 0;
+  }
+
+}
+
+
+/**
+ *  default destructor deletes all unneded stuff
+ */
+WriteSync::~WriteSync()
+{
+  if( this->outData)
+    delete[] this->outData;
+  if( this->inData)
+    delete[] this->inData;
+}
+
+
+/**
+ *  write data to Synchronizeable
+ */
+void WriteSync::writeBytes(const byte* data, int length)
+{
+  PRINTF(0)("WriteSync: got %i bytes of data\n", length);
+  this->recLength = length;
+  if(this->inLength < length)
+    PRINTF(0)("ERROR: local buffer is smaller than the data to receive.\n");
+
+  /* copy the data localy */
+  for( int i = 0; i < length; i++)
+  {
+    this->inData[i] = data[i];
+  }
+  /* and debug output */
+  this->writeDebug();
+}
+
+
+/**
+ *  read data from Synchronizeable
+ */
+int WriteSync::readBytes(byte* data)
+{
+  PRINTF(0)("WriteSync: sent %i bytes of data\n", this->outLength);
+
+  /* debug msg */
+  this->readDebug();
+
+  /* write the test message */
+  for( int i = 0; i < this->outLength; i++)
+    data[i] = this->outData[i];
+
+  /* return the length of the test */
+  return this->outLength;
+}
+
+
+void WriteSync::writeDebug() const
+{
+  PRINTF(0)("Write in bytes: \t(0 <-) |");
+  for(int i = 0; i < this->recLength; i++)
+  {
+    PRINT(0)(" [%u] ",this->inData[i]);
+  }
+  PRINT(0)("|\n");
+}
+
+
+void WriteSync::readDebug() const
+{
+  PRINTF(0)("Read out bytes: \t(0 ->) |");
+  for(int i = 0; i < this->outLength; i++)
+  {
+    PRINT(0)(" [%u] ",this->outData[i]);
+  }
+  PRINT(0)("|\n");
+}
Index: /branches/network/src/subprojects/network/write_sync.h
===================================================================
--- /branches/network/src/subprojects/network/write_sync.h	(revision 5829)
+++ /branches/network/src/subprojects/network/write_sync.h	(revision 5829)
@@ -0,0 +1,35 @@
+/*!
+ * @file simple_sync.h
+ *  implementation of a network sync test
+ */
+
+#ifndef _WRITE_SYNC
+#define _WRITE_SYNC
+
+#include "synchronizeable.h"
+
+
+class WriteSync : public Synchronizeable
+  {
+  public:
+    WriteSync(const char* name);
+    ~WriteSync();
+
+    virtual void writeBytes(const byte* data, int length);
+    virtual int readBytes(byte* data);
+
+
+  private:
+    virtual void writeDebug() const;
+    virtual void readDebug() const;
+
+
+  private:
+    byte* inData;
+    int   inLength;
+    int   recLength;
+    byte* outData;
+    int   outLength;
+  };
+
+#endif /* _WRITE_SYNC */
Index: /branches/network/src/world_entities/player.cc
===================================================================
--- /branches/network/src/world_entities/player.cc	(revision 5828)
+++ /branches/network/src/world_entities/player.cc	(revision 5829)
@@ -39,4 +39,13 @@
 
 CREATE_FACTORY(Player, CL_PLAYER);
+
+
+
+#define UP    0
+#define DOWN  1
+#define RIGHT 2
+#define LEFT  3
+#define TIME  4
+
 
 /**
@@ -107,4 +116,8 @@
   */
   delete this->weaponMan;
+  if( this->outData)
+    delete[] this->outData;
+  if( this->inData)
+    delete[] this->inData;
 }
 
@@ -160,4 +173,12 @@
 //   this->weaponMan->setSlotDirection(9, Quaternion(+M_PI, Vector(1,0,0)));:
 
+  this->outBufferLength = 100;
+  this->outLength = 0;
+  this->recLength = 0;
+  this->inBufferLength = 100;
+  this->inLength = 0;
+  this->sentLength = 0;
+  this->outData = new byte[this->outBufferLength];
+  this->inData = new byte[this->inBufferLength];
 }
 
@@ -282,9 +303,25 @@
   //orthDirection = orthDirection.cross (direction);
 
+
+  if( this->outLength >= this->outBufferLength) return;
+
+  if( this->bUp || this->bDown || this->bRight || this->bLeft)
+  {
+    this->outData[this->outLength++] = TIME;
+    this->outData[this->outLength++] = (byte)(lround(time * 100.0f));
+
+    PRINTF(0)("Writing TIME = %i, or %f\n", this->outData[this->outLength-1], time);
+  }
+
   if( this->bUp && this->getRelCoor().x < 20)
+  {
     accel += direction;
+    this->outData[this->outLength++] = UP;
+  }
   if( this->bDown && this->getRelCoor().x > -5)
+  {
     accel -= direction;
-
+    this->outData[this->outLength++] = DOWN;
+  }
   if( this->bLeft && TrackManager::getInstance()->getWidth() > -this->getRelCoor().z*2)
   {
@@ -292,4 +329,5 @@
     rot +=Vector(1,0,0);
     rotVal -= .4;
+    this->outData[this->outLength++] = LEFT;
   }
   if( this->bRight && TrackManager::getInstance()->getWidth() > this->getRelCoor().z*2)
@@ -298,4 +336,5 @@
     rot += Vector(1,0,0);
     rotVal += .4;
+    this->outData[this->outLength++] = RIGHT;
   }
   if (this->bAscend )
@@ -311,4 +350,5 @@
     rotVal -= .4;
   }
+
 
   Vector move = accel * time *acceleration;
@@ -322,4 +362,6 @@
   this->setRelDirSoft(Quaternion(rotVal, rot), 5);
   this->shiftCoor (move);
+
+
 }
 
@@ -394,2 +436,117 @@
   }
 }
+
+
+
+
+/**
+ *  write data to Synchronizeable
+ */
+void Player::writeBytes(const byte* data, int length)
+{
+  PRINTF(0)("Player: got %i bytes of data\n", length);
+  this->inLength = length;
+
+  /*
+   bytes:  | 0  |  1  |
+           CODE  DIST
+
+
+  CODE:
+       0 :   Up
+       1 :   Down
+       2 :   Right
+       3 :   Left
+       4 :   TIME
+
+  DIST:
+      Coordinate diff multiplied by 100 and casted to a byte: byte a = (byte)(x * 100)
+
+  */
+
+  float time = 0.0f;
+
+  Vector accel(0.0, 0.0, 0.0);
+  Vector direction (1.0, 0.0, 0.0);
+  Vector orthDirection (0.0, 0.0, 1.0);
+
+  byte code = 0;
+
+  /* iterate through all bytes */
+  for( int i = 0; i < length; i++)
+  {
+    code = data[i];
+
+    /* is it a time code? */
+    if( code == TIME)
+    {
+      /* is it the first time */
+      if( time > 0.0f )
+      {
+        /* apply movement */
+        Vector move = accel * time;
+
+        if (accel.z < 0)
+          this->setRelDirSoft(Quaternion(-.4, Vector(1,0,0)), 5);
+        else if (accel.z > 0)
+          this->setRelDirSoft(Quaternion(.4, Vector(1,0,0)), 5);
+        else
+          this->setRelDirSoft(Quaternion(0, Vector(1,0,0)), 5);
+        this->shiftCoor (move);
+      }
+      /* read out new movement */
+      time = (float)(data[++i] / 100.0f);
+      PRINTF(0)("Got time: %f msec\n", time);
+    }
+    else if( code == UP && this->getRelCoor().x < 20)
+      accel = accel+(direction*acceleration);
+    else if( code == DOWN && this->getRelCoor().x > -5)
+      accel = accel -(direction*acceleration);
+    else if( code == LEFT && TrackManager::getInstance()->getWidth() > -this->getRelCoor().z*2)
+      accel = accel - (orthDirection*acceleration);
+    else if( code == RIGHT && TrackManager::getInstance()->getWidth() > this->getRelCoor().z*2)
+      accel = accel + (orthDirection*acceleration);
+  }
+
+
+
+
+  /* and debug output */
+  this->writeDebug();
+}
+
+
+/**
+ *  read data from Synchronizeable
+ */
+int Player::readBytes(byte* data)
+{
+  PRINTF(0)("Player: sent %i bytes of data\n", this->sentLength);
+
+  /* copy data */
+  for( int i = 0; i < this->outLength; ++i)
+    data[i] = this->outData[i];
+
+
+
+  /* debug msg */
+  this->readDebug();
+
+  int length = this->outLength;
+  this->outLength = 0;
+  /* return the length of the test */
+  return length;
+}
+
+
+void Player::writeDebug() const
+{
+
+}
+
+
+void Player::readDebug() const
+{
+
+}
+
Index: /branches/network/src/world_entities/player.h
===================================================================
--- /branches/network/src/world_entities/player.h	(revision 5828)
+++ /branches/network/src/world_entities/player.h	(revision 5829)
@@ -11,5 +11,6 @@
 #include "event_listener.h"
 
-template<class T> class tList;
+template<class T>
+class tList;
 class Weapon;
 class WeaponManager;
@@ -25,5 +26,5 @@
 class Player : public WorldEntity, public EventListener
 {
-  friend class World;
+    friend class World;
 
   public:
@@ -39,4 +40,5 @@
     void removeWeapon(Weapon* weapon);
 
+    /* WorldEntity functions */
     virtual void postSpawn();
     virtual void leftWorld();
@@ -48,8 +50,15 @@
     virtual void process(const Event &event);
 
+    /* Synchronizeable functions */
+    virtual void writeBytes(const byte* data, int length);
+    virtual int readBytes(byte* data);
 
   private:
     void move(float time);
     void weaponAction();
+
+    /* Synchronizeable functions */
+    virtual void writeDebug() const;
+    virtual void readDebug() const;
 
     // !! temporary !!
@@ -70,4 +79,14 @@
     float                 travelSpeed;        //!< the current speed of the player (to make soft movement)
     float                 acceleration;       //!< the acceleration of the player.
+
+    byte*                 inData;
+    int                   inLength;
+    int                   inBufferLength;
+    int                   recLength;
+    byte*                 outData;
+    int                   outLength;
+    int                   outBufferLength;
+    int                   sentLength;
+
 };
 
Index: /branches/network/src/world_entities/world_entity.cc
===================================================================
--- /branches/network/src/world_entities/world_entity.cc	(revision 5828)
+++ /branches/network/src/world_entities/world_entity.cc	(revision 5829)
@@ -41,4 +41,5 @@
  */
 WorldEntity::WorldEntity(const TiXmlElement* root)
+  : Synchronizeable()
 {
   this->setClassID(CL_WORLD_ENTITY, "WorldEntity");
Index: /branches/network/src/world_entities/world_entity.h
===================================================================
--- /branches/network/src/world_entities/world_entity.h	(revision 5828)
+++ /branches/network/src/world_entities/world_entity.h	(revision 5829)
@@ -8,4 +8,6 @@
 
 #include "p_node.h"
+#include "synchronizeable.h"
+#include "model.h"
 
 #include "glincl.h"
@@ -21,5 +23,5 @@
 
 //! Basis-class all interactive stuff in the world is derived from
-class WorldEntity : public PNode
+class WorldEntity : public PNode, public Synchronizeable
 {
  public:
