Index: /trunk/src/Makefile.am
===================================================================
--- /trunk/src/Makefile.am	(revision 6138)
+++ /trunk/src/Makefile.am	(revision 6139)
@@ -25,5 +25,5 @@
                        lib/gui/gl_gui/libORXglgui.a \
                        lib/shell/libORXshell.a \
-                       lib/network/libORXnet.a 
+                       lib/network/libORXnet.a
 
 orxonox_LDADD = util/libORXutils.a \
@@ -49,4 +49,5 @@
                   story_entities/campaign.cc \
                   story_entities/world.cc \
+                  story_entities/network_world.cc \
                   world_entities/world_entity.cc \
                   world_entities/camera.cc \
@@ -85,4 +86,5 @@
                   world_entities/space_ships/space_ship.cc \
                   world_entities/space_ships/helicopter.cc \
+                  world_entities/spawning_point.cc \
                   subprojects/benchmark.cc
 
@@ -94,4 +96,5 @@
                  story_entities/campaign.h \
                  story_entities/world.h \
+                 story_entities/network_world.h \
                  world_entities/world_entity.h \
                  world_entities/camera.h \
@@ -130,4 +133,5 @@
                  world_entities/space_ships/space_ship.h \
                  world_entities/space_ships/helicopter.h \
+                 world_entities/spawning_point.h \
                  defs/stdincl.h \
                  defs/stdlibincl.h \
Index: /trunk/src/defs/class_id.h
===================================================================
--- /trunk/src/defs/class_id.h	(revision 6138)
+++ /trunk/src/defs/class_id.h	(revision 6139)
@@ -147,4 +147,5 @@
   CL_SPACE_SHIP                 =    0x0000020a,
   CL_HELICOPTER                 =    0x0000020b,
+  CL_SPAWNING_POINT             =    0x0000020b,
 
   CL_TURRET_POWER_UP            =    0x00000211,
@@ -230,5 +231,5 @@
 
   // network stuff (range from 0x00000b00 to 0x00000bff)
-  CL_DATA_STREAM                =    0x00b01000,
+  CL_DATA_STREAM                =    0x00b01b00,
   CL_NETWORK_STREAM             =    0x00000b01,
   CL_NETWORK_PROTOCOL           =    0x00000b02,
@@ -236,4 +237,6 @@
   CL_SERVER_SOCKET              =    0X00000b04,
   CL_CONNECTION_MONITOR         =    0x00000b05,
+  CL_HANDSHAKE                  =    0x00000b06,
+  CL_ENTITY_MANAGER             =    0x00000b07,
 
 
Index: /trunk/src/lib/graphics/importer/texture.cc
===================================================================
--- /trunk/src/lib/graphics/importer/texture.cc	(revision 6138)
+++ /trunk/src/lib/graphics/importer/texture.cc	(revision 6139)
@@ -19,4 +19,6 @@
 
 #include "debug.h"
+#include "compiler.h"
+#include <math.h>
 
 // INCLUDING SDL_Image
@@ -37,4 +39,5 @@
   this->texture = 0;
   this->image = NULL;
+  this->priority = 0.5;
 
   if (imageName != NULL)
@@ -177,5 +180,5 @@
  * @returns a !!new!! Surface, that is loadable by openGL.
  */
-SDL_Surface* Texture::prepareSurface(SDL_Surface* surface, bool& hasAlpha)
+SDL_Surface* Texture::prepareSurface(SDL_Surface* surface, bool& hasAlpha) const
 {
   PRINTF(4)("Loading texture to OpenGL-Environment.\n");
@@ -237,5 +240,5 @@
  * @returns The ID of the texture.
  */
-GLuint Texture::loadTexToGL (const SDL_Surface* surface)
+GLuint Texture::loadTexToGL (const SDL_Surface* surface) const
 {
 //   if (this->texture != 0 && glIsTexture(this->texture))
@@ -243,5 +246,10 @@
 //   this->texture = 0;
 
-  GLuint texture;
+  int      errorCode = 0;           //!< the error code for the texture loading functions
+  GLuint   texture;                 //!< the OpenGL texture handle
+  int      mipmapLevel = 0;         //!< the maximum mipmap level for this texture
+  int      mipmapWidth = 0;         //!< the width of the mipmap
+  int      mipmapHight = 0;         //!< the height of the mipmap
+
 
   if (surface == NULL)
@@ -251,7 +259,13 @@
   glGenTextures(1, &texture);
   glBindTexture(GL_TEXTURE_2D, texture);
-  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-  // build the Texture
+
+  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, /*GL_LINEAR*/ GL_LINEAR_MIPMAP_LINEAR);
+  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, /*GL_LINEAR*/ GL_LINEAR);
+  /* control the mipmap levels */
+  glTexParameterf(GL_TEXTURE_ENV, GL_TEXTURE_MIN_LOD, -100);
+  glTexParameterf(GL_TEXTURE_ENV, GL_TEXTURE_MAX_LOD, 0);
+  glTexParameterf(GL_TEXTURE_ENV, GL_TEXTURE_PRIORITY, this->priority);
+
+  /* build the Texture  OpenGL V >= 1.1 */
   glTexImage2D(GL_TEXTURE_2D,
                0,
@@ -262,13 +276,38 @@
                GL_UNSIGNED_BYTE,
                surface->pixels);
-  // build the MipMaps
-  gluBuild2DMipmaps(GL_TEXTURE_2D,
-                    GL_RGBA,
-                    surface->w,
-                    surface->h,
-                    GL_RGBA,
-                    GL_UNSIGNED_BYTE,
-                    surface->pixels);
+
+  // build the MipMaps automaticaly
+  errorCode = gluBuild2DMipmaps(GL_TEXTURE_2D,
+                                GL_RGBA,
+                                surface->w,
+                                surface->h,
+                                GL_RGBA,
+                                GL_UNSIGNED_BYTE,
+                                surface->pixels
+                               );
+  if(unlikely(errorCode != 0))
+    PRINTF(1)("Error while loading texture, gluBuild2DMipmaps returned %i\n", errorCode);
+
+#define max(a,b) (a>b)?a:b
+  mipmapLevel = (int)(log2f(max(surface->w, surface->h)));
+#undef max
+  PRINTF(5)("Built the texture mipmpaps, got: %i levels of detail\n", mipmapLevel);
+
+  /* now actualy load the mipmaps into the graphics memory */
+  glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 1, GL_TEXTURE_WIDTH, &mipmapWidth);
+  glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 1, GL_TEXTURE_WIDTH, &mipmapHight);
+  PRINTF(5)(" Mipmap at level %i has a %ix%i resolution\n", 1, mipmapWidth, mipmapHight);
+  glTexImage2D(GL_PROXY_TEXTURE_2D,
+               1,
+               GL_RGBA,
+               mipmapWidth, mipmapHight,
+               0,
+               GL_RGBA,
+               GL_UNSIGNED_BYTE,
+               NULL
+               );
+
   glBindTexture(GL_TEXTURE_2D, 0);
   return texture;
 }
+
Index: /trunk/src/lib/graphics/importer/texture.h
===================================================================
--- /trunk/src/lib/graphics/importer/texture.h	(revision 6138)
+++ /trunk/src/lib/graphics/importer/texture.h	(revision 6139)
@@ -39,6 +39,6 @@
 
       // Utility functionality:
-      static SDL_Surface* prepareSurface(SDL_Surface* input, bool& hasAlpha);
-      static GLuint loadTexToGL (const SDL_Surface* surface);
+      SDL_Surface* prepareSurface(SDL_Surface* input, bool& hasAlpha) const;
+      GLuint loadTexToGL (const SDL_Surface* surface) const;
 
     protected:
@@ -53,4 +53,5 @@
       bool             bAlpha;             //!< if the texture has an alpha channel.
       SDL_Surface*     image;              //!< The SDL_Surfce that stores the Texture on it.
+      GLclampf         priority;           //!< the priority of the current texture (used for garphics cards with limited mem)
 
       static bool      texturesEnabled;    //!< If the Textures are enabled.
Index: /trunk/src/lib/network/Makefile.am
===================================================================
--- /trunk/src/lib/network/Makefile.am	(revision 6138)
+++ /trunk/src/lib/network/Makefile.am	(revision 6139)
@@ -11,5 +11,9 @@
                       data_stream.cc \
                       network_protocol.cc \
-		      server_socket.cc
+		      server_socket.cc \
+		      handshake.cc \
+		      network_game_manager.cc \
+		      converter.cc
+
 
 
@@ -22,4 +26,8 @@
                  data_stream.h \
                  network_protocol.h \
-		 server_socket.h
+		 server_socket.h \
+		 handshake.h \
+		 network_game_manager.h \
+		 converter.h
 
