Index: /code/branches/dockingsystem2/data/levels/docking.oxw
===================================================================
--- /code/branches/dockingsystem2/data/levels/docking.oxw	(revision 8381)
+++ /code/branches/dockingsystem2/data/levels/docking.oxw	(revision 8382)
@@ -17,5 +17,5 @@
 >
   <templates>
-    <Template link=lodtemplate_default />
+    <Template link="lodtemplate_default" />
   </templates>
 
@@ -25,13 +25,13 @@
   >
 
-    <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" />
+    <Light type="directional" position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" />
 
     <?lua for i = 1, 10, 1 do ?>
-      <SpawnPoint position="<?lua print(math.random() * 500 - 250) ?>,<?lua print(math.random() * 500 - 250) ?>,<?lua print(math.random() * 500 - 250) ?>" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
+      <SpawnPoint position="<?lua print(math.random() * 500 - 250) ?>,<?lua print(math.random() * 500 - 250) ?>,<?lua print(math.random() * 500 - 250) ?>" lookat="0,0,0" spawnclass="SpaceShip" pawndesign="spaceshipassff" />
     <?lua end ?>
 
     <Dock position="-50,-100,50">
             <effects>
-                <DockToShip target="asdf" />
+                <DockToShip target="theDestroyer" />
             </effects>
             <events>
@@ -41,5 +41,5 @@
             </events>
             <attached>
-                <DistanceTrigger position="0,0,0" distance="20" target="Pawn" beaconMode="exclude" targetname="beacon1" name="dockMe" />
+                <DistanceTrigger position="0,0,0" distance="20" target="Pawn" beaconMode="exclude" targetname="destroyerBeacon" name="dockMe" />
                 <Billboard material="Examples/Flare" colour="1.0, 0, 0" />
             </attached>
@@ -47,24 +47,26 @@
 
 
+    
+
       <SpaceShip
-   hudtemplate            = spaceshiphud
-   camerapositiontemplate = spaceshipassffcameras
-   engine                 = spaceshipassffengine
+   hudtemplate            = "spaceshiphud"
+   camerapositiontemplate = "spaceshipassffcameras"
+   engine                 = "spaceshipassffengine"
    spawnparticlesource    = "Orxonox/fairytwirl"
-   spawnparticleduration  = 3
-   explosionchunks        = 6
-
-   health            = 100
-   maxhealth         = 200
-   initialhealth     = 100
-
-   primaryThrust     = 100;
-   auxilaryThrust    = 30;
-   rotationThrust    = 25;
+   spawnparticleduration  = "3"
+   explosionchunks        = "6"
+
+   health            = "100"
+   maxhealth         = "200"
+   initialhealth     = "100"
+
+   primaryThrust     = "100;"
+   auxilaryThrust    = "30;"
+   rotationThrust    = "25;"
 
    collisionType     = "dynamic"
-   mass              = 100
-   linearDamping     = 0.7
-   angularDamping    = 0.9999999
+   mass              = "100"
+   linearDamping     = "0.7"
+   angularDamping    = "0.9999999"
   >
     <attached>
@@ -72,8 +74,8 @@
         <DockingTarget name="asdf" />
 
-      <Model position="0,0,0" yaw=90 pitch=-90 roll=0 scale=4 mesh="assff.mesh" />
-      <BlinkingBillboard position="17,-1.5,0" material="Examples/Flare" colour="1.0, 0.5, 0.3" amplitude=0.1 frequency=0.5 quadratic=1 />
-      <BlinkingBillboard position="-17,-1.5,0" material="Examples/Flare" colour="0.5, 1.0, 0.3" amplitude=0.1 frequency=0.5 phase=180 quadratic=1 />
-      <DistanceTriggerBeacon name="PlayerDistanceTrigger" /> <!--added DistanceTrigger-->
+      <Model position="0,0,0" yaw="90" pitch="-90" roll="0" scale="4" mesh="assff.mesh" />
+      <BlinkingBillboard position="17,-1.5,0" material="Examples/Flare" colour="1.0, 0.5, 0.3" amplitude="0.1" frequency="0.5" quadratic="1" />
+      <BlinkingBillboard position="-17,-1.5,0" material="Examples/Flare" colour="0.5, 1.0, 0.3" amplitude="0.1" frequency="0.5" phase="180" quadratic="1" />
+      <DistanceTriggerBeacon name="PlayerDistanceTrigger" />
     </attached>
     <collisionShapes>
@@ -90,34 +92,36 @@
   </SpaceShip>
 
-
-    <!--  <Destroyer
+    
+
+
+    <Destroyer
       position          = "100,150,0"
-      collisionType     = dynamic
-      mass              = 100000
+      collisionType     = "dynamic"
+      mass              = "100000"
       velocity          = "0,0,0"
