Index: code/branches/spaceboundaries/src/orxonox/worldentities/SpaceBoundaries.cc
===================================================================
--- code/branches/spaceboundaries/src/orxonox/worldentities/SpaceBoundaries.cc	(revision 8403)
+++ code/branches/spaceboundaries/src/orxonox/worldentities/SpaceBoundaries.cc	(revision 8404)
@@ -50,4 +50,5 @@
         this->setShowDistance(2500);
         this->setHealthDecrease(1);
+        this->setReaction(0);
         
         RegisterObject(SpaceBoundaries);
@@ -62,9 +63,4 @@
         delete this->centerRadar_;
         
-        if(this->boundary_ != NULL)
-        {
-            delete this->boundary_;
-        }
-        
         this->pawnsIn_.clear();
         
@@ -106,5 +102,5 @@
         {
             Billboard *tmp = new Billboard(this);
-            setBillboardOptions( tmp );
+            this->setBillboardOptions( tmp );
             tmp->setPosition(position);
             billboardAdministration tmp2 = { true, tmp };
@@ -171,4 +167,13 @@
         return this->healthDecrease_;
     }
+    
+    void SpaceBoundaries::setReaction(int mode)
+    {
+        this->reaction_ = mode;
+    }
+    int SpaceBoundaries::getReaction()
+    {
+        return this->reaction_;
+    }
 
     void SpaceBoundaries::XMLPort(Element& xmlelement, XMLPort::Mode mode)
@@ -179,8 +184,10 @@
         XMLPortParam(SpaceBoundaries, "warnDistance", setWarnDistance, getWarnDistance, xmlelement, mode);
         XMLPortParam(SpaceBoundaries, "healthDecrease", setHealthDecrease, getHealthDecrease, xmlelement, mode);
+        XMLPortParam(SpaceBoundaries, "reactionMode", setReaction, getReaction, xmlelement, mode);
     }
     
     void SpaceBoundaries::tick(float dt)
     {
+        this->checkWhoIsIn();
         this->removeAllBillboards();
         COUT(0) << "Groesse der Liste: " << (int) pawnsIn_.size() << std::endl;
@@ -188,41 +195,40 @@
         float distance;
         bool humanItem;
-        for( std::list<Pawn*>::iterator current = pawnsIn_.begin(); current != pawnsIn_.end(); current++ )
-        {
-            Pawn* currentPawn = *current;
-            distance = this->computeDistance(currentPawn);
-            humanItem = this->isHumanPlayer(currentPawn);
-            COUT(0) << "Distanz:" << distance << std::endl; // message for debugging
-            if(distance > this->warnDistance_ && distance < this->maxDistance_) // Zeige Warnung an!
-            {
-                COUT(0) << "You are leaving the area" << std::endl; // message for debugging
-                if(humanItem)
-                {
-                    COUT(0) << "humanItem ist true" << std::endl;
-                    this->displayWarning("Attention! You are leaving the area!");
-                } else {
-                    
-                }
-            }
-            if( (this->maxDistance_ - distance) < this->showDistance_)
-            {
-                // Zeige Grenze an!
-                this->displayBoundaries(currentPawn);
-            }
-            if(distance > this->maxDistance_)
-            {
-                if(humanItem)
-                {
-                    COUT(0) << "Health should be decreasing!" << std::endl;
-                    this->displayWarning("You are out of the area now!");
-                    currentPawn->removeHealth( (distance - maxDistance_) * this->healthDecrease_);
-                } else {
-                    
-                }
-                
-                this->bounceBack(currentPawn);
-            }
-        }
-        this->checkWhoIsIn();
+        for( std::list<WeakPtr<Pawn> >::iterator current = pawnsIn_.begin(); current != pawnsIn_.end(); current++ )
+        {
+            Pawn* currentPawn = current->get();
+            if( currentPawn && currentPawn->getNode() ) 
+            {
+                distance = this->computeDistance(currentPawn);
+                humanItem = this->isHumanPlayer(currentPawn);
+                COUT(0) << "Distanz:" << distance << std::endl; // message for debugging
+                if(distance > this->warnDistance_ && distance < this->maxDistance_) // Zeige Warnung an!
+                {
+                    COUT(0) << "You are near by the boundaries!" << std::endl; // message for debugging
+                    if(humanItem)
+                    {
+                        COUT(0) << "humanItem ist true" << std::endl;
+                        this->displayWarning("Attention! You are near by the boundaries!");
+                    }
+                }
+                if( (this->maxDistance_ - distance) < this->showDistance_ )
+                {
+                    this->displayBoundaries(currentPawn); // Zeige Grenze an!
+                }
+                if(distance > this->maxDistance_ && (this->reaction_ == 1) )
+                {
+                    if( humanItem )
+                    {
+                        COUT(0) << "Health should be decreasing!" << std::endl;
+                        this->displayWarning("You are out of the area now!");
+                    }
+                    currentPawn->removeHealth( (distance - this->maxDistance_) * this->healthDecrease_);
+                }
+                if( (this->reaction_ == 0) && (distance + 100 > this->maxDistance_)) // Annahme: Ein Pawn kann von einem Tick bis zum nächsten nicht mehr als 100 Distanzeinheiten zurücklegen.
+                {
+                    this->conditionalBounceBack(currentPawn, distance, dt);
+                }
+            }
+        }
     }
     