+
Index: /trunk/src/lib/network/converter.cc
===================================================================
--- /trunk/src/lib/network/converter.cc	(revision 6139)
+++ /trunk/src/lib/network/converter.cc	(revision 6139)
@@ -0,0 +1,214 @@
+/*
+   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: Benjamin Wuest
+   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 your own header */
+#include "converter.h"
+
+
+/* using namespace std is default, this needs to be here */
+using namespace std;
+
+/*!
+ * Standard constructor
+ */
+Converter::Converter()
+{
+  /* set the class id for the base object */
+  //this->setClassID(CL_ENTITY_MANAGER, "EntityManager");
+}
+
+/*!
+ * Standard destructor
+ */
+Converter::~Converter()
+{
+}
+
+const int sgnadd = 128; // = 2^7
+
+/*!
+ * Converts an int into a byte-array
+ * @remarks: The int is stored in big-endian
+ * @param x: The int which is to convert
+ * @return: A byte-array that accords the given int value
+ */
+byte* Converter::intToByteArray(int x)
+{
+  const int mod = 256; // = 2^8
+  
+  
+  byte* result = new byte[INTSIZE];
+  int sgn;
+  if (x >= 0)
+    sgn = 1;
+  else
+  {
+    sgn = -1;
+    x = -x;
+  }
+  
+  for (int i = 0; i < INTSIZE; i++)
+  {
+    result[i] = x % mod;
+    x /= mod;
+  }
+  
+  if (sgn == -1)
+    result[INTSIZE - 1] += sgnadd;
+  
+  
+  return result;
+}
+
+/*!
+ * Converts a byte-array into an int
+ * @param a: The byte-array which is to convert
+ * @return: An int that accords the given byte-array
+ */
+int Converter::byteArrayToInt(byte* a)
+{
+  int mult = 1;
+  const int step = 256; // = 2 ^ 8
+  int result = 0;
+  for (int i = 0; i < INTSIZE - 1; i++)
+  {
+    result += a[i] * mult;
+    mult *= step;
+  }
+  
+  printf("tara: %i", result);
+  
+  if (a[INTSIZE - 1] >= sgnadd)
+  {
+    result += (a[INTSIZE - 1] - sgnadd) * mult;
+    result *= -1;
+  }
+  else
+    result += a[INTSIZE - 1] * mult;
+  
+  return result;
+}
+
+/*char* Converter::floatToBinString(float x)
+{
+  char* result = new char[200];
+  int pos = 0;
+  
+  int h = (int)x;
+  if (h > x)
+    h--;
+  x -= h;
+  
+  
+  while (h > 0 && pos < 200)
+  {
+    //printf("%i ", pos);
+    
+    if (h % 2 == 1)
+    {
+      result[pos] = '1';
+      h -= 1;
+    }
+    else
+      result[pos] = '0';
+    pos++;
+    h /= 2;
+  }
+  
+  //printf("x = %f\n", x);
+  
+  
+  //invert
+  for (int i = 0; i < pos / 2; i++)
+  {
+    char temp = result[i];
+    result[i] = result[pos - 1 - i];
+    result[pos - 1 - i] = temp;
+  }
+  
+  
+  result[pos++] = '.';
+  float sub = 0.5;
+  while (x > 0 && pos < 200)
+  {
+    //printf("%i ", pos);
+    
+    if (x >= sub)
+    {
+      result[pos] = '1';
+      x -= sub;
+    }
+    else
+      result[pos] = '0';
+    pos++;
+    sub /= 2;
+  }
+  
+  
+  return result;
+}*/
+
+char* Converter::floatToBinString(float x)
+{
+  char* result = new char[200];
+  int pos = 0;
+  
+  float sub = 1;
+  while (sub < x)
+    sub *= 2;
+  
+  //printf("sub = %f\n", sub);
+  
+  //while (sub >= 1 && pos < 200)
+  while ((x > 0 || sub >= 1) && pos < 200)
+  {
+    if (x >= sub)
+    {
+      result[pos] = '1';
+      x -= sub;
+    }
+    else
+      result[pos] = '0';
+    pos++;
+    sub /= 2;
+    
+    if (sub == 0.5f)
+      result[pos++] = '.';
+  }
+  
+  /*result[pos++] = '.';
+  sub = 0.5;
+  while (x > 0 && pos < 200)
+  {
+    if (x >= sub)
+    {
+      result[pos] = '1';
+      x -= sub;
+    }
+    else
+      result[pos] = '0';
+    pos++;
+    sub /= 2;
+  }
+  */
+  
+  return result;
+}
Index: /trunk/src/lib/network/converter.h
===================================================================
--- /trunk/src/lib/network/converter.h	(revision 6139)
+++ /trunk/src/lib/network/converter.h	(revision 6139)
@@ -0,0 +1,38 @@
+/*!
+ * @file converter.h
+ *  Is able to convert int to byte-array and vice versa
+ */
+ 
+#ifndef _CONVERTER
+#define _CONVERTER
+
+/* include this file, it contains some default definitions */
+#include "netdefs.h"
+
+/* include base_object.h since all classes are derived from this one */
+#include "base_object.h"
+
+/* The size of an int in byte */
+#define INTSIZE 4
+
+/*!
+ * a class that can convert int to byte-array and vice versa
+ */
+class Converter: public BaseObject
+{
+  public:
+    static byte* intToByteArray(int x);
+    static int byteArrayToInt(byte* a);
+    
+    //byte* floatToByteArray(float x);
+    //float byteArrayToFloat(byte[] a);
+    
+    //Test
+    static char* floatToBinString(float x);
+    
+  private:
+    Converter();
+    ~Converter();
+};
+
+#endif /*_CONVERTER*/
Index: /trunk/src/lib/network/handshake.cc
===================================================================
--- /trunk/src/lib/network/handshake.cc	(revision 6139)
+++ /trunk/src/lib/network/handshake.cc	(revision 6139)
@@ -0,0 +1,196 @@
+/*
+   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: christoph
+   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 "handshake.h"
+
+Handshake::Handshake( bool server, int clientId, int networkGameManagerId )
+{
+  /* set the class id for the base object */
+  this->setClassID(CL_HANDSHAKE, "Handshake");
+
+  this->setIsServer(server);
+  this->clientId = clientId;
+  this->networkGameManagerId = networkGameManagerId;
+  this->state = 0;
+  this->isOk = false;
+  this->setOwner(0);
+
+  PRINTF(5)("Handshake created clientId = %d\n", clientId);
+}
+
+void Handshake::writeBytes( const byte * data, int length )
+{
+  PRINTF(5)("Handshake::writeBytes states = %d %d %d %d (%d)\n", hasState( HS_RECVD_INIT ), hasState( HS_RECVD_VER ), hasState( HS_RECVD_HID ), hasState( HS_COMPLETED ), state);
+
+  if ( hasState( HS_COMPLETED ) )
+       return;
+
+  if ( !hasState( HS_RECVD_INIT ) )
+  {
+    if ( length != _INITIAL_DATA_LENGTH )
+    {
+      PRINTF(0)("initial packet has wrong size %d instead of %d\n", length, _INITIAL_DATA_LENGTH);
+      setState( HS_COMPLETED );
+      return;
+    }
+
+    if ( strncmp((char*)data, _INITIAL_DATA, length) )
+    {
+      PRINTF(0)("initial packed does not match\n");
+      setState( HS_COMPLETED );
+      return;
+    }
+
+    setState( HS_RECVD_INIT );
+    PRINTF(0)("got valid initial packet from client %d\n", clientId);
+    return;
+  }
+
+  if ( hasState( HS_RECVD_INIT ) && !hasState( HS_RECVD_VER ) )
+  {
+    if ( length != _ORXONOX_VERSION_LENGTH )
+    {
+      PRINTF(0)("version number packet has wrong size %d instead of %d\n", length, _ORXONOX_VERSION_LENGTH);
+      setState( HS_COMPLETED );
+      return;
+    }
+
+    if ( strncmp((char*)data, _ORXONOX_VERSION, length) )
+    {
+      PRINTF(0)("versions do not match\n");
+      setState( HS_COMPLETED );
+      return;
+    }
+
+    setState( HS_RECVD_VER );
+
+    PRINTF(0)("client %d's version does match\n", clientId);
+    return;
+  }
+
+  if ( !isServer() && hasState( HS_RECVD_VER ) && !hasState( HS_RECVD_HID ) )
+  {
+    if ( length != 2 )
+    {
+      PRINTF(0)("hostID packet has wrong size %d instead of %d\n", length, 1);
+      setState( HS_COMPLETED );
+      return;
+    }
+
+    setState( HS_COMPLETED );
+    setState( HS_RECVD_HID );
+    this->isOk = true;
+    this->newHostId = data[0];
+    this->newNetworkGameManagerId = data[1];
+
+    if ( newHostId == 0 )
+    {
+      setState( HS_WAS_REJECT );
+      isOk = false;
+      PRINTF(0)("Server did not accept handshake!\n");
+    }
+    else
+    {
+      PRINTF(0)("got my hostID: %d and networkGameManagerId: %d\n", newHostId, newNetworkGameManagerId);
+    }
+    return;
+  }
+
+}
+
+int Handshake::readBytes( byte * data, int maxLength, int * reciever )
+{
+  PRINTF(5)("Handshake::readBytes states = %d %d %d %d (%d)\n", hasState( HS_SENT_INIT ), hasState( HS_SENT_VER ), hasState( HS_SENT_HID ), hasState( HS_COMPLETED ), state);
+
+  if ( hasState( HS_COMPLETED ) )
+    return 0;
+
+  if ( !hasState( HS_SENT_INIT ) )
+  {
+    if ( maxLength < _INITIAL_DATA_LENGTH )
+    {
+      PRINTF(0)("buffer too small for _INITIAL_DATA");
+      setState( HS_COMPLETED );
+      return 0;
+    }
+
+    setState( HS_SENT_INIT );
+    memcpy(data, _INITIAL_DATA, _INITIAL_DATA_LENGTH);
+    if ( this->isServer() )
+      *reciever = clientId;
+    return _INITIAL_DATA_LENGTH;
+  }
+
+  if ( hasState( HS_RECVD_INIT ) && hasState( HS_SENT_INIT ) && !hasState( HS_SENT_VER ) )
+  {
+    if ( maxLength < _ORXONOX_VERSION_LENGTH )
+    {
+      PRINTF(0)("buffer too small for version number");
+      setState( HS_COMPLETED );
+      return 0;
+    }
+
+    setState( HS_SENT_VER );
+    memcpy(data, _ORXONOX_VERSION, _ORXONOX_VERSION_LENGTH);
+    if ( this->isServer() )
+      *reciever = clientId;
+    return _ORXONOX_VERSION_LENGTH;
+  }
+
+  if ( isServer() && hasState( HS_RECVD_VER) && hasState( HS_SENT_VER ) && !hasState( HS_SENT_HID ) )
+  {
+    if ( maxLength < 2 )
+    {
+      PRINTF(0)("buffer too small for ID");
+      setState( HS_COMPLETED );
+      return 0;
+    }
+
+    setState( HS_SENT_HID );
+    setState( HS_COMPLETED );
+
+    if ( hasState( HS_DO_REJECT ) )
+    {
+      isOk = false;
+      //memcpy(data, (byte*)0, 4);
+      data[0] = 0;
+    }
+    else
+    {
+      isOk = true;
+      //memcpy(data, &clientId, 4);
+      data[0] = (byte)clientId;
+      data[1] = (byte)networkGameManagerId;
+    }
+    *reciever = clientId;
+    return 2;
+  }
+
+  return 0;
+}
+
+void Handshake::writeDebug( ) const
+{
+}
+
+void Handshake::readDebug( ) const
+{
+}
Index: /trunk/src/lib/network/handshake.h
===================================================================
--- /trunk/src/lib/network/handshake.h	(revision 6139)
+++ /trunk/src/lib/network/handshake.h	(revision 6139)
@@ -0,0 +1,64 @@
+/*!
+ * @file network_stream.h
+ *  implementation of a network pipe
+ */
+
+#ifndef _HANDSHAKE
+#define _HANDSHAKE
+
+#include "base_object.h"
+#include "synchronizeable.h"
+
+#define _INITIAL_DATA "orxonox"
+#define _INITIAL_DATA_LENGTH 7
+
+#define _ORXONOX_VERSION "\x00\x00\x00\x01"
+#define _ORXONOX_VERSION_LENGTH 4
+
+typedef enum HandshakeState {
+  HS_SENT_INIT  = 0x00000001,
+  HS_RECVD_INIT = 0x00000002,
+  HS_SENT_VER   = 0x00000004,
+  HS_RECVD_VER  = 0x00000008,
+  HS_SENT_HID   = 0x00000010,
+  HS_RECVD_HID  = 0x00000020,
+  HS_COMPLETED  = 0x00000040,
+
+  HS_DO_REJECT  = 0x00010000,
+  HS_WAS_REJECT = 0x00020000,
+
+  NUM_STATES
+};
+
+class Handshake : public Synchronizeable
+{
+  public:
+    Handshake(bool server, int clientId = 0, int networkGameManagerId = 0);
+    inline bool       completed(){ return hasState( HS_COMPLETED ); }
+    inline bool       ok(){ return isOk; }
+    inline int        getHostId(){ return newHostId; }
+    inline int        getNetworkGameManagerId(){ return newNetworkGameManagerId; }
+
+    inline void       doReject(){ setState(HS_DO_REJECT); }
+
+    virtual void      writeBytes(const byte* data, int length);
+    virtual int       readBytes(byte* data, int maxLength, int * reciever);
+    virtual void      writeDebug() const;
+    virtual void      readDebug() const;
+
+  private:
+    int               state;
+    int               clientId;
+    int               networkGameManagerId;
+    int               newHostId;
+    int               newNetworkGameManagerId;
+    bool              isOk;
+
+    inline bool       hasState( int a ){ return (state & a) == a; }
+    inline void       setState( int a ){ state = state | a; }
+    inline void       unsetState( int a ){ state = state & (~a); }
+
+};
+
+
+#endif
Index: /trunk/src/lib/network/network_game_manager.cc
===================================================================
--- /trunk/src/lib/network/network_game_manager.cc	(revision 6139)
+++ /trunk/src/lib/network/network_game_manager.cc	(revision 6139)
@@ -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: Benjamin Wuest
+   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 your own header */
+#include "network_game_manager.h"
+
+
+/* using namespace std is default, this needs to be here */
+using namespace std;
+
+/*!
+ * Standard constructor
+ */
+NetworkGameManager::NetworkGameManager()
+{
+  /* set the class id for the base object */
+  this->setClassID(CL_ENTITY_MANAGER, "EntityManager");
+}
+
+/*!
+ * Standard destructor
+ */
+NetworkGameManager::~NetworkGameManager()
+{
+}
+
+
+void NetworkGameManager::writeBytes(const byte* data, int length)
+{
+}
+
+int NetworkGameManager::readBytes(byte* data, int maxLength, int * reciever)
+{
+}
+
+void NetworkGameManager::writeDebug() const
+{
+}
+
+void NetworkGameManager::readDebug() const
+{
+}
+
+
+/*!
+ * Checks whether this is connected to a server or a client
+ * and afterwards creates the needed entity if possible
+ * @param classID: The ID of the class of which an entity should be created
+ */
+void NetworkGameManager::createEntity(int classID)
+{
+}
+
+/*!
+ * Checks whether this is connected to a server or a client
+ * and afterwards removes the specified entity
+ * @param uniqueID: The ID of the entity object which should be removed
+ */
+void NetworkGameManager::removeEntity(int uniqueID)
+{
+}
+
+
+
+/*!
+ * Creates the needed entity on the server if possible
+ * @param classID: The ID of the class of which an entity should be created
+ */
+void NetworkGameManager::requestCreateEntity(int classID)
+{
+}
+
+/*!
+ * Removes the specified entity on the server
+ * @param uniqueID: The ID of the entity object which should be removed
+ */
+void NetworkGameManager::requestRemoveEntity(int uniqueID)
+{
+}
+
+/*!
+ * Creates the needed entity if possible
+ * This function is called if this is a server
+ * @param classID: The ID of the class of which an entity should be created
+ */
+void NetworkGameManager::executeCreateEntity(int classID)
+{
+}
+
+/*!
+ * Removes the specified entity
+ * This function is called if this is a server
+ * @param uniqueID: The ID of the entity object which should be removed
+ */
+void NetworkGameManager::executeRemoveEntity(int uniqueID)
+{
+}
+
+/*!
+ * Checks whether it is possible to create an entity of a given class
+ * @return: true if the entity can be created, false otherwise
+ */
+bool NetworkGameManager::canCreateEntity(int classID)
+{
+}
Index: /trunk/src/lib/network/network_game_manager.h
===================================================================
--- /trunk/src/lib/network/network_game_manager.h	(revision 6139)
+++ /trunk/src/lib/network/network_game_manager.h	(revision 6139)
@@ -0,0 +1,89 @@
+/*!
+ * @file entity_manager.h
+ *  Manages creation and destruction of entities
+ */
+
+#ifndef _NETWORK_GAME_MANGER
+#define _NETWORK_GAME_MANAGER
+
+/* include this file, it contains some default definitions */
+#include "netdefs.h"
+
+/* include base_object.h since all classes are derived from this one */
+#include "synchronizeable.h"
+
+
+
+/**
+ * protocol definition
+ *
+ *  CREATE_ENTITY:      CLASS_ID, UNIQUE_ID, OWNER
+ *  REMOVE_ENTITY:      UNIQUE_ID
+ *
+ *  CREATE_ENTITY_LIST: NUMBER, [CLASS_ID, UNIQUE_ID, OWNER][0..NUMBER]
+ *  REMOVE_ENTITY_LIST: NUMBER, [UNIQUE_ID][0..NUMBER]
+ *
+ *  REQUEST_CREATE:     CLASS_ID
+ *  REQUEST_REMOVE:     UNIQUE_ID
+ *
+ *  REQUEST_SYNC:       UNIQUE_ID
+ *  REQUEST_SYNC_LIST:  NUMBER, [UNIQUE_ID][0..NUMBER]
+ *
+ *
+ */
+
+
+
+
+
+
+
+
+
+
+/*!
+ * a class that can create and remove entities
+ */
+class NetworkGameManager: public Synchronizeable
+{
+  public:
+    NetworkGameManager();
+    ~NetworkGameManager();
+
+    virtual void writeBytes(const byte* data, int length);
+    virtual int readBytes(byte* data, int maxLength, int * reciever);
+    virtual void writeDebug() const;
+    virtual void readDebug() const;
+
+    void createEntity(int classID);
+    void createEntityList(int* classIDList);
+    void removeEntity(int uniqueID);
+    void removeEntityList(int* uniqueIDList);
+
+    void sync(int uniqueID);
+    void syncList(int* uniqueIDList);
+
+
+  private:
+    void requestCreateEntity(int classID);
+    void executeCreateEntity(int classID);
+    void requestCreateEntityList(int* classIDList);
+    void executeCreateEntityList(int* classIDList);
+
+    void requestRemoveEntity(int uniqueID);
+    void executeRemoveEntity(int uniqueID);
+    void requestRemoveEntityList(int* uniqueIDList);
+    void executeRemoveEntityList(int* uniqueIDList);
+
+
+
+    bool canCreateEntity(int classID);
+
+
+
+  private:
+    byte*          inBuffer;
+    byte*          outBuffer;
+};
+
+#endif /*_ENTITY_MANGER*/
Index: /trunk/src/lib/network/network_manager.cc
===================================================================
--- /trunk/src/lib/network/network_manager.cc	(revision 6138)
+++ /trunk/src/lib/network/network_manager.cc	(revision 6139)
@@ -50,4 +50,5 @@
   this->tmpStream = NULL;
   this->hostID = -1;
+  this->bGameServer = false;
 
   PRINTF(0)("NetworkManager created\n");
@@ -95,5 +96,5 @@
   }
 
-  this->tmpStream = new NetworkStream(ipAddress, NET_CLIENT);
+  this->tmpStream = new NetworkStream(ipAddress);
   return 1;
 }
@@ -106,5 +107,6 @@
 int NetworkManager::createServer(unsigned int port)
 {
-  this->tmpStream = new NetworkStream(port, NET_SERVER);
+  this->tmpStream = new NetworkStream(port);
+  this->bGameServer = true;
   SDL_Delay(20);
   return 1;
@@ -120,5 +122,6 @@
 {
   /* creating a new network stream, it will register itself automaticaly to the class list */
-  this->tmpStream = new NetworkStream(address, sync, NET_CLIENT);
+  this->tmpStream = new NetworkStream(address);
+  this->tmpStream->connectSynchronizeable(sync);
 }
 
@@ -132,5 +135,7 @@
   PRINTF(0)("Create a new server socket\n");
   /* creating a new network stream, it will register itself automaticaly to the class list */
-  this->tmpStream = new NetworkStream(port, sync, NET_SERVER);
+  this->tmpStream = new NetworkStream(port);
+  this->tmpStream->connectSynchronizeable(sync);
+  this->bGameServer = true;
 }
 
Index: /trunk/src/lib/network/network_manager.h
===================================================================
--- /trunk/src/lib/network/network_manager.h	(revision 6138)
+++ /trunk/src/lib/network/network_manager.h	(revision 6139)
@@ -45,19 +45,22 @@
     void setHostID(int id);
     /** Returns the hostID @return The hostID of the object */
-    inline int getHostID() { return this->hostID; };
+    inline int getHostID() { return this->hostID; }
+    inline bool isGameServer() { return this->bGameServer; }
 
-  private:
+
     void connectSynchronizeable(Synchronizeable& sync);
     void synchronize();
 
+  private:
     NetworkManager();
 
 
   private:
-    const std::list<BaseObject*>*    netStreamList;            // list with refs to all network streams
-    const 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
-    int hostID;                                    //!< The Host-ID of the Manager
+    const std::list<BaseObject*>*    netStreamList;           // list with refs to all network streams
+    const 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
+    int                              hostID;                  //!< The Host-ID of the Manager
+    bool                             bGameServer;             //!< true if it is a server
 
 };
Index: /trunk/src/lib/network/network_protocol.cc
===================================================================
--- /trunk/src/lib/network/network_protocol.cc	(revision 6138)
+++ /trunk/src/lib/network/network_protocol.cc	(revision 6139)
@@ -57,34 +57,24 @@
     * @arg bufferLength: the length of the internal buffer
     * @arg source: reference to the source Synchronizeable object
-    * @arg remoteID: id number of the remote Synchronizeable object
     * @return: the new data length with header (the header data is included into byte* data)
     *          -1 if there isn't enough space in the buffer for the header
 */
-int NetworkProtocol::createHeader(byte* data, int length, int bufferLength, const Synchronizeable& source, unsigned int remoteID)
+int NetworkProtocol::createHeader(byte* data, int length, int bufferLength, const Synchronizeable& source)
 {
-  printf("NetworkProtocol: create header length = %i, bufferLength = %i\n", length, bufferLength);
+  PRINTF(5)("create header length = %i, bufferLength = %i\n", length, bufferLength);
   //If there isn't enough space for the header return -1
   if (length + this->headerLength > bufferLength)
     return -1;
 
-//   for(int i = 0; i < length; i++)
-//     printf("send byte[%i]=%u\n", i, data[i]);
 
-
-  //Create space for the header
+  // FIXME: without move Create space for the header
   for( int i = length - 1; i >= 0; i--)
     data[i + this->headerLength] = data[i];
 
   //Now create the header
-  /* protocol identifier */
-  data[0] = 255;
-  /* version number */
-  data[1] = 0;
   /* sender ID: FIXME: there will be a better ID (for example unique:D)*/
-  data[2] = (byte)source.getClassID();
-  /* receiver ID */
-  data[3] = remoteID;
+  data[0] = (byte)(source.getUniqueID());
   /* data length*/
-  data[4] = length;
+  data[1] = length;
 
 
@@ -100,11 +90,11 @@
 Header NetworkProtocol::extractHeader(byte* data, int length)
 {
-  PRINTF(0)("extract Header\n");
+  PRINTF(5)("extract Header\n");
   //Test if received data can contain a header
   if (length < headerLength)
   {
-    PRINTF(0)("Received data is to short; it can't contain a header!");
+    PRINTF(1)("Received data is to short; it can't contain a header!\n");
     Header h;
-    h.protocol = 0;
+    h.length = 0;
     return h;
   }
@@ -114,21 +104,9 @@
   //&h = data;
 
-  h.protocol = data[0];
-  /* version number */
-  h.version = data[1];
-  /* sender ID: FIXME: there will be a better ID (for example unique:D)*/
-  h.senderID = data[2];
-  /* receiver ID */
-  h.receiverID = data[3];
+  /* unique ID */
+  h.synchronizeableID = data[0];
   /* data length*/
-  h.length = data[4];
+  h.length = data[1];
 
-
-//   for(int i = 0; i < length; i++)
-//     printf("recS byte[%i]=%u\n", i, data[i]);
-
-  //Remove header
-//   for (int i = headerLength; i < length; i++)
-//     data[i - headerLength] = data[i];
 
   return h;
Index: /trunk/src/lib/network/network_protocol.h
===================================================================
--- /trunk/src/lib/network/network_protocol.h	(revision 6138)
+++ /trunk/src/lib/network/network_protocol.h	(revision 6139)
@@ -6,4 +6,5 @@
 #define _NETWORK_PROTOCOL_H
 
+/* include base_object.h since all classes are derived from this one */
 #include "base_object.h"
 
@@ -11,12 +12,7 @@
 #include "netdefs.h"
 
-#define HEADER_LENGTH 1
-
 typedef struct Header
 {
-  byte protocol;
-  byte version;
-  byte senderID;
-  byte receiverID;
+  byte synchronizeableID;
   byte length;
 };
@@ -33,5 +29,5 @@
     ~NetworkProtocol();
 
-    int createHeader(byte* data, int length, int bufferLength, const Synchronizeable& source, unsigned int remoteID);
+    int createHeader(byte* data, int length, int bufferLength, const Synchronizeable& source);
     Header extractHeader(byte* data, int length);
 
Index: /trunk/src/lib/network/network_socket.cc
===================================================================
--- /trunk/src/lib/network/network_socket.cc	(revision 6138)
+++ /trunk/src/lib/network/network_socket.cc	(revision 6139)
@@ -28,5 +28,4 @@
 #include "debug.h"
 
-
 /**
  * Default constructor
@@ -52,6 +51,6 @@
   this->tcpSocket = sock;
 
-  SDL_CreateThread(thread_read, (void*)this);
-  SDL_CreateThread(thread_write, (void*)this);
+  readThread = SDL_CreateThread(thread_read, (void*)this);
+  writeThread = SDL_CreateThread(thread_write, (void*)this);
 }
 
@@ -65,6 +64,15 @@
   outgoingBufferLength = 0;
 
+  readThread = NULL;
+  writeThread = NULL;
+
+
+  thread_write_running = false;
+  thread_read_running = false;
+
   incomingBufferMutex = SDL_CreateMutex();
   outgoingBufferMutex = SDL_CreateMutex();
+
+
   socketMutex = SDL_CreateMutex();
   terminateThread = false;
@@ -89,6 +97,7 @@
  * Default destructor
  */
-NetworkSocket::~ NetworkSocket( )
-{
+NetworkSocket::~NetworkSocket( )
+{
+  this->terminateThread = true;
   /* Quit SDL_net */
   // NOTE: what if other instances of NetworkSocket running?
@@ -99,4 +108,5 @@
   SDL_DestroyMutex(outgoingBufferMutex);
   SDL_DestroyMutex(socketMutex);
+  SDL_DestroyMutex(threadTerminationMutex);
 }
 
@@ -122,6 +132,6 @@
   }
 
-  SDL_CreateThread(thread_read, (void*)this);
-  SDL_CreateThread(thread_write, (void*)this);
+  readThread = SDL_CreateThread(thread_read, (void*)this);
+  writeThread = SDL_CreateThread(thread_write, (void*)this);
 }
 
@@ -152,5 +162,5 @@
 int NetworkSocket::writeBytes(byte * data, int length)
 {
-  PRINTF(0)("NetworkSocket::writeBytes()\n");
+  PRINTF(5)("NetworkSocket::writeBytes()\n");
 #ifdef _USE_OUTGOING_BUFFER
 
@@ -200,5 +210,5 @@
 int NetworkSocket::readBytes(byte * data, int length)
 {
-  PRINTF(0)("NetworkSocket::readBytes()\n");
+  PRINTF(5)("NetworkSocket::readBytes()\n");
   if (data==NULL)
     return 0;
@@ -256,4 +266,6 @@
   NetworkSocket * self = (NetworkSocket*)data;
 
+  self->thread_read_running = true;
+
   while (!self->terminateThread)
   {
@@ -263,5 +275,5 @@
 
     //if buffer is full
-    if (nbytestoread<=0)
+    if (nbytestoread<=0 || !self->tcpSocket)
     {
       SDL_Delay(_MSECONDS_SLEEP_FULL_BUFFER);
@@ -275,5 +287,6 @@
     if (nbytesread<=0)
     {
-      printf("SDLNet_TCP_Recv: %s\n", SDLNet_GetError());
+      if (nbytesread<0)
+        printf("SDLNet_TCP_Recv: %s\n", SDLNet_GetError());
 
       SDL_mutexP(self->socketMutex);
@@ -284,5 +297,5 @@
       SDL_mutexV(self->socketMutex);
       SDL_mutexV(self->incomingBufferMutex);
-      return -1;
+      continue;
     }
 
@@ -295,4 +308,19 @@
   }
 
+  SDL_mutexP(self->threadTerminationMutex);
+  self->thread_read_running = false;
+
+  if ( !self->thread_write_running )
+  {
+    //delete self;
+    SDL_mutexV(self->threadTerminationMutex);
+  }
+  else
+  {
+    SDL_mutexV(self->threadTerminationMutex);
+  }
+
+
+  PRINTF(0)("QUIT READ THREAD\n");
   return 0;
 }
@@ -305,4 +333,6 @@
   NetworkSocket * self = (NetworkSocket*)data;
 
+  self->thread_write_running = true;
+
   while (!self->terminateThread)
   {
@@ -314,5 +344,5 @@
 
     //if buffer is full
-    if (nbytestowrite<=0)
+    if (nbytestowrite<=0 || !self->tcpSocket)
     {
       SDL_Delay(_MSECONDS_SLEEP_EMPTY_BUFFER);
@@ -342,10 +372,24 @@
 
       SDL_mutexV(self->socketMutex);
-      return -1;
+      continue;
     }
 
   }
 
-  printf("QUIT WRITE THREAD\n");
+  SDL_mutexP(self->threadTerminationMutex);
+  self->thread_write_running = false;
+
+  if ( !self->thread_read_running )
+  {
+    //delete self;
+    SDL_mutexV(self->threadTerminationMutex);
+  }
+  else
+  {
+    SDL_mutexV(self->threadTerminationMutex);
+  }
+
+
+  PRINTF(0)("QUIT WRITE THREAD\n");
   return 0;
 }
@@ -353,5 +397,5 @@
 bool NetworkSocket::writePacket( byte * data, int length )
 {
-  PRINTF(0)("NetworkSocket::writePacket()\n");
+  PRINTF(5)("NetworkSocket::writePacket()\n");
   if (length>255)
   {
@@ -368,5 +412,5 @@
 int NetworkSocket::readPacket( byte * data, int maxLength )
 {
-  PRINTF(0)("NetworkSocket::readPacket()\n");
+  PRINTF(5)("NetworkSocket::readPacket()\n");
   if (incomingBufferLength<1)
   {
Index: /trunk/src/lib/network/network_socket.h
===================================================================
--- /trunk/src/lib/network/network_socket.h	(revision 6138)
+++ /trunk/src/lib/network/network_socket.h	(revision 6139)
@@ -63,5 +63,12 @@
   bool terminateThread;
 
+  SDL_mutex* threadTerminationMutex;
   static int thread_read(void * data);
+  bool thread_read_running;
+  bool thread_write_running;
+
+  SDL_Thread*            readThread;
+  SDL_Thread*            writeThread;
+
 #ifdef _USE_OUTGOING_BUFFER
   static int thread_write(void * data);
@@ -74,4 +81,7 @@
   void init();
 
+  //dont make this public use destroy() instead
+  ~NetworkSocket();
+
 public:
 
@@ -79,5 +89,6 @@
   NetworkSocket(IPaddress ip);
   NetworkSocket(TCPsocket sock);
-  ~NetworkSocket();
+  void destroy() { terminateThread = true; };
+
 
   void connectToServer(IPaddress ip);
@@ -87,4 +98,6 @@
   int readPacket(byte * data, int maxLength);
 
+  inline bool isOk() { return tcpSocket!=NULL; }
+
 };
 
Index: /trunk/src/lib/network/network_stream.cc
===================================================================
--- /trunk/src/lib/network/network_stream.cc	(revision 6138)
+++ /trunk/src/lib/network/network_stream.cc	(revision 6139)
@@ -26,6 +26,8 @@
 #include "connection_monitor.h"
 #include "synchronizeable.h"
+#include "network_manager.h"
 #include "list.h"
 #include "debug.h"
+#include "class_list.h"
 
 /* include your own header */
@@ -45,57 +47,36 @@
   /* initialize the references */
   this->type = NET_CLIENT;
-  this->networkSocket = new NetworkSocket();
   this->networkProtocol = new NetworkProtocol();
-  this->synchronizeables = NULL;
   this->connectionMonitor = new ConnectionMonitor();
 }
 
-NetworkStream::NetworkStream(IPaddress& address, NodeType type)
-{
-  this->type = type;
+NetworkStream::NetworkStream(IPaddress& address)
+{
+  this->type = NET_CLIENT;
   this->init();
-  this->networkSocket = new NetworkSocket(address);
+  this->networkSockets.push_back(new NetworkSocket(address));
   this->networkProtocol = new NetworkProtocol();
-  this->synchronizeables = NULL;
   this->connectionMonitor = new ConnectionMonitor();
-}
-
-
-NetworkStream::NetworkStream(unsigned int port, NodeType type)
-{
-  this->type = type;
+
+  Handshake* hs = new Handshake(false);
+  hs->setUniqueID( 0 );
+  this->handshakes.push_back(hs);
+  this->connectSynchronizeable(*hs);
+  PRINTF(0)("NetworkStream: %s\n", hs->getName());
+}
+
+
+NetworkStream::NetworkStream(unsigned int port)
+{
+  this->type = NET_SERVER;
   this->init();
-  this->networkSocket = new NetworkSocket();
-//  this->networkSocket->listen(port);
+  this->serverSocket = new ServerSocket(port);
   this->networkProtocol = new NetworkProtocol();
-  this->synchronizeables = NULL;
   this->connectionMonitor = new ConnectionMonitor();
-}
-
-
-NetworkStream::NetworkStream(IPaddress& address, Synchronizeable& sync, NodeType type)
-    : DataStream()
-{
-  this->type = type;
-  this->init();
-  this->networkSocket = new NetworkSocket(address);
-  this->networkProtocol = new NetworkProtocol();
-  this->synchronizeables = &sync;
-  this->connectionMonitor = new ConnectionMonitor();
+  this->networkSockets.push_back( NULL );
+  this->handshakes.push_back( NULL );
   this->bActive = true;
-}
-
-
-NetworkStream::NetworkStream(unsigned int port, Synchronizeable& sync, NodeType type)
-    : DataStream()
-{
-  this->type = type;
-  this->init();
-  this->networkSocket = new NetworkSocket();
-//  this->networkSocket->listen(port);
-  this->networkProtocol = new NetworkProtocol();
-  this->synchronizeables = &sync;
-  this->connectionMonitor = new ConnectionMonitor();
-  this->bActive = true;
+
+  this->setMaxConnections( 10 );
 }
 
@@ -105,6 +86,7 @@
   /* set the class id for the base object */
   this->setClassID(CL_NETWORK_STREAM, "NetworkStream");
-  this->state = NET_REC_HEADER;
   this->bActive = false;
+  this->serverSocket = NULL;
+  myHostId = 0;
 }
 
@@ -112,9 +94,26 @@
 NetworkStream::~NetworkStream()
 {
-
-  networkSocket->disconnectServer();
-
-  if( this->networkSocket)
-    delete networkSocket;
+  if ( this->serverSocket )
+  {
+    serverSocket->close();
+    delete serverSocket;
+  }
+
+  for (NetworkSocketVector::iterator i = networkSockets.begin(); i!=networkSockets.end(); i++)
+  {
+    if ( *i )
+    {
+      (*i)->disconnectServer();
+      (*i)->destroy();
+    }
+  }
+
+  for (HandshakeVector::iterator i = handshakes.begin(); i!=handshakes.end(); i++)
+  {
+    if ( *i )
+    {
+      delete (*i);
+    }
+  }
 
   delete connectionMonitor;
@@ -125,76 +124,255 @@
 void NetworkStream::connectSynchronizeable(Synchronizeable& sync)
 {
-  this->synchronizeables = &sync;
-  if( this->networkSocket != NULL)
+  this->synchronizeables.push_back(&sync);
+  sync.setNetworkStream( this );
+
+  if( this->networkSockets.size()>0 )
     this->bActive = true;
 }
 
+void NetworkStream::disconnectSynchronizeable(Synchronizeable& sync)
+{
+  this->synchronizeables.remove(&sync);
+
+  if( this->networkSockets.size()<=0 )
+    this->bActive = false;
+}
+
 
 void NetworkStream::processData()
 {
-  int dataLength = 0;
+  if ( this->type == NET_SERVER )
+    this->updateConnectionList();
+  else
+  {
+    if ( networkSockets[0] && !networkSockets[0]->isOk() )
+    {
+      PRINTF(1)("lost connection to server\n");
+
+      //delete networkSockets[i];
+      networkSockets[0]->disconnectServer();
+      networkSockets[0]->destroy();
+      networkSockets[0] = NULL;
+      //TODO: delete handshake from synchronizeable list so i can delete it
+      if ( handshakes[0] )
+        delete handshakes[0];
+      handshakes[0] = NULL;
+    }
+  }
+
+  for (int i = 0; i<handshakes.size(); i++)
+  {
+    if ( handshakes[i] )
+    {
+      if ( handshakes[i]->completed() )
+      {
+        if ( handshakes[i]->ok() )
+        {
+          if ( type != NET_SERVER )
+          {
+            NetworkManager::getInstance()->setHostID( handshakes[i]->getHostId() );
+            myHostId = NetworkManager::getInstance()->getHostID();
+          }
+          PRINT(0)("handshake finished\n");
+          delete handshakes[i];
+          handshakes[i] = NULL;
+          //TODO: replace handshake by entitymanager
+        }
+        else
+        {
+          PRINT(1)("handshake failed!\n");
+          networkSockets[i]->disconnectServer();
+          delete handshakes[i];
+          handshakes[i] = NULL;
+          //TODO: handle error
+        }
+      }
+    }
+  }
+
 
   /* DOWNSTREAM */
-  printf("\nSynchronizeable: %s\n", this->synchronizeables->getName());
-  PRINT(0)("============= DOWNSTREAM:===============\n");
-  /* first of all read the synchronizeable's data: */
-  if( this->isServer())
-    dataLength = this->synchronizeables->readBytes((byte*)downBuffer);
-
-  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)*/);
-
-    /* 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");
-    }
-  }
-
+
+  int dataLength;
+  int reciever;
+  Header header;
+  for (SynchronizeableList::iterator it = synchronizeables.begin(); it!=synchronizeables.end(); it++)
+  {
+    //TODO: remove items from synchronizeables if they dont exist
+    if ( (*it)!=NULL && (*it)->getOwner() == myHostId )
+    {
+      do {
+        reciever = 0;
+        dataLength = (*it)->readBytes(downBuffer, DATA_STREAM_BUFFER_SIZE, &reciever);
+
+
+        if ( dataLength<=0 ){
+          reciever = 0;
+          continue;
+        }
+
+        dataLength = networkProtocol->createHeader((byte*)downBuffer, dataLength, DATA_STREAM_BUFFER_SIZE, static_cast<const Synchronizeable&>(*(*it)));
+
+        //FIXME: this is a hack, find a better way
+        Header* header = (Header*)downBuffer;
+        if ( header->synchronizeableID<100 )
+          header->synchronizeableID = 0;
+
+        if ( dataLength<=0 )
+          continue;
+
+        if ( reciever!=0 )
+        {
+          if ( networkSockets[reciever] != NULL )
+          {
+            PRINTF(5)("write %d bytes to socket %d\n", dataLength, reciever);
+            networkSockets[reciever]->writePacket(downBuffer, dataLength);
+          }
+          else
+          {
+            PRINTF(1)("networkSockets[reciever] == NULL\n");
+          }
+        }
+        else
+        {
+          for ( int i = 0; i<networkSockets.size(); i++)
+          {
+            if ( networkSockets[i] != NULL )
+            {
+              PRINTF(5)("write %d bytes to socket %d\n", dataLength, reciever);
+              networkSockets[i]->writePacket(downBuffer, dataLength);
+            }
+          }
+        }
+
+      } while( reciever!=0 );
+    }
+    else
+    {
+      PRINTF(0)("synchronizeables == NULL");
+    }
+  }
 
   /* UPSTREAM */
-  dataLength = 0;
-  PRINT(0)("============== UPSTREAM:================\n");
-  /* first of all read the next Orxonox Network Header */
-
-  if( this->state == NET_REC_HEADER)
-  {
-//    dataLength = this->networkSocket->readBlock((byte*)upBuffer, sizeof(Header));
-    if( dataLength == sizeof(Header))
-    {
-      this->packetHeader = this->networkProtocol->extractHeader((byte*) upBuffer , dataLength);
-      printf("NetworkStream::processData() - Got Header: Protocol %u, Version: %u, Sender: %u, Receiver: %u, Length: %u\n",
-             this->packetHeader.protocol, this->packetHeader.version, this->packetHeader.senderID,
-             this->packetHeader.receiverID, this->packetHeader.length);
-      /* FIXME: what if it was no this->packetHeader? catch? eg: the protocol identifier, receiver id*/
-
-      this->state = NET_REC_DATA;
-    }
-  }
-  if( this->state == NET_REC_DATA)
-  {
-    /* now read the data */
-//    dataLength = this->networkSocket->readBlock((byte*)upBuffer, this->packetHeader.length);
-    /* check if the data is available and process it if so */
-    if( dataLength == this->packetHeader.length)
-    {
-      printf("NetworkStream::processData() - Got Data: %i bytes\n", dataLength);
-      /* send the received data to connectionMonitor */
-      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);
-
-      this->state = NET_REC_HEADER;
-    }
-  }
-
-
-}
+
+  for ( int i = 0; i<networkSockets.size(); i++)
+  {
+    if ( networkSockets[i] )
+    {
+      do {
+        dataLength = networkSockets[i]->readPacket(upBuffer, DATA_STREAM_BUFFER_SIZE);
+
+        if ( dataLength<=0 )
+          continue;
+
+        PRINTF(5)("read %d bytes from socket\n", dataLength);
+        header = networkProtocol->extractHeader(upBuffer, dataLength);
+        dataLength -= sizeof(header);
+
+        if ( dataLength != header.length )
+        {
+          PRINTF(1)("packetsize in header and real packetsize do not match! %d:%d\n", dataLength, header.length);
+          continue;
+        }
+
+        if ( header.synchronizeableID == 0 )
+        {
+          header.synchronizeableID = i;
+        }
+
+        for (SynchronizeableList::iterator it = synchronizeables.begin(); it!=synchronizeables.end(); it++)
+        {
+          if ( *it && (*it)->getUniqueID()==header.synchronizeableID )
+            (*it)->writeBytes(upBuffer+sizeof(header), dataLength);
+        }
+
+      } while ( dataLength>0 );
+    }
+  }
+}
+
+void NetworkStream::updateConnectionList( )
+{
+  //check for new connections
+
+  NetworkSocket* tempNetworkSocket = serverSocket->getNewSocket();
+
+  if ( tempNetworkSocket )
+  {
+    int clientId;
+    if ( freeSocketSlots.size() >0 )
+    {
+      clientId = freeSocketSlots.back();
+      freeSocketSlots.pop_back();
+      networkSockets[clientId] = tempNetworkSocket;
+      handshakes[clientId] = new Handshake(true, clientId);
+      handshakes[clientId]->setUniqueID(clientId);
+    } else
+    {
+      clientId = networkSockets.size();
+      networkSockets.push_back(tempNetworkSocket);
+      Handshake* tHs = new Handshake(true, clientId);
+      tHs->setUniqueID(clientId);
+      handshakes.push_back(tHs);
+    }
+
+    if ( clientId > this->maxConnections )
+    {
+      handshakes[clientId]->doReject();
+      PRINTF(0)("Will reject client %d because there are to many connections!\n", clientId);
+    }
+    else
+
+    PRINTF(0)("New Client: %d\n", clientId);
+
+    this->connectSynchronizeable(*handshakes[clientId]);
+  }
+
+
+  //check if connections are ok else remove them
+  for ( int i = 1; i<networkSockets.size(); i++)
+  {
+    if ( networkSockets[i] && !networkSockets[i]->isOk() )
+    {
+      //TODO: tell EntityManager that this player left the game
+      PRINTF(0)("Client is gone: %d\n", i);
+
+      //delete networkSockets[i];
+      networkSockets[i]->disconnectServer();
+      networkSockets[i]->destroy();
+      networkSockets[i] = NULL;
+      //TODO: delete handshake from synchronizeable list so i can delete it
+      if ( handshakes[i] )
+        delete handshakes[i];
+      handshakes[i] = NULL;
+
+      if ( i == networkSockets.size()-1 )
+      {
+        networkSockets.pop_back();
+        handshakes.pop_back();
+      }
+      else
+      {
+        freeSocketSlots.push_back(i);
+      }
+    }
+  }
+
+
+}
+
+void NetworkStream::setMaxConnections( int n )
+{
+  if ( !this->isServer() )
+  {
+    PRINTF(1)("Cannot set maxConnections because I am no server.\n");
+  }
+  if ( this->networkSockets.size() > 1 )
+  {
+    PRINTF(1)("Cannot set maxConnections because there are already %d connections.\n", this->networkSockets.size());
+    return;
+  }
+  this->maxConnections = n;
+}
+
+
Index: /trunk/src/lib/network/network_stream.h
===================================================================
--- /trunk/src/lib/network/network_stream.h	(revision 6138)
+++ /trunk/src/lib/network/network_stream.h	(revision 6139)
@@ -7,20 +7,21 @@
 #define _NETWORK_STREAM
 
+#include <vector>
+#include <list>
+
 #include "data_stream.h"
 #include "network_protocol.h"
+#include "server_socket.h"
+#include "handshake.h"
 
 class Synchronizeable;
 class NetworkSocket;
+class ServerSocket;
 class ConnectionMonitor;
 class NetworkProtocol;
 
-
-//<! The state of the NetworkStream
-typedef enum NetStat {
-  NET_REC_HEADER = 0,                          //!< Waiting for header
-  NET_REC_DATA,                                //!< Waiting for data
-
-  NUM_STATES                                   //!< Number of states
-};
+typedef std::list<Synchronizeable*>  SynchronizeableList;
+typedef std::vector<NetworkSocket*>  NetworkSocketVector;
+typedef std::vector<Handshake*>      HandshakeVector;
 
 
@@ -30,16 +31,18 @@
   public:
     NetworkStream();
-    NetworkStream(IPaddress& address, NodeType type);
-    NetworkStream(unsigned int port, NodeType type);
+    NetworkStream(IPaddress& address);
+    NetworkStream(unsigned int port);
 
-    NetworkStream(IPaddress& address, Synchronizeable& sync, NodeType type);
-    NetworkStream(unsigned int port, Synchronizeable& sync, NodeType type);
     ~NetworkStream();
     void init();
 
     void connectSynchronizeable(Synchronizeable& sync);
+    void disconnectSynchronizeable(Synchronizeable& sync);
 
     inline bool isServer() const { return (this->type == NET_SERVER)? true:false; }
     inline bool isActive() const { return this->bActive; }
+
+    inline int getMaxConnections(){ return maxConnections; }
+    void setMaxConnections( int n );
 
     virtual void processData();
@@ -48,10 +51,17 @@
     NetworkProtocol*       networkProtocol;
     ConnectionMonitor*     connectionMonitor;
-    Synchronizeable*       synchronizeables;
-    NetworkSocket*         networkSocket;
+    SynchronizeableList    synchronizeables;
+    NetworkSocketVector    networkSockets;
+    HandshakeVector        handshakes;
+    ServerSocket*          serverSocket;
     int                    type;
-    int                    state;
     Header                 packetHeader;
     bool                   bActive;
+    std::list<int>         freeSocketSlots;
+
+    int                    myHostId;
+    int                    maxConnections;
+
+    void updateConnectionList();
 };
 #endif /* _NETWORK_STREAM */
