Index: branches/proxy/src/defs/class_id.h
===================================================================
--- branches/proxy/src/defs/class_id.h	(revision 9346)
+++ branches/proxy/src/defs/class_id.h	(revision 9347)
@@ -127,4 +127,5 @@
   CL_NETWORK_MANAGER            =    0x00000050,
   CL_SHARED_NETWORK_DATA        =    0x00000051,
+  CL_PROXY_SETTINGS             =    0x00000052,
   CL_ATMOSPHERIC_ENGINE         =    0x00000061,
 
@@ -422,4 +423,5 @@
   CL_PLAYER_STATS               =    0x00000d09,
   CL_SIMPLE_SYNC                =    0x00000d0a,
+  CL_NETWORK_MONITOR            =    0x00000d0b,
 
 
Index: branches/proxy/src/lib/collision_detection/obb_tree_node.cc
===================================================================
--- branches/proxy/src/lib/collision_detection/obb_tree_node.cc	(revision 9346)
+++ branches/proxy/src/lib/collision_detection/obb_tree_node.cc	(revision 9347)
@@ -434,4 +434,5 @@
     }
   }
+  delete [] triangleCenter;
   PRINTF(4)("\nPartition1: got \t%i Vertices \nPartition2: got \t%i Vertices\n", partition1.size(), partition2.size());
 
@@ -476,6 +477,6 @@
     return;
 
-  float distanceMax = this->bvElement->radius + ((OBBTreeNode*)treeNode)->bvElement->radius;
-  float distance = fabs((nodeA->getAbsCoor() - nodeB->getAbsCoor()).len());
+//   float distanceMax = this->bvElement->radius + ((OBBTreeNode*)treeNode)->bvElement->radius;
+//   float distance = fabs((nodeA->getAbsCoor() - nodeB->getAbsCoor()).len());
 
 
Index: branches/proxy/src/lib/coord/p_node.h
===================================================================
--- branches/proxy/src/lib/coord/p_node.h	(revision 9346)
+++ branches/proxy/src/lib/coord/p_node.h	(revision 9347)
@@ -20,5 +20,4 @@
 
 #include "base_object.h"
-#include "stdincl.h"
 #include "synchronizeable.h"
 
@@ -112,5 +111,5 @@
   /** @returns the absolute position */
   inline const Vector& getLastAbsCoor () const { return this->lastAbsCoordinate; };
-  
+
   void shiftCoor (const Vector& shift);
   void shiftCoor (float x, float y, float z) { this->shiftCoor(Vector(x, y, z)); };
Index: branches/proxy/src/lib/graphics/effects/snow_effect.cc
===================================================================
--- branches/proxy/src/lib/graphics/effects/snow_effect.cc	(revision 9346)
+++ branches/proxy/src/lib/graphics/effects/snow_effect.cc	(revision 9347)
@@ -1,14 +1,14 @@
 /*
-	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.
+        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: hdavid, amaechler
+        main-programmer: hdavid, amaechler
 */
 
@@ -35,5 +35,4 @@
 SHELL_COMMAND(deactivate, SnowEffect, deactivateSnow);
 