@@ -254,13 +260,16 @@
     }
     
-    void SpaceBoundaries::bounceBack(Pawn *item)
+    void SpaceBoundaries::conditionalBounceBack(Pawn *item, float currentDistance, float dt)
     {
         Vector3 normal = item->getPosition() - this->getPosition();
-        if( item->getVelocity().dotProduct(normal) > 0 ) // Greife nur ein, falls sich das Pawn nach Aussen bewegt.
+        normal.normalise();
+        Vector3 velocity = item->getVelocity();
+        float normalSpeed = item->getVelocity().dotProduct(normal);
+        
+        /* Checke, ob das Pawn innerhalb des nächsten Ticks, das erlaubte Gebiet verlassen würde.
+           Falls ja: Spicke es zurück. */
+        if( currentDistance + normalSpeed * dt > this->maxDistance_ )
         {
             float dampingFactor = 0.5;
-        
-            normal.normalise();
-            Vector3 velocity = item->getVelocity();
             velocity = velocity.reflect(normal);
             Vector3 acceleration = item->getAcceleration();
Index: code/branches/spaceboundaries/src/orxonox/worldentities/SpaceBoundaries.h
===================================================================
--- code/branches/spaceboundaries/src/orxonox/worldentities/SpaceBoundaries.h	(revision 8403)
+++ code/branches/spaceboundaries/src/orxonox/worldentities/SpaceBoundaries.h	(revision 8404)
@@ -27,16 +27,11 @@
  */
  
- /* TODO:   - Sobald Bots im Spiel sind, stürzt das Programm relativ bald ab!!!
- */
- 
- 
- /* REALISIERUNGSIDEEN:
-   
-    Mehrere Instanzen:
-        Im Konstruktor schauen, wer innerhalb der eigenen Grenzen ist und diese in eine Liste geben, die in jeder tick-Funktion
-        durchgearbeitet wird.
-        Moeglichkeit bereitstellen, ein Pawn durch ein Portal einer anderen Instanz von SpaceBoundaries zuzuweisen.
-        Schauen, wie es zu handhaben ist, wenn ein neuer Spieler oder Bot nachtraeglich ins Spiel kommt.
- 
+ /* TODO:   - Textmessages und Billboards sollen teils nur bei einem humanPlayer angezeigt werden, nicht bei allen (vgl. Netzwerk-Spiel mit mehreren humanPlayers)
+                beachte hierzu folgende statische Funktion: 'static unsigned int  Host::getPlayerID()'
+                (file:///home/kmaurus/orxonox/spaceBoundaries/build/doc/api/html/classorxonox_1_1_host.html#9c1e3b39e3b42e467dfbf42902911ce2)
+                
+            - Kommentieren (Betrachte als Beispiel/Vorbild 'libraries/core/WeakPtr.h')
+            
+            - Wiki-SpaceBoundaries-Eintrag aktualisieren
  */
 
@@ -44,6 +39,7 @@
 #define _SpaceBoundaries_H__
 
-/* Einige, spezifische include-Statements */
+
 #include "core/CoreIncludes.h"
+#include "core/WeakPtr.h"
 #include "tools/interfaces/Tickable.h"
 #include "interfaces/RadarViewable.h"
@@ -56,19 +52,22 @@
 #include <vector>
 
+namespace orxonox
+{
+
 /**
-@brief SpaceBoundaries gives level creators the possibility to bar Pawns from leaving a defined area.
+@brief SpaceBoundaries gives level creators the possibility to bar Pawns from leaving a defined area (until now this area is a ball).
 
        Five attributes can/should be defined in the XML-File:
-       - 'position' : absolute position of the SpaceBoundaries class. 'warnDistance' and 'maxDistance' refer to this 'position'.
        - 'warnDistance' : If the distance between the pawn of the human player and 'position' is bigger than 'warnDistance', a message is displayed to
                           inform the player that he'll soon be leaving the allowed area. 
        - 'maxDistance' : defines the area, where a pawn is allowed to be (radius of a ball).
        - 'showDistance' : If the distance between the pawn and the boundary of the allowed area is smaller than 'showDistance', the boundary is shown. 
-       - 'healthDecrease' : a measure to define how fast the health of a pawn should decrease after leaving the allowed area.
-                            Empfohlene Werte: 0.1 (langsame Health-Verminderung) bis 5 (sehr schnelle Health-Verminderung)
+       - 'healthDecrease' : a measure to define how fast the health of a pawn should decrease after leaving the allowed area (unnecessary if 'reactionMode' == 0).
+                            Recommended values: 0.1 (slow health decrease) to 5 (very fast health decrease)
+       - 'reactionMode' : Integer-Value. Defines what effect appears if a space ship has crossed the boundaries.
+                            0: Reflect the space ship (default).
+                            1: Decrease Health of the space ship after having left the allowed area.
 */
 
-namespace orxonox
-{
     class _OrxonoxExport SpaceBoundaries : public StaticEntity, public Tickable
     {
@@ -79,7 +78,7 @@
             void checkWhoIsIn(); //!< Update the list 'pawnsIn_'.
             
-            void positionBillboard(const Vector3 position);
+            void positionBillboard(const Vector3 position); //!< Display a Billboard at the position 'position'.
             void setBillboardOptions(Billboard *billy);
-            void removeAllBillboards();
+            void removeAllBillboards(); //!< Hide all all elements of '*billboard_' and set their attribute 'usedYet' to 0.
             
             void setMaxDistance(float r);
@@ -94,4 +93,7 @@
             void setHealthDecrease(float amount);
             float getHealthDecrease();
+            
+            void setReaction(int mode);
+            int getReaction();
 
             void XMLPort(Element& xmlelement, XMLPort::Mode mode);
@@ -102,8 +104,9 @@
             struct billboardAdministration{ bool usedYet; Billboard* billy; };
             
-            std::list<Pawn*> pawnsIn_; //!< List of the pawns that this instance of SpaceBoundaries has to handle.
+            std::list<WeakPtr<Pawn> > pawnsIn_; //!< List of the pawns that this instance of SpaceBoundaries has to handle.
             
             std::vector<billboardAdministration> billboards_;
         
+            int reaction_; //!< Werte: 0, 1. 0: Reflektion an Boundaries (Standard). 1: Health-Abzug-Modus.
             float maxDistance_; //!< maximal zulaessige Entfernung von 'this->getPosition()'.
             float warnDistance_; //!< Entfernung von 'this->getPosition()', ab der eine Warnung angezeigt wird, dass man bald das zulaessige Areal verlaesst.
@@ -113,6 +116,4 @@
                                    //!< Empfohlene Werte: 0.1 (langsame Health-Verminderung) bis 5 (sehr schnelle Health-Verminderung)
             
-            Billboard *boundary_;
-            
             RadarViewable* centerRadar_; //!< Repraesentation von SpaceBoundaries auf dem Radar.
         
@@ -120,5 +121,5 @@
             void displayWarning(const std::string warnText);
             void displayBoundaries(Pawn *item);
-            void bounceBack(Pawn *item);
+            void conditionalBounceBack(Pawn *item, float currentDistance, float dt);
             bool isHumanPlayer(Pawn *item);
             