Index: /trunk/src/lib/network/server_socket.cc
===================================================================
--- /trunk/src/lib/network/server_socket.cc	(revision 6138)
+++ /trunk/src/lib/network/server_socket.cc	(revision 6139)
@@ -110,6 +110,13 @@
 
 
-NetworkSocket ServerSocket::getNewSocket( )
+NetworkSocket* ServerSocket::getNewSocket( )
 {
+  if ( !listenSocket )
+  {
+    PRINTF(1)("listenSocket == NULL! Maybe you forgot to call listen()\n");
+    close();
+    return NULL;
+  }
+
   TCPsocket sock = SDLNet_TCP_Accept(listenSocket);
 
@@ -120,6 +127,17 @@
   else
   {
-    return NetworkSocket(sock);
+    return new NetworkSocket(sock);
   }
 }
 
+void ServerSocket::close( )
+{
+  if ( listenSocket )
+  {
+    SDLNet_TCP_Close( listenSocket );
+    listenSocket = NULL;
+  }
+
+  _isListening = false;
+}
+
Index: /trunk/src/lib/network/server_socket.h
===================================================================
--- /trunk/src/lib/network/server_socket.h	(revision 6138)
+++ /trunk/src/lib/network/server_socket.h	(revision 6139)
@@ -39,5 +39,7 @@
     ~ServerSocket();
     bool listen( unsigned int port );
-    NetworkSocket getNewSocket( void );
+    NetworkSocket* getNewSocket( void );
+    void close();
+    inline bool isOk(){ return listenSocket!=NULL; }
 };
 
Index: /trunk/src/lib/network/synchronizeable.cc
===================================================================
--- /trunk/src/lib/network/synchronizeable.cc	(revision 6138)
+++ /trunk/src/lib/network/synchronizeable.cc	(revision 6139)
@@ -15,6 +15,10 @@
 */
 
+#define DEBUG_MODULE_NETWORK
+
 #include "synchronizeable.h"
 #include "netdefs.h"
+#include "network_manager.h"
+#include "network_stream.h"
 
 
@@ -25,6 +29,7 @@
 {
 
-  //owner = ?;
-  //hostID = ?;
+  owner = 0;
+  hostID = NetworkManager::getInstance()->getHostID();
+  uniqueID = -1;
   //state = ?;
 
@@ -44,5 +49,8 @@
  */
 Synchronizeable::~Synchronizeable()
-{}
+{
+  if ( this->networkStream )
+    this->networkStream->disconnectSynchronizeable(*this);
+}
 
 /**
@@ -50,11 +58,15 @@
  */
 void Synchronizeable::writeBytes(const byte* data, int length)
-{}
+{
+  PRINTF(1)("Synchronizeable::writeBytes was called\n");
+}
 
 /**
  *  read data from NetworkStream
  */
-int Synchronizeable::readBytes(byte* data)
-{}
+int Synchronizeable::readBytes(byte* data, int maxLength, int * reciever)
+{
+  PRINTF(1)("Synchronizeable::readBytes was called\n");
+}
 
 
@@ -65,7 +77,4 @@
 void Synchronizeable::readDebug() const
 {}
-
-
-
 
 
@@ -111,2 +120,5 @@
   return this->state & STATE_OUTOFSYNC == STATE_OUTOFSYNC;
 }