-using namespace std;
 
 CREATE_SCRIPTABLE_CLASS(SnowEffect, CL_SNOW_EFFECT,
@@ -46,20 +45,19 @@
 SnowEffect::SnowEffect(const TiXmlElement* root)
 {
-	this->setClassID(CL_SNOW_EFFECT, "SnowEffect");
-
-	this->init();
-
-	if (root != NULL)
-		this->loadParams(root);
-
-	//load wind sound
-	if (this->snowWindForce >= 1) {
-		if (this->windBuffer != NULL)
-			ResourceManager::getInstance()->unload(this->windBuffer);
-	  this->windBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/atmosphere/wind.wav", WAV);
-	}
+        this->setClassID(CL_SNOW_EFFECT, "SnowEffect");
+
+        this->init();
+
+        if (root != NULL)
+                this->loadParams(root);
+
+        this->windBuffer = NULL;
+        //load wind sound
+        if (this->snowWindForce >= 1) {
+          this->windBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/atmosphere/wind.wav", WAV);
+        }
 
   if(snowActivate) {
-		this->activate();
+                this->activate();
     SnowEffect::snowParticles->precache((int) this->snowLife);
   }
@@ -69,5 +67,5 @@
 SnowEffect::~SnowEffect()
 {
-	this->deactivate();
+        this->deactivate();
 }
 
@@ -76,52 +74,52 @@
 void SnowEffect::loadParams(const TiXmlElement* root)
 {
-	WeatherEffect::loadParams(root);
-
-	LoadParam(root, "numParticles", this, SnowEffect, numParticles);
-	LoadParam(root, "materialTexture", this, SnowEffect, materialTexture);
-	LoadParam(root, "lifeSpans", this, SnowEffect, lifeSpan);
-	LoadParam(root, "radius", this, SnowEffect, radius);
-	LoadParam(root, "mass", this, SnowEffect, mass);
-	LoadParam(root, "emissionRate", this, SnowEffect, emissionRate);
-	LoadParam(root, "emissionVelocity", this, SnowEffect, emissionVelocity);
-	LoadParam(root, "wind", this, SnowEffect, wind);
-	LoadParam(root, "size", this, SnowEffect, size);
-	LoadParam(root, "coord", this, SnowEffect, coord);
+        WeatherEffect::loadParams(root);
+
+        LoadParam(root, "numParticles", this, SnowEffect, numParticles);
+        LoadParam(root, "materialTexture", this, SnowEffect, materialTexture);
+        LoadParam(root, "lifeSpans", this, SnowEffect, lifeSpan);
+        LoadParam(root, "radius", this, SnowEffect, radius);
+        LoadParam(root, "mass", this, SnowEffect, mass);
+        LoadParam(root, "emissionRate", this, SnowEffect, emissionRate);
+        LoadParam(root, "emissionVelocity", this, SnowEffect, emissionVelocity);
+        LoadParam(root, "wind", this, SnowEffect, wind);
+        LoadParam(root, "size", this, SnowEffect, size);
+        LoadParam(root, "coord", this, SnowEffect, coord);
   LoadParam(root, "cloudcolor", this, SnowEffect, setCloudColor);
   LoadParam(root, "skycolor", this, SnowEffect, setSkyColor);
   LoadParam(root, "fadetime", this, SnowEffect, setFadeTime);
 
-	LOAD_PARAM_START_CYCLE(root, element);
-	{
-		LoadParam_CYCLE(element, "option", this, SnowEffect, setSnowOption);
-	}
-	LOAD_PARAM_END_CYCLE(element);
+        LOAD_PARAM_START_CYCLE(root, element);
+        {
+                LoadParam_CYCLE(element, "option", this, SnowEffect, setSnowOption);
+        }
+        LOAD_PARAM_END_CYCLE(element);
 }
 
 void SnowEffect::init()
 {
-	this->emitter = new PlaneEmitter();
-
-	// Default values
-	this->snowActivate = false;
-	this->snowMove = false;
-	this->particles = 12000;
-	this->texture = "maps/snow_flake_01_32x32.png";
-	this->snowLife = 8;
-	this->randomLife = 2;
-	this->snowRadius = 3.5;
-	this->randomRadius = 1;
-	this->snowMass = 1.0;
-	this->randomMass = 0.3;
-	this->rate = 900;
-	this->velocity = -100;
-	this->randomVelocity = 5;
-	this->angle = 0.5;
-	this->randomAngle = 0.2;
-	this->alpha = 0.5;
-	this->snowSize = Vector2D(2500, 2500);
-	this->snowCoord = Vector(100,450,400);
-	this->snowWindForce = 1;
-  
+        this->emitter = new PlaneEmitter();
+
+        // Default values
+        this->snowActivate = false;
+        this->snowMove = false;
+        this->particles = 12000;
+        this->texture = "maps/snow_flake_01_32x32.png";
+        this->snowLife = 8;
+        this->randomLife = 2;
+        this->snowRadius = 3.5;
+        this->randomRadius = 1;
+        this->snowMass = 1.0;
+        this->randomMass = 0.3;
+        this->rate = 900;
+        this->velocity = -100;
+        this->randomVelocity = 5;
+        this->angle = 0.5;
+        this->randomAngle = 0.2;
+        this->alpha = 0.5;
+        this->snowSize = Vector2D(2500, 2500);
+        this->snowCoord = Vector(100,450,400);
+        this->snowWindForce = 1;
+
   this->fadeTime = 10;
   this->cloudColor = Vector(0.2f, 0.2f, 0.2f);
@@ -131,31 +129,31 @@
 void SnowEffect::activate()
 {
-	PRINTF(3)("Activating SnowEffect\n");
-
-	this->snowActivate = true;
-
-	SnowEffect::snowParticles = new SpriteParticles(particles);
-	SnowEffect::snowParticles->setName("SnowEffectTrailParticles");
-	SnowEffect::snowParticles->setMaterialTexture(texture);
-	SnowEffect::snowParticles->setLifeSpan(snowLife, randomLife);
-	SnowEffect::snowParticles->setRadius(0.0, snowRadius, randomRadius);
-	SnowEffect::snowParticles->setRadius(0.2, snowRadius, randomRadius*0.8);
-	SnowEffect::snowParticles->setRadius(1.0, snowRadius, randomRadius*0.5);
-	SnowEffect::snowParticles->setMass(0, snowMass, randomMass);
-	SnowEffect::snowParticles->setColor(0,1, 1, 1, alpha);
-	SnowEffect::snowParticles->setColor(.5, .6, .6, .6, alpha/2);
-	SnowEffect::snowParticles->setColor(1, .0, .0, .0, .0);
-
-	this->emitter->setSystem(SnowEffect::snowParticles);
-
-	this->emitter->setRelCoor(snowCoord);
-	this->emitter->setEmissionRate(rate);
-	this->emitter->setEmissionVelocity(velocity, randomVelocity);
-	this->emitter->setSpread(angle * this->snowWindForce , randomAngle * this->snowWindForce);
-	this->emitter->setSize(snowSize);
+        PRINTF(3)("Activating SnowEffect\n");
+
+        this->snowActivate = true;
+
+        SnowEffect::snowParticles = new SpriteParticles(particles);
+        SnowEffect::snowParticles->setName("SnowEffectTrailParticles");
+        SnowEffect::snowParticles->setMaterialTexture(texture);
+        SnowEffect::snowParticles->setLifeSpan(snowLife, randomLife);
+        SnowEffect::snowParticles->setRadius(0.0, snowRadius, randomRadius);
+        SnowEffect::snowParticles->setRadius(0.2, snowRadius, randomRadius*0.8);
+        SnowEffect::snowParticles->setRadius(1.0, snowRadius, randomRadius*0.5);
+        SnowEffect::snowParticles->setMass(0, snowMass, randomMass);
+        SnowEffect::snowParticles->setColor(0,1, 1, 1, alpha);
+        SnowEffect::snowParticles->setColor(.5, .6, .6, .6, alpha/2);
+        SnowEffect::snowParticles->setColor(1, .0, .0, .0, .0);
+
+        this->emitter->setSystem(SnowEffect::snowParticles);
+
+        this->emitter->setRelCoor(snowCoord);
+        this->emitter->setEmissionRate(rate);
+        this->emitter->setEmissionVelocity(velocity, randomVelocity);
+        this->emitter->setSpread(angle * this->snowWindForce , randomAngle * this->snowWindForce);
+        this->emitter->setSize(snowSize);
 
   if (this->snowWindForce != 0)
     this->soundSource.play(this->windBuffer, 0.1f * this->snowWindForce, true);
-  
+
   // Store cloud- and sky color before the snow
   this->oldCloudColor = CloudEffect::cloudColor;
@@ -171,12 +169,12 @@
 void SnowEffect::deactivate()
 {
-	PRINTF(3)("Deactivating SnowEffect\n");
-
-	this->snowActivate = false;
-	this->emitter->setSystem(NULL);
-
-	if (this->windBuffer != NULL)
-		ResourceManager::getInstance()->unload(this->windBuffer);
-  
+        PRINTF(3)("Deactivating SnowEffect\n");
+
+        this->snowActivate = false;
+        this->emitter->setSystem(NULL);
+
+        if (this->windBuffer != NULL)
+                ResourceManager::getInstance()->unload(this->windBuffer);
+
   // Restore the old cloud- and sky color
   CloudEffect::changeCloudColor(this->oldCloudColor, this->fadeTime);
@@ -186,50 +184,50 @@
 void SnowEffect::draw() const
 {
-	if (!this->snowActivate)
-		return;
+        if (!this->snowActivate)
+                return;
 }
 
 void SnowEffect::tick(float dt)
 {
-	if (!this->snowActivate)
-		return;
-
-	/*
-	float distance = (State::getCameraNode()->getAbsCoor() - Vector(snowCoord.x, State::getCameraNode()->getAbsCoor().y, snowCoord.z)).len();
-
-	if(activated)
-	{
-	if(distance > 0.3*snowSize.x || distance > 0.3*snowSize.y)
-			this->deactivate();
-	else if(distance > 0.25*snowSize.x || distance > 0.25*snowSize.y)
-	this->alpha = 0.15;
-	else if(distance > 0.2*snowSize.x || distance > 0.2*snowSize.y)
-	this->alpha = 0.25;
-	else if(distance > 0.1*snowSize.x || distance > 0.1*snowSize.y)
-	this->alpha = 0.4;
-
-	SnowEffect::snowParticles->setColor(0,1, 1, 1, alpha);
-	SnowEffect::snowParticles->setColor(.5, .6, .6, .6, alpha/2);
-	SnowEffect::snowParticles->setColor(1, .0, .0, .0, .0);
-	}
-	else
-	{
-	if(distance < 0.3*snowSize.x || distance < 0.3*snowSize.y )
-	this->activate();
-	if( distance < 0.25*snowSize.x || distance < 0.25*snowSize.y )
-	this->alpha = 0.25;
-	else if( distance < 0.2*snowSize.x || distance < 0.2*snowSize.y )
-	this->alpha = 0.4;
-	else if( distance < 0.1*snowSize.x || distance < 0.1*snowSize.y )
-	this->alpha = 0.5;
-
-	SnowEffect::snowParticles->setColor(0,1, 1, 1, alpha);
-	SnowEffect::snowParticles->setColor(.5, .6, .6, .6, alpha/2);
-	SnowEffect::snowParticles->setColor(1, .0, .0, .0, .0);
-	}*/
-
-	if (this->snowMove) {
-		this->snowCoord = State::getCameraNode()->getAbsCoor();
-		this->emitter->setRelCoor(this->snowCoord.x , this->snowCoord.y+300, this->snowCoord.z);
-	}
-}
+        if (!this->snowActivate)
+                return;
+
+        /*
+        float distance = (State::getCameraNode()->getAbsCoor() - Vector(snowCoord.x, State::getCameraNode()->getAbsCoor().y, snowCoord.z)).len();
+
+        if(activated)
+        {
+        if(distance > 0.3*snowSize.x || distance > 0.3*snowSize.y)
+                        this->deactivate();
+        else if(distance > 0.25*snowSize.x || distance > 0.25*snowSize.y)
+        this->alpha = 0.15;
+        else if(distance > 0.2*snowSize.x || distance > 0.2*snowSize.y)
+        this->alpha = 0.25;
+        else if(distance > 0.1*snowSize.x || distance > 0.1*snowSize.y)
+        this->alpha = 0.4;
+
+        SnowEffect::snowParticles->setColor(0,1, 1, 1, alpha);
+        SnowEffect::snowParticles->setColor(.5, .6, .6, .6, alpha/2);
+        SnowEffect::snowParticles->setColor(1, .0, .0, .0, .0);
+        }
+        else
+        {
+        if(distance < 0.3*snowSize.x || distance < 0.3*snowSize.y )
+        this->activate();
+        if( distance < 0.25*snowSize.x || distance < 0.25*snowSize.y )
+        this->alpha = 0.25;
+        else if( distance < 0.2*snowSize.x || distance < 0.2*snowSize.y )
+        this->alpha = 0.4;
+        else if( distance < 0.1*snowSize.x || distance < 0.1*snowSize.y )
+        this->alpha = 0.5;
+
+        SnowEffect::snowParticles->setColor(0,1, 1, 1, alpha);
+        SnowEffect::snowParticles->setColor(.5, .6, .6, .6, alpha/2);
+        SnowEffect::snowParticles->setColor(1, .0, .0, .0, .0);
+        }*/
+
+        if (this->snowMove) {
+                this->snowCoord = State::getCameraNode()->getAbsCoor();
+                this->emitter->setRelCoor(this->snowCoord.x , this->snowCoord.y+300, this->snowCoord.z);
+        }
+}
Index: branches/proxy/src/lib/graphics/effects/snow_effect.h
===================================================================
--- branches/proxy/src/lib/graphics/effects/snow_effect.h	(revision 9346)
+++ branches/proxy/src/lib/graphics/effects/snow_effect.h	(revision 9347)
@@ -101,31 +101,31 @@
 
 private:
-    int         particles;
+    int               particles;
     std::string       texture;
-    float       snowLife, randomLife;
-    float       snowRadius, randomRadius;
-    float       snowMass, randomMass;
-    float         rate;
-    float         velocity, randomVelocity;
-    float         angle, randomAngle;
-    float         alpha;
-    float         fadeTime;
-    Vector        snowCoord;
-    Vector2D      snowSize;
-    int       snowWindForce;
+    float             snowLife, randomLife;
+    float             snowRadius, randomRadius;
+    float             snowMass, randomMass;
+    float             rate;
+    float             velocity, randomVelocity;
+    float             angle, randomAngle;
+    float             alpha;
+    float             fadeTime;
+    Vector            snowCoord;
+    Vector2D          snowSize;
+    int               snowWindForce;
 
-    bool        snowMove;
-    bool        snowActivate;
+    bool              snowMove;
+    bool              snowActivate;
 
     PlaneEmitter*     emitter;
 
     static SpriteParticles*   snowParticles;
-    OrxSound::SoundSource   soundSource;
+    OrxSound::SoundSource     soundSource;
     OrxSound::SoundBuffer*    windBuffer;
 
-    Vector oldSkyColor;
-    Vector oldCloudColor;
-    Vector skyColor;
-    Vector cloudColor;
+    Vector            oldSkyColor;
+    Vector            oldCloudColor;
+    Vector            skyColor;
+    Vector            cloudColor;
 };
 
Index: branches/proxy/src/lib/graphics/importer/md3/md3_animation_cfg.cc
===================================================================
--- branches/proxy/src/lib/graphics/importer/md3/md3_animation_cfg.cc	(revision 9346)
+++ branches/proxy/src/lib/graphics/importer/md3/md3_animation_cfg.cc	(revision 9347)
@@ -19,11 +19,9 @@
 #include "md3_animation.h"
 
-#include "tokenizer.h"
+#include "substring.h"
 #include "helper_functions.h"
 
 #include "debug.h"
 
-#include <stdio.h>
-#include <stdlib.h>
 
 
@@ -98,6 +96,5 @@
         if( inHeader && line.find("sex") == 0) {
           //parse line: sex [m | f | ...]
-          std::vector<std::string> tokens;
-          Tokenizer::tokenize(line, tokens, " \t\n\r\f/");
+          SubString tokens(line, " \t\n\r\f/");
 
           std::string sexStr = tokens.back();
@@ -115,6 +112,5 @@
         else if( inHeader && line.find("headoffset") == 0) {
           // parse line: headoffset X Y Z
-          std::vector<std::string> tokens;
-          Tokenizer::tokenize(line, tokens, " \t\n\r\f/");
+          SubString tokens(line, " \t\n\r\f/");
 
           float z = atof(tokens.back().c_str()); tokens.pop_back();
@@ -128,6 +124,5 @@
         else if( inHeader && line.find("footsteps") == 0) {
           //parse line: footsteps [normal | mech | ...]
-          std::vector<std::string> tokens;
-          Tokenizer::tokenize(line, tokens, " \t\n\r\f/");
+          SubString tokens (line, " \t\n\r\f/");
 
           this->footsteps = tokens.back();
@@ -187,6 +182,5 @@
     // parse the line:
     // first frame, num frames, looping frames, frames per second (fps)
-    std::vector<std::string> tokens;
-    Tokenizer::tokenize(line, tokens, " \t\n\r\f/");
+    SubString tokens(line, " \t\n\r\f/");
 
     anim->fps = atoi(tokens.back().c_str()); tokens.pop_back();
Index: branches/proxy/src/lib/lang/base_object.cc
===================================================================
--- branches/proxy/src/lib/lang/base_object.cc	(revision 9346)
+++ branches/proxy/src/lib/lang/base_object.cc	(revision 9347)
@@ -21,9 +21,4 @@
 #include "util/loading/load_param.h"
 #include "class_list.h"
-
-#include "synchronizeable.h"
-
-using namespace std;
-
 
 /**
@@ -50,5 +45,4 @@
   ClassList::removeFromClassList(this);
 
-  //  delete []this->className;
   if (this->xmlElem != NULL)
     delete this->xmlElem;
@@ -61,10 +55,12 @@
 void BaseObject::loadParams(const TiXmlElement* root)
 {
-  // all loadParams should sometime arrive here.
+  // all loadParams should arrive here, and be tested for (root != NULL)
   assert (root != NULL);
 
+  // copy the xml-element for to know how it was loaded.
   if (this->xmlElem != NULL)
     delete this->xmlElem;
   this->xmlElem = root->Clone();
+
   // name setup
   LoadParam(root, "name", this, BaseObject, setName)
@@ -92,4 +88,5 @@
 /**
  * @brief set the name of the Object
+ * @param objectName The new name of the Object.
  */
 void BaseObject::setName (const std::string& objectName)
@@ -164,16 +161,7 @@
  * @returns true on match, false otherwise.
  */
-bool BaseObject::operator==(const std::string& objectName)
+bool BaseObject::operator==(const std::string& objectName) const
 {
   return (this->objectName == objectName);
 }
 
-
-/**
- * @brief displays everything this class is
- * @TODO REIMPLEMENT WITH SENSE.
- */
-void BaseObject::whatIs() const
-{
-
-}
Index: branches/proxy/src/lib/lang/base_object.h
===================================================================
--- branches/proxy/src/lib/lang/base_object.h	(revision 9346)
+++ branches/proxy/src/lib/lang/base_object.h	(revision 9347)
@@ -1,12 +1,16 @@
 /*!
  * @file base_object.h
-  *  Definition of the base object class.
-
-    This is a global handler for all classes.
-*/
+ * @brief Definition of the BaseObject class.
+ *
+ * This is a global handler for all classes Object and Class names
+ *
+ * BaseObject is the class, that handles object registration and
+ * is the only write-access member of ClassList, where the Objects
+ * References are stored.
+ */
 
 
-#ifndef _BASE_OBJECT_H
-#define _BASE_OBJECT_H
+#ifndef __BASE_OBJECT_H_
+#define __BASE_OBJECT_H_
 
 #include "class_id.h"
@@ -41,9 +45,8 @@
   bool isA (ClassID classID) const;
   bool isA (const std::string& className) const;
-  void whatIs() const;
 
-  bool operator==(const std::string& objectName);
   /** @param classID comparer for a ClassID @returns true on match, false otherwise */
-  bool operator==(ClassID classID) { return this->isA(classID); };
+  bool operator==(ClassID classID) const  { return this->isA(classID); };
+  bool operator==(const std::string& objectName) const;
 
 protected:
@@ -54,5 +57,4 @@
 
 private:
-
   std::string        className;        //!< the name of the class
   long               classID;          //!< this is the id from the class_id.h enumeration
@@ -64,3 +66,3 @@
 };
 
-#endif /* _BASE_OBJECT_H */
+#endif /* __BASE_OBJECT_H_ */
Index: branches/proxy/src/lib/network/Makefile.am
===================================================================
--- branches/proxy/src/lib/network/Makefile.am	(revision 9346)
+++ branches/proxy/src/lib/network/Makefile.am	(revision 9347)
@@ -8,5 +8,4 @@
 		      shared_network_data.cc \
 		      network_socket.cc \
-		      connection_monitor.cc \
 		      network_stream.cc \
                       data_stream.cc \
@@ -20,4 +19,5 @@
 		      network_game_manager.cc \
 		      converter.cc \
+		      peer_info.cc \
 		      message_manager.cc \
 		      network_log.cc \
@@ -25,4 +25,10 @@
 		      player_stats.cc \
 		      udp_broadcast.cc \
+		      \
+		      proxy/proxy_settings.cc \
+		      \
+      		      monitor/connection_monitor.cc \
+		      monitor/network_monitor.cc \
+		      monitor/network_node.cc \
 		      \
 		      synchronizeable_var/synchronizeable_var.cc \
@@ -33,5 +39,8 @@
 		      synchronizeable_var/synchronizeable_float.cc \
 		      synchronizeable_var/synchronizeable_bool.cc \
-		      synchronizeable_var/synchronizeable_uint.cc 
+		      synchronizeable_var/synchronizeable_uint.cc \
+		      synchronizeable_var/synchronizeable_ip.cc \
+		      \
+		      ip.cc
 
 
@@ -42,5 +51,4 @@
                  shared_network_data.h \
                  network_socket.h \
-                 connection_monitor.h \
 		 network_stream.h \
                  data_stream.h \
@@ -54,4 +62,5 @@
 		 network_game_manager.h \
 		 converter.h \
+		 peer_info.h \
 		 netdefs.h \
 		 message_manager.h \
@@ -60,4 +69,10 @@
 		 player_stats.h \
 		 udp_broadcast.h \
+		 \
+		 proxy/proxy_settings.cc \
+		 \
+                 monitor/connection_monitor.h \
+                 monitor/network_monitor.h \
+                 monitor/network_node.h \
 		 \
 		 synchronizeable_var/synchronizeable_var.h \
@@ -68,5 +83,8 @@
 		 synchronizeable_var/synchronizeable_float.h \
 		 synchronizeable_var/synchronizeable_bool.h \
-		 synchronizeable_var/synchronizeable_uint.h
+		 synchronizeable_var/synchronizeable_uint.h \
+		 synchronizeable_var/synchronizeable_ip.h \
+		 \
+		 ip.h
 
 
Index: branches/proxy/src/lib/network/connection_monitor.cc
===================================================================
--- branches/proxy/src/lib/network/connection_monitor.cc	(revision 9346)
+++ 	(revision )
@@ -1,257 +1,0 @@
-/*
-   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 Renner
-   co-programmer: ...
-*/
-
-#include "connection_monitor.h"
-#include "network_log.h"
-
-#include <debug.h>
-#include <SDL/SDL.h>
-#include <string.h>
-
-/* using namespace std is default, this needs to be here */
-using namespace std;
-
-/**
- * constructor
- * @param userId user's id
- */
-ConnectionMonitor::ConnectionMonitor( int userId )
-{
-  /* set the class id for the base object and add ist to class list*/
-  this->setClassID(CL_CONNECTION_MONITOR, "ConnectionMonitor");
-  
-  this->userId = userId;
-  this->ping = 0;
-  this->incomingUnzippedBandWidth = 0;
-  this->outgoingUnzippedBandWidth = 0;
-  this->incomingZippedBandWidth = 0;
-  this->outgoingZippedBandWidth = 0;
-  this->nIncomingPackets = 0;
-  this->nOutgoingPackets = 0;
-  this->nZIncomingPackets = 0;
-  this->nZOutgoingPackets = 0;
-  
-  this->lastPacketTick = 0;
-  this->lastPrintTick = 0;
-}
-
-/**
- * deconstructor
- */
-ConnectionMonitor::~ConnectionMonitor( )
-{
-}
-
-/**
- * process unzipped outgoing packet
- * @param data pointer to packet data
- * @param length length of packet
- * @param stateId packet's state id
- */
-void ConnectionMonitor::processUnzippedOutgoingPacket( int tick, byte * data, int length, int stateId )
-{
-  nOutgoingPackets++;
-  
-  // for ping calculation
-  sentStateTicks[stateId] = tick;
-  
-  // calculate bandwidth
-  outgoingUnzippedPacketHistory[tick] = length;
-  outgoingUnzippedBandWidth = calculateBandWidth( outgoingUnzippedPacketHistory, tick );
-  
-  //NETPRINTF(n)("UNZIPPED UPSTREAM: user: %d bandwidth %f\n", userId, outgoingUnzippedBandWidth );
-  
-  // count zero bytes
-  //int nZeroBytes = 0;
-  
-  //for ( int i = 0; i < length; i++ )
-  //  if ( data[i] == '\0' )
-  //    nZeroBytes++;
-  
-  //NETPRINTF(n)( "ZEROBYTES: %d (%f%%)\n", nZeroBytes, ((float)100)*nZeroBytes/length );
-}
-
-/**
- * process unzipped incoming packet
- * @param data pointer to packet data
- * @param length length of packet
- * @param stateId packet's state id
- * @param ackedState state which was acked by this packet
- */
-void ConnectionMonitor::processUnzippedIncomingPacket( int tick, byte * data, int length, int stateId, int ackedState )
-{
-  nIncomingPackets++;
-  
-  lastPacketTick = tick;
-  
-  // calculate ping
-  if ( sentStateTicks.find( ackedState ) != sentStateTicks.end() )
-  {
-    ackDelay.push_back( tick - sentStateTicks[ackedState] );
-  }
-  
-  while ( sentStateTicks.begin() != sentStateTicks.end() && sentStateTicks.begin()->first <= ackedState )
-    sentStateTicks.erase( sentStateTicks.begin() );
-      
-  while ( ackDelay.size() > N_PACKETS_FOR_PING )
-    ackDelay.erase( ackDelay.begin() );
-      
-  ping = 0;
-      
-  for ( std::list<int>::iterator it = ackDelay.begin(); it != ackDelay.end(); it++ )
-    ping += *it;
-      
-  if ( ackDelay.size() == 0 )
-    ping = -1;
-  else
-    ping /= ackDelay.size();
-      
-  //NETPRINTF(n)("PING: user: %d ping: %d\n", userId, ping );
-  
-  // calculate bandwidth
-  incomingUnzippedPacketHistory[tick] = length;
-  incomingUnzippedBandWidth = calculateBandWidth( incomingUnzippedPacketHistory, tick );
-  
-  //NETPRINTF(n)("UNZIPPED DOWNSTREAM: user: %d bandwidth %f\n", userId, incomingUnzippedBandWidth );
-  
-}
-
-/**
- * remove old packets
- * @param packetHistory 
- * @param tick 
- */
-void ConnectionMonitor::removeOldPackets( std::map< int, int > & packetHistory, int tick )
-{
-  while ( packetHistory.begin()->first < tick - MSECS_TO_CALC_BWIDTH )
-    packetHistory.erase( packetHistory.begin() );
-}
-
-/**
- * calculate bandwidth out of packethistory
- * @param packetHistory packet history
- * @param tick current tick from SDL_GetTicks
- * @return bandwidth in bytes/sec
- */
-float ConnectionMonitor::calculateBandWidth( std::map< int, int > & packetHistory, int tick )
-{
-  removeOldPackets( packetHistory, tick );
-  
-  float res = 0.0f;
-#if 0
-  for ( std::map<int,int>::iterator it = packetHistory.begin(); it != packetHistory.end(); it++ )
-  {
-    if ( it != packetHistory.begin() )
-      res += it->second;
-  }
-  
-  if ( packetHistory.size() <= 1 || tick - packetHistory.begin()->first == 0 )
-    res = 0.0f;
-  else
-    res /= (float)(tick - packetHistory.begin()->first);
-  
-  res *= 1000.0f;
-#endif
-
-  for ( std::map<int,int>::iterator it = packetHistory.begin(); it != packetHistory.end(); it++ )
-  {
-    res += it->second;
-  }
-  
-  if ( packetHistory.size() <= 1 )
-    res = 0.0f;
-  else
-    res /= (float)(tick - packetHistory.begin()->first);
-  
-  res *= 1000.0f;
-
-  return res;
-}
-
-
-/**
- * process zipped outgoing packet
- * @param data pointer to packet data
- * @param length length of packet
- * @param stateId packet's state id
- */
-void ConnectionMonitor::processZippedOutgoingPacket( int tick, byte * data, int length, int stateId )
-{
-  nZOutgoingPackets++;
-  
-  // calculate bandwidth
-  outgoingZippedPacketHistory[tick] = length;
-  outgoingZippedBandWidth = calculateBandWidth( outgoingZippedPacketHistory, tick );
-  
-  //NETPRINTF(n)("UPSTREAM: user: %d bandwidth %f nOutgoingPackets %d\n", userId, outgoingZippedBandWidth, nOutgoingPackets );
-
-  if ( lastPrintTick < tick-1000 )
-  {
-    printStatis();
-    lastPrintTick = tick;
-  }
-}
-
-
-/**
- * process zipped incoming packet
- * @param data pointer to packet data
- * @param length length of packet
- * @param stateId packet's state id
- * @param ackedState state which was acked by this packet
- */
-void ConnectionMonitor::processZippedIncomingPacket( int tick, byte * data, int length )
-{
-  nZIncomingPackets++;
-  
-  // calculate bandwidth
-  incomingZippedPacketHistory[tick] = length;
-  incomingZippedBandWidth = calculateBandWidth( incomingZippedPacketHistory, tick );
-  
-  //NETPRINTF(n)("DOWNSTREAM: user: %d bandwidth %f nIncomingPackets %d\n", userId, incomingZippedBandWidth, nIncomingPackets );
-  
-}
-
-
-/**
- * check if client sent no packets for SECS_TO_TIMEOUT
- * @return true if last packet recieved \< NOW() - SECS_TO_TIMEOUT
- */
-bool ConnectionMonitor::hasTimedOut( )
-{
-  if ( lastPacketTick + SECS_TO_TIMEOUT*1000 < SDL_GetTicks() && nIncomingPackets > 0 )
-    return true;
-  
-  if ( nIncomingPackets == 0 && nOutgoingPackets >= NETWORK_FREQUENCY*SECS_TO_TIMEOUT )
-    return true;
-  
-  return false;
-}
-
-
-
-/**
- * prints bandwith usage, ping and other important things to telnet-console
- */
-void ConnectionMonitor::printStatis( )
-{
-  NETPRINT(n)("============NETWORKSTATS FOR USER %d============\n", userId);
-  NETPRINT(n)("PING = %d\n", ping );
-  NETPRINT(n)("BANDWIDTH: UP: %f (%f) DOWN %f (%f)\n", outgoingZippedBandWidth, outgoingUnzippedBandWidth, incomingZippedBandWidth, incomingUnzippedBandWidth);
-  NETPRINT(n)("PACKETS: RECIEVED %d; SENT %d\n", nIncomingPackets, nOutgoingPackets );
-  NETPRINT(n)("================================================\n");
-}
-
-
Index: branches/proxy/src/lib/network/connection_monitor.h
===================================================================
--- branches/proxy/src/lib/network/connection_monitor.h	(revision 9346)
+++ 	(revision )
@@ -1,71 +1,0 @@
-/*!
- * @file connection_monitor.h
-    \brief provides information about the quality of a connection.
- */
-
-#ifndef _CONNECTION_MONITOR_H
-#define _CONNECTION_MONITOR_H
-
-#include "base_object.h"
-#include "netdefs.h"
-
-#include <map>
-#include <list>
-
-#define N_PACKETS_FOR_PING 20
-#define MSECS_TO_CALC_BWIDTH 1000
-#define SECS_TO_TIMEOUT 30
-
-class ConnectionMonitor : virtual public BaseObject
-{
-  public:
-    ConnectionMonitor( int userId );
-    virtual ~ConnectionMonitor();
-
-    void processUnzippedOutgoingPacket( int tick, byte * data, int length, int stateId );
-    void processUnzippedIncomingPacket( int tick, byte * data, int length, int stateId, int ackedState );
-
-    void processZippedOutgoingPacket( int tick, byte * data, int length, int stateId );
-    void processZippedIncomingPacket( int tick, byte * data, int length );
-
-    void calculatePing();
-
-    bool hasTimedOut();
-
-    void printStatis();
-
-  private:
-    float calculateBandWidth( std::map<int,int> & packetHistory, int tick );
-    void removeOldPackets( std::map<int,int> & packetHistory, int tick );
-
-    int userId;       //!< user's id
-
-    std::map<int,int>   sentStateTicks;
-
-    std::map<int,int>   incomingUnzippedPacketHistory;
-    std::map<int,int>   outgoingUnzippedPacketHistory;
-
-    std::map<int,int>   incomingZippedPacketHistory;
-    std::map<int,int>   outgoingZippedPacketHistory;
-
-    std::list<int>      ackDelay;
-    int                 ping;
-
-    float               incomingUnzippedBandWidth;
-    float               outgoingUnzippedBandWidth;
-
-    float               incomingZippedBandWidth;
-    float               outgoingZippedBandWidth;
-
-    int                 nIncomingPackets;
-    int                 nOutgoingPackets;
-
-    int                 nZIncomingPackets;
-    int                 nZOutgoingPackets;
-
-    int                 lastPacketTick;
-
-    int                 lastPrintTick;
-  };
-
-#endif
Index: branches/proxy/src/lib/network/handshake.cc
===================================================================
--- branches/proxy/src/lib/network/handshake.cc	(revision 9346)
+++ branches/proxy/src/lib/network/handshake.cc	(revision 9347)
@@ -10,12 +10,9 @@
 
 ### File Specific:
-   main-programmer: christoph
-   co-programmer:
+   main-programmer: Christoph Renner (rennerc@ee.ethz.ch)
+   co-programmer: Patirck Boenzli (boenzlip@orxonox.ethz.ch)
 */
 
 
-/* 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
 
@@ -25,5 +22,9 @@
 #include "debug.h"
 
-Handshake::Handshake( bool server, int clientId, int networkGameManagerId, int messageManagerId )
+
+
+
+
+ Handshake::Handshake( int nodeType, int clientId, int networkGameManagerId, int messageManagerId )
   : Synchronizeable()
 {
@@ -31,6 +32,5 @@
   this->setClassID(CL_HANDSHAKE, "Handshake");
 
-  this->setIsServer(server);
-
+  // register all variable handlers
   orxId_handler = registerVarId( new SynchronizeableInt( &localState.orxId, &remoteState.orxId, "orxonoxId", PERMISSION_ALL ) );
   version_handler = registerVarId( new SynchronizeableInt( &localState.version, &remoteState.version, "version", PERMISSION_ALL ) );
@@ -42,8 +42,14 @@
   errorString_handler = registerVarId( new SynchronizeableString( &localState.errorString, &remoteState.errorString, "errorString", PERMISSION_ALL ) );
 
+  this->nodeTypeHandler = registerVarId( new SynchronizeableInt( &localState.nodeType, &remoteState.nodeType, "nodeType", PERMISSION_ALL ) );
+
   candel_id = registerVarId( new SynchronizeableInt( &localState.canDel, &remoteState.canDel, "canDel", PERMISSION_ALL ) );
-  
+
   registerVar( new SynchronizeableString( &localState.preferedNickName, &remoteState.preferedNickName, "preferedNickName", PERMISSION_ALL ) );
+  // now synchronize only two of the available proxy server addresses
+  registerVar( new SynchronizeableIP( &localState.proxy1, &remoteState.proxy1, "proxy server 1", PERMISSION_ALL ) );
+  registerVar( new SynchronizeableIP( &localState.proxy2, &remoteState.proxy1, "proxy server 2", PERMISSION_ALL ) );
 
+  // init the local state
   localState.completed = 0;
   localState.error = 0;
@@ -54,6 +60,12 @@
   localState.orxId = _ORXONOX_ID;
   localState.version = _ORXONOX_VERSION;
+  localState.nodeType = nodeType;
   localState.canDel = 0;
+  localState.redirectProxy = 0;
+  localState.proxy1 = IP(0, 0);
+  localState.proxy2 = IP (0, 0);
 
+
+  // init the remote state
   remoteState.completed = 0;
   remoteState.error = 0;
@@ -64,9 +76,15 @@
   remoteState.orxId = 0;
   remoteState.version = 0;
+  remoteState.nodeType = NET_CLIENT;
   remoteState.canDel = 0;
+  remoteState.redirectProxy = 0;
+  remoteState.proxy1 = IP(0, 0);
+  remoteState.proxy2 = IP(0, 0);
 
+  // activate the synchronization process
   this->setSynchronized(true);
   PRINTF(0)("Handshake created clientId = %d\n", clientId);
 }
+
 
 /**
@@ -78,5 +96,6 @@
   for ( std::list<int>::iterator it = id.begin(); it != id.end(); it++ )
   {
-    if ( *it == orxId_handler )
+    // orxonox id handler
+    if ( *it == this->orxId_handler )
     {
       if ( remoteState.orxId != _ORXONOX_ID )
@@ -87,8 +106,8 @@
         continue;
       }
-
     }
 
-    if ( *it == version_handler )
+    // orxonox version handler
+    if ( *it == this->version_handler )
     {
       if ( remoteState.version != _ORXONOX_VERSION )
@@ -99,7 +118,24 @@
         continue;
       }
-
     }
 
+    // node type handler: for each node type there is a specific action to be taken
+    if ( *it == this->nodeTypeHandler)
+    {
+      if ( remoteState.nodeType == NET_MASTER_SERVER )
+      {
+        continue;
+      }
+      else if( remoteState.nodeType == NET_PROXY_SERVER_ACTIVE)
+      {
+        continue;
+      }
+      else if( remoteState.nodeType == NET_CLIENT)
+      {
+        continue;
+      }
+    }
+
+    // cancel
     if ( *it == candel_id )
     {
@@ -109,9 +145,10 @@
   }
 
-  if (
-      remoteState.orxId == _ORXONOX_ID &&
-      remoteState.version == _ORXONOX_VERSION
-     )
+  // handshake completed
+  if ( remoteState.orxId == _ORXONOX_ID &&
+       remoteState.version == _ORXONOX_VERSION )
+  {
     localState.completed = 1;
+  }
 }
 
Index: branches/proxy/src/lib/network/handshake.h
===================================================================
--- branches/proxy/src/lib/network/handshake.h	(revision 9346)
+++ branches/proxy/src/lib/network/handshake.h	(revision 9347)
@@ -1,5 +1,9 @@
 /*!
  * @file network_stream.h
- *  implementation of a network pipe
+ *  implementation of a network pipe. This node handles the handshake of two network nodes and exchanges informationas
+ * vial to the connection setup.
+ *
+ * the local node only writes in the localState variable. the remoteState variable will be written from the remote network node
+ * so don't write into it!
  */
 
@@ -8,61 +12,107 @@
 
 #include "base_object.h"
+#include "ip.h"
 #include "synchronizeable.h"
 
-#define _ORXONOX_ID 0xF91337A0
+//!< a struct to save the handshakes to
+struct HandshakeState
+{
+  int           orxId;                         //!< orxonox id
+  int           version;                       //!< network protocol version
 
-#define _ORXONOX_VERSION 1
+  int           networkManagerId;              //!< unique id of the network manager
+  int           messageManagerId;              //!< unique id of the message manager
+  int           hostId;                        //!< host id
+  int           nodeType;                      //!< type of the network node
 
-struct HandshakeState {
-  int orxId;
-  int version;
-  
-  int networkManagerId;
-  int messageManagerId;
-  int hostId;
-  
-  int completed;
-  int canDel;
-  
-  int error;
-  
-  std::string errorString;
-  
+  int           completed;                     //!< true if completed
+  int           canDel;                        //!< true if marked for deletion
+
+  int           error;                         //!< error number
+
+  std::string   errorString;                   //!< error string
+
   //additional data
-  std::string preferedNickName;
+  std::string   preferedNickName;              //!< prefered nick name
+
+  int           redirectProxy;                 //!< true if the client should reconnect to a proxy server (either 1 or 2 )
+  IP            proxy1;                        //!< ip address of the first proxy (0.0.0.0 of not available)
+  IP            proxy2;                        //!< ip address of the second proxy (0.0.0.0 of not available)
 };
 
+
+//!< the handshake itself with some interface functions
 class Handshake : public Synchronizeable
 {
+
   public:
-    Handshake( bool server, int clientId = 0, int networkGameManagerId = 0, int messageManagerId = 0 );
-    inline bool       completed(){ return localState.completed != 0 && remoteState.completed != 0; }
-    inline bool       ok(){ return localState.error == 0 && remoteState.error == 0; }
-    inline int        getHostId(){ return remoteState.hostId; }
-    inline int        getNetworkGameManagerId(){ return remoteState.networkManagerId; }
-    inline int        getMessageManagerId(){ return remoteState.messageManagerId; }
-    inline void       doReject( std::string reason ){ localState.error = 1; localState.errorString = "the server rejected your connection ["+ reason +"]"; }
-    inline bool       canDel(){ return localState.canDel == 1 && remoteState.canDel == 1; }
-    inline bool       allowDel(){ return localState.canDel == 1; }
-    inline void       del(){ localState.canDel = 1; }
-    
-    inline void       setPreferedNickName( const std::string & nick ){ localState.preferedNickName = nick; }
+    Handshake( int nodeType, int clientId = 0, int networkGameManagerId = 0, int messageManagerId = 0 );
+
+
+    /* functions indicating states of the handshake */
+    /** @returns true if the handshake is completed */
+    inline bool completed(){ return localState.completed != 0 && remoteState.completed != 0; }
+    /** @returns true if no error has occured until now */
+    inline bool ok(){ return localState.error == 0 && remoteState.error == 0; }
+    /** stops the handshake and reject the other side with @param reason: string describing the reason */
+    inline void doReject( std::string reason ){ localState.error = 1; localState.errorString = "the server rejected your connection ["+ reason +"]"; }
+    /** @returns true if the handshake is finished and the instances can be deleted */
+    inline bool canDel(){ return localState.canDel == 1 && remoteState.canDel == 1; }
+    /** @returns true if the local state can be removed*/
+    inline bool allowDel(){ return localState.canDel == 1; }
+    /** marks the handshake to be deleted */
+    inline void del(){ localState.canDel = 1; }
+
+
+    /* the actual informations exchanged in the handshake */
+    /** @returns the host id of the remote host */
+    inline int  getHostId(){ return remoteState.hostId; }
+    /** @returns the unique id of the network game manager*/
+    inline int  getNetworkGameManagerId(){ return remoteState.networkManagerId; }
+    /** @returns the unique id of the message manager */
+    inline int  getMessageManagerId(){ return remoteState.messageManagerId; }
+    /** @returns the node type of the remote host */
+    inline int getRemoteNodeType() { return this->remoteState.nodeType; }
+
+    /** sets @param nick the prefereded nick name */
+    inline void setPreferedNickName( const std::string & nick ){ localState.preferedNickName = nick; }
+    /** @returns the prefered nick name */
     inline std::string getPreferedNickName(){ return remoteState.preferedNickName; }
-    
+
+    /** @returns if true the local client should reconnect to a proxy server from the proxy server list */
+    inline bool redirect() { return this->remoteState.redirectProxy;}
+    /** @param flag: indicating if the client should be redirected */
+    inline void setRedirect(bool flag) { this->localState.redirectProxy = flag; }
+
+    /** @param address: the address of the proxy server 1 if any */
+    inline void setProxy1Address(IP address) { this->localState.proxy1 = address; }
+    /** @returns the address of the proxy server 1 if any */
+    inline IP getProxy1Address() { return this->remoteState.proxy1; }
+    /** @param address: the address of the proxy server 2 if any */
+    inline void setProxy2Address(IP address) { this->localState.proxy2 = address; }
+    /** @returns the address of the proxy server 2 if any */
+    inline IP getProxy2Address() { return this->remoteState.proxy2; }
+
+
+    /* variable handler function */
     virtual void varChangeHandler( std::list<int> & id );
 
+
   private:
-    HandshakeState localState;
-    HandshakeState remoteState;
-    
-    int netManId_handler;
-    int msgManId_handler;
-    int hostId_handler;
-    int completed_handler;
-    int error_handler;
-    int errorString_handler;
-    int orxId_handler;
-    int version_handler;
-    int candel_id;
+    HandshakeState     localState;                            //!< the local handshake state
+    HandshakeState     remoteState;                           //!< the remote handshake state
+
+    int                orxId_handler;                         //!< orxonox id handler
+    int                version_handler;                       //!< orxonox version id handler
+    int                netManId_handler;                      //!< network manager handler
+    int                msgManId_handler;                      //!< message manager handler
+    int                hostId_handler;                        //!< host id handler
+    int                nodeTypeHandler;                       //!< node type handler
+
+    int                completed_handler;                     //!< handshake completion handler
+    int                error_handler;                         //!< handshake error handler
+    int                errorString_handler;                   //!< handshake error string handler
+    int                candel_id;                             //!< handshake deletion handler
+    int                nodeType;                              //!, the type of the network node
 
 };
Index: branches/proxy/src/lib/network/ip.cc
===================================================================
--- branches/proxy/src/lib/network/ip.cc	(revision 9347)
+++ branches/proxy/src/lib/network/ip.cc	(revision 9347)
@@ -0,0 +1,276 @@
+/**
+ * @file ip.cc
+ * @brief A IP class, that handles IP names and resolution.
+ *
+ * code taken from audiere.
+ *
+ *
+   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 Grauer
+ * co-programmer: Patrick Boenzli
+ */
+
+#include "ip.h"
+
+#include <iostream>
+
+#include "multi_type.h"
+#include "substring.h"
+
+/**
+ * @brief default constructor
+ */
+IP::IP()
+{
+  this->_ip = 0;
+  this->_port = IP::_defaultPort;
+}
+
+
+/**
+ * @brief constructor from ip and port
+ * @param ip the IP
+ * @param port the Port
+ * @return self
+ */
+IP::IP(int ip, int port)
+{
+  this->_ip = ip;
+  if (port != -1)
+    this->_port = port;
+  else
+    this->_port = IP::_defaultPort;
+}
+
+
+/**
+ * @brief constructor from a String
+ * @param ip the IP as a String.
+ * @param resolve if true, the IP is resolved via DNS,
+ * @return self
+ */
+IP::IP(const std::string& ip, bool resolve)
+{
+  *this = IP::stringToIP(ip, IP::_defaultPort, resolve);
+}
+
+/**
+ * @brief constructor from a String
+ * @param ip the IP as a String.
+ * @param port The port to be resolved.
+ * @param resolve if true, the IP is resolved via DNS,
+ * @return self
+ */
+IP::IP(const std::string& ip, int port, bool resolve)
+{
+  *this = IP::stringToIP(ip, port, resolve);
+}
+
+
+/**
+ * @brief constructor from an SDL net structure IPaddress
+ * @param ip the ip.
+ * @return self
+ */
+IP::IP(const IPaddress& ip)
+{
+  this->_ip = ip.host;
+  this->_port = ip.port;
+}
+
+
+/**
+ * @brief copy constructor.
+ * @param ip the IP to copy.
+ * @return self
+ */
+IP::IP(const IP& ip)
+{
+  *this = ip;
+}
+
+/**
+ * @brief copy operator
+ * @param ip the IP to copy.
+ * @return self.
+ */
+const IP& IP::operator=(const IP& ip)
+{
+  this->_ip = ip.host();
+  this->_port = ip.port();
+  return *this;
+}
+
+
+/**
+ * @brief copy operator
+ * @param ip the IP to copy.
+ * @return self.
+ */
+const IP& IP::operator=(const IPaddress& ip)
+{
+  this->_ip = ip.host;
+  this->_port = ip.port;
+  return *this;
+}
+
+
+/**
+ * @brief comparison operator
+ * @param ip the IP to compare
+ * @return true if ip _and_ port match.
+ */
+bool IP::operator==(const IP& ip)
+{
+  return (this->_ip == ip.host() &&
+          this->_port == ip.port());
+}
+
+
+/**
+ * @brief comparison operator
+ * @param ip the IP to compare
+ * @return true if ip _and_ port do not match.
+ */
+bool IP::operator!=(const IP& ip)
+{
+  return (this->_ip != ip.host() ||
+      this->_port != ip.port());
+}
+
+
+/**
+ * @brief converts a String into an IP Object.
+ * @param ip The string holding an IP.
+ * @param port The port to be resolved.
+ * @param resolve if true, the IP is resolved via DNS,
+ * otherwise (resolve == false) the IP is being transformed
+ * from a String (xxx.xxx.xxx.xxx) to an integer.
+ *
+ * @return A newly constructed IP.
+ */
+IP IP::stringToIP(const std::string& ip, int port, bool resolve)
+{
+  if (resolve)
+  {
+    IPaddress ipaddr;
+
+    SDLNet_ResolveHost(&ipaddr, NULL, 2000);
+
+    return IP(ipaddr.host, port);
+  }
+  else
+  {
+    SubString ipaddr(ip, '.');
+    if(ip.size() != 4 )
+      return IP();
+
+    MultiType part0(ipaddr[0]);
+    MultiType part1(ipaddr[1]);
+    MultiType part2(ipaddr[2]);
+    MultiType part3(ipaddr[3]);
+
+    int addr = (part0.getInt() << 24) +
+               (part1.getInt() << 16) +
+               (part2.getInt() <<  8) +
+               part3.getInt();
+    return IP(addr, port);
+  }
+}
+
+
+/**
+ * @brief if you want to have a specific part of an IP
+ * @param part the n'th part of the IP addr (splitted by '.').
+ * @return the amount held in the designated part.
+ */
+int IP::ipPart(unsigned int part) const
+{
+  switch (part)
+  {
+    case 0:
+      return  (_ip & 0xFF000000) >> 24;
+    case 1:
+      return  (_ip & 0x00FF0000) >> 16;
+    case 2:
+      return  (_ip & 0x0000FF00) >> 8;
+    case 3:
+      return  (_ip & 0x000000FF);
+    default:
+      return -1;
+  }
+}
+
+
+/**
+ * @return the Ip as a string.
+ */
+std::string IP::ipString() const
+{
+  return IP::ipToString(this->_ip, this->_port);
+}
+
+
+/**
+ * @brief converts an IPaddress struct into a String.
+ * @param ipaddr the IP address as a SDL_net struct.
+ * @return the string retrieved from the IP.
+ */
+std::string IP::ipToString(const IPaddress& ipaddr)
+{
+  int ip = SDLNet_Read32 (ipaddr.host);
+  return IP::ipToString(ip, ipaddr.port);
+}
+
+
+/**
+ * @brief converts a IP into a String (without port).
+ * @param ip the IP to put into the string.
+ * @param port -1 if not wanted
+ * @return the string of the ip.
+ */
+std::string IP::ipToString(int ip, int port)
+{
+  MultiType part0((int) (ip & 0xFF000000) >> 24);
+  MultiType part1((int) (ip & 0x00FF0000) >> 16);
+  MultiType part2((int) (ip & 0x0000FF00) >>  8);
+  MultiType part3((int) (ip & 0x000000FF) );
+
+  std::string addr = part3.getString() + "." + part2.getString() + "." +
+                     part1.getString() + "." + part0.getString();
+
+  if (port != -1)
+    addr += ":" + MultiType(port).getString();
+  return addr;
+}
+
+
+/// default port definition.
+short IP::_defaultPort = 9999;
+
+/**
+ * @brief if no IP is supplied this port is used, so that IP can be resolved usefully.
+ * @param defaultPort The default port.
+ */
+void IP::setDefaultPort(short defaultPort)
+{
+  IP::_defaultPort = defaultPort;
+}
+
+
+/**
+ * @brief print out the IP in a nice fashion
+ */
+void IP::debug() const
+{
+  std::cout << "IP is " << this->ipString() << std::endl;
+}
Index: branches/proxy/src/lib/network/ip.h
===================================================================
--- branches/proxy/src/lib/network/ip.h	(revision 9347)
+++ branches/proxy/src/lib/network/ip.h	(revision 9347)
@@ -0,0 +1,64 @@
+
+/*!
+ * @file ip.h
+ *
+ * @brief the ip class is used to transform strings to ip's and backwards
+ * it can also be used to
+ */
+
+#ifndef __IP_H__
+#define __IP_H__
+
+#include "netdefs.h"
+#include <string>
+
+
+
+//! A class to handle time itself
+class IP
+{
+  public:
+    /// CONSTRUCTORS
+    IP();
+    IP(int ip, int port);
+    IP(const std::string& ip, bool resolve = true);
+    IP(const std::string& ip, int port = -1, bool resolve = true);
+    IP(const IPaddress& ip);
+    IP(const IP& ip);
+
+    /// OPERATORS
+    const IP& operator=(const IP& ip);
+    const IP& operator=(const IPaddress& ip);
+    bool operator==(const IP& ip);
+    bool operator!=(const IP& up);
+
+    /// RETRIVEAL
+    /** @returns the IP */
+    int host() const { return this->_ip; };
+    /** @returns the Port */
+    short port() const { return this->_port; };
+    inline IPaddress getSDLNotation() { IPaddress sdlIP; sdlIP.host = this->_ip; sdlIP.port = this->_port; return sdlIP; }
+
+    int ipPart(unsigned int part) const;
+    std::string ipString() const;
+
+    void debug() const;
+
+  public:
+    /// SETUP
+    static IP stringToIP(const std::string& ip, int port = -1, bool resolve = true);
+
+    static std::string ipToString(const IPaddress& ipaddr);
+    static std::string ipToString(int ip, int port = -1);
+
+    static void setDefaultPort(short defaultPort);
+    static short defaultPort(short defaultPort) { return IP::_defaultPort; };
+
+  private:
+    int           _ip;           //!< The IP in int form.
+    short         _port;         //!< The Port number of the IP
+
+    static short  _defaultPort;  //!< Default Port
+};
+
+#endif /* __IP_H__ */
Index: branches/proxy/src/lib/network/message_manager.cc
===================================================================
--- branches/proxy/src/lib/network/message_manager.cc	(revision 9346)
+++ branches/proxy/src/lib/network/message_manager.cc	(revision 9347)
@@ -52,13 +52,13 @@
       }
     }
-    
+
     it->second.messages.clear();
     it->second.toAck.clear();
   }
-  
+
   messageQueue.clear();
-  
+
   this->messageHandlerMap.clear();
-  
+
   MessageManager::singletonRef = NULL;
 }
@@ -82,9 +82,9 @@
   int i = 0;
   int n;
-  
+
   n = Converter::intToByteArray( messageQueue[userId].toAck.size(), data + i, maxLength );
   i += n;
   assert( n == INTSIZE );
-  
+
   for ( std::list<int>::iterator it = messageQueue[userId].toAck.begin(); it != messageQueue[userId].toAck.end(); it++)
   {
@@ -93,11 +93,11 @@
     assert( n == INTSIZE );
   }
-  
+
   messageQueue[userId].toAck.clear();
-  
+
   n = Converter::intToByteArray( messageQueue[userId].messages.size(), data + i, maxLength );
   i += n;
   assert( n == INTSIZE );
-  
+
   for ( std::list<NetworkMessage>::iterator it = messageQueue[userId].messages.begin(); it != messageQueue[userId].messages.end(); it++ )
   {
@@ -105,18 +105,18 @@
     i += n;
     assert( n == INTSIZE );
-    
+
     n = Converter::intToByteArray( it->number, data + i, maxLength );
     i += n;
     assert( n == INTSIZE );
-    
+
     n = Converter::intToByteArray( it->messageId, data + i, maxLength );
     i += n;
     assert( n == INTSIZE );
-    
+
     assert( i + it->length <= maxLength );
     memcpy( data + i, it->data, it->length );
     i += it->length;
   }
-  
+
   return i;
 }
@@ -136,16 +136,16 @@
   int i = 0;
   int n;
-  
+
   int nAcks;
-  
+
   assert( i + INTSIZE <= length );
   n = Converter::byteArrayToInt( data + i, &nAcks );
   assert( n == INTSIZE );
   i += n;
-  
+
   std::list<int> acks;
-  
+
   int number;
-  
+
   for ( int j = 0; j < nAcks; j++ )
   {
@@ -154,10 +154,10 @@
     assert( n == INTSIZE );
     i += n;
-    
+
     acks.push_back( number );
   }
-  
+
   int nMessages;
-  
+
   assert( i + INTSIZE <= length );
   n = Converter::byteArrayToInt( data + i, &nMessages );
@@ -166,5 +166,5 @@
 
   int messageLength, messageId;
-  
+
   for ( int j = 0; j < nMessages; j++ )
   {
@@ -173,18 +173,18 @@
     assert( n == INTSIZE );
     i += n;
-    
+
     assert( i + INTSIZE <= length );
     n = Converter::byteArrayToInt( data + i, &number );
     assert( n == INTSIZE );
     i += n;
-  
+
     assert( i + INTSIZE <= length );
     n = Converter::byteArrayToInt( data + i, &messageId );
     assert( n == INTSIZE );
     i += n;
-    
+
     if ( number > 0 )
       messageQueue[userId].toAck.push_back( number );
-    
+
     assert( i + messageLength <= length );
     assert( messageHandlerMap.find( (MessageId)messageId ) != messageHandlerMap.end() );
@@ -194,5 +194,5 @@
       {
         NetworkMessage msg;
-        
+
         msg.data = new byte[messageLength];
         memcpy( msg.data, data + i, messageLength );
@@ -200,5 +200,5 @@
         msg.messageId = (MessageId)messageId;
         msg.number = userId;
-        
+
         incomingMessageBuffer.push_back( msg );
       }
@@ -207,6 +207,6 @@
     i += messageLength;
   }
-  
-  
+
+
   //TODO maybe handle incomingMessage in tick function. else local messages will not be handled if no clients are connected
   for ( std::list<NetworkMessage>::iterator it = incomingMessageBuffer.begin(); it != incomingMessageBuffer.end();  )
@@ -223,5 +223,5 @@
     it++;
   }