-      angularDamping    = 0.9999999
-      health            = 10000
-      maxhealth         = 10000
-      initialhealth     = 10000
+      angularDamping    = "0.9999999"
+      health            = "10000"
+      maxhealth         = "10000"
+      initialhealth     = "10000"
     >
 
       <attached>
-        
-        <DistanceTriggerBeacon name="beacon1" />
-        <DockingTarget name="asdf" />
-
-
-        <TeamSpawnPoint team=1 position="150,0,7" direction="-1,0,0" roll=90 yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff />
-        <TeamSpawnPoint team=1 position="0,0,7" lookat="-1,0,0" roll="90"  yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff />
-        <TeamSpawnPoint team=1 position="-50,0,7" lookat="-1,0,0" roll="90" yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff />
-        <TeamSpawnPoint team=1 position="100,0,7" lookat="-1,0,0" roll="90" yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff />
-        <TeamSpawnPoint team=1 position="50,0,7" lookat="-1,0,0" roll="90" yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff />
+
+        <DistanceTriggerBeacon name="destroyerBeacon" />
+        <DockingTarget name="theDestroyer" />
+
+
+        <TeamSpawnPoint team="1" position="150,0,7" direction="-1,0,0" roll="90" yaw="0" spawnclass="SpaceShip" pawndesign="spaceshipassff" />
+        <TeamSpawnPoint team="1" position="0,0,7" lookat="-1,0,0" roll="90"  yaw="0" spawnclass="SpaceShip" pawndesign="spaceshipassff" />
+        <TeamSpawnPoint team="1" position="-50,0,7" lookat="-1,0,0" roll="90" yaw="0" spawnclass="SpaceShip" pawndesign="spaceshipassff" />
+        <TeamSpawnPoint team="1" position="100,0,7" lookat="-1,0,0" roll="90" yaw="0" spawnclass="SpaceShip" pawndesign="spaceshipassff" />
+        <TeamSpawnPoint team="1" position="50,0,7" lookat="-1,0,0" roll="90" yaw="0" spawnclass="SpaceShip" pawndesign="spaceshipassff" />
         <?lua for i = 1, 100, 1 do ?>
           <TeamSpawnPoint
-            team=0
+            team="0"
             position="<?lua print((math.random() * 500 + 500) * (math.floor(math.random() + 0.5) * 2 - 1)) ?>,<?lua print((math.random() * 500 + 500) * (math.floor(math.random() + 0.5) * 2 - 1)) ?>,<?lua print((math.random() * 500 + 500) * (math.floor(math.random() + 0.5) * 2 - 1)) ?>"
             lookat="0,0,0"
-            spawnclass=SpaceShip
-            pawndesign=spaceshipassff
+            spawnclass="SpaceShip"
+            pawndesign="spaceshipassff"
           />
         <?lua end ?>
@@ -125,19 +129,41 @@
         <Model mesh="Carrier.mesh" scale="5" />
         <Backlight
-          mainstate=activity
-          active=false
-          scale=0.4
-          name=bltest
+          mainstate="activity"
+          active="false"
+          scale="0.4"
+          name="bltest"
           position=" 7.6, 0, 6"
           colour="0.2, 0.65, 1.0, 1.0"
-          width=15
-          length=1500
-          lifetime=2
-          elements=50
+          width="15"
+          length="1500"
+          lifetime="2"
+          elements="50"
           trailmaterial="Trail/backlighttrail"
-          turnontime=1
-          turnofftime=1
+          turnontime="1"
+          turnofftime="1"
           material="Flares/ThrusterFlare1"
         />
+        <Backlight
+                  scale="1"
+                  position=" 169, 75, -15"
+                  colour="1, 0.85, 0.5, 0.5"
+                  width="40"
+                  length="1000"
+                  lifetime="5"
+                  elements="15"
+                  trailmaterial="Trail/backlighttrail"
+                  material="Examples/Flare"
+                  />
+        <Backlight
+                  scale="1"
+                  position=" 169, -75, -15"
+                  colour="1, 0.85, 0.5, 0.5"
+                  width="40"
+                  length="1000"
+                  lifetime="5"
+                  elements="15"
+                  trailmaterial="Trail/backlighttrail"
+                  material="Examples/Flare"
+         />
         <?lua for i=0,8,1 do ?>
           <BlinkingBillboard
@@ -146,7 +172,7 @@
             colour="1.0, 0.5, 0.3"
             phase="<?lua print(-360/8*i)?>"
-            amplitude=0.1
-            frequency=0.5
-            quadratic=1
+            amplitude="0.1"
+            frequency="0.5"
+            quadratic="1"
           />
 