+
+
+
Index: /trunk/src/lib/network/synchronizeable.h
===================================================================
--- /trunk/src/lib/network/synchronizeable.h	(revision 6138)
+++ /trunk/src/lib/network/synchronizeable.h	(revision 6139)
@@ -19,4 +19,6 @@
 #define STATE_OUTOFSYNC 2
 
+class NetworkStream;
+
 
 class Synchronizeable : virtual public BaseObject
@@ -29,23 +31,27 @@
 
     virtual void      writeBytes(const byte* data, int length);
-    virtual int       readBytes(byte* data);
+    virtual int       readBytes(byte* data, int maxLength, int * reciever);
     virtual void      writeDebug() const;
     virtual void      readDebug() const;
-    
-    
-    
-    
-    
-    void setIsServer(bool isServer);
-    void setIsOutOfSync(bool outOfSync);
+
+    void setIsServer( bool isServer );
+    void setIsOutOfSync( bool outOfSync );
     bool isServer();
     bool isOutOfSync();
+    void setUniqueID( int id ){ uniqueID = id; }
+    int  getUniqueID() const { return uniqueID; };
+    void requestSync( int hostID ){ this->synchronizeRequests.push_back( hostID ); }
+
+    inline int getOwner(){ return owner; }
+    inline void setOwner(int owner){ this->owner = owner; }
+
+    inline void setNetworkStream(NetworkStream* stream) { this->networkStream = stream; }
 
   private:
 
     int               uniqueID;
-    
-    
-    
+
+
+
     //static std::vector<Synchronizeable*> classList;
     int owner;
@@ -54,4 +60,6 @@
     std::list<int> synchronizeRequests;
 
+    NetworkStream* networkStream;
+
   };
 #endif /* _SYNCHRONIZEABLE_H */
Index: /trunk/src/lib/sound/sound_source.cc
===================================================================
--- /trunk/src/lib/sound/sound_source.cc	(revision 6138)
+++ /trunk/src/lib/sound/sound_source.cc	(revision 6139)
@@ -69,5 +69,5 @@
     SoundEngine::getInstance()->popALSource(this->sourceID);
 
-  printf("%d\n",sourceID);
+  //printf("%d\n",sourceID);
   alSourceStop(this->sourceID);
   alSourcei (this->sourceID, AL_BUFFER, buffer->getID());
Index: /trunk/src/orxonox.cc
===================================================================
--- /trunk/src/orxonox.cc	(revision 6138)
+++ /trunk/src/orxonox.cc	(revision 6139)
@@ -280,6 +280,7 @@
   if( this->serverName != NULL) // we are a client
     NetworkManager::getInstance()->establishConnection(this->serverName, port);
-  else if( this->port > 0)      // we are a server
+  else if( this->port > 0) {    // we are a server
     NetworkManager::getInstance()->createServer(port);
+  }
 
   return 0;
@@ -352,8 +353,8 @@
   this->gameLoader = GameLoader::getInstance();
 
-  if( this->port != -1 || this->serverName != NULL)
-    this->gameLoader->loadCampaign("worlds/DefaultCampaign.oxc"); /* actualy loadNetworkCampaign*/
+  if( this->port != -1)
+    this->gameLoader->loadNetworkCampaign("worlds/DefaultNetworkCampaign.oxc");
   else
-    this->gameLoader->loadCampaign("worlds/DefaultCampaign.oxc");
+    this->gameLoader->loadCampaign("worlds/DefaultCampaign.oxc");                       /* start orxonox in single player mode */
 
   //  this->gameLoader->loadDebugCampaign(DEBUG_CAMPAIGN_0);
Index: /trunk/src/story_entities/campaign.cc
===================================================================
--- /trunk/src/story_entities/campaign.cc	(revision 6138)
+++ /trunk/src/story_entities/campaign.cc	(revision 6139)
@@ -150,4 +150,5 @@
       delete (*it);
     }
+    PRINTF(1)("There is no StoryEnity left to play, quitting\n");
 }
 