-  
+
   //walk throu message queue and remove acked messages
   for ( std::list<NetworkMessage>::iterator it = messageQueue[userId].messages.begin(); it != messageQueue[userId].messages.end();  )
@@ -236,5 +236,5 @@
     it++;
   }
-  
+
   //TODO find bether way. maybe with timestamp
   if ( messageQueue[userId].recievedMessages.size() > 1000 )
@@ -255,5 +255,5 @@
   if ( messageQueue.find( userId ) == messageQueue.end() )
     return;
-    
+
   for ( std::list<NetworkMessage>::iterator it = messageQueue[userId].messages.begin(); it != messageQueue[userId].messages.end(); it++ )
   {
@@ -262,7 +262,7 @@
     it->data = NULL;
   }
-  
+
   messageQueue[userId].toAck.clear();
-  
+
   messageQueue.erase( userId );
 }
@@ -270,5 +270,5 @@
 /**
  * registers function to handle messages with id messageId. someData is passed to callbackfuntion
- * @param messageId message id to handle 
+ * @param messageId message id to handle
  * @param cb function pointer to callback function
  * @param someData this pointer is passed to callback function without modification
@@ -278,11 +278,11 @@
 {
   MessageHandler messageHandler;
-  
+
   messageHandler.cb = cb;
   messageHandler.messageId = messageId;
   messageHandler.someData = someData;
-  
+
   messageHandlerMap[messageId] = messageHandler;
-  
+
   return true;
 }
@@ -309,6 +309,6 @@
  * @param data pointer to data
  * @param dataLength length of data
- * @param recieverType 
- * @param reciever 
+ * @param recieverType
+ * @param reciever
  */
 void MessageManager::sendMessage( MessageId messageId, byte * data, int dataLength, RecieverType recieverType, int reciever, MessagePriority messagePriority )