@@ -156,31 +182,10 @@
             colour="1.0, 0.5, 0.3"
             phase="<?lua print(-360/8*i)?>"
-            amplitude=0.1
-            frequency=0.5
-            quadratic=1
+            amplitude="0.1"
+            frequency="0.5"
+            quadratic="1"
           />
         <?lua end ?>
 
-        <Backlight
-          scale=1
-          position=" 169, 75, -15"
-          colour="1, 0.85, 0.5, 0.5"
-          width=40
-          length=1000
-          lifetime=5
-          elements=15
-          trailmaterial="Trail/backlighttrail"
-          material="Examples/Flare"
-        />
-        <Backlight
-          scale=1
-          position=" 169, -75, -15"
-          colour="1, 0.85, 0.5, 0.5"
-          width=40
-          length=1000
-          lifetime=5
-          elements=15
-          trailmaterial="Trail/backlighttrail"
-          material="Examples/Flare" />
       </attached>
       <collisionShapes>
@@ -193,6 +198,6 @@
         <BoxCollisionShape position="167,0,70"      halfExtents="17, 20, 20" />
       </collisionShapes>
+
     </Destroyer>
-    //-->
 
   </Scene>
Index: /code/branches/dockingsystem2/src/modules/docking/Dock.cc
===================================================================
--- /code/branches/dockingsystem2/src/modules/docking/Dock.cc	(revision 8381)
+++ /code/branches/dockingsystem2/src/modules/docking/Dock.cc	(revision 8382)
@@ -33,7 +33,11 @@
 
 #include "Dock.h"
+
 #include "infos/HumanPlayer.h"
 #include "worldentities/pawns/Pawn.h"
 #include "interfaces/PlayerTrigger.h"
