Index: code/branches/objecthierarchy/src/orxonox/objects/gametypes/Gametype.cc
===================================================================
--- code/branches/objecthierarchy/src/orxonox/objects/gametypes/Gametype.cc	(revision 2112)
+++ code/branches/objecthierarchy/src/orxonox/objects/gametypes/Gametype.cc	(revision 2160)
@@ -67,7 +67,8 @@
         if (!this->bStarted_)
             this->checkStart();
+        else
+            this->spawnDeadPlayersIfRequested();
 
         this->assignDefaultPawnsIfNeeded();
-        this->spawnDeadPlayersIfRequested();
     }
 
@@ -88,5 +89,5 @@
     void Gametype::playerEntered(PlayerInfo* player)
     {
-        this->players_.insert(player);
+        this->players_[player] = PlayerState::Joined;
 
         std::string message = player->getName() + " entered the game";
@@ -97,5 +98,5 @@
     void Gametype::playerLeft(PlayerInfo* player)
     {
-        std::set<PlayerInfo*>::iterator it = this->players_.find(player);
+        std::map<PlayerInfo*, PlayerState::Enum>::iterator it = this->players_.find(player);
         if (it != this->players_.end())
         {
@@ -165,11 +166,11 @@
     }
 
-    void Gametype::assignDefaultPawnsIfNeeded() const
-    {
-        for (std::set<PlayerInfo*>::const_iterator it = this->players_.begin(); it != this->players_.end(); ++it)
-        {
-            if (!(*it)->getControllableEntity() && (!(*it)->isReadyToSpawn() || !this->bStarted_))
-            {
-                SpawnPoint* spawn = this->getBestSpawnPoint(*it);
+    void Gametype::assignDefaultPawnsIfNeeded()
+    {
+        for (std::map<PlayerInfo*, PlayerState::Enum>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
+        {
+            if (!it->first->getControllableEntity() && (!it->first->isReadyToSpawn() || !this->bStarted_))
+            {
+                SpawnPoint* spawn = this->getBestSpawnPoint(it->first);
                 if (spawn)
                 {
@@ -177,5 +178,6 @@
                     ControllableEntity* entity = this->defaultControllableEntity_.fabricate(spawn);
                     spawn->spawn(entity);
-                    (*it)->startControl(entity);
+                    it->first->startControl(entity);
+                    it->second = PlayerState::Dead;
                 }
                 else
@@ -210,7 +212,7 @@
                 {
                     bool allplayersready = true;
-                    for (std::set<PlayerInfo*>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
+                    for (std::map<PlayerInfo*, PlayerState::Enum>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
                     {
-                        if (!(*it)->isReadyToSpawn())
+                        if (!it->first->isReadyToSpawn())
                             allplayersready = false;
                     }
@@ -227,15 +229,15 @@
     void Gametype::spawnPlayersIfRequested()
     {
-        for (std::set<PlayerInfo*>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
-            if ((*it)->isReadyToSpawn() || this->bForceSpawn_)
-                this->spawnPlayer(*it);
+        for (std::map<PlayerInfo*, PlayerState::Enum>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
+            if (it->first->isReadyToSpawn() || this->bForceSpawn_)
+                this->spawnPlayer(it->first);
     }
 
     void Gametype::spawnDeadPlayersIfRequested()
     {
-        for (std::set<PlayerInfo*>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
-            if (!(*it)->getControllableEntity())
-                if ((*it)->isReadyToSpawn() || this->bForceSpawn_)
-                    this->spawnPlayer(*it);
+        for (std::map<PlayerInfo*, PlayerState::Enum>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
+            if (it->second == PlayerState::Dead)
+                if (it->first->isReadyToSpawn() || this->bForceSpawn_)
+                    this->spawnPlayer(it->first);
     }
 
@@ -246,4 +248,5 @@
         {
             player->startControl(spawnpoint->spawn());
+            this->players_[player] = PlayerState::Alive;
         }
         else