@@ -316,10 +316,10 @@
   for ( MessageQueue::iterator it = messageQueue.begin(); it != messageQueue.end(); it++ )
   {
-    if ( 
+    if (
          recieverType == RT_ALL_ME ||
          recieverType == RT_ALL_NOT_ME ||
          recieverType == RT_USER && it->first == reciever ||
          recieverType == RT_NOT_USER && it->first != reciever ||
-         recieverType == RT_SERVER && getNetworkStream()->isUserServer( it->first )
+         recieverType == RT_SERVER && getNetworkStream()->isUserMasterServer( it->first )
        )
     {
@@ -336,5 +336,5 @@
     }
   }
-  
+
   if ( recieverType == RT_ALL_ME )
   {
Index: branches/proxy/src/lib/network/monitor/connection_monitor.cc
===================================================================
--- branches/proxy/src/lib/network/monitor/connection_monitor.cc	(revision 9347)
+++ branches/proxy/src/lib/network/monitor/connection_monitor.cc	(revision 9347)
@@ -0,0 +1,257 @@
+/*
+   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 Renner
+   co-programmer: ...
+*/
+
+#include "connection_monitor.h"
+#include "network_log.h"
+
+#include <debug.h>
+#include <SDL/SDL.h>
+#include <string.h>
+
+/* using namespace std is default, this needs to be here */
+using namespace std;
+
+/**
+ * constructor
+ * @param userId user's id
+ */
+ConnectionMonitor::ConnectionMonitor( int userId )
+{
+  /* set the class id for the base object and add ist to class list*/
+  this->setClassID(CL_CONNECTION_MONITOR, "ConnectionMonitor");
+  
+  this->userId = userId;
+  this->ping = 0;
+  this->incomingUnzippedBandWidth = 0;
+  this->outgoingUnzippedBandWidth = 0;
+  this->incomingZippedBandWidth = 0;
+  this->outgoingZippedBandWidth = 0;
+  this->nIncomingPackets = 0;
+  this->nOutgoingPackets = 0;
+  this->nZIncomingPackets = 0;
+  this->nZOutgoingPackets = 0;
+  
+  this->lastPacketTick = 0;
+  this->lastPrintTick = 0;
+}
+
+/**
+ * deconstructor
+ */
+ConnectionMonitor::~ConnectionMonitor( )
+{
+}
+
+/**
+ * process unzipped outgoing packet
+ * @param data pointer to packet data
+ * @param length length of packet
+ * @param stateId packet's state id
+ */
+void ConnectionMonitor::processUnzippedOutgoingPacket( int tick, byte * data, int length, int stateId )
+{
+  nOutgoingPackets++;
+  
+  // for ping calculation
+  sentStateTicks[stateId] = tick;
+  
+  // calculate bandwidth
+  outgoingUnzippedPacketHistory[tick] = length;
+  outgoingUnzippedBandWidth = calculateBandWidth( outgoingUnzippedPacketHistory, tick );
+  
+  //NETPRINTF(n)("UNZIPPED UPSTREAM: user: %d bandwidth %f\n", userId, outgoingUnzippedBandWidth );
+  
+  // count zero bytes
+  //int nZeroBytes = 0;
+  
+  //for ( int i = 0; i < length; i++ )
+  //  if ( data[i] == '\0' )
+  //    nZeroBytes++;
+  
+  //NETPRINTF(n)( "ZEROBYTES: %d (%f%%)\n", nZeroBytes, ((float)100)*nZeroBytes/length );
+}
+
+/**
+ * process unzipped incoming packet
+ * @param data pointer to packet data
+ * @param length length of packet
+ * @param stateId packet's state id
+ * @param ackedState state which was acked by this packet
+ */
+void ConnectionMonitor::processUnzippedIncomingPacket( int tick, byte * data, int length, int stateId, int ackedState )
+{
+  nIncomingPackets++;
+  
+  lastPacketTick = tick;
+  
+  // calculate ping
+  if ( sentStateTicks.find( ackedState ) != sentStateTicks.end() )
+  {
+    ackDelay.push_back( tick - sentStateTicks[ackedState] );
+  }
+  
+  while ( sentStateTicks.begin() != sentStateTicks.end() && sentStateTicks.begin()->first <= ackedState )
+    sentStateTicks.erase( sentStateTicks.begin() );
+      
+  while ( ackDelay.size() > N_PACKETS_FOR_PING )
+    ackDelay.erase( ackDelay.begin() );
+      
+  ping = 0;
+      
+  for ( std::list<int>::iterator it = ackDelay.begin(); it != ackDelay.end(); it++ )
+    ping += *it;
+      
+  if ( ackDelay.size() == 0 )
+    ping = -1;
+  else
+    ping /= ackDelay.size();
+      
+  //NETPRINTF(n)("PING: user: %d ping: %d\n", userId, ping );
+  
+  // calculate bandwidth
+  incomingUnzippedPacketHistory[tick] = length;
+  incomingUnzippedBandWidth = calculateBandWidth( incomingUnzippedPacketHistory, tick );
+  
+  //NETPRINTF(n)("UNZIPPED DOWNSTREAM: user: %d bandwidth %f\n", userId, incomingUnzippedBandWidth );
+  
+}
+
+/**
+ * remove old packets
+ * @param packetHistory 
+ * @param tick 
+ */
+void ConnectionMonitor::removeOldPackets( std::map< int, int > & packetHistory, int tick )
+{
+  while ( packetHistory.begin()->first < tick - MSECS_TO_CALC_BWIDTH )
+    packetHistory.erase( packetHistory.begin() );
+}
+
+/**
+ * calculate bandwidth out of packethistory
+ * @param packetHistory packet history
+ * @param tick current tick from SDL_GetTicks
+ * @return bandwidth in bytes/sec
+ */
+float ConnectionMonitor::calculateBandWidth( std::map< int, int > & packetHistory, int tick )
+{
+  removeOldPackets( packetHistory, tick );
+  
+  float res = 0.0f;
+#if 0
+  for ( std::map<int,int>::iterator it = packetHistory.begin(); it != packetHistory.end(); it++ )
+  {
+    if ( it != packetHistory.begin() )
+      res += it->second;
+  }
+  
+  if ( packetHistory.size() <= 1 || tick - packetHistory.begin()->first == 0 )
+    res = 0.0f;
+  else
+    res /= (float)(tick - packetHistory.begin()->first);
+  
+  res *= 1000.0f;
+#endif
+
+  for ( std::map<int,int>::iterator it = packetHistory.begin(); it != packetHistory.end(); it++ )
+  {
+    res += it->second;
+  }
+  
+  if ( packetHistory.size() <= 1 )
+    res = 0.0f;
+  else
+    res /= (float)(tick - packetHistory.begin()->first);
+  
+  res *= 1000.0f;
+
+  return res;
+}
+
+
+/**
+ * process zipped outgoing packet
+ * @param data pointer to packet data
+ * @param length length of packet
+ * @param stateId packet's state id
+ */
+void ConnectionMonitor::processZippedOutgoingPacket( int tick, byte * data, int length, int stateId )
+{
+  nZOutgoingPackets++;
+  
+  // calculate bandwidth
+  outgoingZippedPacketHistory[tick] = length;
+  outgoingZippedBandWidth = calculateBandWidth( outgoingZippedPacketHistory, tick );
+  
+  //NETPRINTF(n)("UPSTREAM: user: %d bandwidth %f nOutgoingPackets %d\n", userId, outgoingZippedBandWidth, nOutgoingPackets );
+
+  if ( lastPrintTick < tick-1000 )
+  {
+    printStatis();
+    lastPrintTick = tick;
+  }
+}
+
+
+/**
+ * process zipped incoming packet
+ * @param data pointer to packet data
+ * @param length length of packet
+ * @param stateId packet's state id
+ * @param ackedState state which was acked by this packet
+ */
+void ConnectionMonitor::processZippedIncomingPacket( int tick, byte * data, int length )
+{
+  nZIncomingPackets++;
+  
+  // calculate bandwidth
+  incomingZippedPacketHistory[tick] = length;
+  incomingZippedBandWidth = calculateBandWidth( incomingZippedPacketHistory, tick );
+  
+  //NETPRINTF(n)("DOWNSTREAM: user: %d bandwidth %f nIncomingPackets %d\n", userId, incomingZippedBandWidth, nIncomingPackets );
+  
+}
+
+
+/**
+ * check if client sent no packets for SECS_TO_TIMEOUT
+ * @return true if last packet recieved \< NOW() - SECS_TO_TIMEOUT
+ */
+bool ConnectionMonitor::hasTimedOut( )
+{
+  if ( lastPacketTick + SECS_TO_TIMEOUT*1000 < SDL_GetTicks() && nIncomingPackets > 0 )
+    return true;
+  
+  if ( nIncomingPackets == 0 && nOutgoingPackets >= NETWORK_FREQUENCY*SECS_TO_TIMEOUT )
+    return true;
+  
+  return false;
+}
+
+
+
+/**
+ * prints bandwith usage, ping and other important things to telnet-console
+ */
+void ConnectionMonitor::printStatis( )
+{
+  NETPRINT(n)("============NETWORKSTATS FOR USER %d============\n", userId);
+  NETPRINT(n)("PING = %d\n", ping );
+  NETPRINT(n)("BANDWIDTH: UP: %f (%f) DOWN %f (%f)\n", outgoingZippedBandWidth, outgoingUnzippedBandWidth, incomingZippedBandWidth, incomingUnzippedBandWidth);
+  NETPRINT(n)("PACKETS: RECIEVED %d; SENT %d\n", nIncomingPackets, nOutgoingPackets );
+  NETPRINT(n)("================================================\n");
+}
+
+
Index: branches/proxy/src/lib/network/monitor/connection_monitor.h
===================================================================
--- branches/proxy/src/lib/network/monitor/connection_monitor.h	(revision 9347)
+++ branches/proxy/src/lib/network/monitor/connection_monitor.h	(revision 9347)
@@ -0,0 +1,71 @@
+/*!
+ * @file connection_monitor.h
+    \brief provides information about the quality of a connection.
+ */
+
+#ifndef _CONNECTION_MONITOR_H
+#define _CONNECTION_MONITOR_H
+
+#include "base_object.h"
+#include "netdefs.h"
+
+#include <map>
+#include <list>
+
+#define N_PACKETS_FOR_PING 20
+#define MSECS_TO_CALC_BWIDTH 1000
+#define SECS_TO_TIMEOUT 30
+
+class ConnectionMonitor : virtual public BaseObject
+{
+  public:
+    ConnectionMonitor( int userId );
+    virtual ~ConnectionMonitor();
+
+    void processUnzippedOutgoingPacket( int tick, byte * data, int length, int stateId );
+    void processUnzippedIncomingPacket( int tick, byte * data, int length, int stateId, int ackedState );
+
+    void processZippedOutgoingPacket( int tick, byte * data, int length, int stateId );
+    void processZippedIncomingPacket( int tick, byte * data, int length );
+
+    void calculatePing();
+
+    bool hasTimedOut();
+
+    void printStatis();
+
+  private:
+    float calculateBandWidth( std::map<int,int> & packetHistory, int tick );
+    void removeOldPackets( std::map<int,int> & packetHistory, int tick );
+
+    int userId;       //!< user's id
+
+    std::map<int,int>   sentStateTicks;
+
+    std::map<int,int>   incomingUnzippedPacketHistory;
+    std::map<int,int>   outgoingUnzippedPacketHistory;
+
+    std::map<int,int>   incomingZippedPacketHistory;
+    std::map<int,int>   outgoingZippedPacketHistory;
+
+    std::list<int>      ackDelay;
+    int                 ping;
+
+    float               incomingUnzippedBandWidth;
+    float               outgoingUnzippedBandWidth;
+
+    float               incomingZippedBandWidth;
+    float               outgoingZippedBandWidth;
+
+    int                 nIncomingPackets;
+    int                 nOutgoingPackets;
+
+    int                 nZIncomingPackets;
+    int                 nZOutgoingPackets;
+
+    int                 lastPacketTick;
+
+    int                 lastPrintTick;
+  };
+
+#endif
Index: branches/proxy/src/lib/network/monitor/network_monitor.cc
===================================================================
--- branches/proxy/src/lib/network/monitor/network_monitor.cc	(revision 9347)
+++ branches/proxy/src/lib/network/monitor/network_monitor.cc	(revision 9347)
@@ -0,0 +1,269 @@
+/*
+   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
+*/
+
+#include "glgui.h"
+#include "shell_command.h"
+
+#include "network_stream.h"
+#include "debug.h"
+
+#include "proxy/proxy_settings.h"
+#include "shared_network_data.h"
+
+#include "network_monitor.h"
+#include "network_node.h"
+#include "peer_info.h"
+#include "network_stream.h"
+#include "netdefs.h"
+
+#include <vector>
+
+
+SHELL_COMMAND(showGUI, NetworkMonitor, showGUI);
+SHELL_COMMAND(hideGUI, NetworkMonitor, hideGUI);
+// SHELL_COMMAND(output, MappedWater, saveParams);
+
+
+
+/**
+ * starts a network monitor
+ */
+NetworkMonitor::NetworkMonitor(NetworkStream* networkStream)
+  : Synchronizeable()
+{
+  this->setClassID(CL_NETWORK_MONITOR, "NetworkMonitor");
+
+  this->networkStream = networkStream;
+  this->playerNumber = 0;
+  // create the localnode, init it and add it to the nodes list
+  this->localNode = new NetworkNode( this->networkStream->getPeerInfo());
+  this->addNode(this->localNode);
+
+  this->setSynchronized(false);
+
+  // read in the proxy server list, this is only the case for the master server
+  if( SharedNetworkData::getInstance()->isMasterServer())
+  {
+    // assuming that the config files are already read we get the proxy servers
+    std::vector<IPaddress*>* proxyList = ProxySettings::getInstance()->getProxyList();
+    std::vector<IPaddress*>::iterator it = proxyList->begin();
+    // create a peer info class and a network node class for each new proxy and add them to the passive list
+    for(; it < proxyList->end(); it++)
+    {
+      PeerInfo* peer = new PeerInfo();
+      peer->ip = *(*it);
+      peer->nodeType = NET_PROXY_SERVER_ACTIVE;
+      peer->userId = -1;
+
+      NetworkNode* node = new NetworkNode(peer);
+      this->addNode( node);
+      this->addActiveProxyServer( this->localNode, peer);
+    }
+  }
+}
+
+
+/**
+ * deconstructor
+ */
+NetworkMonitor::~NetworkMonitor()
+{
+  if( this->localNode)
+    delete this->localNode;
+}
+
+
+/**
+ * add the network node
+ * @param node to add
+ */
+void NetworkMonitor::addNetworkNode(NetworkNode* node)
+{
+  this->nodeList.push_back(node);
+}
+
+
+/**
+ * add the network node
+ * @param node to add
+ */
+void NetworkMonitor::removeNetworkNode(NetworkNode* node)
+{
+  std::list<NetworkNode*>::iterator it = this->nodeList.begin();
+  for(; it != this->nodeList.end(); it++)
+  {
+    if( *it == node)
+    {
+      this->nodeList.erase(it);
+      this->playerNumber--;
+      return;
+    }
+  }
+}
+
+/**
+ * tihs adds the new network node
+ * @param ip ip of the new node
+ */
+void NetworkMonitor::addNode(IP ip, int nodeType)
+{
+  PeerInfo* pInfo = new PeerInfo();
+  pInfo->nodeType = nodeType;
+  pInfo->ip = ip;
+
+  this->addNode( pInfo);
+}
+
+
+/**
+ * adds a network node to the local node
+ *  @param pInfo node information
+ */
+void NetworkMonitor::addNode(PeerInfo* pInfo)
+{
+  if( this->localNode == NULL)
+    return;
+
+  if( pInfo->isClient())
+    this->localNode->addClient(pInfo);
+  else if( pInfo->isProxyServer())
+  {
+    this->localNode->addActiveProxyServer(pInfo);
+    // create a new node, since a proxy can connect clients again
+    NetworkNode* node = new NetworkNode(pInfo);
+    this->nodeList.push_back(node);
+  }
+  else if( pInfo->isMasterServer())
+  {
+    this->localNode->addMasterServer(pInfo);
+  }
+}
+
+
+/**
+ * adds a network node to the local node
+ *  @param node node to add to
+ *  @param pInfo node information
+ */
+void NetworkMonitor::addNode(NetworkNode* node, PeerInfo* pInfo)
+{
+  if( node == NULL)
+    return;
+
+  if( pInfo->isClient())
+    node->addClient(pInfo);
+  else if( pInfo->isProxyServer())
+    node->addActiveProxyServer(pInfo);
+  else if( pInfo->isMasterServer())
+    node->addMasterServer(pInfo);
+}
+
+
+/**
+ * @returns the proxy server of the first choice
+ */
+PeerInfo* NetworkMonitor::getFirstChoiceProxy()
+{
+  // return the fist proxy in the list
+  return this->localNode->getActiveProxyServer(0);
+}
+
+
+/**
+ * @returns the proxy server of second choice
+ */
+PeerInfo* NetworkMonitor::getSecondChoiceProxy()
+{
+  // return the second server in the list
+  return this->localNode->getActiveProxyServer(1);
+}
+
+
+/**
+ * this displays the network monitor gui
+ */
+void NetworkMonitor::showGUI()
+{
+  if (this->box == NULL)
+  {
+    this->box = new OrxGui::GLGuiBox(OrxGui::Vertical);
+    {
+      OrxGui::GLGuiBox* waterColorBox = new OrxGui::GLGuiBox(OrxGui::Horizontal);
+      {
+        OrxGui::GLGuiText* waterColorText = new OrxGui::GLGuiText();
+        waterColorText->setText("NetworkMonitor");
+        waterColorBox->pack(waterColorText);
+      }
+      this->box->pack(waterColorBox);
+    }
+
+    this->box->showAll();
+    this->box->setAbsCoor2D(300, 40);
+    OrxGui::GLGuiHandler::getInstance()->activate();
+//     OrxGui::GLGuiHandler::getInstance()->activateCursor();
+  }
+}
+
+
+/**
+ * hides the network monitor gui again
+ */
+void NetworkMonitor::hideGUI()
+{
+  if( this->box == NULL)
+    return;
+
+  OrxGui::GLGuiHandler::getInstance()->deactivate();
+//   OrxGui::GLGuiHandler::getInstance()->deactivateCursor();
+
+  delete this->box;
+  this->box = NULL;
+}
+
+
+/**
+ * processes the network monitor data
+ */
+void NetworkMonitor::process()
+{
+  this->playerNumber = 0;
+  std::list<NetworkNode*>::iterator it = this->nodeList.begin();
+  for(; it != this->nodeList.end(); it++)
+  {
+    this->playerNumber += (*it)->getPlayerNumber();
+  }
+
+  // check if a proxy server has to activated
+
+//   this->debug();
+}
+
+/**
+ * prints out the debug informations
+ */
+void NetworkMonitor::debug()
+{
+  PRINT(0)("================================= Network Monitor::debug() =====\n");
+  PRINT(0)(" I am: %s\n", this->localNode->getPeerInfo()->getNodeTypeString().c_str());
+  PRINT(0)(" Total count of network connections: %i\n", this->playerNumber);
+
+  std::list<NetworkNode*>::iterator it = this->nodeList.begin();
+  for(; it != this->nodeList.end(); it++)
+  {
+    (*it)->debug(0);
+  }
+
+  PRINT(0)("================================================================\n");
+}
+
Index: branches/proxy/src/lib/network/monitor/network_monitor.h
===================================================================
--- branches/proxy/src/lib/network/monitor/network_monitor.h	(revision 9347)
+++ branches/proxy/src/lib/network/monitor/network_monitor.h	(revision 9347)
@@ -0,0 +1,89 @@
+/*!
+ * @file network_monitor.h
+ *  a class to monitor the network: throughput, network nodes
+ */
+
+#ifndef _NETWORK_MONITOR_H
+#define _NETWORK_MONITOR_H
+
+#include "base_object.h"
+#include "synchronizeable.h"
+#include "shared_network_data.h"
+#include "ip.h"
+
+#include "network_node.h"
+
+#include <list>
+
+class NetworkStream;
+class PeerInfo;
+
+
+namespace OrxGui { class GLGuiBox; };
+
+
+
+//!< a class that monitors the whole network. it tries to gather all informations its able to from the network
+class NetworkMonitor : public Synchronizeable
+{
+
+  public:
+    NetworkMonitor(NetworkStream* networkStream);
+    virtual ~NetworkMonitor();
+
+    /* client/masterserver/proxyserver addition/removal interface */
+    void addNetworkNode(NetworkNode* node);
+    void removeNetworkNode(NetworkNode* node);
+
+    void addNode(PeerInfo* pInfo);
+    void addNode(IP ip, int nodeType);
+    void addNode(NetworkNode* node) { this->nodeList.push_back(node); }
+    void addNode(NetworkNode* node, PeerInfo* pInfo);
+
+    /** adds to @param node a network node @param pInfo a new client */
+    inline void addClient(NetworkNode* node, PeerInfo* pInfo) { node->addClient(pInfo); }
+    /** adds to @param node a network node @param pInfo a new proxy server */
+    inline void addActiveProxyServer(NetworkNode* node, PeerInfo* pInfo) { node->addActiveProxyServer(pInfo); }
+    /** adds to @param node a network node @param pInfo a new proxy server */
+    inline void addPassiveProxyServer(NetworkNode* node, PeerInfo* pInfo) { node->addPassiveProxyServer(pInfo); }
+    /** adds to @param node a network node @param pInfo a new master server*/
+    inline void addMasterServer(NetworkNode* node, PeerInfo* pInfo) { node->addMasterServer(pInfo); }
+
+    inline void removeClient(NetworkNode* node, PeerInfo* pInfo) { node->removeClient(pInfo); }
+    inline void removeActiveProxyServer(NetworkNode* node, PeerInfo* pInfo) { node->removeActiveProxyServer(pInfo); }
+    inline void removePassiveProxyServer(NetworkNode* node, PeerInfo* pInfo) { node->removePassiveProxyServer(pInfo); }
+    inline void removeMasterServer(NetworkNode* node, PeerInfo* pInfo) { node->removeMasterServer(pInfo); }
+
+    /* slots admin and info interface */
+    /** @returns the total number of players in this game (including all proxy servers etc)*/
+    inline int getPlayerNumber() { return this->playerNumber; }
+
+    /** @returns true if there are still free network slots available */
+    inline bool gotFreeSlots() { return (this->localNode->getPlayerNumber() < SharedNetworkData::getInstance()->getMaxPlayer())?true:false; }
+    /** @param node node to be checked for slots @returns true if there are still free network slots available at this node */
+    inline bool gotFreeSlots(NetworkNode* node) { return (node->getPlayerNumber() < SharedNetworkData::getInstance()->getMaxPlayer())?true:false; }
+    PeerInfo* getFirstChoiceProxy();
+    PeerInfo* getSecondChoiceProxy();
+    /** @returns true if the next client should be reconnected to some other proxy server with more connections */
+    inline bool isReconnectNextClient() { return (this->localNode->getPlayerNumber() >= SharedNetworkData::getInstance()->getMaxPlayer())?true:false; }
+
+
+    void showGUI();
+    void hideGUI();
+
+    void process();
+    void debug();
+
+
+  private:
+    NetworkStream*               networkStream;              //!< reference to the one networkstream of the network
+    NetworkNode*                 localNode;                  //!< reference to the local node
+    std::list<NetworkNode*>      nodeList;                   //!< list of all network nodes
+
+    OrxGui::GLGuiBox*            box;
+
+    int                          playerNumber;                 //!< total number of players in the game
+};
+
+
+#endif
Index: branches/proxy/src/lib/network/monitor/network_node.cc
===================================================================
--- branches/proxy/src/lib/network/monitor/network_node.cc	(revision 9347)
+++ branches/proxy/src/lib/network/monitor/network_node.cc	(revision 9347)
@@ -0,0 +1,269 @@
+/*
+   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
+*/
+
+
+#include "network_node.h"
+
+#include "debug.h"
+
+
+/**
+ * constructor
+ */
+NetworkNode::NetworkNode(PeerInfo* pInfo)
+{
+  this->playerNumber = 0;
+  this->peerInfo = pInfo;
+}
+
+
+/**
+ * deconstructor
+ */
+NetworkNode::~NetworkNode()
+{}
+
+
+/**
+ * adds a client
+ */
+void NetworkNode::addClient(PeerInfo* node)
+{
+  this->clientList.push_back(node);
+  this->playerNumber++;
+}
+
+/**
+ * adds a proxy server
+ */
+void NetworkNode::addActiveProxyServer(PeerInfo* node)
+{
+  this->activeProxyServerList.push_back(node);
+  this->playerNumber++;
+}
+
+/**
+ * adds a proxy server
+ */
+void NetworkNode::addPassiveProxyServer(PeerInfo* node)
+{
+  this->passiveProxyServerList.push_back(node);
+}
+
+/**
+ * adds a master server
+ */
+void NetworkNode::addMasterServer(PeerInfo* node)
+{
+  this->masterServerList.push_back(node);
+  this->playerNumber++;
+}
+
+/**
+ * removes a client
+ */
+void NetworkNode::removeClient(PeerInfo* node)
+{
+  std::list<PeerInfo*>::iterator it = this->clientList.begin();
+  for(; it != this->clientList.end(); it++)
+  {
+    if( *it == node)
+    {
+      this->clientList.erase(it);
+      this->playerNumber--;
+      return;
+    }
+  }
+
+  PRINTF(2)("Could not remove client from the list, very strange...");
+}
+
+/**
+ * removes a proxy server
+ */
+void NetworkNode::removeActiveProxyServer(PeerInfo* node)
+{
+  std::list<PeerInfo*>::iterator it = this->activeProxyServerList.begin();
+  for(; it != this->activeProxyServerList.end(); it++)
+  {
+    if( *it == node)
+    {
+      this->activeProxyServerList.erase(it);
+      this->playerNumber--;
+      return;
+    }
+  }
+
+  PRINTF(2)("Could not remove proxy server from the list, very strange...");
+}
+
+/**
+ * removes a proxy server
+ */
+void NetworkNode::removePassiveProxyServer(PeerInfo* node)
+{
+  std::list<PeerInfo*>::iterator it = this->passiveProxyServerList.begin();
+  for(; it != this->passiveProxyServerList.end(); it++)
+  {
+    if( *it == node)
+    {
+      this->passiveProxyServerList.erase(it);
+      return;
+    }
+  }
+
+  PRINTF(2)("Could not remove proxy server from the list, very strange...");
+}
+
+/**
+ * removes a master server
+ */
+void NetworkNode::removeMasterServer(PeerInfo* node)
+{
+  std::list<PeerInfo*>::iterator it = this->masterServerList.begin();
+  for(; it != this->masterServerList.end(); it++)
+  {
+    if( *it == node)
+    {
+      this->masterServerList.erase(it);
+      this->playerNumber--;
+      return;
+    }
+  }
+
+  PRINTF(2)("Could not remove client from the list, very strange...");
+}
+
+
+/**
+ * @param index index to the client
+ * @return the client in the list or NULL if none
+ */
+PeerInfo* NetworkNode::getClient(int index)
+{
+  if( this->clientList.size() < index)
+    return NULL;
+
+  std::list<PeerInfo*>::iterator it = this->clientList.begin();
+  for(int i = 0; it != this->clientList.end(); it++, i++)
+  {
+  if( i == index)
+    return (*it);
+  }
+
+  return NULL;
+}
+
+
+/**
+ * @param index index to the client
+ * @return the active proxy server in the list or NULL if none
+ */
+PeerInfo* NetworkNode::getActiveProxyServer(int index)
+{
+  if( this->activeProxyServerList.size() < index)
+    return NULL;
+
+  std::list<PeerInfo*>::iterator it = this->activeProxyServerList.begin();
+  for(int i = 0; it != this->activeProxyServerList.end(); it++, i++)
+  {
+    if( i == index)
+      return (*it);
+  }
+
+  return NULL;
+}
+
+
+/**
+ * @param index index to the client
+ * @return the passive proxy server in the list or NULL if none
+ */
+PeerInfo* NetworkNode::getPassiveProxyServer(int index)
+{
+  if( this->passiveProxyServerList.size() < index)
+    return NULL;
+
+  std::list<PeerInfo*>::iterator it = this->passiveProxyServerList.begin();
+  for(int i = 0; it != this->passiveProxyServerList.end(); it++, i++)
+  {
+    if( i == index)
+      return (*it);
+  }
+
+  return NULL;
+}
+
+
+/**
+ * @param index index to the client
+ * @return the master server in the list or NULL if none
+ */
+PeerInfo* NetworkNode::getMasterServer(int index)
+{
+  if( this->masterServerList.size() < index)
+    return NULL;
+
+  std::list<PeerInfo*>::iterator it = this->masterServerList.begin();
+  for(int i = 0; it != this->masterServerList.end(); it++, i++)
+  {
+    if( i == index)
+      return (*it);
+  }
+
+  return NULL;
+}
+
+
+/**
+ * debug function
+ * @param depth: depth in the tree
+ */
+void NetworkNode::debug(int depth)
+{
+  PRINT(0)(" = %s\n", this->peerInfo->getNodeTypeString().c_str());
+
+  PRINT(0)("    master servers: %i\n", this->masterServerList.size());
+  std::list<PeerInfo*>::iterator it = this->masterServerList.begin();
+  for(; it != this->masterServerList.end(); it++)
+  {
+    IP* ip = &(*it)->ip;
+    PRINT(0)("     - ms, id: %i (%s)\n", (*it)->userId, ip->ipString().c_str());
+  }
+
+  PRINT(0)("    proxy servers active: %i\n", this->activeProxyServerList.size());
+  it = this->activeProxyServerList.begin();
+  for(; it != this->activeProxyServerList.end(); it++)
+  {
+    IP* ip = &(*it)->ip;
+    PRINT(0)("     - ps-a, id: %i (%s)\n", (*it)->userId, ip->ipString().c_str());
+  }
+
+  PRINT(0)("    proxy servers passive: %i\n", this->passiveProxyServerList.size());
+  it = this->passiveProxyServerList.begin();
+  for(; it != this->passiveProxyServerList.end(); it++)
+  {
+    IP* ip = &(*it)->ip;
+    PRINT(0)("     - ps-p, id: %i (%s)\n", (*it)->userId, ip->ipString().c_str());
+  }
+
+  PRINT(0)("    clients: %i\n", this->clientList.size());
+  it = this->clientList.begin();
+  for(; it != this->clientList.end(); it++)
+  {
+    IP* ip = &(*it)->ip;
+    PRINT(0)("     - client, id: %i (%s)\n", (*it)->userId, ip->ipString().c_str());
+  }
+}
+
Index: branches/proxy/src/lib/network/monitor/network_node.h
===================================================================
--- branches/proxy/src/lib/network/monitor/network_node.h	(revision 9347)
+++ branches/proxy/src/lib/network/monitor/network_node.h	(revision 9347)
@@ -0,0 +1,61 @@
+/*!
+ * @file network_node.h
+ *  a class representing a node in the network (this can be a MASTER_SERVER, PROXY_SERVER or a CLIENT
+ */
+
+#ifndef _NETWORK_NODE_H
+#define _NETWORK_NODE_H
+
+#include "base_object.h"
+#include "synchronizeable.h"
+#include "peer_info.h"
+
+#include <list>
+
+
+//!< a class representing a node in the network (this can be a MASTER_SERVER, PROXY_SERVER or a CLIENT
+class NetworkNode
+{
+  public:
+    NetworkNode(PeerInfo* pInfo);
+    ~NetworkNode();
+
+
+    void addClient(PeerInfo* node);
+    void addActiveProxyServer(PeerInfo* node);
+    void addPassiveProxyServer(PeerInfo* node);
+    void addMasterServer(PeerInfo* node);
+
+    void removeClient(PeerInfo* node);
+    void removeActiveProxyServer(PeerInfo* node);
+    void removePassiveProxyServer(PeerInfo* node);
+    void removeMasterServer(PeerInfo* node);
+
+    PeerInfo* getClient(int index);
+    PeerInfo* getActiveProxyServer(int index);
+    PeerInfo* getPassiveProxyServer(int index);
+    PeerInfo* getMasterServer(int index);
+
+    /** @returns the number of players */
+    inline int getPlayerNumber() { return this->playerNumber; }
+    /** @returns the node type of this node */
+    inline int getNodeType() { return this->peerInfo->nodeType; }
+    /** @returns the peer info of this node */
+    inline PeerInfo* getPeerInfo() { return this->peerInfo; }
+
+    void debug(int depth);
+
+
+  private:
+    int                          playerNumber;                 //!< localy direct connected player number
+    PeerInfo*                    peerInfo;                     //!< the peer informationa about this node
+
+    /* network nodes directly connected to this node */
+    std::list<PeerInfo*>         clientList;                   //!< list of all clients in the network
+    std::list<PeerInfo*>         activeProxyServerList;        //!< list of all proxy servers in the network
+    std::list<PeerInfo*>         passiveProxyServerList;       //!< list of all proxy servers in the network
+    std::list<PeerInfo*>         masterServerList;             //!< list of all master servers in the network (should be 1!! :D)
+
+};
+
+#endif /* _NETWORK_NODE_H */
Index: branches/proxy/src/lib/network/netdefs.h
===================================================================
--- branches/proxy/src/lib/network/netdefs.h	(revision 9346)
+++ branches/proxy/src/lib/network/netdefs.h	(revision 9347)
@@ -1,12 +1,28 @@
+/*
+   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 Renner rennerc@ee.ethz.ch
+   co-programmer:   Patrick Boenzli  boenzlip@orxonox.ethz.ch
+
+     June 2006: finishing work on the network stream for pps presentation (rennerc@ee.ethz.ch)
+     July 2006: some code rearangement and integration of the proxy server mechanism (boenzlip@ee.ethz.ch)
+*/
 
 /*!
  * @file network_manager.h
  *  Main interface for the network module. Manages all the modules
-
  */
 
 #ifndef _NETDEFS
 #define _NETDEFS
+
 
 #ifdef HAVE_SDL_NET_H
@@ -17,7 +33,18 @@
 
 
-#define MAX_CONNECTIONS 1000
+//!< maximal connectinons for the server
+#define NET_MAX_CONNECTIONS 100
 
+//!< the amount of slots used before a proxy server is activated
+#define NET_CONNECTION_SATURATION 0.75
+
+//!< network polling frequency
 #define NETWORK_FREQUENCY 66
+
+
+//!< orxonox protocol id
+#define _ORXONOX_ID        0xF91337A0
+//!< orxonox network version identifier
+#define _ORXONOX_VERSION   1
 
 
@@ -27,6 +54,11 @@
 //!< enum indicating the type of the node
 typedef enum {
-  NET_SERVER,
-  NET_CLIENT
+  NET_MASTER_SERVER,
+  NET_PROXY_SERVER_ACTIVE,
+  NET_PROXY_SERVER_PASSIVE,
+  NET_CLIENT,
+
+  NET_NR_TYPES
+
 } NodeType;
 
Index: branches/proxy/src/lib/network/network_game_manager.cc
===================================================================
--- branches/proxy/src/lib/network/network_game_manager.cc	(revision 9346)
+++ branches/proxy/src/lib/network/network_game_manager.cc	(revision 9347)
@@ -10,12 +10,13 @@
 
 ### File Specific:
-   main-programmer: Benjamin Wuest
-   co-programmer: ...
+   main-programmer: Christoph Renner rennerc@ee.ethz.ch
+   co-programmer:   Patrick Boenzli  boenzlip@orxonox.ethz.ch
+
+     June 2006: finishing work on the network stream for pps presentation (rennerc@ee.ethz.ch)
+     July 2006: some code rearangement and integration of the proxy server mechanism (boenzlip@ee.ethz.ch)
 */
 
 
-/* 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
 
@@ -45,5 +46,4 @@
 
 
-/* using namespace std is default, this needs to be here */
 using namespace std;
 
@@ -62,9 +62,9 @@
 
   this->setSynchronized(true);
-  
+
   MessageManager::getInstance()->registerMessageHandler( MSGID_DELETESYNCHRONIZEABLE, delSynchronizeableHandler, NULL );
   MessageManager::getInstance()->registerMessageHandler( MSGID_PREFEREDTEAM, preferedTeamHandler, NULL );
   MessageManager::getInstance()->registerMessageHandler( MSGID_CHATMESSAGE, chatMessageHandler, NULL );
-  
+
   this->gameState = 0;
   registerVar( new SynchronizeableInt( &gameState, &gameState, "gameState" ) );
@@ -77,7 +77,7 @@
 {
   delete MessageManager::getInstance();
-  
+
   PlayerStats::deleteAllPlayerStats();
-  
+
   NetworkGameManager::singletonRef = NULL;
 }
@@ -86,15 +86,15 @@
 /**
  * insert new player into game
- * @param userId 
- * @return 
+ * @param userId
+ * @return
  */
 bool NetworkGameManager::signalNewPlayer( int userId )
 {
-  assert( SharedNetworkData::getInstance()->isGameServer() );
+  assert( SharedNetworkData::getInstance()->isMasterServer() );
   assert( State::getGameRules() );
   assert( State::getGameRules()->isA( CL_NETWORK_GAME_RULES ) );
-  
+
   NetworkGameRules & rules = *(dynamic_cast<NetworkGameRules*>(State::getGameRules()));
-  
+
   int team = rules.getTeamForNewUser();
   ClassID playableClassId = rules.getPlayableClassId( userId, team );
@@ -102,36 +102,36 @@
   std::string playableTexture = rules.getPlayableModelFileName( userId, team, playableClassId );
   float       playableScale = rules.getPlayableScale( userId, team, playableClassId );
-  
+
   BaseObject * bo = Factory::fabricate( playableClassId );
-  
+
   assert( bo != NULL );
   assert( bo->isA( CL_PLAYABLE ) );
-  
+
   Playable & playable = *(dynamic_cast<Playable*>(bo));
-  
+
   playable.loadMD2Texture( playableTexture );
-  
+
   playable.loadModel( playableModel, 100.0f );
   playable.setOwner( userId );
   playable.setUniqueID( SharedNetworkData::getInstance()->getNewUniqueID() );
   playable.setSynchronized( true );
-  
+
   PlayerStats * stats = rules.getNewPlayerStats( userId );
-  
+
   stats->setUniqueID( SharedNetworkData::getInstance()->getNewUniqueID() );
   stats->setSynchronized( true );
   stats->setOwner( SharedNetworkData::getInstance()->getHostID() );
-  
+
   stats->setTeamId( team );
   stats->setPlayableClassId( playableClassId );
   stats->setPlayableUniqueId( playable.getUniqueID() );
   stats->setModelFileName( playableModel );
-  
+
   if ( userId == 0 )
     stats->setNickName( Preferences::getInstance()->getString( "multiplayer", "nickname", "Server" ) );
-  
+
   if ( rules.isA( CL_MULTIPLAYER_TEAM_DEATHMATCH ) )
     dynamic_cast<MultiplayerTeamDeathmatch*>(&rules)->respawnPlayable( &playable, team, 0.0f );
-  
+
   return true;
 }
@@ -140,6 +140,6 @@
 /**
  * remove player from game
- * @param userID 
- * @return 
+ * @param userID
+ * @return
  */
 bool NetworkGameManager::signalLeftPlayer(int userID)
@@ -151,5 +151,5 @@
     delete PlayerStats::getStats( userID );
   }
-  
+
   return true;
 }
@@ -159,22 +159,22 @@
 /**
  * handler for remove synchronizeable messages
- * @param messageId 
- * @param data 
- * @param dataLength 
- * @param someData 
- * @param userId 
+ * @param messageId
+ * @param data
+ * @param dataLength
+ * @param someData
+ * @param userId
  * @return true on successfull handling else handler will be called again
  */
 bool NetworkGameManager::delSynchronizeableHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId )
 {
-  if ( getInstance()->isServer() )
+  if ( SharedNetworkData::getInstance()->isMasterServer() )
   {
     PRINTF(2)("Recieved DeleteSynchronizeable message from client %d!\n", userId);
     return true;
   }
-  
+
   int uniqueId = 0;
   int len = Converter::byteArrayToInt( data, &uniqueId );
-  
+
   if ( len != dataLength )
   {
@@ -182,7 +182,7 @@
     return true;
   }
-  
+
   const std::list<BaseObject*> * list = ClassList::getList( CL_SYNCHRONIZEABLE );
-  
+
   for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
   {
@@ -194,10 +194,10 @@
         return true;
       }
-      
+
       delete dynamic_cast<Synchronizeable*>(*it);
       return true;
     }
   }
-  
+
   return true;
 }
@@ -210,5 +210,5 @@
 {
   byte buf[INTSIZE];
-  
+
   assert( Converter::intToByteArray( uniqueId, buf, INTSIZE ) == INTSIZE );
 
@@ -220,18 +220,18 @@
 /**
  * handler for MSGID_PREFEREDTEAM message
- * @param messageId 
- * @param data 
- * @param dataLength 
- * @param someData 
- * @param userId 
- * @return 
+ * @param messageId
+ * @param data
+ * @param dataLength
+ * @param someData
+ * @param userId
+ * @return
  */
 bool NetworkGameManager::preferedTeamHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId )
 {
-  assert( NetworkGameManager::getInstance()->isServer() );
-  
+  assert( SharedNetworkData::getInstance()->isMasterServer() );
+
   int teamId = 0;
   int len = Converter::byteArrayToInt( data, &teamId );
-  
+
   if ( len != dataLength )
   {
@@ -239,7 +239,7 @@
     return true;
   }
-  
+
   NetworkGameManager::getInstance()->setPreferedTeam( userId, teamId );
-  
+
   return true;
 }
@@ -249,7 +249,7 @@
   if ( !PlayerStats::getStats( userId ) )
     return;
-  
+
   PlayerStats & stats = *(PlayerStats::getStats( userId ));
-  
+
   stats.setPreferedTeamId( teamId );
 }
@@ -257,16 +257,16 @@
 /**
  * set prefered team for this host
- * @param teamId 
+ * @param teamId
  */
 void NetworkGameManager::prefereTeam( int teamId )
 {
-  if ( isServer() )
+  if ( SharedNetworkData::getInstance()->isMasterServer() )
     setPreferedTeam( SharedNetworkData::getInstance()->getHostID(), teamId );
   else
   {
     byte buf[INTSIZE];
-    
+
     assert( Converter::intToByteArray( teamId, buf, INTSIZE) == INTSIZE );
-    
+
     MessageManager::getInstance()->sendMessage( MSGID_PREFEREDTEAM, buf, INTSIZE, RT_USER, 0, MP_HIGHBANDWIDTH );
   }
@@ -285,7 +285,7 @@
     {
       const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYABLE );
-       
+
       if ( list && std::find( list->begin(), list->end(), *it ) != list->end() )
-      {      
+      {
         PRINTF(0)("Delete unused playable: %s owner: %d\n", (*it)->getClassName(), (*it)->getOwner() );
         std::list<Playable*>::iterator delit = it;
@@ -305,21 +305,21 @@
 {
   PRINTF(0)("NetworkGameManager::chatMessageHandler %d %d\n", userId, SharedNetworkData::getInstance()->getHostID() );
-  if ( NetworkGameManager::getInstance()->isServer() && userId !=  SharedNetworkData::getInstance()->getHostID() )
+  if ( SharedNetworkData::getInstance()->isMasterServer() && userId !=  SharedNetworkData::getInstance()->getHostID() )
   {
     MessageManager::getInstance()->sendMessage( messageId, data, dataLength, RT_ALL_NOT_ME, 0, MP_HIGHBANDWIDTH );
   }
-  
+
   assert( State::getGameRules() );
   assert( State::getGameRules()->isA( CL_NETWORK_GAME_RULES ) );
-  
+
   NetworkGameRules & rules = *(dynamic_cast<NetworkGameRules*>(State::getGameRules()));
-  
+
   if ( dataLength < 3*INTSIZE )
   {
     PRINTF(2)("got too small chatmessage from client %d\n", userId);
-    
+
     return true;
   }
-  
+
   int messageType = 0;
   Converter::byteArrayToInt( data, &messageType );
@@ -328,5 +328,5 @@
   std::string message;
   Converter::byteArrayToString( data+2*INTSIZE, message, dataLength-2*INTSIZE );
-  
+
   rules.handleChatMessage( senderUserId, message, messageType );
 
@@ -346,11 +346,11 @@
   assert( Converter::intToByteArray( SharedNetworkData::getInstance()->getHostID(), buf+INTSIZE, INTSIZE ) == INTSIZE );
   assert( Converter::stringToByteArray(message, buf+2*INTSIZE, message.length()+INTSIZE) == message.length()+INTSIZE );
-  
-  if ( this->isServer() )
+
+  if ( SharedNetworkData::getInstance()->isMasterServer() )
     MessageManager::getInstance()->sendMessage( MSGID_CHATMESSAGE, buf, message.length()+3*INTSIZE, RT_ALL_ME, 0, MP_HIGHBANDWIDTH );
   else
     MessageManager::getInstance()->sendMessage( MSGID_CHATMESSAGE, buf, message.length()+3*INTSIZE, RT_ALL_NOT_ME, 0, MP_HIGHBANDWIDTH );
 
-  
+
   delete [] buf;
 }
Index: branches/proxy/src/lib/network/network_game_manager.h
===================================================================
--- branches/proxy/src/lib/network/network_game_manager.h	(revision 9346)
+++ branches/proxy/src/lib/network/network_game_manager.h	(revision 9347)
@@ -28,6 +28,4 @@
   NET_YOU_ARE_ENTITY,
   NET_REQUEST_ENTITY_LIST,
-  NET_REQUEST_PNODE_PATH,
-  NET_SEND_PNODE_PATH,
 
   NET_NUMBER
@@ -42,11 +40,12 @@
 
 /*!
- * a class that can create and remove entities
+ * a class that can create and remove entities over the network
  */
 class NetworkGameManager: public Synchronizeable
 {
+
   public:
     virtual ~NetworkGameManager();
-    
+
     static NetworkGameManager* NetworkGameManager::getInstance()
     { if (!NetworkGameManager::singletonRef) NetworkGameManager::singletonRef = new NetworkGameManager(); return NetworkGameManager::singletonRef; }
@@ -55,29 +54,32 @@
     bool signalNewPlayer( int userId );
     bool signalLeftPlayer( int userID );
-    
-    void removeSynchronizeable( int uniqueId );
-    
+
     void prefereTeam( int teamId );
+
 
     inline void setGameState( int gameState ){ this->gameState = gameState; }
     inline int getGameState(){ return this->gameState; }
-    
+
     void tick( float ds );
-    
+
+    void removeSynchronizeable( int uniqueId );
     void sendChatMessage( const std::string & message, int messageType );
+
 
   private:
     NetworkGameManager();
-    
+
     static bool delSynchronizeableHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId );
     static bool preferedTeamHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId );
     static bool chatMessageHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId );
-    
+
     void setPreferedTeam( int userId, int teamId );
 
+
+  private:
     static NetworkGameManager*    singletonRef;
-    
+
     int                           gameState;
-    
+
     std::list<Playable*>          playablesToDelete;
 };