+#include "controllers/HumanController.h"
+#include "core/command/ConsoleCommand.h"
+
 
 
@@ -41,4 +45,7 @@
 {
     CreateFactory(Dock);
+
+    SetConsoleCommand("Dock", "dock",    &Dock::cmdDock).addShortcut().setAsInputCommand();
+    SetConsoleCommand("Dock", "undock",  &Dock::cmdUndock).addShortcut().setAsInputCommand();
 
     Dock::Dock(BaseObject* creator) : StaticEntity(creator)
@@ -80,15 +87,15 @@
         {
             if(!pTrigger->isForPlayer()) {  // The PlayerTrigger is not exclusively for Pawns which means we cannot extract one.
-                COUT(0) << "Docking:execute PlayerTrigger was not triggered by a player.." << std::endl;
+                COUT(2) << "Docking:execute PlayerTrigger was not triggered by a player.." << std::endl;
                 return false;
             }
             pawn = pTrigger->getTriggeringPlayer();
         } else {
-            COUT(0) << "Docking::execute Not a player trigger, can't extract pawn from it.." << std::endl;
+            COUT(2) << "Docking::execute Not a player trigger, can't extract pawn from it.." << std::endl;
             return false;
         }
         if(pawn == NULL)
         {
-            COUT(0) << "Docking::execute Can't retrieve Pawn from Trigger. (" << trigger->getIdentifier()->getName() << ")" << std::endl;
+            COUT(2) << "Docking::execute Can't retrieve Pawn from Trigger. (" << trigger->getIdentifier()->getName() << ")" << std::endl;
             return false;
         }
@@ -98,5 +105,5 @@
         if(player == NULL)
         {
-            COUT(0) << "The PlayerInfo* is NULL." << std::endl;
+            COUT(2) << "The PlayerInfo* is NULL." << std::endl;
             return false;
         }
@@ -105,8 +112,13 @@
 
         if(bTriggered) {
-            DockingEffect::invokeEffect(docking::DOCKING, player, effects_);
-            DockingEffect::invokeEffect(docking::ATTACH, player, effects_);
+            // Add player to this Docks candidates
+            candidates.insert(player);
+
+            //DockingEffect::invokeEffect(docking::DOCKING, player, effects_);
         } else {
-            DockingEffect::invokeEffect(docking::RELEASE, player, effects_);
+            // Remove player from candidates list
+            candidates.erase(player);
+
+            //DockingEffect::invokeEffect(docking::RELEASE, player, effects_);
         }
 
@@ -115,7 +127,53 @@
 
 
+    void Dock::cmdDock() {
+        PlayerInfo* player = HumanController::getLocalControllerSingleton()->getPlayer();
+        for(ObjectList<Dock>::iterator it = ObjectList<Dock>::begin(); it != ObjectList<Dock>::end(); ++it) {
+            if(it->dock(player))
+                break;
+        }
+    }
+
+    void Dock::cmdUndock() {
+        PlayerInfo* player = HumanController::getLocalControllerSingleton()->getPlayer();
+        for(ObjectList<Dock>::iterator it = ObjectList<Dock>::begin(); it != ObjectList<Dock>::end(); ++it) {
+            if(it->undock(player))
+                break;
+        }
+    }
+
+
+    bool Dock::dock(PlayerInfo* player) {
+        // Check if player is a candidate
+        if(candidates.find(player) == candidates.end()) {
+            COUT(0) << "Player is not a candidate!";
+            return false;
+        }
+
+        // Remove player from candidates, add to docked players and invoke docking effect
+        candidates.erase(player);
+        docked.insert(player);
+        DockingEffect::invokeEffect(docking::ATTACH, player, effects);
+        return true;
+    }
+
+    bool Dock::undock(PlayerInfo* player) {
+        // Check if player is docked to this Dock
+        if(docked.find(player) == docked.end()) {
+            COUT(0) << "Player is not docked to this Dock." << std::endl;
+            return false;
+        }
+
+        // Remove player from docked, add to candidates and reverse DockingEffect 
+        docked.erase(player);
+        candidates.insert(player);
+        DockingEffect::invokeEffect(docking::RELEASE, player, effects);
+        return true;
+    }
+
+
     bool Dock::addEffect(DockingEffect* effect) {
         assert(effect);
-        effects_.push_back(effect);
+        effects.push_back(effect);
         return true;
     }
@@ -123,9 +181,7 @@
     const DockingEffect* Dock::getEffect(unsigned int index) const {
         int i = index;
-        for (std::list<DockingEffect*>::const_iterator effect = this->effects_.begin(); effect != this->effects_.end(); ++effect)
-        {
+        for (std::list<DockingEffect*>::const_iterator effect = this->effects.begin(); effect != this->effects.end(); ++effect) {
             if(i == 0)
                return *effect;
-
             i--;
         }
Index: /code/branches/dockingsystem2/src/modules/docking/Dock.h
===================================================================
--- /code/branches/dockingsystem2/src/modules/docking/Dock.h	(revision 8381)
+++ /code/branches/dockingsystem2/src/modules/docking/Dock.h	(revision 8382)
@@ -36,4 +36,6 @@
 #define _Dock_H__
 
+#include <map>
+
 #include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
@@ -41,9 +43,10 @@
 
 #include "worldentities/StaticEntity.h"
+#include "notifications/NotificationManager.h"
+
 #include "DockingEffect.h"
 #include "DockingPrereqs.h"
 
-namespace orxonox { 
-
+namespace orxonox {
 
     class _DockingExport Dock : public StaticEntity {
@@ -60,6 +63,14 @@
         const DockingEffect* getEffect(unsigned int index) const; //!< Get the DockingEffect at a given index.
 
+        bool dock(PlayerInfo* player); //!< Returns true if given player docked successfully (player must be a candidate)
+        bool undock(PlayerInfo* player); //!< Undocks a player (player must be docked)
+
+        static void cmdDock();
+        static void cmdUndock();
+
     private:
-        std::list<DockingEffect*> effects_; //!< The list of DockingEffects to be executed when a player docks.
+        std::set<PlayerInfo*> candidates; //!< A set of all players which are allowed to dock using the console command.
+        std::set<PlayerInfo*> docked; //!< A set of all docked players
+        std::list<DockingEffect*> effects; //!< The list of DockingEffects to be executed when a player docks.
     };
 
Index: /code/branches/dockingsystem2/src/modules/docking/DockToShip.cc
===================================================================
--- /code/branches/dockingsystem2/src/modules/docking/DockToShip.cc	(revision 8381)
+++ /code/branches/dockingsystem2/src/modules/docking/DockToShip.cc	(revision 8382)
@@ -89,4 +89,6 @@
         }
 
+        // Make sure target isn't removed when undocking
+        dockTo->setDestroyWhenPlayerLeft(false);
         player->startTemporaryControl(dockTo);
 
@@ -97,4 +99,7 @@
     {
         COUT(0) << "DockToShip::release" << endl;
+
+        player->stopTemporaryControl();
+
         return true;
     }
Index: /code/branches/dockingsystem2/src/orxonox/infos/PlayerInfo.cc
===================================================================
--- /code/branches/dockingsystem2/src/orxonox/infos/PlayerInfo.cc	(revision 8381)
+++ /code/branches/dockingsystem2/src/orxonox/infos/PlayerInfo.cc	(revision 8382)
@@ -223,5 +223,5 @@
         this->controllableEntity_->setController(0);
         
-        this->controllableEntity_ = this->previousControllableEntity_.back();
+//        this->controllableEntity_ = this->previousControllableEntity_.back();
         do {
             this->controllableEntity_ = this->previousControllableEntity_.back();