Index: /trunk/src/story_entities/network_world.cc
===================================================================
--- /trunk/src/story_entities/network_world.cc	(revision 6139)
+++ /trunk/src/story_entities/network_world.cc	(revision 6139)
@@ -0,0 +1,942 @@
+/*
+   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: Christian Meyer
+   co-programmer: Benjamin Grauer
+*/
+
+#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD
+
+#include "network_world.h"
+
+#include "shell_command.h"
+
+#include "state.h"
+
+#include "p_node.h"
+#include "pilot_node.h"
+#include "world_entity.h"
+#include "player.h"
+#include "camera.h"
+#include "environment.h"
+#include "skysphere.h"
+#include "skybox.h"
+#include "satellite.h"
+#include "test_entity.h"
+#include "terrain.h"
+#include "light.h"
+#include "load_param.h"
+#include "shell.h"
+
+#include "garbage_collector.h"
+#include "fast_factory.h"
+#include "animation_player.h"
+#include "particle_engine.h"
+#include "graphics_engine.h"
+#include "physics_engine.h"
+#include "fields.h"
+
+#include "md2Model.h"
+
+#include "glmenu_imagescreen.h"
+#include "list.h"
+#include "game_loader.h"
+
+#include "animation3d.h"
+
+#include "substring.h"
+
+#include "factory.h"
+
+#include "weapons/projectile.h"
+#include "event_handler.h"
+#include "sound_engine.h"
+#include "ogg_player.h"
+
+#include "class_list.h"
+
+#include "cd_engine.h"
+#include "npcs/npc_test1.h"
+#include "shader.h"
+
+#include "playable.h"
+#include "network_manager.h"
+#include "playable.h"
+
+
+SHELL_COMMAND(speed, NetworkWorld, setSpeed);
+SHELL_COMMAND(togglePNodeVisibility, NetworkWorld, togglePNodeVisibility);
+SHELL_COMMAND(toggleBVVisibility, NetworkWorld, toggleBVVisibility);
+
+using namespace std;
+
+//! This creates a Factory to fabricate a NetworkWorld
+CREATE_FACTORY(NetworkWorld, CL_WORLD);
+
+NetworkWorld::NetworkWorld(const TiXmlElement* root)
+{
+  this->constuctorInit("", -1);
+  this->path = NULL;
+
+  this->loadParams(root);
+}
+
+/**
+  *  create a new NetworkWorld
+
+    This creates a new empty world!
+*/
+NetworkWorld::NetworkWorld (const char* name)
+{
+  this->path = NULL;
+  this->constuctorInit(name, -1);
+}
+
+/**
+ *  creates a new NetworkWorld...
+ * @param worldID with this ID
+*/
+NetworkWorld::NetworkWorld (int worldID)
+{
+  this->path = NULL;
+  this->constuctorInit(NULL, worldID);
+}
+
+/**
+ *  remove the NetworkWorld from memory
+
+    delete everything explicitly, that isn't contained in the parenting tree!
+    things contained in the tree are deleted automaticaly
+ */
+NetworkWorld::~NetworkWorld ()
+{
+  delete this->shell;
+  PRINTF(3)("NetworkWorld::~NetworkWorld() - deleting current world\n");
+
+
+  // here everything that is alocated by the NetworkWorld is deleted
+  delete this->entities;
+  State::setWorldEntityList(NULL);
+
+  delete this->localPlayer;
+
+  // delete all the initialized Engines.
+  FastFactory::flushAll(true);
+  delete LightManager::getInstance();
+  delete ParticleEngine::getInstance();
+  delete AnimationPlayer::getInstance();
+  delete PhysicsEngine::getInstance();
+
+  // external engines initialized by the orxonox-class get deleted
+  SoundEngine::getInstance()->flushAllBuffers();
+  SoundEngine::getInstance()->flushAllSources();
+
+
+  // erease everything that is left.
+  delete PNode::getNullParent();
+
+  //secondary cleanup of PNodes;
+  const std::list<BaseObject*>* nodeList = ClassList::getList(CL_PARENT_NODE);
+  if (nodeList != NULL)
+    while (!nodeList->empty())
+      delete nodeList->front();
+
+  Shader::suspendShader();
+
+  // unload the resources !!
+  ResourceManager::getInstance()->unloadAllByPriority(RP_LEVEL);
+
+  delete[] this->path;
+}
+
+/**
+ * initializes the world.
+ * @param name the name of the world
+ * @param worldID the ID of this world
+ *
+ * set all stuff here that is world generic and does not use to much memory
+ * because the real init() function StoryEntity::init() will be called
+ * shortly before start of the game.
+ * since all worlds are initiated/referenced before they will be started.
+ * NO LEVEL LOADING HERE - NEVER!
+*/
+void NetworkWorld::constuctorInit(const char* name, int worldID)
+{
+  this->setClassID(CL_WORLD, "NetworkWorld");
+
+  this->setName(name);
+  this->debugNetworkWorldNr = worldID;
+  this->gameTime = 0.0f;
+  this->setSpeed(1.0);
+  this->music = NULL;
+  this->shell = NULL;
+  this->entities = NULL;
+  this->localPlayer = NULL;
+  this->localCamera = NULL;
+
+  this->showPNodes = false;
+  this->showBV = false;
+}
+
+/**
+ * loads the parameters of a NetworkWorld from an XML-element
+ * @param root the XML-element to load from
+ */
+void NetworkWorld::loadParams(const TiXmlElement* root)
+{
+  PRINTF(4)("Creating a NetworkWorld\n");
+
+  LoadParam(root, "identifier", this, NetworkWorld, setStoryID)
+    .describe("Sets the StoryID of this world");
+
+  LoadParam(root, "nextid", this, NetworkWorld, setNextStoryID)
+    .describe("Sets the ID of the next world");
+
+  LoadParam(root, "path", this, NetworkWorld, setPath)
+    .describe("The Filename of this NetworkWorld (relative from the data-dir)");
+}
+
+/**
+ * this is executed just before load
+ *
+ * since the load function sometimes needs data, that has been initialized
+ * before the load and after the proceeding storyentity has finished
+*/
+ErrorMessage NetworkWorld::preLoad()
+{
+  State::setWorldEntityList(this->entities = new tList<WorldEntity>());
+  this->cycle = 0;
+
+  /* init the world interface */
+  this->shell = new Shell();
+
+  LightManager::getInstance();
+  PNode::getNullParent();
+
+  AnimationPlayer::getInstance(); // initializes the animationPlayer
+  ParticleEngine::getInstance();
+  PhysicsEngine::getInstance();
+
+  this->localCamera = new Camera();
+  this->localCamera->setName ("NetworkWorld-Camera");
+
+  State::setCamera(this->localCamera, this->localCamera->getTarget());
+
+  GraphicsEngine::getInstance()->displayFPS(true);
+
+  CDEngine::getInstance()->setEntityList( this->entities);
+}
+
+
+/**
+ *  loads the NetworkWorld by initializing all resources, and set their default values.
+*/
+ErrorMessage NetworkWorld::load()
+{
+  PRINTF(3)("> Loading world: '%s'\n", getPath());
+  TiXmlElement* element;
+  GameLoader* loader = GameLoader::getInstance();
+
+  if( getPath() == NULL)
+    {
+      PRINTF(1)("NetworkWorld has no path specified for loading");
+      this->loadDebugNetworkWorld(this->getStoryID());
+      return (ErrorMessage){213,"Path not specified","NetworkWorld::load()"};
+    }
+
+  TiXmlDocument* XMLDoc = new TiXmlDocument( getPath());
+  // load the campaign document
+  if( !XMLDoc->LoadFile())
+  {
+    // report an error
+    PRINTF(1)("loading XML File: %s @ %s:l%d:c%d\n", XMLDoc->ErrorDesc(), this->getPath(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());
+    delete XMLDoc;
+    return (ErrorMessage){213,"XML File parsing error","NetworkWorld::load()"};
+  }
+
+  // check basic validity
+  TiXmlElement* root = XMLDoc->RootElement();
+  assert( root != NULL);
+
+  if( root == NULL || root->Value() == NULL || strcmp( root->Value(), "WorldDataFile"))
+    {
+      // report an error
+      PRINTF(1)("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n");
+      delete XMLDoc;
+      return (ErrorMessage){213,"Path not a WorldDataFile","NetworkWorld::load()"};
+    }
+
+
+  // load the parameters
+  // name
+  const char* string = grabParameter( root, "name");
+  if( string == NULL)
+    {
+      PRINTF(2)("World is missing a proper 'name'\n");
+      this->setName("Unknown");
+    }
+  else
+    {
+      this->setName(string);
+    }
+
+
+  ////////////////
+  // LOADSCREEN //
+  ////////////////
+  element = root->FirstChildElement("LoadScreen");
+  if (element == NULL)
+    {
+      PRINTF(2)("no LoadScreen specified, loading default\n");
+
+      glmis->setBackgroundImage("pictures/load_screen.jpg");
+      this->glmis->setMaximum(8);
+      this->glmis->draw();
+    }
+  else
+    {
+      this->glmis->loadParams(element);
+      this->glmis->draw();
+    }
+  this->glmis->draw();
+
+
+
+  ////////////////////////////
+  // Loading Spawning Point //
+  ////////////////////////////
+  element = root->FirstChildElement("SpawningPoints");
+  if( element == NULL)
+  {
+    PRINTF(1)("NetworkWorld is missing 'SpawningPoints'\n");
+  }
+  else
+  {
+    element = element->FirstChildElement();
+      // load Players/Objects/Whatever
+    PRINTF(4)("Loading Spawning Points\n");
+    while( element != NULL)
+    {
+      BaseObject* created = Factory::fabricate(element);
+      if( created != NULL )
+      {
+        if(created->isA(CL_SPAWNING_POINT))
+          this->spawn(dynamic_cast<WorldEntity*>(created));
+        printf("Created a Spawning Point %s: %s\n", created->getClassName(), created->getName());
+      }
+
+
+      element = element->NextSiblingElement();
+      glmis->step(); //! @todo temporary
+    }
+    PRINTF(4)("Done loading NetworkWorldEntities\n");
+  }
+
+
+  ////////////////////////
+  // find WorldEntities //
+  ////////////////////////
+  if( NetworkManager::getInstance()->isGameServer())
+  {}
+
+  element = root->FirstChildElement("WorldEntities");
+  if( element == NULL)
+  {
+    PRINTF(1)("NetworkWorld is missing 'WorldEntities'\n");
+  }
+  else
+  {
+    element = element->FirstChildElement();
+      // load Players/Objects/Whatever
+    PRINTF(4)("Loading NetworkWorldEntities\n");
+    while( element != NULL)
+    {
+      if( NetworkManager::getInstance()->isGameServer() || !strcmp( element->Value(), "SkyBox") || !strcmp( element->Value(), "Terrain")
+          || !strcmp( element->Value(), "SpaceShip"))
+      {
+        BaseObject* created = Factory::fabricate(element);
+        if( created != NULL )
+        {
+          if(created->isA(CL_WORLD_ENTITY))
+            this->spawn(dynamic_cast<WorldEntity*>(created));
+          printf("Created a %s: %s\n", created->getClassName(), created->getName());
+        }
+
+          // if we load a 'Player' we use it as localPlayer
+
+
+          //todo do this more elegant
+        if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox"))
+          sky = dynamic_cast<SkyBox*>(created);
+        if( element->Value() != NULL && !strcmp( element->Value(), "Terrain"))
+        {
+          terrain = dynamic_cast<Terrain*>(created);
+          CDEngine::getInstance()->setTerrain(terrain);
+        }
+
+      }
+      element = element->NextSiblingElement();
+      glmis->step(); //! @todo temporary
+      PRINTF(4)("Done loading NetworkWorldEntities\n");
+    }
+  }
+
+
+    //////////////////////////////
+    // LOADING ADDITIONAL STUFF //
+    //////////////////////////////
+
+    LoadParamXML(root, "LightManager", LightManager::getInstance(), LightManager, loadParams);
+
+   LoadParamXML(root, "ParticleEngine", ParticleEngine::getInstance(), ParticleEngine, loadParams);
+//   LoadParamXML(root, "PhysicsEngine", PhysicsEngine::getInstance(), PhysicsEngine, loadParams);
+
+  // free the XML data
+
+  delete XMLDoc;
+  /* GENERIC LOADING PROCESS FINISHED */
+
+
+  // Create a Player
+  this->localPlayer = new Player();
+
+  Playable* playable;
+  const list<BaseObject*>* playableList = ClassList::getList(CL_PLAYABLE);
+  if (playableList != NULL)
+  {
+    playable = dynamic_cast<Playable*>(playableList->front());
+    this->localPlayer->setControllable(playable);
+  }
+
+  // bind camera
+  playable->addChild (this->localCamera);
+
+//   //localCamera->setParent(TrackNode::getInstance());
+//  tn->addChild(this->localCamera);
+  localCamera->setClipRegion(1, 10000.0);
+  localCamera->lookAt(playable);
+//  this->localPlayer->setParentMode(PNODE_ALL);
+  if (sky != NULL)
+  {
+    this->sky->setParent(this->localCamera);
+    this->sky->setParentMode(PNODE_MOVEMENT);
+  }
+
+  // initialize debug coord system
+  objectList = glGenLists(1);
+  glNewList (objectList, GL_COMPILE);
+
+  glEndList();
+
+  SoundEngine::getInstance()->setListener(this->localCamera);
+
+
+
+  ////////////
+  // STATIC //
+  ////////////
+
+
+//   TestEntity* testEntity = new TestEntity();
+//   testEntity->setRelCoor(Vector(570, 10, -15));
+//   testEntity->setRelDir(Quaternion(M_PI, Vector(0, 1, 0)));
+//   this->spawn(testEntity);
+
+  for(int i = 0; i < 100; i++)
+  {
+    WorldEntity* tmp = new NPCTest1();
+    char npcChar[10];
+    sprintf (npcChar, "NPC_%d", i);
+        tmp->setName(npcChar);
+    tmp->setAbsCoor(((float)rand()/RAND_MAX) * 5000, 50/*+ (float)rand()/RAND_MAX*20*/, ((float)rand()/RAND_MAX -.5) *30);
+    this->spawn(tmp);
+  }
+
+  this->music = NULL;
+  //(OggPlayer*)ResourceManager::getInstance()->load("sound/00-luke_grey_-_hypermode.ogg", OGG, RP_LEVEL);
+  //music->playback();
+}
+
+
+
+/**
+ * creates a debug world: only for experimental stuff
+*/
+void NetworkWorld::loadDebugNetworkWorld(int worldID)
+{
+  /*monitor progress*/
+  this->glmis->step();
+  // stuff beyond this point remains to be loaded properly
+
+  // LIGHT initialisation
+  LightManager::getInstance()->setAmbientColor(.1,.1,.1);
+//  LightManager::getInstance()->addLight();
+  LightManager::getInstance()->debug();
+
+  switch(this->debugNetworkWorldNr)
+    {
+      /*
+        this loads the hard-coded debug world. this only for simplicity and will be
+        removed by a reald world-loader, which interprets a world-file.
+        if you want to add an own debug world, just add a case DEBUG_WORLD_[nr] and
+        make whatever you want...
+      */
+    case DEBUG_WORLD_0:
+      {
+        LightManager::getInstance()->getLight()->setAbsCoor(-5.0, 10.0, -40.0);
+        /*monitor progress*/
+        this->glmis->step();
+
+        // bind camera
+        this->localCamera = new Camera();
+        this->localCamera->setName ("camera");
+        /*monitor progress*/
+        this->glmis->step();
+
+
+        // Create SkySphere
+        this->sky = new Skysphere("pictures/sky-replace.jpg");
+        this->sky->setName("SkySphere");
+        this->spawn(this->sky);
+        this->localCamera->addChild(this->sky);
+        this->sky->setParentMode(PNODE_MOVEMENT);
+        /*monitor progress*/
+        this->glmis->step();
+
+
+        terrain = new Terrain("worlds/newGround.obj");
+        terrain->setRelCoor(Vector(0,-10,0));
+        this->spawn(terrain);
+        /*monitor progress*/
+        this->glmis->step();
+
+        this->glmis->step();
+        break;
+      }
+    case DEBUG_WORLD_1:
+      {
+
+        break;
+      }
+    case DEBUG_WORLD_2:
+      {
+
+        break;
+      }
+    default:
+      break;
+    }
+}
+
+/**
+ *  initializes a new NetworkWorld shortly before start
+ *
+ * this is the function, that will be loaded shortly before the world is
+ * started
+*/
+ErrorMessage NetworkWorld::init()
+{
+  this->bPause = false;
+
+  /* update the object position before game start - so there are no wrong coordinates used in the first processing */
+  PNode::getNullParent()->updateNode (0.001f);
+  PNode::getNullParent()->updateNode (0.001f);
+
+}
+
+
+/**
+ *  starts the NetworkWorld
+*/
+ErrorMessage NetworkWorld::start()
+{
+  PRINTF(3)("NetworkWorld::start() - starting current NetworkWorld: nr %i\n", this->debugNetworkWorldNr);
+  this->bQuitOrxonox = false;
+  this->bQuitCurrentGame = false;
+  this->mainLoop();
+}
+
+/**
+ *  stops the world.
+
+   This happens, when the player decides to end the Level.
+*/
+ErrorMessage NetworkWorld::stop()
+{
+  PRINTF(3)("NetworkWorld::stop() - got stop signal\n");
+  this->bQuitCurrentGame = true;
+}
+
+/**
+ *  pauses the Game
+*/
+ErrorMessage NetworkWorld::pause()
+{
+  this->isPaused = true;
+}
+
+/**
+ *  ends the pause Phase
+*/
+ErrorMessage NetworkWorld::resume()
+{
+  this->isPaused = false;
+}
+
+/**
+ *  destroys the NetworkWorld
+*/
+ErrorMessage NetworkWorld::destroy()
+{
+
+}
+
+/**
+ *  shows the loading screen
+*/
+void NetworkWorld::displayLoadScreen ()
+{
+  PRINTF(3)("NetworkWorld::displayLoadScreen - start\n");
+
+  //GLMenuImageScreen*
+  this->glmis = new GLMenuImageScreen();
+  this->glmis->setMaximum(8);
+
+  PRINTF(3)("NetworkWorld::displayLoadScreen - end\n");
+}
+
+/**
+ *  removes the loadscreen, and changes over to the game
+
+   @todo take out the delay
+*/
+void NetworkWorld::releaseLoadScreen ()
+{
+  PRINTF(3)("NetworkWorld::releaseLoadScreen - start\n");
+  this->glmis->setValue(this->glmis->getMaximum());
+  PRINTF(3)("NetworkWorld::releaseLoadScreen - end\n");
+  delete this->glmis;
+}
+
+
+/**
+ *  gets the list of entities from the world
+ * @returns entity list
+*/
+tList<WorldEntity>* NetworkWorld::getEntities()
+{
+  return this->entities;
+}
+
+
+/**
+ *  this returns the current game time
+ * @returns elapsed game time
+*/
+double NetworkWorld::getGameTime()
+{
+  return this->gameTime;
+}
+
+
+/**
+ *  function to put your own debug stuff into it. it can display informations about
+   the current class/procedure
+*/
+void NetworkWorld::debug()
+{
+  PRINTF(0)("Printing out the List of alive NetworkWorldEntities:\n");
+  tIterator<WorldEntity>* iterator = this->entities->getIterator();
+  WorldEntity* entity = iterator->firstElement();
+  while( entity != NULL)
+  {
+    PRINTF(0)("%s::%s\n", entity->getClassName(), entity->getName());
+    entity = iterator->nextElement();
+  }
+  delete iterator;
+}
+
+
+/**
+  \brief main loop of the world: executing all world relevant function
+
+  in this loop we synchronize (if networked), handle input events, give the heart-beat to
+  all other member-entities of the world (tick to player, enemies etc.), checking for
+  collisions drawing everything to the screen.
+*/
+void NetworkWorld::mainLoop()
+{
+  this->lastFrame = SDL_GetTicks ();
+  PRINTF(3)("NetworkWorld::mainLoop() - Entering main loop\n");
+
+  while( !this->bQuitOrxonox && !this->bQuitCurrentGame) /* @todo implement pause */
+    {
+      ++this->cycle;
+      PRINTF(4)("NetworkWorld::mainloop() - number of entities: %i\n", this->entities->getSize());
+      // Network
+      this->synchronize ();
+      // Process input
+      this->handleInput ();
+      if( this->bQuitCurrentGame || this->bQuitOrxonox)
+          break;
+      // Process time
+      this->tick ();
+      // Process collision
+      this->collide ();
+      // Update the state
+      this->update ();
+      // Draw
+      this->display ();
+    }
+
+  PRINTF(3)("NetworkWorld::mainLoop() - Exiting the main loop\n");
+}
+
+
+/**
+ *  synchronize local data with remote data
+*/
+void NetworkWorld::synchronize ()
+{
+  // Get remote input
+  // Update synchronizables
+  NetworkManager::getInstance()->synchronize();
+}
+
+
+/**
+ *  run all input processing
+
+   the command node is the central input event dispatcher. the node uses the even-queue from
+   sdl and has its own event-passing-queue.
+*/
+void NetworkWorld::handleInput ()
+{
+  EventHandler::getInstance()->process();
+
+  // remoteinput
+}
+
+
+/**
+ *  advance the timeline
+
+   this calculates the time used to process one frame (with all input handling, drawing, etc)
+   the time is mesured in ms and passed to all world-entities and other classes that need
+   a heart-beat.
+*/
+void NetworkWorld::tick ()
+{
+  Uint32 currentFrame = SDL_GetTicks();
+  if(!this->bPause)
+    {
+      this->dt = currentFrame - this->lastFrame;
+
+      if( this->dt > 10)
+        {
+          float fps = 1000/dt;
+
+          // temporary, only for showing how fast the text-engine is
+          char tmpChar[20];
+          sprintf(tmpChar, "fps: %4.0f", fps);
+        }
+      else
+        {
+          /* the frame-rate is limited to 100 frames per second, all other things are for
+             nothing.
+          */
+          PRINTF(3)("fps = 1000 - frame rate is adjusted\n");
+          SDL_Delay(10-dt);
+          this->dt = 10;
+        }
+
+      this->dtS = (float)this->dt / 1000.0 * this->speed;
+      this->gameTime += this->dtS;
+
+      tIterator<WorldEntity>* iterator = this->entities->getIterator();
+      WorldEntity* entity = iterator->firstElement();
+      while( entity != NULL)
+        {
+          entity->tick (this->dtS);
+          entity = iterator->nextElement();
+        }
+      delete iterator;
+
+      /* update tick the rest */
+      this->localCamera->tick(this->dtS);
+      // tick the engines
+      AnimationPlayer::getInstance()->tick(this->dtS);
+//      if (this->cycle > 5)
+        PhysicsEngine::getInstance()->tick(this->dtS);
+
+      ParticleEngine::getInstance()->tick(this->dtS);
+      GarbageCollector::getInstance()->tick(this->dtS);
+
+
+      /** actualy the Graphics Engine should tick the world not the other way around...
+         but since we like the things not too complicated we got it this way around
+         until there is need or time to do it the other way around.
+         @todo: GraphicsEngine ticks world: separation of processes and data...
+
+        bensch: in my opinion the GraphicsEngine could draw the world, but not tick it,
+         beceause graphics have nothing(or at least not much) to do with Motion.
+      */
+      GraphicsEngine::getInstance()->tick(this->dtS);
+    }
+  this->lastFrame = currentFrame;
+}
+
+
+/**
+ *  this function gives the world a consistant state
+
+   after ticking (updating the world state) this will give a constistant
+   state to the whole system.
+*/
+void NetworkWorld::update()
+{
+  GarbageCollector::getInstance()->update();
+  GraphicsEngine::getInstance()->update(this->dtS);
+  PNode::getNullParent()->updateNode (this->dtS);
+
+  SoundEngine::getInstance()->update();
+  //music->update();
+}
+
+
+void NetworkWorld::collide()
+{
+  CDEngine::getInstance()->checkCollisions();
+}
+
+/**
+ *  render the current frame
+
+   clear all buffers and draw the world
+*/
+void NetworkWorld::display ()
+{
+  // clear buffer
+  glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
+  // set camera
+  this->localCamera->apply ();
+  // draw world
+  this->draw();
+  // draw HUD
+  /** @todo draw HUD */
+  // flip buffers
+  GraphicsEngine::swapBuffers();
+  //SDL_Surface* screen = Orxonox::getInstance()->getScreen ();
+  //SDL_Flip (screen);
+}
+
+
+/**
+ *  runs through all entities calling their draw() methods
+ */
+void NetworkWorld::draw ()
+{
+  /* draw entities */
+  WorldEntity* entity;
+  glLoadIdentity();
+  tIterator<WorldEntity>* iterator = this->entities->getIterator();
+  entity = iterator->firstElement();
+  while( entity != NULL )
+  {
+    if( entity->isVisible() ) entity->draw();
+    if( unlikely( this->showBV)) entity->drawBVTree(3, 226);  // to draw the bounding boxes of the objects at level 2 for debug purp
+    entity = iterator->nextElement();
+  }
+  delete iterator;
+
+  glCallList (objectList);
+
+  ParticleEngine::getInstance()->draw();
+
+  if (unlikely(this->showPNodes))
+    PNode::getNullParent()->debugDraw(0);
+
+  GraphicsEngine::getInstance()->draw();
+  //TextEngine::getInstance()->draw();
+}
+
+/**
+ *  add and spawn a new entity to this world
+ * @param entity to be added
+*/
+void NetworkWorld::spawn(WorldEntity* entity)
+{
+  this->entities->add (entity);
+  entity->postSpawn ();
+}
+
+
+/**
+ *  add and spawn a new entity to this world
+ * @param entity to be added
+ * @param absCoor At what coordinates to add this entity.
+ * @param absDir In which direction should it look.
+*/
+void NetworkWorld::spawn(WorldEntity* entity, Vector* absCoor, Quaternion* absDir)
+{
+  this->entities->add (entity);
+
+  entity->setAbsCoor (*absCoor);
+  entity->setAbsDir (*absDir);
+
+  entity->postSpawn ();
+}
+
+
+/**
+ *  add and spawn a new entity to this world
+ * @param entity to be added
+ * @param entity to be added to (PNode)
+ * @param At what relative  coordinates to add this entity.
+ * @param In which relative direction should it look.
+*/
+void NetworkWorld::spawn(WorldEntity* entity, PNode* parentNode,
+                  Vector* relCoor, Quaternion* relDir)
+{
+  if( parentNode != NULL)
+    {
+      parentNode->addChild (entity);
+
+      entity->setRelCoor (*relCoor);
+      entity->setRelDir (*relDir);
+
+      this->entities->add (entity);
+
+      entity->postSpawn ();
+    }
+}
+
+void NetworkWorld::setPath( const char* name)
+{
+  if (this->path)
+    delete this->path;
+  if (ResourceManager::isFile(name))
+  {
+    this->path = new char[strlen(name)+1];
+    strcpy(this->path, name);
+  }
+  else
+    {
+      this->path = new char[strlen(ResourceManager::getInstance()->getDataDir()) + strlen(name) +1];
+      sprintf(this->path, "%s%s", ResourceManager::getInstance()->getDataDir(), name);
+    }
+}
+
+const char* NetworkWorld::getPath( void)
+{
+  return path;
+}
Index: /trunk/src/story_entities/network_world.h
===================================================================
--- /trunk/src/story_entities/network_world.h	(revision 6139)
+++ /trunk/src/story_entities/network_world.h	(revision 6139)
@@ -0,0 +1,124 @@
+/*!
+ * @file world.h
+  *  Holds and manages all game data
+*/
+
+#ifndef _WORLD_H
+#define _WORLD_H
+
+#include "stdincl.h"
+#include "comincl.h"
+#include "story_entity.h"
+#include "p_node.h"
+
+class NetworkWorld;
+class WorldEntity;
+class Camera;
+class Player;
+class GLMenuImageScreen;
+class Terrain;
+class GarbageCollector;
+class Text;
+class TiXmlElement;
+
+class Shell;
+class OggPlayer;
+template<class T> class tList;
+
+//! The game world
+/**
+   this class initializes everything that should be displayed inside of the current level.
+   it is the main driving factor during gameplay.
+*/
+class NetworkWorld : public StoryEntity {
+
+ public:
+  NetworkWorld (const char* name);
+  NetworkWorld (int worldID);
+  NetworkWorld (const TiXmlElement* root = NULL);
+  virtual ~NetworkWorld ();
+
+  void loadParams(const TiXmlElement* root);
+
+  double getGameTime();
+
+  /* classes from story-entity */
+  virtual ErrorMessage preLoad();
+  virtual ErrorMessage load ();
+  virtual ErrorMessage init ();
+  virtual ErrorMessage start ();
+  virtual ErrorMessage stop ();
+  virtual ErrorMessage pause ();
+  virtual ErrorMessage resume ();
+  virtual ErrorMessage destroy ();
+
+  void loadDebugNetworkWorld(int worldID);
+
+  virtual void displayLoadScreen();
+  virtual void releaseLoadScreen();
+
+  /* command node functions */
+  bool command (Command* cmd);
+
+  tList<WorldEntity>* getEntities();
+
+  /* interface to world */
+  void spawn (WorldEntity* entity);
+  void spawn (WorldEntity* entity, Vector* absCoor, Quaternion* absDir);
+  void spawn(WorldEntity* entity, PNode* parentNode, Vector* relCoor, Quaternion* relDir);
+
+  /** @param speed sets the speed of the Game */
+  inline void setSpeed(float speed) { this->speed = speed; };
+  const char* getPath();
+  void setPath( const char* name);
+
+  inline Camera* getLocalCamera() { return this->localCamera; };
+
+  void togglePNodeVisibility() { this->showPNodes = !this->showPNodes; };
+  void toggleBVVisibility() { this->showBV = !this->showBV; };
+
+ private:
+  void constuctorInit(const char* name, int worldID);
+  /* function for main-loop */
+  void mainLoop ();
+  void synchronize ();
+  void handleInput ();
+  void tick ();
+  void update ();
+  void collide ();
+  void draw ();
+  void display ();
+  void debug ();
+
+  private:
+    bool   showPNodes;                  //!< if the PNodes should be visible.
+    bool   showBV;                      //!< if the Bounding Volumes should be visible.
+    Uint32 lastFrame;                   //!< last time of frame
+    Uint32 cycle;                       //!< The cycle we are in (starts with 0 and rises with every frame)
+    Uint32 dt;                          //!< time needed to calculate this frame (in milliSeconds)
+    float dtS;                          //!< The time needed for caluculations in seconds
+    float speed;                        //!< how fast the game flows
+    double gameTime;                    //!< this is where the game time is saved
+    bool bQuitOrxonox;                  //!< quit this application
+    bool bQuitCurrentGame;              //!< quit only the current game and return to menu
+    bool bPause;                        //!< pause mode
+
+    GLMenuImageScreen* glmis;           //!< The Level-Loader Display
+
+    int debugNetworkWorldNr;                   //!< The Debug Nr. needed, if something goes wrong
+    char* path;                         //!< The file from which this world is loaded
+
+    Shell*     shell;
+    OggPlayer* music;
+
+  // IMPORTANT WORLD-ENTITIES
+    Camera* localCamera;                //!< The current Camera
+    WorldEntity* sky;                   //!< The Environmental Heaven of orxonox @todo insert this to environment insted
+    Terrain* terrain;                   //!< The Terrain of the NetworkWorld.
+
+    GLuint objectList;                  //!< temporary: @todo this will be ereased soon
+    tList<WorldEntity>* entities;       //!< A template List of all entities. Every moving thing should be included here, and world automatically updates them.
+    Player* localPlayer;                //!< The Player, you fly through the level.
+};
+
+#endif /* _WORLD_H */
Index: /trunk/src/subprojects/network/Makefile.am
===================================================================
--- /trunk/src/subprojects/network/Makefile.am	(revision 6138)
+++ /trunk/src/subprojects/network/Makefile.am	(revision 6139)
@@ -11,5 +11,5 @@
 network_LDADD = $(MAINSRCDIR)/lib/network/libORXnet.a \
                 \
-                $(MAINSRCDIR)/lib/tinyxml/libtinyxml.a
+                $(MAINSRCDIR)/lib/parser/tinyxml/libtinyxml.a
 
 network_SOURCES=  network_unit_test.cc \
Index: /trunk/src/subprojects/network/network_unit_test.cc
===================================================================
--- /trunk/src/subprojects/network/network_unit_test.cc	(revision 6138)
+++ /trunk/src/subprojects/network/network_unit_test.cc	(revision 6139)
@@ -11,4 +11,5 @@
 #include "network_stream.h"
 #include "synchronizeable.h"
+#include "converter.h"
 
 #include "simple_sync.h"
@@ -40,19 +41,19 @@
   server.listen(9999);
 
-  NetworkSocket client1(ip);
-
-  NetworkSocket server1 = server.getNewSocket();
-
-  NetworkSocket client2(ip);
-
-  NetworkSocket server2 = server.getNewSocket();
+  NetworkSocket* client1 = new NetworkSocket(ip);
+
+  NetworkSocket* server1 = server.getNewSocket();
+
+  NetworkSocket* client2 = new NetworkSocket(ip);
+
+  NetworkSocket* server2 = server.getNewSocket();
 
   char buf[1024];
 
   printf("read from client1 before sending data\n");
-  printf("result: %d bytes\n", client1.readPacket((byte*)buf, 1024));
+  printf("result: %d bytes\n", client1->readPacket((byte*)buf, 1024));
 
   printf("read from client2 before sending data\n");
-  printf("result: %d bytes\n", client2.readPacket((byte*)buf, 1024));
+  printf("result: %d bytes\n", client2->readPacket((byte*)buf, 1024));
 
   int n;
@@ -61,16 +62,16 @@
   char * str3 = "client2 to server";
   char * str4 = "server2 to client";
-  n = client1.writePacket((byte*)str1, strlen(str1)+1);
+  n = client1->writePacket((byte*)str1, strlen(str1)+1);
   printf("%d bytes send from client1\n", n);
-  n = server1.writePacket((byte*)str2, strlen(str2)+1);
+  n = server1->writePacket((byte*)str2, strlen(str2)+1);
   printf("%d bytes send from server1\n", n);
-  n = client2.writePacket((byte*)str3, strlen(str3)+1);
+  n = client2->writePacket((byte*)str3, strlen(str3)+1);
   printf("%d bytes send from client2\n", n);
-  n = server2.writePacket((byte*)str4, strlen(str4)+1);
+  n = server2->writePacket((byte*)str4, strlen(str4)+1);
   printf("%d bytes send from server2\n", n);
   SDL_Delay(1000);
 
   printf("read from server1\n");
-  n = server1.readPacket((byte*)buf, 1024);
+  n = server1->readPacket((byte*)buf, 1024);
   printf("read %d bytes\n", n);
   if (n<0)
@@ -80,5 +81,5 @@
 
   printf("read from server2\n");
-  n = server2.readPacket((byte*)buf, 1024);
+  n = server2->readPacket((byte*)buf, 1024);
   printf("read %d bytes\n", n);
   if (n<0)
@@ -88,5 +89,5 @@
 
   printf("read from client1\n");
-  n = client1.readPacket((byte*)buf, 1024);
+  n = client1->readPacket((byte*)buf, 1024);
   printf("read %d bytes\n", n);
   if (n<0)
@@ -96,5 +97,5 @@
 
   printf("read from client2\n");
-  n = client2.readPacket((byte*)buf, 1024);
+  n = client2->readPacket((byte*)buf, 1024);
   printf("read %d bytes\n", n);
   if (n<0)
@@ -106,10 +107,10 @@
 
   printf("try to send more than 255 bytes\n");
-  printf("result: %d\n", client1.writePacket((byte*)buf, 1000));
-
-  server1.writePacket((byte*)str1, strlen(str1)+1);
+  printf("result: %d\n", client1->writePacket((byte*)buf, 1000));
+
+  server1->writePacket((byte*)str1, strlen(str1)+1);
   SDL_Delay(500);
   printf("try to read with a too small buffer\n");
-  printf("result: %d\n", client1.readPacket((byte*)buf, strlen(str1)));
+  printf("result: %d\n", client1->readPacket((byte*)buf, strlen(str1)));
 
   return 0;
@@ -190,5 +191,5 @@
   Synchronizeable* ss = new SimpleSync("Server\0");
 
-  netMan->createServer(*ss, port);
+  netMan->createServer(/**ss, */port);
   SDL_Delay(20);
 
@@ -196,5 +197,5 @@
   {
     netMan->synchronize();
-    SDL_Delay(500);
+    SDL_Delay(1000);
   }
 
@@ -229,5 +230,5 @@
   Synchronizeable* ss = new SimpleSync("Client\0");
 
-  netMan->establishConnection(ip, *ss);
+  netMan->establishConnection((const char*)"localhost", port/*,ip, *ss*/);
 
   for(;;)
@@ -280,4 +281,53 @@
   delete ss;
 
+  return 0;
+}
+
+
+int converter(int argc, char** argv)
+{
+  int x = 200564786;
+  printf("To convert: %i\n", x);
+  byte* res = Converter::intToByteArray(x);
+  for (int i = 0; i < 4; i++)
+    printf("%i  ", res[i]);
+  printf("\n");
+  
+  int z = Converter::byteArrayToInt(res);
+  
+  printf("ReConvert: %i\n", z);
+
+  
+  //float a = 5.4f;
+  //float b = 2.0f;
+  //printf("%f mod %f = %f", a, b, a % b);
+  
+  printf("\n");
+  
+  float y;
+  char* s;
+  
+  y = 12.0f;
+  s = Converter::floatToBinString(y);
+  printf("%f = ", y);
+  printf(s); printf("\n");
+  
+  y = 24549026.0f;
+  s = Converter::floatToBinString(y);
+  printf("%f = ", y);
+  printf(s); printf("\n");
+  
+  y = 12.4e20f;
+  s = Converter::floatToBinString(y);
+  printf("%f = ", y);
+  printf(s); printf("\n");
+  
+  y = 4.7824f;
+  s = Converter::floatToBinString(y);
+  printf("%f = ", y);
+  printf(s); printf("\n");
+  
+  
+  
   return 0;
 }