Index: branches/proxy/src/lib/network/network_manager.cc
===================================================================
--- branches/proxy/src/lib/network/network_manager.cc	(revision 9346)
+++ branches/proxy/src/lib/network/network_manager.cc	(revision 9347)
@@ -53,8 +53,8 @@
   this->networkStream = NULL;
   this->elapsedTime = 0.0f;
-  
-    
+
+
   int port = Preferences::getInstance()->getInt( "network", "telnetport", 0 );
-  
+
   if ( port > 0 )
     NetworkLog::getInstance()->listen( port );
@@ -75,5 +75,5 @@
     this->networkStream = NULL;
   }
-  
+
   NetworkManager::singletonRef = NULL;
 }
@@ -118,5 +118,5 @@
 {
   SharedNetworkData::getInstance()->setHostID(0);
-  SharedNetworkData::getInstance()->setGameServer(true);
+  SharedNetworkData::getInstance()->setNodeType(NET_MASTER_SERVER);
   this->networkStream = new NetworkStream(port);
   SharedNetworkData::getInstance()->setDefaultSyncStream(this->networkStream);
@@ -148,5 +148,5 @@
   if ( networkStream )
     networkStream->processData();
-  
+
   NetworkGameManager::getInstance()->tick( this->elapsedTime );
 }
Index: branches/proxy/src/lib/network/network_manager.h
===================================================================
--- branches/proxy/src/lib/network/network_manager.h	(revision 9346)
+++ branches/proxy/src/lib/network/network_manager.h	(revision 9347)
@@ -41,5 +41,7 @@
     /** Returns the hostID @return The hostID of the object */
     inline int getHostID() { return SharedNetworkData::getInstance()->getHostID(); }
-    inline bool isGameServer() { return SharedNetworkData::getInstance()->isGameServer(); }
+    inline bool isMasterServer() { return SharedNetworkData::getInstance()->isMasterServer(); }
+    inline bool isProxyServer() { return SharedNetworkData::getInstance()->isProxyServer(); }
+    inline bool isClient() { return SharedNetworkData::getInstance()->isClient(); }
 
 
Index: branches/proxy/src/lib/network/network_socket.cc
===================================================================
--- branches/proxy/src/lib/network/network_socket.cc	(revision 9346)
+++ branches/proxy/src/lib/network/network_socket.cc	(revision 9347)
@@ -33,4 +33,6 @@
 {
   bOk = true;
+  this->ip.host = 0;
+  this->ip.port = 0;
 }
 
Index: branches/proxy/src/lib/network/network_socket.h
===================================================================
--- branches/proxy/src/lib/network/network_socket.h	(revision 9346)
+++ branches/proxy/src/lib/network/network_socket.h	(revision 9347)
@@ -27,9 +27,19 @@
      */
     virtual void connectToServer( std::string host, int port ) = 0;
-    
+
     /**
      * disconnect from server
      */
     virtual void disconnectServer() = 0;
+
+    /**
+     * reconnecting to another server by terminating old connection and init a new connection
+     */
+    virtual void reconnectToServer( std::string host, int port) = 0;
+
+    /**
+     * reconnecting to anoter server softly
+     */
+    virtual void reconnectToServerSoft( std::string host, int port) = 0;
 
     /**
@@ -40,5 +50,5 @@
      */
     virtual bool writePacket(byte * data, int length) = 0;
-    
+
     /**
      * read a packet sent by another NetworkSocket
@@ -54,8 +64,13 @@
      */
     inline bool isOk() { return this->bOk; }
-  
+
+    /** @returns the ip adderess of the destination socket */
+    IPaddress getRemoteAddress() { return ip; }
+
+
   protected:
-    bool bOk;            //!< check for socket status
+    bool              bOk;            //!< check for socket status
 
+    IPaddress         ip;             //!< host,port
 };
 
Index: branches/proxy/src/lib/network/network_stream.cc
===================================================================
--- branches/proxy/src/lib/network/network_stream.cc	(revision 9346)
+++ branches/proxy/src/lib/network/network_stream.cc	(revision 9347)
@@ -12,4 +12,7 @@
    main-programmer: Christoph Renner rennerc@ee.ethz.ch
    co-programmer:   Patrick Boenzli  boenzlip@orxonox.ethz.ch
+
+     June 2006: finishing work on the network stream for pps presentation (rennerc@ee.ethz.ch)
+     July 2006: some code rearangement and integration of the proxy server mechanism (boenzlip@ee.ethz.ch)
 */
 
@@ -22,6 +25,8 @@
 #include "udp_socket.h"
 #include "udp_server_socket.h"
-#include "connection_monitor.h"
+#include "monitor/connection_monitor.h"
+#include "monitor/network_monitor.h"
 #include "synchronizeable.h"
+#include "ip.h"
 #include "network_game_manager.h"
 #include "shared_network_data.h"
@@ -42,8 +47,8 @@
 #include <algorithm>
 
-/* include your own header */
+
 #include "network_stream.h"
 
-/* probably unnecessary */
+
 using namespace std;
 
@@ -52,4 +57,7 @@
 
 
+/**
+ * empty constructor
+ */
 NetworkStream::NetworkStream()
     : DataStream()
@@ -57,10 +65,10 @@
   this->init();
   /* initialize the references */
-  this->type = NET_CLIENT;
-}
-
-
-/**
- * connect to a server as a client
+  this->pInfo->nodeType = NET_CLIENT;
+}
+
+
+/**
+ * start as a client, connect to a server
  *  @param host: host name (address)
  *  @param port: port number
@@ -68,10 +76,17 @@
 NetworkStream::NetworkStream( std::string host, int port )
 {
-  this->type = NET_CLIENT;
   this->init();
+  // init the peers[0] the server to ceonnect to
   this->peers[0].socket = new UdpSocket( host, port );
   this->peers[0].userId = 0;
-  this->peers[0].isServer = true;
+  this->peers[0].nodeType = NET_MASTER_SERVER;
   this->peers[0].connectionMonitor = new ConnectionMonitor( 0 );
+  this->peers[0].ip = this->peers[0].socket->getRemoteAddress();
+  // and set also the localhost
+  this->pInfo->nodeType = NET_CLIENT;
+  // get the local ip address
+  IPaddress ip;
+  SDLNet_ResolveHost( &ip, NULL, port );
+  this->pInfo->ip = ip;
 }
 
@@ -83,8 +98,11 @@
 NetworkStream::NetworkStream( int port )
 {
-  this->type = NET_SERVER;
   this->init();
   this->serverSocket = new UdpServerSocket(port);
-  this->bActive = true;
+  this->pInfo->nodeType = NET_MASTER_SERVER;
+  // get the local ip address
+  IPaddress ip;
+  SDLNet_ResolveHost( &ip, NULL, port );
+  this->pInfo->ip = ip;
 }
 
@@ -97,9 +115,15 @@
   /* set the class id for the base object */
   this->setClassID(CL_NETWORK_STREAM, "NetworkStream");
-  this->bActive = false;
   this->serverSocket = NULL;
   this->networkGameManager = NULL;
-  myHostId = 0;
-  currentState = 0;
+  this->networkMonitor = NULL;
+
+  this->pInfo = new PeerInfo();
+  this->pInfo->userId = 0;
+  this->pInfo->lastAckedState = 0;
+  this->pInfo->lastRecvedState = 0;
+
+
+  this->currentState = 0;
 
   remainingBytesToWriteToDict = Preferences::getInstance()->getInt( "compression", "writedict", 0 );
@@ -147,4 +171,10 @@
   for ( SynchronizeableList::const_iterator it = getSyncBegin(); it != getSyncEnd(); it ++ )
     (*it)->setNetworkStream( NULL );
+
+  if( this->pInfo)
+    delete this->pInfo;
+
+  if( this->networkMonitor)
+    delete this->networkMonitor;
 }
 
@@ -165,17 +195,17 @@
 /**
  * starts the network handshake
+ * handsakes are always initialized from the client side first. this starts the handshake and therefore is only
+ * executed as client
  */
 void NetworkStream::startHandshake()
 {
-  Handshake* hs = new Handshake(false);
+  Handshake* hs = new Handshake(this->pInfo->nodeType);
   hs->setUniqueID( 0 );
   assert( peers[0].handshake == NULL );
   peers[0].handshake = hs;
 
+  // set the preferred nick name
   hs->setPreferedNickName( Preferences::getInstance()->getString( "multiplayer", "nickname", "Player" ) );
 
-//   peers[0].handshake->setSynchronized( true );
-  //this->connectSynchronizeable(*hs);
-  //this->connectSynchronizeable(*hs);
   PRINTF(0)("NetworkStream: Handshake created: %s\n", hs->getName());
 }
@@ -192,5 +222,5 @@
   sync.setNetworkStream( this );
 
-  this->bActive = true;
+//   this->bActive = true;
 }
 
@@ -215,14 +245,29 @@
 void NetworkStream::processData()
 {
+  // create the network monitor after all the init work and before there is any connection handlings
+  if( this->networkMonitor == NULL)
+    this->networkMonitor = new NetworkMonitor(this);
+
+
   int tick = SDL_GetTicks();
 
-  currentState++;
-
-  if ( this->type == NET_SERVER )
-  {
+  this->currentState++;
+  // there was a wrap around
+  if( this->currentState < 0)
+  {
+    PRINTF(1)("A wrap around in the state variable as occured. The server was running so long? Pls restart server or write a mail to the supporters!\n");
+  }
+
+  if ( this->pInfo->nodeType == NET_MASTER_SERVER )
+  {
+    // execute everytthing the master server shoudl do
     if ( serverSocket )
       serverSocket->update();
 
     this->updateConnectionList();
+  }
+  else if( this->pInfo->nodeType == NET_PROXY_SERVER_ACTIVE)
+  {
+    // execute everything the proxy server should do
   }
   else
@@ -249,4 +294,7 @@
   cleanUpOldSyncList();
   handleHandshakes();
+
+  // update the network monitor
+  this->networkMonitor->process();
 
   // order of up/downstream is important!!!!
@@ -258,6 +306,6 @@
 
 /**
- * if we are a server update the connection list to accept new connections (clients)
- * also start the handsake for the new clients
+ * if we are a NET_MASTER_SERVER or NET_PROXY_SERVER_ACTIVE update the connection list to accept new
+ * connections (clients) also start the handsake for the new clients
  */
 void NetworkStream::updateConnectionList( )
@@ -276,10 +324,4 @@
       clientId = freeSocketSlots.back();
       freeSocketSlots.pop_back();
-      peers[clientId].socket = tempNetworkSocket;
-      peers[clientId].handshake = new Handshake(true, clientId, this->networkGameManager->getUniqueID(), MessageManager::getInstance()->getUniqueID() );
-      peers[clientId].connectionMonitor = new ConnectionMonitor( clientId );
-      peers[clientId].handshake->setUniqueID(clientId);
-      peers[clientId].userId = clientId;
-      peers[clientId].isServer = false;
     }
     else
@@ -290,27 +332,52 @@
         if ( it->first >= clientId )
           clientId = it->first + 1;
-
-      peers[clientId].socket = tempNetworkSocket;
-      peers[clientId].handshake = new Handshake(true, clientId, this->networkGameManager->getUniqueID(), MessageManager::getInstance()->getUniqueID());
-      peers[clientId].handshake->setUniqueID(clientId);
-      peers[clientId].connectionMonitor = new ConnectionMonitor( clientId );
-      peers[clientId].userId = clientId;
-      peers[clientId].isServer = false;
-
-      PRINTF(0)("num sync: %d\n", synchronizeables.size());
-    }
-
-    // check if there are too many clients connected
-    if ( clientId > MAX_CONNECTIONS )
-    {
-      peers[clientId].handshake->doReject( "too many connections" );
-      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]);
+    }
+
+    peers[clientId].socket = tempNetworkSocket;
+    // create new handshake and init its variables
+    peers[clientId].handshake = new Handshake(this->pInfo->nodeType, clientId, this->networkGameManager->getUniqueID(), MessageManager::getInstance()->getUniqueID() );
+    peers[clientId].handshake->setUniqueID(clientId);
+
+    peers[clientId].connectionMonitor = new ConnectionMonitor( clientId );
+    peers[clientId].userId = clientId;
+
+    PRINTF(0)("num sync: %d\n", synchronizeables.size());
+
+    // get the proxy server informations and write them to the handshake, if any (proxy)
+    assert( this->networkMonitor != NULL);
+    PeerInfo* pi = this->networkMonitor->getFirstChoiceProxy();
+    if( pi != NULL)
+    {
+      peers[clientId].handshake->setProxy1Address( pi->ip);
+      PRINTF(0)("proxy1 ip set to: %s\n", pi->ip.ipString().c_str());
+    }
+
+    pi = this->networkMonitor->getSecondChoiceProxy();
+    if( pi != NULL)
+      peers[clientId].handshake->setProxy2Address( pi->ip);
+
+    // check if the connecting client should reconnect to a proxy server
+    peers[clientId].handshake->setRedirect(this->networkMonitor->isReconnectNextClient());
+
+    // the connecting node of course is a client
+    peers[clientId].nodeType = NET_CLIENT;
+    peers[clientId].ip = peers[clientId].socket->getRemoteAddress();
+
+
+    // check if there are too many clients connected (DEPRECATED: new: the masterserver sends a list of proxy servers)
+//     if ( clientId > SharedNetworkData::getInstance()->getMaxPlayer() )
+//     {
+// //       peers[clientId].handshake->setRedirect(true);
+// //
+// //       peers[clientId].handshake->doReject( "too many connections" );
+//       PRINTF(0)("Will reject client %d because there are to many connections!\n", clientId);
+//     }
+//     else
+//     {
+//       PRINTF(0)("New Client: %d\n", clientId);
+//     }
+    PRINTF(0)("New Client: %d\n", clientId);
+
+
   }
 
@@ -373,8 +440,8 @@
 void NetworkStream::debug()
 {
-  if( this->isServer())
-    PRINT(0)(" Host ist Server with ID: %i\n", this->myHostId);
+  if( this->isMasterServer())
+    PRINT(0)(" Host ist Server with ID: %i\n", this->pInfo->userId);
   else
-    PRINT(0)(" Host ist Client with ID: %i\n", this->myHostId);
+    PRINT(0)(" Host ist Client with ID: %i\n", this->pInfo->userId);
 
   PRINT(0)(" Got %i connected Synchronizeables, showing active Syncs:\n", this->synchronizeables.size());
@@ -385,5 +452,5 @@
                (*it)->getUniqueID(), (*it)->beSynchronized());
   }
-  PRINT(0)(" Maximal Connections: %i\n", MAX_CONNECTIONS );
+  PRINT(0)(" Maximal Connections: %i\n", SharedNetworkData::getInstance()->getMaxPlayer() );
 
 }
@@ -414,17 +481,35 @@
     if ( it->second.handshake )
     {
+      // handshake finished
       if ( it->second.handshake->completed() )
       {
+        //handshake is correct
         if ( it->second.handshake->ok() )
         {
           if ( !it->second.handshake->allowDel() )
           {
-            if ( type != NET_SERVER )
+            if ( this->pInfo->nodeType == NET_CLIENT )
             {
               SharedNetworkData::getInstance()->setHostID( it->second.handshake->getHostId() );
-              myHostId = SharedNetworkData::getInstance()->getHostID();
-
+              this->pInfo->userId = SharedNetworkData::getInstance()->getHostID();
+
+              it->second.nodeType = it->second.handshake->getRemoteNodeType();
+              it->second.ip = it->second.socket->getRemoteAddress();
+              // add the new server to the nodes list (it can be a NET_MASTER_SERVER or NET_PROXY_SERVER)
+              this->networkMonitor->addNode(&it->second);
+              // get proxy 1 address and add it
+              this->networkMonitor->addNode(it->second.handshake->getProxy1Address(), NET_PROXY_SERVER_ACTIVE);
+              PRINTF(0)("proxy1 ip read to: %s\n", it->second.handshake->getProxy1Address().ipString().c_str());
+              // get proxy 2 address and add it
+              this->networkMonitor->addNode(it->second.handshake->getProxy2Address(), NET_PROXY_SERVER_ACTIVE);
+
+              // now check if the server accepted the connection
+              if( it->second.handshake->redirect())
+                this->handleReconnect( it->second.userId);
+
+              // create the new network game manager and init it
               this->networkGameManager = NetworkGameManager::getInstance();
               this->networkGameManager->setUniqueID( it->second.handshake->getNetworkGameManagerId() );
+              // init the new message manager
               MessageManager::getInstance()->setUniqueID( it->second.handshake->getMessageManagerId() );
             }
@@ -437,9 +522,15 @@
           else
           {
+            // handshake finished registring new player
             if ( it->second.handshake->canDel() )
             {
-              if ( type == NET_SERVER )
+              if ( this->pInfo->nodeType == NET_MASTER_SERVER )
               {
-                handleNewClient( it->second.userId );
+                it->second.nodeType = it->second.handshake->getRemoteNodeType();
+                it->second.ip = it->second.socket->getRemoteAddress();
+
+                this->networkMonitor->addNode(&it->second);
+
+                this->handleNewClient( it->second.userId );
 
                 if ( PlayerStats::getStats( it->second.userId ) && it->second.handshake->getPreferedNickName() != "" )
@@ -468,4 +559,33 @@
 
 /**
+ * this functions handles a reconnect event received from the a NET_MASTER_SERVER or NET_PROXY_SERVER
+ */
+void NetworkStream::handleReconnect(int userId)
+{
+  PRINTF(0)("===============================================\n");
+  PRINTF(0)("Client is redirected to the other proxy servers\n");
+  PRINTF(0)("===============================================\n");
+
+  PeerInfo* pInfo = &this->peers[userId];
+
+  // reject the server
+  pInfo->handshake->doReject( "redirected to different server");
+
+  // flush the old synchronization states, since the numbering could be completely different
+  pInfo->lastAckedState = 0;
+  pInfo->lastRecvedState = 0;
+  // not sure if this works as expected
+  if( pInfo->handshake)
+    delete pInfo->handshake;
+
+  // disconnect from the current server and reconnect to proxy server
+  pInfo->socket->reconnectToServer( pInfo->handshake->getProxy1Address().ipString(), pInfo->handshake->getProxy1Address().port());
+
+  // and restart the handshake
+  this->startHandshake();
+}
+
+
+/**
  * handle upstream network traffic
  */
@@ -513,5 +633,5 @@
 
       // if we are a server and this is not our handshake
-      if ( isServer() && sync.getLeafClassID() == CL_HANDSHAKE && sync.getUniqueID() != peer->second.userId )
+      if ( isMasterServer() && sync.getLeafClassID() == CL_HANDSHAKE && sync.getUniqueID() != peer->second.userId )
         continue;
 
@@ -524,5 +644,5 @@
 
       // server fakes uniqueid == 0 for handshake
-      if ( this->isServer() && sync.getUniqueID() < MAX_CONNECTIONS - 1 )
+      if ( this->isMasterServer() && sync.getUniqueID() < SharedNetworkData::getInstance()->getMaxPlayer() - 1 )
         n = Converter::intToByteArray( 0, buf + offset, UDP_PACKET_SIZE - offset );
       else
@@ -573,5 +693,5 @@
     // now compress the data with the zip library
     int compLength = 0;
-    if ( this->isServer() )
+    if ( this->isMasterServer() )
       compLength = Zip::getInstance()->zip( buf, offset, compBuf, UDP_PACKET_SIZE, dictServer );
     else
@@ -637,12 +757,10 @@
       assert( Converter::byteArrayToInt( buf + 2*INTSIZE, &fromState ) == INTSIZE );
       assert( Converter::byteArrayToInt( buf + 3*INTSIZE, &ackedState ) == INTSIZE );
-      //NETPRINTF(n)("ackedstate: %d\n", ackedState);
       offset = 4*INTSIZE;
 
       peer->second.connectionMonitor->processUnzippedIncomingPacket( tick, buf, packetLength, state, ackedState );
 
-      //NETPRINTF(n)("got packet: %d, %d\n", length, packetLength);
-
-    //if this is an old state drop it
+
+      //if this is an old state drop it
       if ( state <= peer->second.lastRecvedState )
         continue;
@@ -688,5 +806,5 @@
           }
 
-          if ( !peers[peer->second.userId].isServer )
+          if ( !peers[peer->second.userId].isMasterServer() )
           {
             offset += syncDataLength;
@@ -779,12 +897,16 @@
 /**
  * is executed when a handshake has finished
- * @todo create playable for new user
  */
 void NetworkStream::handleNewClient( int userId )
 {
+  // init and assign the message manager
   MessageManager::getInstance()->initUser( userId );
-
+  // do all game relevant stuff here
   networkGameManager->signalNewPlayer( userId );
-}
+
+  // register the new client at the network monitor
+//   this->networkMonitor->addClient();
+}
+
 
 /**
Index: branches/proxy/src/lib/network/network_stream.h
===================================================================
--- branches/proxy/src/lib/network/network_stream.h	(revision 9346)
+++ branches/proxy/src/lib/network/network_stream.h	(revision 9347)
@@ -14,6 +14,9 @@
 #include "server_socket.h"
 #include "handshake.h"
-#include "connection_monitor.h"
+#include "monitor/connection_monitor.h"
 #include "udp_server_socket.h"
+#include "peer_info.h"
+
+#include "shared_network_data.h"
 
 class Synchronizeable;
@@ -21,22 +24,6 @@
 class ServerSocket;
 class NetworkGameManager;
+class NetworkMonitor;
 
-//!< this structure contains informations about the network node
-class PeerInfo
-{
-  public:
-    PeerInfo() { clear(); }
-    void clear() { userId = 0; isServer = false; socket = NULL; handshake = NULL; lastAckedState = 0; lastRecvedState = 0; connectionMonitor = NULL; }
-
-
-  public:
-    int                 userId;
-    bool                isServer;
-    NetworkSocket *     socket;
-    Handshake *         handshake;
-    ConnectionMonitor * connectionMonitor;
-    int                 lastAckedState;
-    int                 lastRecvedState;
-};
 
 typedef std::list<Synchronizeable*>  SynchronizeableList;
@@ -58,33 +45,49 @@
     void startHandshake();
 
+    /* synchronizeable interface */
     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; }
+    /* functions for the localhost settings */
+    inline bool isMasterServer() const { return (this->pInfo->nodeType == NET_MASTER_SERVER)? true:false; }
+    inline bool isProxyServer() const { return (this->pInfo->nodeType == NET_PROXY_SERVER_ACTIVE)? true:false; }
+    inline bool isClient() const { return (this->pInfo->nodeType == NET_CLIENT)? true:false; }
+//     inline bool isActive() const { return this->bActive; }
+    inline int getMaxConnections(){ return SharedNetworkData::getInstance()->getMaxPlayer(); }
 
-    inline int getMaxConnections(){ return MAX_CONNECTIONS; }
+    /* functions for the peerInfo information retreival */
+    inline bool isUserIdActive( int userID ) { return (peers.find(userID) != peers.end()); }
+    inline bool isUserMasterServer( int userID ){ if ( !isUserIdActive(userID) ) return false; return peers[userID].isMasterServer(); }
+    inline bool isUserProxyServer( int userID ){ if ( !isUserIdActive(userID) ) return false; return peers[userID].isProxyServer(); }
+    inline bool isUserClient( int userID ){ if ( !isUserIdActive(userID) ) return false; return peers[userID].isClient(); }
 
+    /* peering interface */
+    inline PeerInfo & getPeerInfo( int userId ) { return peers[userId]; }
+    inline PeerInfo* getPeerInfo() { return this->pInfo; }
+    inline PeerList getPeerInfoList() { return this->peers; }
+
+    /* data processing*/
     virtual void processData();
+
+    /* debugging */
+    void debug();
+
+
+  private:
 
     inline SynchronizeableList::const_iterator getSyncBegin(){ return synchronizeables.begin(); }
     inline SynchronizeableList::const_iterator getSyncEnd(){ return synchronizeables.end(); }
+    void cleanUpOldSyncList();
     int getSyncCount();
 
-    inline bool isUserIdActive( int userID ) { return (peers.find(userID) != peers.end()); }
-    inline bool isUserServer( int userID ){ if ( !isUserIdActive(userID) ) return false; return peers[userID].isServer; }
-
-    void debug();
-
-    inline PeerInfo & getPeerInfo( int userId ) { return peers[userId]; }
-
-
-  private:
     void updateConnectionList();
+    /* handle processes */
     void handleHandshakes();
     void handleUpstream( int tick );
     void handleDownstream(int tick );
+
+    /* handle events*/
     void handleNewClient( int userId );
-    void cleanUpOldSyncList();
+    void handleReconnect( int userId );
 
     void writeToNewDict( byte * data, int length, bool upstream );
@@ -92,26 +95,24 @@
 
   private:
-    SynchronizeableList        synchronizeables;
-    PeerList                   peers;
-    ServerSocket*              serverSocket;
-    int                        type;
-    bool                       bActive;
-    std::list<int>             freeSocketSlots;
+    PeerList                   peers;                       //!< list of the network node informations
 
-    int                        myHostId;
+    PeerInfo*                  pInfo;                       //!< the info about the local peer node (not in the PeerList)
 
+    std::list<int>             freeSocketSlots;             //!< list of free sockets (to ensure not to resycle sockets)
     int                        currentState;                //!< current state id
 
-    NetworkGameManager*        networkGameManager;
+    NetworkMonitor*            networkMonitor;              //!< the network monitor
+    NetworkGameManager*        networkGameManager;          //!< reference to the network game manager
+    ServerSocket*              serverSocket;                //!< the listening socket of the server
 
     std::map<int,int>          oldSynchronizeables;         //!< used to save recently deleted sync ids to not recreate them
+    SynchronizeableList        synchronizeables;            //!< list of the synchronizeables
 
     byte                       buf[UDP_PACKET_SIZE];        //!< used by handleUp/Downstream
     byte                       compBuf[UDP_PACKET_SIZE];    //!< used by handleUp/Downstream
-
     int                        remainingBytesToWriteToDict; //!< if > 0 NetworkStream will write packets to DATA/dicts/newdict
 
-    int dictServer;
-    int dictClient;
+    int                        dictServer;                  //!< the zip dict for the server
+    int                        dictClient;                  //!< the zip dict for the client
 };
 #endif /* _NETWORK_STREAM */
Index: branches/proxy/src/lib/network/peer_info.cc
===================================================================
--- branches/proxy/src/lib/network/peer_info.cc	(revision 9347)
+++ branches/proxy/src/lib/network/peer_info.cc	(revision 9347)
@@ -0,0 +1,71 @@
+/*
+   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 Renner rennerc@ee.ethz.ch
+   co-programmer:   Patrick Boenzli  boenzlip@orxonox.ethz.ch
+
+     June 2006: finishing work on the network stream for pps presentation (rennerc@ee.ethz.ch)
+     July 2006: some code rearangement and integration of the proxy server mechanism (boenzlip@ee.ethz.ch)
+*/
+
+
+#define DEBUG_MODULE_NETWORK
+
+
+#include "peer_info.h"
+
+
+using namespace std;
+
+
+
+/**
+ * constructor
+ */
+PeerInfo::PeerInfo()
+{
+  this->clear();
+}
+
+
+/**
+ * clearint and initializing the peer info
+ */
+void PeerInfo::clear()
+{
+  this->userId = 0;
+  this->nodeType = NET_CLIENT;
+  this->socket = NULL;
+  this->handshake = NULL;
+  this->lastAckedState = 0;
+  this->lastRecvedState = 0;
+  this->connectionMonitor = NULL;
+
+  this->ip = IP(0,0);
+}
+
+
+std::string PeerInfo::getNodeTypeString()
+{
+  switch( this->nodeType)
+  {
+    case NET_CLIENT:
+      return std::string("client");
+    case NET_PROXY_SERVER_ACTIVE:
+      return std::string("proxy server active");
+    case NET_PROXY_SERVER_PASSIVE:
+      return std::string("proxy server passive");
+    case NET_MASTER_SERVER:
+      return std::string("master server");
+  }
+
+  return std::string("node is uninit");
+}
Index: branches/proxy/src/lib/network/peer_info.h
===================================================================
--- branches/proxy/src/lib/network/peer_info.h	(revision 9347)
+++ branches/proxy/src/lib/network/peer_info.h	(revision 9347)
@@ -0,0 +1,46 @@
+/*!
+ * @file peer_info.h
+ *  implementation a peer info
+ */
+
+#ifndef _PEER_INFO_H
+#define _PEER_INFO_H
+
+#include "server_socket.h"
+#include "handshake.h"
+#include "monitor/connection_monitor.h"
+
+#include <string>
+
+//!< this structure contains informations about the network node
+class PeerInfo
+{
+  public:
+    PeerInfo();
+
+    void clear();
+
+
+    inline bool isMasterServer() { return this->nodeType == NET_MASTER_SERVER; }
+    inline bool isProxyServer() { return this->nodeType == NET_PROXY_SERVER_ACTIVE; }
+    inline bool isClient() { return this->nodeType == NET_CLIENT; }
+
+    std::string getNodeTypeString();
+
+
+  public:
+    int                 userId;
+    int                 nodeType;
+    IP                  ip;
+
+    NetworkSocket *     socket;
+    Handshake *         handshake;
+    ConnectionMonitor * connectionMonitor;
+
+    int                 lastAckedState;
+    int                 lastRecvedState;
+};
+
+
+
+#endif /* _PEER_INFO_H */
Index: branches/proxy/src/lib/network/player_stats.cc
===================================================================
--- branches/proxy/src/lib/network/player_stats.cc	(revision 9346)
+++ branches/proxy/src/lib/network/player_stats.cc	(revision 9347)
@@ -38,5 +38,5 @@
 {
   init();
-  
+
   this->userId = userId;
 }
@@ -62,5 +62,5 @@
   this->nickName = "Player";
   this->oldNickName = "Player";
-  
+
   userId_handle = registerVarId( new SynchronizeableInt( &userId, &userId, "userId" ) );
   teamId_handle = registerVarId( new SynchronizeableInt( &teamId, &teamId, "teamId" ) );
@@ -71,7 +71,7 @@
   modelFileName_handle = registerVarId( new SynchronizeableString( &modelFileName, &modelFileName, "modelFileName" ) );
   nickName_handler = registerVarId( new SynchronizeableString( &nickName, &nickName, "nickName" ) );
-  
+
   MessageManager::getInstance()->registerMessageHandler( MSGID_CHANGENICKNAME, changeNickHandler, NULL );
-  
+
   PRINTF(0)("PlayerStats created\n");
 }
@@ -96,8 +96,8 @@
   {
     this->setPlayableUniqueId( this->playableUniqueId );
-    
+
     PRINTF(0)("uniqueID changed %d %d %d\n", userId, SharedNetworkData::getInstance()->getHostID(), getUniqueID());
   }
-  
+
   if ( std::find( id.begin(), id.end(), nickName_handler ) != id.end() )
   {
@@ -115,10 +115,10 @@
 {
   const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS );
-  
+
   if ( !list )
   {
     return NULL;
   }
-  
+
   for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
   {
@@ -128,5 +128,5 @@
     }
   }
-  
+
   return NULL;
 }
@@ -138,5 +138,5 @@
 {
   const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYABLE );
-  
+
   if ( !list )
   {
@@ -144,5 +144,5 @@
     return;
   }
-  
+
   this->playable = NULL;
   for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
@@ -156,10 +156,10 @@
     }
   }
-  
+
   if ( this->playable && userId == SharedNetworkData::getInstance()->getHostID() )
   {
     State::getPlayer()->setPlayable( this->playable );
   }
-  
+
   this->playableUniqueId = uniqueId;
 }
@@ -173,11 +173,11 @@
   if ( playable )
     return playable;
-  
+
   assert( playableUniqueId > 0 );
-  
+
   setPlayableUniqueId( playableUniqueId );
-  
+
   assert( playable );
-  
+
   return playable;
 }
@@ -189,5 +189,5 @@
 void PlayerStats::setNickName( std::string nick )
 {
-  if ( SharedNetworkData::getInstance()->isGameServer() )
+  if ( SharedNetworkData::getInstance()->isMasterServer() )
   {
     this->nickName = nick;
@@ -199,7 +199,7 @@
   {
     byte * data = new byte[nick.length()+INTSIZE];
-    
+
     assert( Converter::stringToByteArray( nick, data, nick.length()+INTSIZE) == nick.length()+INTSIZE );
-    
+
     MessageManager::getInstance()->sendMessage( MSGID_CHANGENICKNAME, data, nick.length()+INTSIZE, RT_SERVER, 0, MP_HIGHBANDWIDTH );
     return;
@@ -211,5 +211,5 @@
   std::string newNick;
   int res = Converter::byteArrayToString( data, newNick, dataLength );
-  
+
   if ( res != dataLength )
   {
@@ -217,8 +217,8 @@
     newNick = "invalid";
   }
-  
+
   if ( PlayerStats::getStats( userId ) )
     PlayerStats::getStats( userId )->setNickName( newNick );
-  
+
   return true;
 }
@@ -228,5 +228,5 @@
   if ( getStats( SharedNetworkData::getInstance()->getHostID() ) )
     getStats( SharedNetworkData::getInstance()->getHostID() )->setNickName( newNick );
-    
+
   Preferences::getInstance()->setString( "multiplayer", "nickname", newNick );
 }
@@ -237,5 +237,5 @@
 {
   const std::list<BaseObject*> * list;
-  
+
   while ( (list  = ClassList::getList( CL_PLAYER_STATS )) != NULL && list->begin() != list->end() )
     delete *list->begin();
@@ -247,30 +247,30 @@
 {
   ScoreList result;
-  
+
   const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS );
-  
+
   if ( !list )
   {
     return result;
   }
-  
+
   for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
   {
     PlayerStats & stats = *dynamic_cast<PlayerStats*>(*it);
-    
+
     TeamScoreList::iterator it = result[stats.getTeamId()].begin();
-    
+
     while (  it != result[stats.getTeamId()].end() && stats.score > it->score )
     {
       it++;
     }
-    
+
     PlayerScore score;
     score.name = stats.getNickName();
     score.score = stats.getScore();
-    
+
     result[stats.getTeamId()].insert(it, score);
   }
-  
+
   return result;
 }
Index: branches/proxy/src/lib/network/proxy/proxy_settings.cc
===================================================================
--- branches/proxy/src/lib/network/proxy/proxy_settings.cc	(revision 9347)
+++ branches/proxy/src/lib/network/proxy/proxy_settings.cc	(revision 9347)
@@ -0,0 +1,97 @@
+/*
+   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
+*/
+
+
+#define DEBUG_MODULE_NETWORK
+
+#include "proxy_settings.h"
+#include "netdefs.h"
+
+#include "loading/load_param.h"
+
+
+using namespace std;
+
+
+ProxySettings* ProxySettings::singletonRef = NULL;
+
+/**
+ * Standard constructor
+ */
+ProxySettings::ProxySettings()
+{
+  /* set the class id for the base object */
+  this->setClassID(CL_PROXY_SETTINGS, "ProxySettings");
+  // suggest a good standard max players value
+  this->maxPlayer = 10;
+}
+
+
+/**
+ * Standard destructor
+ */
+ProxySettings::~ProxySettings()
+{
+  ProxySettings::singletonRef = NULL;
+
+  // remove all unused proxy data again
+  for( int i = 0; i < this->proxies.size(); i++)
+  {
+    IPaddress* ip = this->proxies.back();
+    this->proxies.pop_back();
+    delete ip;
+  }
+}
+
+
+
+/**
+ * load the proxy settings
+ * @param root: the root element of the xml elemnts
+ */
+void ProxySettings::loadProxySettings(const TiXmlElement* root)
+{
+
+  LoadParam(root, "max-player", this, ProxySettings, setMaxPlayer);
+
+  LOAD_PARAM_START_CYCLE(root, element);
+  {
+    element->ToText();
+    // PER-PARTICLE-ATTRIBUTES:
+    LoadParam(root, "proxy-addr", this, ProxySettings, setProxyAddr);
+  }
+  LOAD_PARAM_END_CYCLE(element);
+
+}
+
+
+/**
+ * sets the proxy address to
+ *  @param proxyAddr: the proxy address
+ */
+void ProxySettings::setProxyAddr(const std::string& proxyAddr)
+{
+  IPaddress *ip = new IPaddress;
+
+  SDLNet_ResolveHost( ip, proxyAddr.c_str(), 9999 );
+
+  this->proxies.push_back(ip);
+}
+
+
+
+
+
+
+
Index: branches/proxy/src/lib/network/proxy/proxy_settings.h
===================================================================
--- branches/proxy/src/lib/network/proxy/proxy_settings.h	(revision 9347)
+++ branches/proxy/src/lib/network/proxy/proxy_settings.h	(revision 9347)
@@ -0,0 +1,54 @@
+/*!
+ * @file proxy_settings.h
+ *  some shared data from the proxy settings
+ */
+
+#ifndef _PROXY_SETTINGS_H
+#define _PROXY_SETTINGS_H
+
+#include "base_object.h"
+#include "netdefs.h"
+
+#include <vector>
+
+
+class NetworkStream;
+class Synchronizeable;
+class TiXmlElement;
+
+
+/* and here is the class itsself*/
+class ProxySettings : public BaseObject
+{
+
+  public:
+    inline static ProxySettings* getInstance() { if (!ProxySettings::singletonRef) ProxySettings::singletonRef = new ProxySettings();
+      return ProxySettings::singletonRef; }
+    virtual ~ProxySettings();
+
+    void loadProxySettings(const TiXmlElement* root);
+
+    /** @param number: sets the max number of players */
+    inline void setMaxPlayer(int number) { this->maxPlayer = number; }
+    /** @returns teh max number of players */
+    int getMaxPlayer() { return this->maxPlayer; }
+    void setProxyAddr(const std::string& proxyAddr);
+
+    /** @returns the list of proxy servers from the init file */
+    inline std::vector<IPaddress*>* getProxyList() { return &this->proxies; }
+
+
+  private:
+    ProxySettings();
+
+
+  private:
+    static ProxySettings*        singletonRef;            //!< Pointer to the only instance of this Class
+    int                          maxPlayer;               //!< maximal number of players
+    std::vector<IPaddress*>      proxies;                 //!< all registered proxies
+
+};
+
+
+
+#endif /* _PROXY_SETTINGS_H */
Index: branches/proxy/src/lib/network/shared_network_data.cc
===================================================================
--- branches/proxy/src/lib/network/shared_network_data.cc	(revision 9346)
+++ branches/proxy/src/lib/network/shared_network_data.cc	(revision 9347)
@@ -35,6 +35,6 @@
   this->hostID = -1;
   this->defaultSyncStream = NULL;
-  this->newUniqueID = MAX_CONNECTIONS + 2;
-  this->bGameServer = false;
+  this->newUniqueID = NET_MAX_CONNECTIONS + 2;
+  this->nodeType = NET_CLIENT;
 }
 
Index: branches/proxy/src/lib/network/shared_network_data.h
===================================================================
--- branches/proxy/src/lib/network/shared_network_data.h	(revision 9346)
+++ branches/proxy/src/lib/network/shared_network_data.h	(revision 9347)
@@ -8,10 +8,11 @@
 
 #include "base_object.h"
+#include "netdefs.h"
+#include "proxy/proxy_settings.h"
 
 
 class NetworkStream;
 class Synchronizeable;
-template<typename>
-    class tList;
+
 
 /* and here is the class itsself*/
@@ -25,10 +26,17 @@
 
     /** @returns the next uniqueID free for an object */
-    inline int getNewUniqueID() { return ( this->bGameServer)?this->newUniqueID++:-1; }
+    inline int getNewUniqueID() { return ( this->nodeType != NET_CLIENT)?this->newUniqueID++:-1; }
 
-    /** @returns true is this node is a game server */
-    inline bool isGameServer() { return this->bGameServer; }
+    /** @returns true is this node is a master server */
+    inline bool isMasterServer() { return this->nodeType == NET_MASTER_SERVER; }
+    /** @returns true is this node is a proxy server */
+    inline bool isProxyServer() { return this->nodeType == NET_PROXY_SERVER_ACTIVE; }
+    /** @returns true is this node is a client*/
+    inline bool isClient() { return this->nodeType == NET_CLIENT; }
     /** sets the game server flag @param bGameServer true if it is a game server */
-    inline void setGameServer(bool bGameServer) { this->bGameServer = bGameServer; }
+    inline void setNodeType(int nodeType) { this->nodeType = nodeType; }
+
+    /** @returns the maximum number of players for this server */
+    inline int getMaxPlayer() { return ProxySettings::getInstance()->getMaxPlayer(); }
 
     /** @returns the hostID of the node */
@@ -49,5 +57,6 @@
   private:
     int                             newUniqueID;             //!< next uniqueID
-    bool                            bGameServer;             //!< true if it is a server
+    int                             nodeType;                //!< saves the node type here
+
     int                             hostID;                  //!< The Host-ID of the Manager
     NetworkStream*                  defaultSyncStream;       //!< default synchronize NetworkStream
Index: branches/proxy/src/lib/network/synchronizeable.cc
===================================================================
--- branches/proxy/src/lib/network/synchronizeable.cc	(revision 9346)
+++ branches/proxy/src/lib/network/synchronizeable.cc	(revision 9347)
@@ -38,9 +38,9 @@
   this->setClassID(CL_SYNCHRONIZEABLE, "Synchronizeable");
   this->owner = 0;
-  this->setIsServer(SharedNetworkData::getInstance()->getHostID() == 0);
+//   this->setIsServer(SharedNetworkData::getInstance()->getHostID() == 0);
   this->uniqueID = NET_UID_UNASSIGNED;
   this->networkStream = NULL;
   this->bSynchronize = false;
-  
+
   if( State::isOnline())
   {
@@ -54,5 +54,5 @@
   assert( syncVarList.size() == 0 );
   mLeafClassId = this->registerVarId( new SynchronizeableInt( (int*)&this->getLeafClassID(), (int*)&this->getLeafClassID(), "leafClassId" ) );
-    
+
   this->registerVar( new SynchronizeableInt( &this->owner, &this->owner, "owner" ) );
   this->registerVar( new SynchronizeableString( &this->objectName, &this->objectName, "objectName" ) );
@@ -69,9 +69,9 @@
   {
     this->networkStream->disconnectSynchronizeable(*this);
-  
-    if ( this->isServer() && this->beSynchronized() && this->getUniqueID() > 0 && !this->isA( CL_MESSAGE_MANAGER ) )
+
+    if ( SharedNetworkData::getInstance()->isMasterServer() && this->beSynchronized() && this->getUniqueID() > 0 && !this->isA( CL_MESSAGE_MANAGER ) )
       NetworkGameManager::getInstance()->removeSynchronizeable( this->getUniqueID() );
   }
-    
+
   for ( SyncVarList::iterator it = syncVarList.begin(); it != syncVarList.end(); it++ )
   {
@@ -79,5 +79,5 @@
   }
   syncVarList.clear();
-  
+
   for ( UserStateHistory::iterator it = recvStates.begin(); it != recvStates.end(); it++ )
   {
@@ -93,5 +93,5 @@
 
   }
-  
+
   for ( UserStateHistory::iterator it = sentStates.begin(); it != sentStates.end(); it++ )
   {
@@ -105,28 +105,5 @@
       delete *it2;
     }
-
-  }
-}
-
-/**
- * Sets the server flag to a given value
- * @param isServer: the boolean value which the server flag is to set to
- */
-void Synchronizeable::setIsServer(bool isServer)
-{
-  if( isServer )
-    this->state = this->state | STATE_SERVER;
-  else
-    this->state = this->state & (~STATE_SERVER);
-}
-
-
-/**
- * Determines if the server flag is set
- * @return true, if the server flag is true, false else
- */
-bool Synchronizeable::isServer()
-{
-  return (this->state & STATE_SERVER) >0;
+  }
 }
 
@@ -169,5 +146,5 @@
         (*it2)->data = NULL;
       }
-      
+
       delete *it2;
     }
@@ -181,9 +158,4 @@
   while ( it != sentStates[userId].end() && (*it)->stateId != fromStateId )
     it++;
-  
-//  if ( getLeafClassID() == CL_SPACE_SHIP )
-//  {
-//    PRINTF(0)("getStateDiff:SpaceShip from: %d stateId: %d\n", (it == sentStates[userId].end())?-1:fromStateId, stateId);
-//  }
 
   if ( it == sentStates[userId].end() )
@@ -196,5 +168,5 @@
 
     stateFrom = initialEntry;
-    
+
     sentStates[userId].push_back( stateFrom );
   }
@@ -205,5 +177,5 @@
 
   sentStates[userId].push_back( stateTo );
-  
+
   stateTo->stateId = stateId;
   stateTo->dataLength = neededSize;
@@ -214,5 +186,5 @@
   int i = 0;
   int n;
-  
+
   bool hasPermission;
   bool sizeChanged = false;
@@ -222,13 +194,13 @@
   {
     hasPermission = (
-            this->isServer() && (*it)->checkPermission( PERMISSION_SERVER ) ||
+        SharedNetworkData::getInstance()->isMasterServer() && (*it)->checkPermission( PERMISSION_MASTER_SERVER ) ||
         this->owner == SharedNetworkData::getInstance()->getHostID() && (*it)->checkPermission( PERMISSION_OWNER ) ||
-            this->isServer() && this->owner != userId && (*it)->checkPermission( PERMISSION_OWNER ) ||
-            (*it)->checkPermission( PERMISSION_ALL ) 
+        SharedNetworkData::getInstance()->isMasterServer() && this->owner != userId && (*it)->checkPermission( PERMISSION_OWNER ) ||
+            (*it)->checkPermission( PERMISSION_ALL )
                     );
-    
-    if ( sizeIter == stateFrom->sizeList.end() || *sizeIter != (*it)->getSize() ) 
+
+    if ( sizeIter == stateFrom->sizeList.end() || *sizeIter != (*it)->getSize() )
       sizeChanged = true;
-    
+
     if ( ( hasPermission && (*it)->getPriority() >= priorityTH ) || sizeChanged )
     {
@@ -303,5 +275,5 @@
     it++;
 
-  
+
 //  if ( getLeafClassID() == CL_SPACE_SHIP )
 //  {
@@ -318,10 +290,10 @@
 
     stateFrom = initialEntry;
-    
+
     recvStates[userId].push_back( stateFrom );
   }
   else
     stateFrom = (*it);
-  
+
   //apply diff
   for ( int i = 0; i<length; i++ )
@@ -331,21 +303,21 @@
     else
       stateTo->data[i] = data[i];
-    
-  }
-  
+
+  }
+
   //add state to state history
   recvStates[userId].push_back( stateTo );
-  
+
   int i = 0;
   int n = 0;
   std::list<int> changes;
-  
+
   for ( SyncVarList::iterator it = syncVarList.begin(); it != syncVarList.end(); it++ )
   {
     if (
-        (*it)->checkPermission( PERMISSION_SERVER ) && networkStream->isUserServer( userId ) ||
+        (*it)->checkPermission( PERMISSION_MASTER_SERVER ) && networkStream->isUserMasterServer( userId ) ||
         (*it)->checkPermission( PERMISSION_OWNER ) && this->owner == userId ||
-        networkStream->isUserServer( userId ) && this->owner != SharedNetworkData::getInstance()->getHostID() && (*it)->checkPermission( PERMISSION_OWNER ) ||
-        (*it)->checkPermission( PERMISSION_ALL ) 
+        networkStream->isUserMasterServer( userId ) && this->owner != SharedNetworkData::getInstance()->getHostID() && (*it)->checkPermission( PERMISSION_OWNER ) ||
+        (*it)->checkPermission( PERMISSION_ALL )
        )
     {
@@ -361,5 +333,5 @@
     else
     {
-//      PRINTF(0)("DONT SET VAR BECAUSE OF PERMISSION: %s %d %d %d %d %d %d\n", (*it)->getName().c_str(), (*it)->checkPermission( PERMISSION_SERVER ), (*it)->checkPermission( PERMISSION_OWNER ), (*it)->checkPermission( PERMISSION_ALL ), networkStream->isUserServer( userId ), this->owner, userId );
+//      PRINTF(0)("DONT SET VAR BECAUSE OF PERMISSION: %s %d %d %d %d %d %d\n", (*it)->getName().c_str(), (*it)->checkPermission( PERMISSION_MASTER_SERVER ), (*it)->checkPermission( PERMISSION_OWNER ), (*it)->checkPermission( PERMISSION_ALL ), networkStream->isUserServer( userId ), this->owner, userId );
       n = (*it)->getSizeFromBuf( stateTo->data + i, stateTo->dataLength - i );
       //NETPRINTF(0)("%s::setvar %s %d\n", getClassName(), (*it)->getName().c_str(), n);
@@ -370,5 +342,5 @@
 
   this->varChangeHandler( changes );
-  
+
   return i;
 }
@@ -423,13 +395,13 @@
         (*it)->data = NULL;
       }
-    
+
       delete *it;
     }
     recvStates[userId].clear();
   }
- 
+
   if ( sentStates.size() > userId )
   {
-    
+
     for ( std::list<StateHistoryEntry*>::iterator it = sentStates[userId].begin(); it != sentStates[userId].end(); it++ )
     {
@@ -439,5 +411,5 @@
         (*it)->data = NULL;
       }
-    
+
       delete *it;
     }
@@ -448,7 +420,7 @@
 /**
  * this function is called after recieving a state.
- * @param userId 
- * @param stateId 
- * @param fromStateId 
+ * @param userId
+ * @param stateId
+ * @param fromStateId
  */
 void Synchronizeable::handleRecvState( int userId, int stateId, int fromStateId )
@@ -457,5 +429,5 @@
   if ( recvStates.size() <= userId )
     recvStates.resize( userId+1 );
-  
+
   //remove old states
   StateHistory::iterator it = recvStates[userId].begin();
@@ -485,5 +457,5 @@
       StateHistory::iterator delIt = it;
       it ++;
-      
+
       if ( (*delIt)->data )
       {
@@ -493,13 +465,13 @@
       delete *delIt;
       recvStates[userId].erase( delIt );
-      
+
       continue;
     }
     it++;
   }
-  
+
   StateHistory::iterator fromState = recvStates[userId].end();
   StateHistory::iterator toState = recvStates[userId].end();
-  
+
   for ( it = recvStates[userId].begin(); it != recvStates[userId].end(); it++ )
   {
@@ -508,19 +480,19 @@
     if ( (*it)->stateId == fromStateId )
       fromState = it;
-    
+
     if ( fromState != recvStates[userId].end() && toState != recvStates[userId].end() )
       break;
   }
-  
+
   // setStateDiff was not called and i know fromStateId
   if ( fromState != recvStates[userId].end() && toState == recvStates[userId].end() )
   {
     StateHistoryEntry * entry = new StateHistoryEntry;
-    
+
     entry->dataLength = (*fromState)->dataLength;
     if ( entry->dataLength > 0 )
     {
       entry->data = new byte[entry->dataLength];
-          
+
       assert( (*fromState)->data );
       memcpy( entry->data, (*fromState)->data, entry->dataLength );
@@ -528,8 +500,8 @@
     else
       entry->data = NULL;
-    
+
     entry->sizeList = (*fromState)->sizeList;
     entry->stateId = stateId;
-    
+
     recvStates[userId].push_back(entry);
   }
@@ -538,7 +510,7 @@
 /**
  * this function is called after sending a state
- * @param userId 
- * @param stateId 
- * @param fromStateId 
+ * @param userId
+ * @param stateId
+ * @param fromStateId
  */
 void Synchronizeable::handleSentState( int userId, int stateId, int fromStateId )
@@ -557,5 +529,5 @@
       StateHistory::iterator delIt = it;
       it ++;
-      
+
       if ( (*delIt)->data )
       {
@@ -565,5 +537,5 @@
       delete *delIt;
       sentStates[userId].erase( delIt );
-      
+
       continue;
     }
@@ -571,8 +543,8 @@
   }
 
-  
+
   StateHistory::iterator fromState = sentStates[userId].end();
   StateHistory::iterator toState = sentStates[userId].end();
-  
+
   for ( it = sentStates[userId].begin(); it != sentStates[userId].end(); it++ )
   {
@@ -581,20 +553,20 @@
     if ( (*it)->stateId == fromStateId )
       fromState = it;
-    
+
     if ( fromState != sentStates[userId].end() && toState != sentStates[userId].end() )
       break;
   }
 