@@ -308,4 +358,6 @@
     else if (! strcmp( "--listen", argv[i]) || !strcmp("-l", argv[i]))
       return startListen(argc, argv);
+    else if (! strcmp( "--converter", argv[i]) || !strcmp("-o", argv[i]))
+      return converter(argc, argv);
   }
 
Index: /trunk/src/subprojects/network/read_sync.cc
===================================================================
--- /trunk/src/subprojects/network/read_sync.cc	(revision 6138)
+++ /trunk/src/subprojects/network/read_sync.cc	(revision 6139)
@@ -80,5 +80,5 @@
  *  read data from Synchronizeable
  */
-int ReadSync::readBytes(byte* data)
+int ReadSync::readBytes(byte* data, int maxLength, int * reciever)
 {
   return 0;
Index: /trunk/src/subprojects/network/read_sync.h
===================================================================
--- /trunk/src/subprojects/network/read_sync.h	(revision 6138)
+++ /trunk/src/subprojects/network/read_sync.h	(revision 6139)
@@ -17,5 +17,5 @@
 
     virtual void writeBytes(const byte* data, int length);
-    virtual int readBytes(byte* data);
+    virtual int readBytes(byte* data, int maxLength, int * reciever);
 
 
Index: /trunk/src/subprojects/network/simple_sync.cc
===================================================================
--- /trunk/src/subprojects/network/simple_sync.cc	(revision 6138)
+++ /trunk/src/subprojects/network/simple_sync.cc	(revision 6139)
@@ -86,5 +86,5 @@
  *  read data from Synchronizeable
  */
-int SimpleSync::readBytes(byte* data)
+int SimpleSync::readBytes(byte* data, int maxLength, int * reciever)
 {
   PRINTF(0)("SimpleSync: sent %i bytes of data\n", this->outLength);
Index: /trunk/src/subprojects/network/simple_sync.h
===================================================================
--- /trunk/src/subprojects/network/simple_sync.h	(revision 6138)
+++ /trunk/src/subprojects/network/simple_sync.h	(revision 6139)
@@ -17,5 +17,5 @@
 
     virtual void writeBytes(const byte* data, int length);
-    virtual int readBytes(byte* data);
+    virtual int readBytes(byte* data, int maxLength, int * reciever);
 
 
Index: /trunk/src/subprojects/network/write_sync.cc
===================================================================
--- /trunk/src/subprojects/network/write_sync.cc	(revision 6138)
+++ /trunk/src/subprojects/network/write_sync.cc	(revision 6139)
@@ -86,5 +86,5 @@
  *  read data from Synchronizeable
  */
-int WriteSync::readBytes(byte* data)
+int WriteSync::readBytes(byte* data, int maxLength, int * reciever)
 {
   PRINTF(0)("WriteSync: sent %i bytes of data\n", this->outLength);
Index: /trunk/src/subprojects/network/write_sync.h
===================================================================
--- /trunk/src/subprojects/network/write_sync.h	(revision 6138)
+++ /trunk/src/subprojects/network/write_sync.h	(revision 6139)
@@ -17,5 +17,5 @@
 
     virtual void writeBytes(const byte* data, int length);
-    virtual int readBytes(byte* data);
+    virtual int readBytes(byte* data, int maxLength, int * reciever);
 
 
Index: /trunk/src/util/loading/game_loader.cc
===================================================================
--- /trunk/src/util/loading/game_loader.cc	(revision 6138)
+++ /trunk/src/util/loading/game_loader.cc	(revision 6139)
@@ -46,5 +46,5 @@
 /**
  *  simple constructor
-*/
+ */
 GameLoader::GameLoader ()
 {
@@ -57,5 +57,5 @@
 /**
  *  simple deconstructor
-*/
+ */
 GameLoader::~GameLoader ()
 {
@@ -69,7 +69,7 @@
  *  this class is a singleton class
  * @returns an instance of itself
-
-   if you are unsure about singleton classes, check the theory out on the internet :)
-*/
+ *
+ * if you are unsure about singleton classes, check the theory out on the internet :)
+ */
 GameLoader* GameLoader::getInstance()
 {
@@ -81,5 +81,5 @@
 /**
  *  initializes the GameLoader
-*/
+ */
 ErrorMessage GameLoader::init()
 {
@@ -100,7 +100,7 @@
  * @param fileName to be loaded
  * @returns the loaded campaign
-
-   this will interprete the map/campaign files and recursivly load a tree of worlds/campaigns
-*/
+ *
+ * this will interprete the map/campaign files and recursivly load a tree of worlds/campaigns
+ */
 ErrorMessage GameLoader::loadCampaign(const char* fileName)
 {
@@ -112,8 +112,25 @@
       delete[] campaignName;
     }
-//   World* world0 = new World(DEBUG_WORLD_0);
-//   world0->setNextStoryID(WORLD_ID_GAMEEND);
-//   this->currentCampaign->addEntity(world0, WORLD_ID_2);
-}
+}
+
+
+/**
+ *  reads a campaign definition file into a campaign class
+ * @param fileName to be loaded
+ * @returns the loaded campaign
+ *
+ * this will interprete the map/campaign files and recursivly load a tree of worlds/campaigns
+ */
+ErrorMessage GameLoader::loadNetworkCampaign(const char* fileName)
+{
+  ErrorMessage errorCode;
+  char* campaignName = ResourceManager::getFullName(fileName);
+  if (campaignName)
+  {
+    this->currentCampaign = this->fileToNetworkCampaign(campaignName);
+    delete[] campaignName;
+  }
+}
+
 
 /**
@@ -121,5 +138,5 @@
  * @param campaignID the identifier of the campaign.
  * @returns error message if not able to do so.
-*/
+ */
 ErrorMessage GameLoader::loadDebugCampaign(Uint32 campaignID)
 {
@@ -156,7 +173,7 @@
 
 /**
-  *  starts the current entity
-  * @returns error code if this action has caused a error
-*/
+ *  starts the current entity
+ * @returns error code if this action has caused a error
+ */
 ErrorMessage GameLoader::start()
 {
@@ -167,13 +184,13 @@
 
 /**
-  *  stops the current entity
-  * @returns error code if this action has caused a error
-
-    ATTENTION: this function shouldn't call other functions, or if so, they must return
-    after finishing. If you ignore or forget to do so, the current entity is not able to
-    terminate and it will run in the background or the ressources can't be freed or even
-    worse: are freed and the program will end in a segmentation fault!
-    hehehe, have ya seen it... :)
-*/
+ *  stops the current entity
+ * @returns error code if this action has caused a error
+ *
+ *  ATTENTION: this function shouldn't call other functions, or if so, they must return
+ *  after finishing. If you ignore or forget to do so, the current entity is not able to
+ *  terminate and it will run in the background or the ressources can't be freed or even
+ *  worse: are freed and the program will end in a segmentation fault!
+ *  hehehe, have ya seen it... :)
+ */
 void GameLoader::stop()
 {
@@ -184,9 +201,9 @@
 
 /**
-  *  pause the current entity
-  * @returns error code if this action has caused a error
-
-    this pauses the current entity or passes this call forth to the running entity.
-*/
+ *  pause the current entity
+ * @returns error code if this action has caused a error
+ *
+ * this pauses the current entity or passes this call forth to the running entity.
+ */
 ErrorMessage GameLoader::pause()
 {
@@ -198,9 +215,9 @@
 
 /**
-  *  resumes a pause
-  * @returns error code if this action has caused a error
-
-    this resumess the current entity or passes this call forth to the running entity.
-*/
+ *  resumes a pause
+ * @returns error code if this action has caused a error
+ *
+ *  this resumess the current entity or passes this call forth to the running entity.
+ */
 ErrorMessage GameLoader::resume()
 {
@@ -224,7 +241,7 @@
  * @param fileName to be loaded
  * @returns the loaded campaign
-
-   this will interprete the map/campaign files and recursivly load a tree of worlds/campaigns
-*/
+ *
+ * this will interprete the map/campaign files and recursivly load a tree of worlds/campaigns
+ */
 Campaign* GameLoader::fileToCampaign(const char* fileName)
 {
@@ -273,4 +290,56 @@
 
 /**
+ *  reads a campaign definition file into a campaign class
+ * @param fileName to be loaded
+ * @returns the loaded campaign
+ *
+ *  this will interprete the map/campaign files and recursivly load a tree of worlds/campaigns
+ */
+Campaign* GameLoader::fileToNetworkCampaign(const char* fileName)
+{
+  /* do not entirely load the campaign. just the current world
+  before start of each world, it has to be initialized so it
+  can load everything it needs into memory then.
+  */
+
+  if( fileName == NULL)
+  {
+    PRINTF(2)("No filename specified for loading");
+    return NULL;
+  }
+
+  TiXmlDocument* XMLDoc = new TiXmlDocument( fileName);
+  // load the campaign document
+  if( !XMLDoc->LoadFile())
+  {
+      // report an error
+    PRINTF(1)("Could not load XML File %s: %s @ %d:%d\n", fileName, XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());
+    delete XMLDoc;
+    return NULL;
+  }
+
+  // check basic validity
+  TiXmlElement* root = XMLDoc->RootElement();
+  assert( root != NULL);
+
+  if( strcmp( root->Value(), "Campaign"))
+  {
+      // report an error
+    PRINTF(2)("Specified XML File is not an orxonox campaign file (Campaign element missing)\n");
+    delete XMLDoc;
+    return NULL;
+  }
+
+  // construct campaign
+  Campaign* c = new Campaign( root);
+
+  // free the XML data
+  delete XMLDoc;
+
+  return c;
+}
+
+
+/**
  *  handle keyboard commands
  * @param event the event to handle
@@ -312,6 +381,6 @@
 
 /**
-  \brief this changes to the next level
-*/
+ *  \brief this changes to the next level
+ */
 void GameLoader::nextLevel()
 {
@@ -322,8 +391,8 @@
 
 /**
-  \brief change to the previous level - not implemented
-
-  this propably useless
-*/
+ *  change to the previous level - not implemented
+ *
+ * this propably useless
+ */
 void GameLoader::previousLevel()
 {
Index: /trunk/src/util/loading/game_loader.h
===================================================================
--- /trunk/src/util/loading/game_loader.h	(revision 6138)
+++ /trunk/src/util/loading/game_loader.h	(revision 6139)
@@ -40,4 +40,5 @@
 {
 
+
  public:
   ~GameLoader ();
@@ -46,5 +47,4 @@
 
   ErrorMessage init();
-  ErrorMessage loadCampaign(const char* name);
   ErrorMessage start();
   void stop();
@@ -53,12 +53,13 @@
   ErrorMessage destroy();
 
+  ErrorMessage loadCampaign(const char* name);
+  ErrorMessage loadDebugCampaign(Uint32 campaignID);
+  ErrorMessage loadNetworkCampaign(const char* fileName);
+
   void nextLevel();
   void previousLevel();
 
-  /** \brief a world command to send to the GameLoader @param cmd the command */
-  bool worldCommand(Command* cmd);
-  ErrorMessage loadDebugCampaign(Uint32 campaignID);
+  void process(const Event &event);
 
-  void process(const Event &event);
 
  private:
@@ -66,4 +67,6 @@
 
   Campaign* fileToCampaign(const char* name);
+  Campaign* fileToNetworkCampaign(const char* fileName);
+
 
  private:
Index: /trunk/src/world_entities/Makefile.am
===================================================================
--- /trunk/src/world_entities/Makefile.am	(revision 6138)
+++ /trunk/src/world_entities/Makefile.am	(revision 6139)
@@ -8,5 +8,5 @@
                   camera.cc \
                   playable.cc \
-		  player.cc \
+		              player.cc \
                   npc.cc \
                   npc2.cc \
@@ -18,5 +18,5 @@
                   character_attributes.cc \
                   test_entity.cc \
-		  space_ships/space_ship.cc \
+		              space_ships/space_ship.cc \
                   weapons/weapon_manager.cc \
                   weapons/weapon.cc \
@@ -27,7 +27,7 @@
                   weapons/rocket.cc \
                   weapons/laser.cc \
-		  weapons/ground_turret.cc \
+		              weapons/ground_turret.cc \
                   weapons/crosshair.cc \
-		  weapons/ground_turret.cc \
+		              weapons/ground_turret.cc \
                   power_ups/power_up.cc \
                   power_ups/turret_power_up.cc \
@@ -38,5 +38,5 @@
                  camera.h \
                  playable.h \
-		 player.h \
+		             player.h \
                  npc.h \
                  npc2.h \
Index: /trunk/src/world_entities/camera.h
===================================================================
--- /trunk/src/world_entities/camera.h	(revision 6138)
+++ /trunk/src/world_entities/camera.h	(revision 6139)
@@ -8,5 +8,4 @@
 
 #include "p_node.h"
-#include "vector.h"
 #include "event_listener.h"
 
Index: /trunk/src/world_entities/spawning_point.cc
===================================================================
--- /trunk/src/world_entities/spawning_point.cc	(revision 6139)
+++ /trunk/src/world_entities/spawning_point.cc	(revision 6139)
@@ -0,0 +1,128 @@
+
+/*
+   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:
+*/
+
+#include "spawning_point.h"
+#include "load_param.h"
+#include "factory.h"
+#include "compiler.h"
+#include "world.h" /* only temp. until the object manager is implemented*/
+
+/**
+ *  standard constructor
+ */
+SpawningPoint::SpawningPoint (World* world, const Vector& absCoordinate)
+{
+  this->world = world;
+  this->frequency = 0.5f;
+  this->seed = 0.0f;
+
+  this->init();
+}
+
+
+/**
+ *  constructor
+ */
+SpawningPoint::SpawningPoint (const Vector& position, float frequency,
+                              float seed, ClassID classID, World* world)
+{
+  this->frequency = frequency;
+  this->seed = seed;
+  this->classID = classID;
+  this->world = world;
+
+  this->init();
+}
+
+
+void SpawningPoint::init()
+{
+  this->countDown = 0.0f;
+}
+
+
+/**
+ *  deconstructor
+ */
+SpawningPoint::~SpawningPoint ()
+{}
+
+
+/**
+ * loads the WorldEntity Specific Parameters.
+ * @param root: the XML-Element to load the Data From
+ */
+void SpawningPoint::loadParams(const TiXmlElement* root)
+{
+  /* let the world entity its stuff first */
+  static_cast<WorldEntity*>(this)->loadParams(root);
+
+  /* now load the frequency */
+  LoadParam(root, "frequency", this, SpawningPoint, setSpawningFrequency)
+  .describe("sets the frequency of the spawning point")
+  .defaultValues(1, 1.0f);
+
+
+  /* now load the seed */
+  LoadParam(root, "randomseed", this, SpawningPoint, setPositionSeed)
+      .describe("sets the random position seed (variance in the spawning location around the position)")
+      .defaultValues(1, 0.0f);
+
+  /* now load the seed */
+/*  LoadParam(root, "classid", this, SpawningPoint, setSpawningEntity)
+      .describe("sets the class id of the entity to spawn")
+      .defaultValues(1, CL_WORLD_ENTITY);*/
+}
+
+
+/**
+ *  spawn the entity
+ */
+void SpawningPoint::spawn()
+{
+  PRINTF(5)("Spangingpoint creates a new Entity (id: %i, frequency: %f, seed: %f)\n", this->classID,
+            this->frequency, this->seed);
+  BaseObject* spawningEntity = Factory::fabricate(this->classID);
+  if( likely(this->world != NULL))
+    this->world->spawn(dynamic_cast<WorldEntity*>(spawningEntity));
+}
+
+
+/**
+ *  this method is called every frame
+ * @param time: the time in seconds that has passed since the last tick
+ *
+ * Handle all stuff that should update with time inside this method (movement, animation, etc.)
+ */
+void SpawningPoint::tick(float dt)
+{
+  this->countDown += dt;
+  if( this->countDown > this->frequency)
+  {
+    this->spawn();
+    this->countDown = 0.0f;
+  }
+}
+
+
+/**
+ *  the entity is drawn onto the screen with this function
+ *
+ * This is a central function of an entity: call it to let the entity painted to the screen.
+ * Just override this function with whatever you want to be drawn.
+ */
+void SpawningPoint::draw()
+{}
Index: /trunk/src/world_entities/spawning_point.h
===================================================================
--- /trunk/src/world_entities/spawning_point.h	(revision 6139)
+++ /trunk/src/world_entities/spawning_point.h	(revision 6139)
@@ -0,0 +1,47 @@
+/*!
+ * @file spawning_point.h
+ *  Definition of a spawning point within the game, used for network game
+ */
+
+
+#ifndef _SPAWNING_POINT
+#define _SPAWNING_POINT
+
+#include "world_entity.h"
+
+class World;
+class TiXmlElement;
+
+//! The spawning point for world entities
+class SpawningPoint : public WorldEntity {
+
+  public:
+    SpawningPoint (World* world, const Vector& absCoordinate = Vector(0.0, 0.0, 0.0));
+    SpawningPoint (const Vector& position, float frequency, float seed, ClassID classID, World* world);
+    virtual ~SpawningPoint ();
+    void init();
+
+    void loadParams(const TiXmlElement* root);
+
+    /**  sets the entity that is going to be spawned by this point @param classID: the id from the class_id.h file */
+    void SpawningPoint::setSpawningEntity(ClassID classID) { this->classID = classID; }
+    /** sets the frequency with which the point is going to spawn entities (1/sec) @param frequency: the frequency */
+    void SpawningPoint::setSpawningFrequency(float frequency) { this->frequency = frequency; }
+    /**  sets the seed of the position vector @param seed: the random seed around the given vector */
+    void SpawningPoint::setPositionSeed(float seed) { this->seed = seed; }
+
+    void spawn();
+
+    virtual void tick(float dt);
+    virtual void draw();
+
+  private:
+    float                frequency;                      //!< the frequency for entity spawning
+    float                countDown;                      //!< the timer that counts down until the next spawn
+    float                seed;                           //!< the random seed of the position
+    ClassID              classID;                        //!< the classid of the entity to spawn
+    World*               world;                          //!< reference to the world it belongs to (or in the future: the object manager)
+
+};
+
+#endif /* _SPAWNING_POINT */