-  
+
   // getStateDiff was not called and i know fromStateId
   if ( fromState != sentStates[userId].end() && toState == sentStates[userId].end() )
   {
     StateHistoryEntry * entry = new StateHistoryEntry;
-    
+
     entry->dataLength = (*fromState)->dataLength;
     if ( entry->dataLength > 0 )
     {
       entry->data = new byte[entry->dataLength];
-      
+
       assert( (*fromState)->data );
       memcpy( entry->data, (*fromState)->data, entry->dataLength );
@@ -602,13 +574,13 @@
     else
       entry->data = NULL;
-    
+
     entry->sizeList = (*fromState)->sizeList;
     entry->stateId = stateId;
-    
+
     sentStates[userId].push_back(entry);
   }
-  
-}
-
-
-
+
+}
+
+
+
Index: branches/proxy/src/lib/network/synchronizeable.h
===================================================================
--- branches/proxy/src/lib/network/synchronizeable.h	(revision 9346)
+++ branches/proxy/src/lib/network/synchronizeable.h	(revision 9347)
@@ -20,4 +20,5 @@
 #include "synchronizeable_var/synchronizeable_bool.h"
 #include "synchronizeable_var/synchronizeable_uint.h"
+#include "synchronizeable_var/synchronizeable_ip.h"
 
 
@@ -51,6 +52,6 @@
     virtual ~Synchronizeable();
 
-    void setIsServer( bool isServer );
-    bool isServer();
+//     void setIsServer( bool isServer );
+//     bool isServer();
 
     virtual void varChangeHandler( std::list<int> & id );
@@ -61,5 +62,5 @@
     virtual void handleSentState( int userId, int stateId, int fromStateId );
     virtual void handleRecvState( int userId, int stateId, int fromStateId );
-    
+
     void registerVar( SynchronizeableVar * var );
     int registerVarId( SynchronizeableVar * var );
@@ -82,5 +83,5 @@
   protected:
     NetworkStream*    networkStream;  //!< reference network stream we are connected to
-    int               state;
+//     int               state;
 
   private:
Index: branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_bool.h
===================================================================
--- branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_bool.h	(revision 9346)
+++ branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_bool.h	(revision 9347)
@@ -12,5 +12,5 @@
 
   public:
-    SynchronizeableBool( bool * ptrIn, bool * ptrOut, std::string name, int permission = PERMISSION_SERVER, int priority = 0 );
+    SynchronizeableBool( bool * ptrIn, bool * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
     virtual ~SynchronizeableBool();
     
Index: branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_float.h
===================================================================
--- branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_float.h	(revision 9346)
+++ branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_float.h	(revision 9347)
@@ -12,5 +12,5 @@
 
   public:
-    SynchronizeableFloat( float * ptrIn, float * ptrOut, std::string name, int permission = PERMISSION_SERVER, int priority = 0 );
+    SynchronizeableFloat( float * ptrIn, float * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
     virtual ~SynchronizeableFloat();
     
Index: branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_int.h
===================================================================
--- branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_int.h	(revision 9346)
+++ branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_int.h	(revision 9347)
@@ -12,5 +12,5 @@
 
   public:
-    SynchronizeableInt( int * ptrIn, int * ptrOut, std::string name, int permission = PERMISSION_SERVER, int priority = 0 );
+    SynchronizeableInt( int * ptrIn, int * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
     virtual ~SynchronizeableInt();
     
Index: branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_ip.cc
===================================================================
--- branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_ip.cc	(revision 9347)
+++ branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_ip.cc	(revision 9347)
@@ -0,0 +1,106 @@
+/*
+   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
+*/
+
+
+#include "synchronizeable_ip.h"
+#include "converter.h"
+// #include "ip.h"
+
+/**
+ * standard constructor
+ * @todo this constructor is not jet implemented - do it
+*/
+SynchronizeableIP::SynchronizeableIP( IP * ptrIn, IP * ptrOut, std::string name, int permission, int priority) : SynchronizeableVar( ptrIn, ptrOut, name, 2*INTSIZE, permission, priority )
+{
+  this->vPtrIn = ptrIn;
+  this->vPtrOut = ptrOut;
+}
+
+
+/**
+ * standard deconstructor
+*/
+SynchronizeableIP::~SynchronizeableIP ()
+{
+}
+
+/**
+ * write var data to byte buffer
+ * @param buf pointer to write to
+ * @param maxLength writeToBuf will not write more than maxLength bytes
+ * @return number bytes written
+ */
+int SynchronizeableIP::writeToBuf( byte * buf, int maxLength )
+{
+  int n = 0;
+  int res;
+
+  res = Converter::intToByteArray( (int)vPtrIn->host(), buf, maxLength );
+  assert(res > 0);
+  n += res;
+
+  res = Converter::intToByteArray( (int)vPtrIn->port(), buf, maxLength);
+  assert(res > 0);
+  n += res;
+
+  assert( 2 * INTSIZE == n);
+
+  return n;
+}
+
+/**
+ * read var data from byte buffer
+ * @param buf pointer to read from
+ * @param maxLength readFromBuf will not read more than maxLength bytes
+ * @return number bytes read
+ */
+int SynchronizeableIP::readFromBuf( byte * buf, int maxLength )
+{
+  assert( maxLength >= 2 * INTSIZE);
+
+  int host, port;
+
+  int res;
+  int n = 0;
+
+  IP oldVal = *vPtrOut;
+
+  res = Converter::byteArrayToInt( buf + n, &host);
+  assert( res > 0);
+  n += res;
+
+
+  res = Converter::byteArrayToInt( buf + n, &port);
+  assert( res > 0);
+  n += res;
+
+  *this->vPtrOut = IP(host, port);
+
+  printf(" vtrp out old: %i, %i -- new: %i, %i\n", oldVal.host(), oldVal.port(), this->vPtrOut->host(), this->vPtrOut->port());
+  setHasChanged( *this->vPtrOut != oldVal);
+
+  assert( n == 2 * INTSIZE);
+
+  return n;
+}
+
+
+/**
+ * print out variable value
+ */
+void SynchronizeableIP::SynchronizeableIP::debug( )
+{
+  printf("SYNCHRONIZEABLE_VAR: %s IN: %i, %i OUT: %i, %i\n", name.c_str(), vPtrIn->host(), vPtrIn->port(), vPtrOut->host(), vPtrOut->port());
+}
+
Index: branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_ip.h
===================================================================
--- branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_ip.h	(revision 9347)
+++ branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_ip.h	(revision 9347)
@@ -0,0 +1,40 @@
+/*!
+ * @file synchronizeable_ip.h
+ * @brief Definition of SynchronizeableIP
+*/
+
+#include "synchronizeable_var/synchronizeable_var.h"
+
+#ifndef _SYNCHRONIZEABLE_IP_H
+#define _SYNCHRONIZEABLE_IP_H
+
+#include "vector.h"
+
+#include "netdefs.h"
+#include "ip.h"
+
+class SynchronizeableIP : public SynchronizeableVar {
+
+  public:
+    SynchronizeableIP( IP *ptrIn, IP * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
+    virtual ~SynchronizeableIP();
+
+    virtual int writeToBuf( byte * buf, int maxLength );
+    virtual int readFromBuf( byte * buf, int maxLength );
+
+    /**
+     * check if writeToBuf will return the same size every time
+     * @return true if same size every time
+     */
+    virtual bool hasStaticSize(){ return true; }
+
+    virtual void debug();
+
+
+  private:
+    IP * vPtrIn;       //!< pointer to data (read)
+    IP * vPtrOut;      //!< pointer to data (write)
+
+};
+
+#endif /* _PROTO_CLASS_H */
Index: branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_quaternion.h
===================================================================
--- branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_quaternion.h	(revision 9346)
+++ branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_quaternion.h	(revision 9347)
@@ -14,5 +14,5 @@
 
   public:
-    SynchronizeableQuaternion( Quaternion * ptrIn, Quaternion * ptrOut, std::string name, int permission = PERMISSION_SERVER, int priority = 0 );
+    SynchronizeableQuaternion( Quaternion * ptrIn, Quaternion * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
     virtual ~SynchronizeableQuaternion();
     
Index: branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_string.h
===================================================================
--- branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_string.h	(revision 9346)
+++ branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_string.h	(revision 9347)
@@ -15,5 +15,5 @@
 
   public:
-    SynchronizeableString( std::string * ptrIn, std::string * ptrOut, std::string name, int permission = PERMISSION_SERVER, int priority = 0 );
+    SynchronizeableString( std::string * ptrIn, std::string * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
     virtual ~SynchronizeableString();
     
Index: branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_uint.h
===================================================================
--- branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_uint.h	(revision 9346)
+++ branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_uint.h	(revision 9347)
@@ -12,5 +12,5 @@
 
   public:
-    SynchronizeableUInt( unsigned int * ptrIn, unsigned int * ptrOut, std::string name, int permission = PERMISSION_SERVER, int priority = 0 );
+    SynchronizeableUInt( unsigned int * ptrIn, unsigned int * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
     virtual ~SynchronizeableUInt();
     
Index: branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_var.h
===================================================================
--- branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_var.h	(revision 9346)
+++ branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_var.h	(revision 9347)
@@ -12,7 +12,8 @@
 
 enum {
-  PERMISSION_SERVER = 1,
-  PERMISSION_OWNER  = 2,
-  PERMISSION_ALL    = 4
+  PERMISSION_MASTER_SERVER = 1,
+  PERMISSION_PROXY_SERVER  = 2,
+  PERMISSION_OWNER         = 4,
+  PERMISSION_ALL           = 8
 };
 
@@ -20,5 +21,5 @@
 
   public:
-    SynchronizeableVar( void * ptrIn, void * ptrOut, std::string name, int length, int permission = PERMISSION_SERVER, int priority = 0 );
+    SynchronizeableVar( void * ptrIn, void * ptrOut, std::string name, int length, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
     virtual ~SynchronizeableVar();
 
@@ -28,6 +29,6 @@
      */
     inline bool beWatched(){ return this->bWatched; }
-    
-    /** 
+
+    /**
      * set flag if synchronizeable wants to be informed on changes
      */
@@ -96,5 +97,5 @@
      */
     inline void resetPriority() { this->priority = this->realPriority; }
-    
+
     /**
      * reads actual size from buffer. this is used when size is not constant
@@ -104,5 +105,5 @@
      */
     virtual inline int getSizeFromBuf( byte * buf, int maxLength ){ return this->getSize(); }
-    
+
     /**
      * set variable id
@@ -110,11 +111,11 @@
      */
     inline void setVarId( int id ){ this->varId = id; }
-    
-    /** 
+
+    /**
      * get variable id
      * @return variable id
      */
     inline int getVarId(){ return varId; }
-    
+
     /**
      * set hasChanged
@@ -122,11 +123,11 @@
      */
     inline void setHasChanged( bool changed ){ this->changed = changed; }
-    
-    /** 
+
+    /**
      * get hasChanged
      * @return variable id
      */
     inline bool getHasChanged(){ return changed; }
-    
+
     /**
      * print out variable value
@@ -137,10 +138,10 @@
   private:
     bool bWatched;      //!< true if synchronizeable wants to be informed on changes
-    
+
     int permission;     //!< who is allowed to change this var
     int priority;       //!< priority assigned to var
     int realPriority;   //!< priority assigned to var, increased every time not sent
     int varId;          //!< id to identify varables
-    
+
     bool changed;       //!< true if last readFromBuf changed anything
 
Index: branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_vector.h
===================================================================
--- branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_vector.h	(revision 9346)
+++ branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_vector.h	(revision 9347)
@@ -14,5 +14,5 @@
 
   public:
-    SynchronizeableVector( Vector * ptrIn, Vector * ptrOut, std::string name, int permission = PERMISSION_SERVER, int priority = 0 );
+    SynchronizeableVector( Vector * ptrIn, Vector * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
     virtual ~SynchronizeableVector();
     
Index: branches/proxy/src/lib/network/tcp_server_socket.cc
===================================================================
--- branches/proxy/src/lib/network/tcp_server_socket.cc	(revision 9346)
+++ branches/proxy/src/lib/network/tcp_server_socket.cc	(revision 9347)
@@ -136,2 +136,3 @@
   _isListening = false;
 }
+
Index: branches/proxy/src/lib/network/tcp_server_socket.h
===================================================================
--- branches/proxy/src/lib/network/tcp_server_socket.h	(revision 9346)
+++ branches/proxy/src/lib/network/tcp_server_socket.h	(revision 9347)
@@ -28,5 +28,5 @@
     virtual void close();
     virtual void update() {};
-    
+
   private:
     TCPsocket listenSocket;
@@ -36,5 +36,5 @@
 
     void init();
- 
+
 };
 
Index: branches/proxy/src/lib/network/tcp_socket.h
===================================================================
--- branches/proxy/src/lib/network/tcp_socket.h	(revision 9346)
+++ branches/proxy/src/lib/network/tcp_socket.h	(revision 9347)
@@ -1,5 +1,5 @@
 /*!
- * @file network_socket.h
-  *  Main interface for the network module. Manages all the modules
+ * @file tcp_socket.h
+  *  tcp socket network interface
 
 */
@@ -47,6 +47,8 @@
 
     virtual void connectToServer( std::string host, int port );
-    
+
     virtual void disconnectServer();
+    virtual void reconnectToServer( std::string host, int port);
+    virtual void reconnectToServerSoft( std::string host, int port);
 
     virtual bool writePacket(byte * data, int length);
Index: branches/proxy/src/lib/network/udp_socket.cc
===================================================================
--- branches/proxy/src/lib/network/udp_socket.cc	(revision 9346)
+++ branches/proxy/src/lib/network/udp_socket.cc	(revision 9347)
@@ -74,4 +74,5 @@
 {
   this->init();
+  this->ip = ip;
   this->serverSocket = serverSocket;
   this->userId = userId;
@@ -105,11 +106,9 @@
   assert( serverSocket == NULL );
 
-  IPaddress ip;
-  
   this->randomByte = generateNewRandomByte();
 
   PRINTF(0)("connect to server %s on port %d\n", host.c_str(), port);
 
-  if ( SDLNet_ResolveHost( &ip, host.c_str(), port ) != 0 )
+  if ( SDLNet_ResolveHost( &this->ip, host.c_str(), port ) != 0 )
   {
     PRINTF(1)("SDLNet_ResolveHost: %s\n", SDLNet_GetError() );
@@ -126,5 +125,5 @@
   }
 
-  int channel = SDLNet_UDP_Bind(socket, 1, &ip);
+  int channel = SDLNet_UDP_Bind(socket, 1, &this->ip);
   if ( channel == -1 )
   {
@@ -147,5 +146,37 @@
   bOk = false;
   socket = NULL;
-}
+
+  this->ip.host = 0;
+  this->ip.port = 0;
+}
+
+
+/**
+ * reconnects to
+ * @param host new server address
+ * @param port new port number
+ *
+ * this terminates the current connection and starts a new connection to the new server
+ */
+void UdpSocket::reconnectToServer( std::string host, int port)
+{
+  // first disconnect the old server
+  this->disconnectServer();
+
+  // now connect to the new
+  this->connectToServer( host, port);
+}
+
+
+/**
+ * reconnects to
+ * @param host new server address
+ * @param port new port number
+ *
+ * this terminates the current connection and starts a new connection to the new server
+ */
+void UdpSocket::reconnectToServerSoft( std::string host, int port)
+{}
+
 
 /**
@@ -179,5 +210,5 @@
 
     byte udpCmd = 0;
-    
+
     if ( networkPacket.length > 0 )
     {
@@ -189,5 +220,5 @@
     else
       return 0;
-      
+
     if ( !checkRandomByte( networkPacket.data[0] ) )
       return 0;
@@ -198,5 +229,5 @@
       networkPacket.data = NULL;
     }
-    
+
     if ( !checkUdpCmd( udpCmd ) )
       return 0;
@@ -207,5 +238,5 @@
   {
     int numrecv = SDLNet_UDP_Recv( socket, packet);
-    
+
     byte udpCmd = 0;
 
@@ -218,8 +249,8 @@
       else
         return 0;
-            
+
       if ( !checkRandomByte( packet->data[0] ) )
         return 0;
-              
+
       if ( !checkUdpCmd( udpCmd ) )
         return 0;
@@ -283,5 +314,5 @@
     return false;
   }
-  
+
   if ( !this->serverSocket && ( udpCmd & UDPCMD_INVALIDRNDBYTE ) )
   {
@@ -292,5 +323,5 @@
     return false;
   }
-  
+
   return true;
 }
@@ -300,7 +331,7 @@
   srand( SDL_GetTicks() );
   byte res = ( rand() & 0xFC );
-  
+
   PRINTF(0)("generated random byte: %x\n", res);
-  
+
   return res;
 }
Index: branches/proxy/src/lib/network/udp_socket.h
===================================================================
--- branches/proxy/src/lib/network/udp_socket.h	(revision 9346)
+++ branches/proxy/src/lib/network/udp_socket.h	(revision 9347)
@@ -31,25 +31,26 @@
 
     virtual void connectToServer( std::string host, int port );
-    
     virtual void disconnectServer();
 
+    virtual void reconnectToServer( std::string host, int port);
+    virtual void reconnectToServerSoft( std::string host, int port);
+
     virtual bool writePacket(byte * data, int length );
+    virtual int readPacket(byte * data, int maxLength);
 
-    virtual int readPacket(byte * data, int maxLength);
-    
+
   private:
     UdpServerSocket * serverSocket;   //!< will get packets here
     int               userId;         //!< user id used by serverSocket
-    IPaddress         ip;             //!< host,port
     UDPsocket         socket;         //!< socket used to send/recieve
     UDPpacket *       packet;
-    
+
     byte              randomByte;     //!< contains random bytes & 0xFC
-    
+
     bool writeRawPacket( byte * data, int length );
     bool checkUdpCmd( byte udpCmd );
     bool checkRandomByte( byte rndByte );
     byte generateNewRandomByte();
-    
+
     void init();
 
Index: branches/proxy/src/lib/shell/shell_command.cc
===================================================================
--- branches/proxy/src/lib/shell/shell_command.cc	(revision 9346)
+++ branches/proxy/src/lib/shell/shell_command.cc	(revision 9347)
@@ -299,5 +299,5 @@
       {
         PRINT(0)("Command '%s' on '%s::%s'\n", sc->getName(), (*bo)->getClassName(), (*bo)->getName());
-        (*sc->executor)((*bo), inputSplits.getSubSet(paramBegin));
+        (*sc->executor)((*bo), inputSplits.subSet(paramBegin));
       }
       return true;
@@ -375,5 +375,5 @@
 //       if(this->completors[parameter] == NULL)
 //       delete this->completors[parameter];
-//       this->completors[parameter] = completorPlugin.clone(); 
+//       this->completors[parameter] = completorPlugin.clone();
     }
     return this;
Index: branches/proxy/src/lib/util/Makefile.am
===================================================================
--- branches/proxy/src/lib/util/Makefile.am	(revision 9346)
+++ branches/proxy/src/lib/util/Makefile.am	(revision 9347)
@@ -6,5 +6,4 @@
 libORXlibutil_a_SOURCES = \
 		substring.cc \
-		tokenizer.cc \
 		color.cc \
 		helper_functions.cc \
@@ -32,5 +31,4 @@
 noinst_HEADERS = \
 		substring.h \
-		tokenizer.h \
 		multi_type.h \
 		color.h \
Index: branches/proxy/src/lib/util/executor/executor_functional.h
===================================================================
--- branches/proxy/src/lib/util/executor/executor_functional.h	(revision 9346)
+++ branches/proxy/src/lib/util/executor/executor_functional.h	(revision 9347)
@@ -179,5 +179,5 @@
   {
     (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
-      fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)) );
+      (sub.size() > 0) ? fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)) : (fromMulti<type0>(this->defaultValue[0])));
   };
 
@@ -222,6 +222,6 @@
   {
     (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
-      fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)),
-      fromString<type1>(sub[1], getDefault<type1>(this->defaultValue, 1)));
+      (sub.size() > 0) ? fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)) : (fromMulti<type0>(this->defaultValue[0])),
+      (sub.size() > 1) ? fromString<type1>(sub[1], getDefault<type1>(this->defaultValue, 1)) : (fromMulti<type1>(this->defaultValue[1])));
   };
 
@@ -276,7 +276,7 @@
   {
     (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
-      fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)),
-      fromString<type1>(sub[1], getDefault<type1>(this->defaultValue, 1)),
-      fromString<type2>(sub[2], getDefault<type2>(this->defaultValue, 2)));
+      (sub.size() > 0) ? fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)) : (fromMulti<type0>(this->defaultValue[0])),
+      (sub.size() > 1) ? fromString<type1>(sub[1], getDefault<type1>(this->defaultValue, 1)) : (fromMulti<type1>(this->defaultValue[1])),
+      (sub.size() > 2) ? fromString<type2>(sub[2], getDefault<type2>(this->defaultValue, 2)) : (fromMulti<type2>(this->defaultValue[2])));
   };
 
@@ -333,8 +333,8 @@
   {
     (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
-      fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)),
-      fromString<type1>(sub[1], getDefault<type1>(this->defaultValue, 1)),
-      fromString<type2>(sub[2], getDefault<type2>(this->defaultValue, 2)),
-      fromString<type3>(sub[3], getDefault<type3>(this->defaultValue, 3)));
+      (sub.size() > 0) ? fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)) : (fromMulti<type0>(this->defaultValue[0])),
+      (sub.size() > 1) ? fromString<type1>(sub[1], getDefault<type1>(this->defaultValue, 1)) : (fromMulti<type1>(this->defaultValue[1])),
+      (sub.size() > 2) ? fromString<type2>(sub[2], getDefault<type2>(this->defaultValue, 2)) : (fromMulti<type2>(this->defaultValue[2])),
+      (sub.size() > 3) ? fromString<type3>(sub[3], getDefault<type3>(this->defaultValue, 3)) : (fromMulti<type3>(this->defaultValue[3])));
   };
 
@@ -392,9 +392,9 @@
   {
     (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
-      fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)),
-      fromString<type1>(sub[1], getDefault<type1>(this->defaultValue, 1)),
-      fromString<type2>(sub[2], getDefault<type2>(this->defaultValue, 2)),
-      fromString<type3>(sub[3], getDefault<type3>(this->defaultValue, 3)),
-      fromString<type4>(sub[4], getDefault<type4>(this->defaultValue, 4)));
+      (sub.size() > 0) ? fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)) : (fromMulti<type0>(this->defaultValue[0])),
+      (sub.size() > 1) ? fromString<type1>(sub[1], getDefault<type1>(this->defaultValue, 1)) : (fromMulti<type1>(this->defaultValue[1])),
+      (sub.size() > 2) ? fromString<type2>(sub[2], getDefault<type2>(this->defaultValue, 2)) : (fromMulti<type2>(this->defaultValue[2])),
+      (sub.size() > 3) ? fromString<type3>(sub[3], getDefault<type3>(this->defaultValue, 3)) : (fromMulti<type3>(this->defaultValue[3])),
+      (sub.size() > 4) ? fromString<type4>(sub[4], getDefault<type4>(this->defaultValue, 4)) : (fromMulti<type4>(this->defaultValue[4])));
   };
 
Index: branches/proxy/src/lib/util/executor/functor_list.h
===================================================================
--- branches/proxy/src/lib/util/executor/functor_list.h	(revision 9346)
+++ branches/proxy/src/lib/util/executor/functor_list.h	(revision 9347)
@@ -135,4 +135,5 @@
 
   //! mixed values:
+  FUNCTOR_LIST(2)(l_STRING, l_INT);
   FUNCTOR_LIST(2)(l_STRING, l_FLOAT);
   FUNCTOR_LIST(2)(l_UINT, l_LONG);
Index: branches/proxy/src/lib/util/multi_type.cc
===================================================================
--- branches/proxy/src/lib/util/multi_type.cc	(revision 9346)
+++ branches/proxy/src/lib/util/multi_type.cc	(revision 9347)
@@ -18,9 +18,4 @@
 #include "multi_type.h"
 
-//#include "stdincl.h"
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
 #include <sstream>
 
@@ -28,6 +23,4 @@
 #include "debug.h"
 #endif
-
-using namespace std;
 
 /**
Index: branches/proxy/src/lib/util/substring.cc
===================================================================
--- branches/proxy/src/lib/util/substring.cc	(revision 9346)
+++ branches/proxy/src/lib/util/substring.cc	(revision 9347)
@@ -28,8 +28,4 @@
 #include "substring.h"
 
-#include <string.h>
-#include <cassert>
-
-
 /**
  * @brief default constructor
@@ -108,5 +104,5 @@
 
 /** @brief An empty String */
-const std::string SubString::emptyString = "";
+// const std::string SubString::emptyString = "";
 /** @brief Helper that gets you a String consisting of all White Spaces */
 const std::string SubString::WhiteSpaces = " \n\t";
@@ -238,5 +234,8 @@
   }
   else
-    return SubString::emptyString;
+  {
+    static std::string empty;
+    return empty;
+  }
 }
 
@@ -250,5 +249,5 @@
  * SubString::SubString(const SubString& subString, unsigned int subSetBegin)
  */
-SubString SubString::getSubSet(unsigned int subSetBegin) const
+SubString SubString::subSet(unsigned int subSetBegin) const
 {
   return SubString(*this, subSetBegin);
@@ -265,5 +264,5 @@
  * SubString::SubString(const SubString& subString, unsigned int subSetBegin)
  */
-SubString SubString::getSubSet(unsigned int subSetBegin, unsigned int subSetEnd) const
+SubString SubString::subSet(unsigned int subSetBegin, unsigned int subSetEnd) const
 {
   return SubString(*this, subSetBegin, subSetEnd);
@@ -289,6 +288,4 @@
  * Supports delimiters, escape characters,
  * ignores special  characters between safemode_char and between comment_char and linend '\n'.
- *
- *
  */
 SubString::SPLIT_LINE_STATE
Index: branches/proxy/src/lib/util/substring.h
===================================================================
--- branches/proxy/src/lib/util/substring.h	(revision 9346)
+++ branches/proxy/src/lib/util/substring.h	(revision 9347)
@@ -2,8 +2,22 @@
  * @file substring.h
  * @brief a small class to get the parts of a string separated by commas
+ *
+ * This class is also identified as a Tokenizer. It splits up one long
+ * String into multiple small ones by a designated Delimiter.
+ *
+ * Substring is Advanced, and it is possible, to split a string by ','
+ * but also removing leading and trailing spaces around the comma.
+ *
+ * @example
+ * Split the String std::string st = "1345, The new empire   , is , orxonox"
+ * is splitted with:
+ * SubString(st, ',', " \n\t")
+ * into
+ * "1345", "The new empire", "is", "orxonox"
+ * As you can see, the useless spaces around ',' were removed.
  */
 
-#ifndef _SUBSTRING_H
-#define _SUBSTRING_H
+#ifndef __SUBSTRING_H__
+#define __SUBSTRING_H__
 
 #include <vector>
@@ -61,6 +75,6 @@
 
   // retrieve a SubSet from the String
-  SubString getSubSet(unsigned int subSetBegin) const;
-  SubString getSubSet(unsigned int subSetBegin, unsigned int subSetEnd) const;
+  SubString subSet(unsigned int subSetBegin) const;
+  SubString subSet(unsigned int subSetBegin, unsigned int subSetEnd) const;
 
   // retrieve Information from within
@@ -70,7 +84,13 @@
   inline unsigned int size() const { return this->strings.size(); };
   /** @param i the i'th String @returns the i'th string from the subset of Strings */
-  inline const std::string& operator[](unsigned int i) const { return (i < this->strings.size()) ? this->strings[i] : emptyString; };
+  inline const std::string& operator[](unsigned int i) const { return this->strings[i]; };
   /** @param i the i'th String @returns the i'th string from the subset of Strings */
   inline const std::string& getString(unsigned int i) const { return (*this)[i]; };
+  /** @returns the front of the StringList. */
+  inline const std::string& front() const { return this->strings.front(); };
+  /** @returns the back of the StringList. */
+  inline const std::string& back() const { return this->strings.back(); };
+  /** @brief removes the back of the strings list. */
+  inline void pop_back() { this->strings.pop_back(); };
 
   // the almighty algorithm.
@@ -93,7 +113,5 @@
 private:
   std::vector<std::string>  strings;                      //!< strings produced from a single string splitted in multiple strings
-
-  static const std::string emptyString;
 };
 
-#endif /* _SUBSTRING_H */
+#endif /* __SUBSTRING_H__ */
Index: branches/proxy/src/lib/util/tokenizer.cc
===================================================================
--- branches/proxy/src/lib/util/tokenizer.cc	(revision 9346)
+++ 	(revision )
@@ -1,29 +1,0 @@
-/**
- * @file tokenizer.cc
- * @brief a tokenizer class
- *
- */
-
-#include "tokenizer.h"
-
-
-/**
- * tokenize a string
- */
-void Tokenizer::tokenize(const std::string& str, std::vector<std::string>& tokens, const std::string& delimiters)
-{
-    // Skip delimiters at beginning.
-  std::string::size_type lastPos = str.find_first_not_of(delimiters, 0);
-    // Find first "non-delimiter".
-  std::string::size_type pos     = str.find_first_of(delimiters, lastPos);
-
-  while (std::string::npos != pos || std::string::npos != lastPos)
-  {
-        // Found a token, add it to the vector.
-    tokens.push_back(str.substr(lastPos, pos - lastPos));
-        // Skip delimiters.  Note the "not_of"
-    lastPos = str.find_first_not_of(delimiters, pos);
-        // Find next "non-delimiter"
-    pos = str.find_first_of(delimiters, lastPos);
-  }
-}
Index: branches/proxy/src/lib/util/tokenizer.h
===================================================================
--- branches/proxy/src/lib/util/tokenizer.h	(revision 9346)
+++ 	(revision )
@@ -1,26 +1,0 @@
-
-/*!
- * @file tokenzier.h
- * @brief Definition of Tokenizer
- *
- */
-
-#ifndef _TOKENIZER_H
-#define _TOKENIZER_H
-
-
-#include <vector>
-#include <string>
-
-
-//! A class to handle time itself
-class Tokenizer
-{
-
-  public:
-    static void tokenize(const std::string& str, std::vector<std::string>& tokens, const std::string& delimiters = " ");
-
-
-};
-
-#endif /* _TOKENIZER_H */
Index: branches/proxy/src/orxonox.cc
===================================================================
--- branches/proxy/src/orxonox.cc	(revision 9346)
+++ branches/proxy/src/orxonox.cc	(revision 9347)
@@ -453,6 +453,6 @@
   if ( Preferences::getInstance()->getString("misc", "bt-to-file", "1") == "1" )
   {
-    SignalHandler::getInstance()->doCatch( argv[0] );
-
+    SignalHandler::getInstance()->doCatch( argv[0], "orxonox.backtrace" );
+    SignalHandler::getInstance()->registerCallback( EventHandler::releaseMouse, NULL );
   }
 
Index: branches/proxy/src/story_entities/game_world_data.h
===================================================================
--- branches/proxy/src/story_entities/game_world_data.h	(revision 9346)
+++ branches/proxy/src/story_entities/game_world_data.h	(revision 9347)
@@ -42,4 +42,5 @@
     void loadGameRule(const TiXmlElement* root);
 
+
   protected:
     virtual ErrorMessage loadGUI(const TiXmlElement* root);
Index: branches/proxy/src/story_entities/multi_player_world_data.cc
===================================================================
--- branches/proxy/src/story_entities/multi_player_world_data.cc	(revision 9346)
+++ branches/proxy/src/story_entities/multi_player_world_data.cc	(revision 9347)
@@ -47,4 +47,5 @@
 #include "player_stats.h"
 
+#include "proxy/proxy_settings.h"
 
 #include "glmenu_imagescreen.h"
@@ -110,6 +111,6 @@
 {
   const TiXmlElement* element = NULL;
-  
-  if( NetworkManager::getInstance()->isGameServer() )
+
+  if( NetworkManager::getInstance()->isMasterServer() )
   {
     /* load the spawning points */
@@ -147,5 +148,5 @@
     element = element->FirstChildElement();
 
-    if( NetworkManager::getInstance()->isGameServer() )
+    if( NetworkManager::getInstance()->isMasterServer() )
     {
       while( element != NULL)
@@ -205,5 +206,5 @@
 
 
-    if( NetworkManager::getInstance()->isGameServer())
+    if( NetworkManager::getInstance()->isMasterServer())
     {
       this->localPlayer = new Player();
@@ -280,6 +281,8 @@
   GameWorldData::loadScene(root);
 
+  LoadParamXML(root, "ProxySettings", ProxySettings::getInstance(), ProxySettings, loadProxySettings);
+
   // create server playable
-  if ( NetworkManager::getInstance()->isGameServer() )
+  if ( NetworkManager::getInstance()->isMasterServer() )
   {
     NetworkGameManager::getInstance()->signalNewPlayer( 0 );
@@ -296,4 +299,7 @@
 ErrorMessage MultiPlayerWorldData::unloadScene()
 {
+  // delete the proxy settings
+  delete ProxySettings::getInstance();
+
   /* call underlying function */
   return GameWorldData::unloadScene();
Index: branches/proxy/src/subprojects/network/network_unit_test.cc
===================================================================
--- branches/proxy/src/subprojects/network/network_unit_test.cc	(revision 9346)
+++ branches/proxy/src/subprojects/network/network_unit_test.cc	(revision 9347)
@@ -208,5 +208,5 @@
 
   /* esatblish a connection */
-  IPaddress ip;
+  IP ip;
   int error = SDLNet_ResolveHost(&ip, "127.0.0.1", port);
   //SDLNet_ResolveHost(&ip, "localhost", port);
@@ -353,5 +353,5 @@
   printf("Connecting to %s, on port %i\n", name, port);
 
-  IPaddress ip;
+  IP ip;
   int error = SDLNet_ResolveHost(&ip, name, port);
   if(error == -1)
Index: branches/proxy/src/subprojects/recapture_mouse/Makefile.am
===================================================================
--- branches/proxy/src/subprojects/recapture_mouse/Makefile.am	(revision 9347)
+++ branches/proxy/src/subprojects/recapture_mouse/Makefile.am	(revision 9347)
@@ -0,0 +1,29 @@
+MAINSRCDIR=../..
+include $(MAINSRCDIR)/defs/include_paths.am
+
+LIB_PREFIX=$(MAINSRCDIR)/lib
+include $(MAINSRCDIR)/lib/BuildLibs.am
+
+
+importer_LDFLAGS = \
+		$(MWINDOWS)
+
+
+bin_PROGRAMS = \
+		recapturemouse
+
+
+DEPENDENCIES = \
+		$(MAINSRCDIR)/world_entities/libORXwe.a \
+		$(libORXlibs_a_LIBRARIES_) \
+		$(MAINSRCDIR)/util/libORXutils.a
+
+LDADD = \
+		$(MAINSRCDIR)/util/libORXutils.a \
+		$(libORXlibs_a_LIBRARIES_) \
+		$(MAINSRCDIR)/world_entities/libORXwe.a \
+		$(libORXlibs_a_LIBRARIES_) \
+		$(MAINSRCDIR)/util/libORXutils.a
+
+recapturemouse_SOURCES= \
+		recapturer.cc
Index: branches/proxy/src/subprojects/recapture_mouse/recapturer.cc
===================================================================
--- branches/proxy/src/subprojects/recapture_mouse/recapturer.cc	(revision 9347)
+++ branches/proxy/src/subprojects/recapture_mouse/recapturer.cc	(revision 9347)
@@ -0,0 +1,27 @@
+/*
+   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 Grauer
+   co-programmer: ...
+
+   this file extends the framework file, so it renders what i want.
+*/
+
+#include "event_handler.h"
+
+int verbose = 3;
+
+int main(int argc, char** argv)
+{
+  EventHandler::getInstance()->grabEvents(true);
+  EventHandler::getInstance()->grabEvents(false);
+  exit(-1);
+}
Index: branches/proxy/src/util/Makefile.am
===================================================================
--- branches/proxy/src/util/Makefile.am	(revision 9346)
+++ branches/proxy/src/util/Makefile.am	(revision 9347)
@@ -14,4 +14,6 @@
 			singleplayer_shootemup.cc \
 			\
+			\
+			\
 			mission_goal.cc\
 			kill_target.cc\
@@ -24,5 +26,7 @@
 			animation/animation_player.cc \
 			\
-			track/pilot_node.cc
+			track/pilot_node.cc \
+			\
+			network_stats_widget.cc
 
 #			track/track_manager.cc \
@@ -50,5 +54,8 @@
 			animation/t_animation.h \
 			\
-			track/pilot_node.h
+			track/pilot_node.h \
+			\
+			network_stats_widget.h
+
 
 #			track/track_manager.h \
Index: branches/proxy/src/util/game_rules.cc
===================================================================
--- branches/proxy/src/util/game_rules.cc	(revision 9346)
+++ branches/proxy/src/util/game_rules.cc	(revision 9347)
@@ -88,5 +88,5 @@
 void GameRules::registerKill(const Kill& kill)
 {
-  if ( !SharedNetworkData::getInstance()->isGameServer() )
+  if ( !SharedNetworkData::getInstance()->isMasterServer() )
     return;
 
Index: branches/proxy/src/util/multiplayer_team_deathmatch.cc
===================================================================
--- branches/proxy/src/util/multiplayer_team_deathmatch.cc	(revision 9346)
+++ branches/proxy/src/util/multiplayer_team_deathmatch.cc	(revision 9347)
@@ -204,5 +204,5 @@
   assignPlayable();
 
-  if ( !SharedNetworkData::getInstance()->isGameServer() )
+  if ( !SharedNetworkData::getInstance()->isMasterServer() )
     return;
 
@@ -214,5 +214,5 @@
     this->killList.erase( this->killList.begin() );
   }
-  
+
 
 
@@ -268,5 +268,5 @@
 void MultiplayerTeamDeathmatch::checkGameRules()
 {
-  if ( !SharedNetworkData::getInstance()->isGameServer() )
+  if ( !SharedNetworkData::getInstance()->isMasterServer() )
     return;
 
@@ -320,5 +320,5 @@
       return "maps/male_fiend.pcx";
   }
-  
+
   return "";
 }
@@ -330,5 +330,5 @@
     return 10.0f;
   }
-  
+
   return 1.0f;
 }
@@ -680,5 +680,5 @@
   char st[10];
   int i = 0;
-  
+
   i = 2;
   for ( TeamScoreList::const_iterator it = scoreList[0].begin(); it != scoreList[0].end(); it++ )
@@ -719,13 +719,13 @@
     return;
   }
-  
+
   int killerUserId = killer->getOwner();
   int victimUserId = victim->getOwner();
-  
+
   PRINTF(0)("%d %d %x %x %s %s\n", killerUserId, victimUserId, killer, victim, killer->getClassName(), victim->getClassName());
 
   PlayerStats & victimStats = *PlayerStats::getStats( victimUserId );
   PlayerStats & killerStats = *PlayerStats::getStats( killerUserId );
-  
+
   if ( killerStats.getPlayable() != killer || victimStats.getPlayable() != victim )
   {
Index: branches/proxy/src/util/network_stats_widget.cc
===================================================================
--- branches/proxy/src/util/network_stats_widget.cc	(revision 9347)
+++ branches/proxy/src/util/network_stats_widget.cc	(revision 9347)
@@ -0,0 +1,90 @@
+/*
+   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 Grauer
+   co-programmer: ...
+*/
+
+//#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_
+
+#include "network_stats_widget.h"
+
+namespace OrxGui
+{
+  /**
+   * @brief standard constructor
+   */
+  NetworkStatsWidget::NetworkStatsWidget ()
+  {
+    //   this->setClassID(CL_PROTO_ID, "NetworkStatsWidget");
+
+    this->_bar.setSize2D(100, 30);
+    this->pack(&this->_valueText);
+    this->_bar.setParent2D(&this->_valueText);
+
+    this->_valueText.setChangedTextColor(Color::white);
+
+    //this->setBackgroundTexture("maps/gui_element_background_2.png");
+    this->setBackgroundColor(Color(.5,.5,.5,1));
+
+    //this->_name.setBackgroundTexture(Texture());
+    //this->_valueText.setBackgroundTexture("maps/gui_element_background_2.png");
+    this->_bar.setBackgroundTexture(Texture());
+    this->_bar.setBackgroundColor(Color(0,0,0,0));
+    this->_bar.setForegroundTexture("maps/gui_element_background_faded.png");
+    this->_bar.setForegroundColor(Color(.5, .5, .5, 1));
+    this->_bar.setChangedValueColor(Color::black);
+  }
+
+
+  /**
+   * @brief standard deconstructor
+   */
+  NetworkStatsWidget::~NetworkStatsWidget ()
+  {
+  }
+
+
+  void NetworkStatsWidget::setMaximum(float max)
+  {
+    this->_bar.setMaximum(max);
+  }
+
+  void NetworkStatsWidget::setValue(float value)
+  {
+    MultiType val(value);
+    val.setType(MT_INT);
+
+
+    this->_bar.setValue(value);
+    this->_bar.setForegroundColor(Color::slerpHSVColor(Color::red, Color::green, value/this->_bar.maximum()));
+    this->_bar.setFrontColor(Color(1,1,1,1), true);
+    this->_valueText.setText(val.getString());
+  }
+
+  void NetworkStatsWidget::resize()
+  {
+    GLGuiBox::resize();
+  }
+
+
+  void NetworkStatsWidget::showing()
+  {
+    this->_valueText.show();
+    this->_bar.show();
+  }
+
+  void NetworkStatsWidget::hiding()
+  {
+    this->_valueText.hide();
+    this->_bar.hide();
+  }
+}
Index: branches/proxy/src/util/network_stats_widget.h
===================================================================
--- branches/proxy/src/util/network_stats_widget.h	(revision 9347)
+++ branches/proxy/src/util/network_stats_widget.h	(revision 9347)
@@ -0,0 +1,59 @@
+/*!
+ * @file network_stats_widget.h
+ * @brief Definition of an EnergyWidget, that displays a bar and a Text
+*/
+
+#ifndef _NETWORK_STATS_WIDGET_H
+#define _NETWORK_STATS_WIDGET_H
+
+#include "glgui_box.h"
+#include "glgui_bar.h"
+#include "glgui_text.h"
+
+#include "network/ip.h"
+
+
+namespace OrxGui
+{
+
+  //! A class to display network Statistics.
+  class NetworkStatsWidget : public GLGuiBox
+  {
+
+  public:
+    NetworkStatsWidget();
+    virtual ~NetworkStatsWidget();
+
+    void setUpstream(unsigned int upstream);
+    void setDownstream(unsigned int upstream);
+    void setIP(const IP& ip);
+
+
+
+    //void rebuildConnectedHosts(std::vector<hosts> hosts);
+
+    void setMaximum(float max);
+    void setValue(float value);
+
+  protected:
+    virtual void resize();
+    virtual void showing();
+    virtual void hiding();
+
+  private:
+    IP                     _ip;
+    GLGuiText              _ipText;
+
+    GLGuiText              _upstreamText;
+    GLGuiText              _downstreamText;
+
+    std::vector<GLGuiText> _connectedHosts;
+
+    GLGuiText              _serverIP;
+
+
+    GLGuiText              _valueText;
+    GLGuiBar               _bar;
+  };
+}
+#endif /* _NETWORK_STATS_WIDGET_H */
Index: branches/proxy/src/util/signal_handler.cc
===================================================================
--- branches/proxy/src/util/signal_handler.cc	(revision 9346)
+++ branches/proxy/src/util/signal_handler.cc	(revision 9347)
@@ -27,7 +27,16 @@
 }
 
-void SignalHandler::doCatch( std::string appName )
+/**
+ * register signal handlers for SIGSEGV and SIGABRT
+ * @param appName path to executable eg argv[0]
+ * @param fileName filename to append backtrace to
+ */
+void SignalHandler::doCatch( const std::string & appName, const std::string & fileName )
 {
   this->appName = appName;
+  this->fileName = fileName;
+  
+  // make sure doCatch is only called once without calling dontCatch
+  assert( sigRecList.size() == 0 );
 
   catchSignal( SIGSEGV );
@@ -35,4 +44,7 @@
 }
 
+/**
+ * restore previous signal handlers
+ */
 void SignalHandler::dontCatch()
 {
@@ -45,4 +57,8 @@
 }
 
+/**
+ * catch signal sig
+ * @param sig signal to catch
+ */
 void SignalHandler::catchSignal( int sig )
 {
@@ -58,4 +74,8 @@
 }
 
+/**
+ * sigHandler is called when receiving signals
+ * @param sig 
+ */
 void SignalHandler::sigHandler( int sig )
 {
@@ -167,4 +187,6 @@
         )
           charsFound++;
+    else
+      charsFound = 0;
 
     if ( charsFound == 6 )
@@ -183,5 +205,5 @@
   write( sigPipe[1], &someData, sizeof(someData) );
 
-  write( gdbIn[1], "bt\nq\n", 5 );
+  write( gdbIn[1], "bt\nk\nq\n", 7 );
 
   
@@ -202,4 +224,6 @@
         )
           charsFound++;
+    else
+      charsFound = 0;
 
     if ( charsFound == 6 )
@@ -210,5 +234,5 @@
     }
 
-    if ( promptFound == 2 )
+    if ( promptFound == 3 )
     {
       break;
@@ -240,9 +264,9 @@
   bt.insert(0, timeString);
   
-  FILE * f = fopen( GDB_BT_FILE, "a" );
+  FILE * f = fopen( getInstance()->fileName.c_str(), "a" );
 
   if ( !f )
   {
-    perror("could not append to " GDB_BT_FILE);
+    perror( ( std::string( "could not append to " ) + getInstance()->fileName ).c_str() );
     exit(EXIT_FAILURE);
   }
@@ -250,5 +274,5 @@
   if ( fwrite( bt.c_str(), 1, bt.length(), f ) != bt.length() )
   {
-    printf("could not write %d byte to " GDB_BT_FILE, bt.length());
+    printf( ( std::string("could not write %d byte to ") + getInstance()->fileName ).c_str(), bt.length());
     exit(EXIT_FAILURE);
   }
Index: branches/proxy/src/util/signal_handler.h
===================================================================
--- branches/proxy/src/util/signal_handler.h	(revision 9346)
+++ branches/proxy/src/util/signal_handler.h	(revision 9347)
@@ -9,7 +9,4 @@
 #include <list>
 #include <string>
-
-
-#define GDB_BT_FILE "orxonox.backtrace"
 
 typedef int (*SignalCallback)( void * someData );
@@ -44,5 +41,5 @@
     void registerCallback( SignalCallback cb, void * someData );
 
-    void doCatch( std::string appName );
+    void doCatch( const std::string & appName, const std::string & fileName );
     void dontCatch();
 
@@ -58,4 +55,5 @@
 
     std::string appName;
+    std::string fileName;
 };
 
Index: branches/proxy/src/world_entities/camera.cc
===================================================================
--- branches/proxy/src/world_entities/camera.cc	(revision 9346)
+++ branches/proxy/src/world_entities/camera.cc	(revision 9347)
@@ -17,4 +17,5 @@
 #include "camera.h"
 #include "key_mapper.h"
+#include "glincl.h"
 
 /**
Index: branches/proxy/src/world_entities/creatures/fps_player.cc
===================================================================
--- branches/proxy/src/world_entities/creatures/fps_player.cc	(revision 9346)
+++ branches/proxy/src/world_entities/creatures/fps_player.cc	(revision 9347)
@@ -287,5 +287,5 @@
   //dealing damage
 
-  if ( State::isOnline() && SharedNetworkData::getInstance()->isGameServer() )
+  if ( State::isOnline() && SharedNetworkData::getInstance()->isMasterServer() )
   {
     this->damageTicker -= time;
Index: branches/proxy/src/world_entities/playable.cc
===================================================================
--- branches/proxy/src/world_entities/playable.cc	(revision 9346)
+++ branches/proxy/src/world_entities/playable.cc	(revision 9347)
@@ -361,28 +361,4 @@
   }
 }
-/**
- * @brief helps us colliding Playables
- * @param entity the Entity to collide
- * @param location where the collision occured.
- */
-void Playable::collidesWith(WorldEntity* entity, const Vector& location)
-{
-  if (entity == collider)
-    return;
-  collider = entity;
-
-  if ( entity->isA(CL_PROJECTILE) && ( !State::isOnline() || SharedNetworkData::getInstance()->isGameServer() ) )
-  {
-    this->decreaseHealth(entity->getHealth() *(float)rand()/(float)RAND_MAX);
-    // EXTREME HACK
-    if (this->getHealth() <= 0.0f)
-    {
-//       this->destory();
-
-      if( State::getGameRules() != NULL)
-        State::getGameRules()->registerKill(Kill(entity, this));
-    }
-  }
-}
 
 
@@ -413,5 +389,5 @@
     }
     this->bDead = true;
-    
+
     if( State::getGameRules() != NULL)
       State::getGameRules()->registerKill(Kill(killer, this));
Index: branches/proxy/src/world_entities/playable.h
===================================================================
--- branches/proxy/src/world_entities/playable.h	(revision 9346)
+++ branches/proxy/src/world_entities/playable.h	(revision 9347)
@@ -82,5 +82,4 @@
   virtual void destroy(WorldEntity* killer);
   virtual void respawn();
-  virtual void collidesWith(WorldEntity* entity, const Vector& location);
   virtual void process(const Event &event);
   virtual void tick(float dt);
@@ -90,5 +89,5 @@
   static const std::string& playmodeToString(Playable::Playmode playmode);
   static const std::string playmodeNames[];
-  
+
   inline bool beFire(){ return this->bFire; }
   inline void fire(bool bF){ this->bFire = bF;}
Index: branches/proxy/src/world_entities/space_ships/space_ship.cc
===================================================================
--- branches/proxy/src/world_entities/space_ships/space_ship.cc	(revision 9346)
+++ branches/proxy/src/world_entities/space_ships/space_ship.cc	(revision 9347)
@@ -314,5 +314,5 @@
   if( entity->isA(CL_PROJECTILE) && entity != ref)
   {
-    if ( isServer() )
+    if ( SharedNetworkData::getInstance()->isMasterServer() )
     {
       //TODO handle this
Index: branches/proxy/src/world_entities/spawning_point.cc
===================================================================
--- branches/proxy/src/world_entities/spawning_point.cc	(revision 9346)
+++ branches/proxy/src/world_entities/spawning_point.cc	(revision 9347)
@@ -41,5 +41,5 @@
 
   this->init();
-  
+
   if (root != NULL)
     this->loadParams(root);
@@ -50,12 +50,12 @@
   this->setClassID(CL_SPAWNING_POINT, "SpawningPoint");
   PRINTF(0)("Created SpawningPoint\n");
-  
+
   this->teamId = -1;
   this->localTimer = 0.0f;
-  
+
   this->toList( OM_DEAD_TICK );
-  
+
   MessageManager::getInstance()->registerMessageHandler( MSGID_RESPAWN, respawnMessageHandler, NULL );
-  
+
   this->setSynchronized( true );
 }
@@ -94,5 +94,5 @@
   qe.entity = entity;
   qe.respawnTime = this->localTimer + delay;
-  
+
   queue.push_back( qe );
 }
@@ -105,10 +105,10 @@
 {
   const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYABLE );
-  
+
   bool found = false;
-  
+
   if ( !list )
     return;
-    
+
   for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
   {
@@ -119,5 +119,5 @@
     }
   }
-  
+
   if ( !found )
     return;
@@ -128,12 +128,12 @@
   entity->setAbsCoor( this->getAbsCoor() );
   entity->setAbsDir( this->getAbsDir() );
-  
+
   //TODO set camera (not smooth)
-  
+
   if ( State::getGameRules() )
   {
     (State::getGameRules())->registerSpawn( entity );
   }
-  
+
   entity->respawn();
 }
@@ -157,12 +157,12 @@
       //spawn the player
       this->spawn(it->entity);
-      
+
       const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYABLE );
-  
+
       bool found = false;
-  
+
       if ( !list )
         return;
-    
+
       for ( std::list<BaseObject*>::const_iterator it2 = list->begin(); it2 != list->end(); it2++ )
       {
@@ -173,16 +173,16 @@
         }
       }
-  
-      if ( found && SharedNetworkData::getInstance()->isGameServer() )
+
+      if ( found && SharedNetworkData::getInstance()->isMasterServer() )
         this->sendRespawnMessage( it->entity->getUniqueID() );
 
       std::list<QueueEntry>::iterator delit = it;
       it++;
-      
+
       queue.erase( delit );
-      
+
       continue;
     }
-    
+
     it++;
   }
@@ -204,8 +204,8 @@
 {
   byte * buf = new byte[2*INTSIZE];
-  
+
   assert( Converter::intToByteArray( this->getUniqueID(), buf, INTSIZE ) == INTSIZE );
   assert( Converter::intToByteArray( uniqueId, buf + INTSIZE, INTSIZE ) == INTSIZE );
-  
+
   MessageManager::getInstance()->sendMessage( MSGID_RESPAWN, buf, 2*INTSIZE, RT_ALL_NOT_ME, 0, MP_HIGHBANDWIDTH );
 }
@@ -213,13 +213,13 @@
 bool SpawningPoint::respawnMessageHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId )
 {
-  if ( SharedNetworkData::getInstance()->isGameServer() )
+  if ( SharedNetworkData::getInstance()->isMasterServer() )
   {
     PRINTF(2)("server received spawn message!\n");
     return true;
   }
-    
+
   int spUniqueId;
   int uniqueId;
-  
+
   if ( dataLength != 2*INTSIZE )
   {
@@ -227,15 +227,15 @@
     return true;
   }
-  
+
   assert( Converter::byteArrayToInt( data, &spUniqueId ) == INTSIZE );
   assert( Converter::byteArrayToInt( data+INTSIZE, &uniqueId ) == INTSIZE );
-  
+
   PRINTF(0)("SPAWNMESSAGE %d\n", uniqueId);
-  
+
   SpawningPoint * sp = NULL;
   Playable      * playable = NULL;
-  
+
   const std::list<BaseObject*> * list = ClassList::getList( CL_SPAWNING_POINT );
-  
+
   if ( list )
   {
@@ -250,5 +250,5 @@
     }
   }
-  
+
   if ( !sp )
   {
@@ -256,7 +256,7 @@
     return false;
   }
-  
+
   list = ClassList::getList( CL_PLAYABLE );
-  
+
   if ( list )
   {
@@ -270,5 +270,5 @@
     }
   }
-  
+
   if ( !playable )
   {
@@ -276,7 +276,7 @@
     return false;
   }
-  
+
   sp->spawn( playable );
-  
+
   return true;
 }
