Index: code/branches/dynamicmatch/src/orxonox/gametypes/Dynamicmatch.cc
===================================================================
--- code/branches/dynamicmatch/src/orxonox/gametypes/Dynamicmatch.cc	(revision 6847)
+++ code/branches/dynamicmatch/src/orxonox/gametypes/Dynamicmatch.cc	(revision 6848)
@@ -56,4 +56,5 @@
 #include "items/Engine.h"
 #include "tools/Timer.h"
+#include "worldentities/TeamSpawnPoint.h"
 
 namespace orxonox
@@ -99,5 +100,5 @@
     }
 
-    bool Dynamicmatch::allowPawnDamage(Pawn* victim, Pawn* originator)//tested - works fine
+    bool Dynamicmatch::allowPawnDamage(Pawn* victim, Pawn* originator)
     {	
         if (!originator||!victim)
@@ -113,17 +114,13 @@
 			
                 numberOf[target]--;				//decrease numberof victims's party
-                const std::string& message = std::string(" Chasers ") + multi_cast<std::string>(numberOf[chaser]); COUT(0) << message << std::endl; Host::Broadcast(message);
                 playerParty_[victim->getPlayer()]=piggy;	//victim's new party: pig
                 setPlayerColour(victim->getPlayer());		//victim's new colour
                 numberOf[piggy]++; 				//party switch: number of players is not affected (decrease and increase)
-                const std::string& message1 = std::string(" Pig") + multi_cast<std::string>(numberOf[piggy]); COUT(0) << message1 << std::endl; Host::Broadcast(message1);
                     if (notEnoughKillers) 			//reward the originator
                     {
                         numberOf[source]--;			//decrease numberof originator's party
-                        const std::string& message = std::string(" Chasers ") + multi_cast<std::string>(numberOf[chaser]); COUT(0) << message << std::endl; Host::Broadcast(message);
                         playerParty_[originator->getPlayer()]=killer;		//originator's new party: killer
                         setPlayerColour(originator->getPlayer());		//originator's new colour
                         numberOf[killer]++;
-                        const std::string& message2 = std::string(" Killers ") + multi_cast<std::string>(numberOf[killer]); COUT(0) << message2 << std::endl; Host::Broadcast(message2);
                     }
                 evaluatePlayerParties(); 			//check if the party change has to trigger futher party changes
@@ -137,7 +134,4 @@
                     new Timer(10, false, &createExecutor(createFunctor(&Dynamicmatch::resetSpeedFactor, this))->setDefaultValue(0, ptr), true);
                 }
-                std::string message5("First victim.");// for testing purposes
-                COUT(0) << message5 << std::endl;
-                Host::Broadcast(message5);
             }
 
@@ -149,5 +143,4 @@
                 setPlayerColour(victim->getPlayer()); 		//victim colour
                 numberOf[killer]++;				//party switch: number of players is not affected (decrease and increase)
-                const std::string& message = std::string(" Killers ") + multi_cast<std::string>(numberOf[killer]); COUT(0) << message << std::endl; Host::Broadcast(message);
                 evaluatePlayerParties();			//check if the party change has to trigger futher party changes
             }
@@ -159,5 +152,4 @@
                 setPlayerColour(victim->getPlayer()); 		//victim colour
                 numberOf[chaser]++;				//party switch: number of players is not affected (decrease and increase)
-                const std::string& message = std::string(" Chasers ") + multi_cast<std::string>(numberOf[chaser]); COUT(0) << message << std::endl; Host::Broadcast(message);
                 evaluatePlayerParties();			//check if the party change has to trigger futher party changes
             }
@@ -184,8 +176,4 @@
                 playerParty_[victim->getPlayer()]=piggy;
                 playerParty_[originator->getPlayer()]=chaser;
-                //announce
-                const std::string& messageVictim = victim->getPlayer()->getName() + " is victim";
-                COUT(0) << messageVictim << std::endl;
-                Host::Broadcast(messageVictim);
 
                 //party switch -> colour switch		
@@ -203,5 +191,5 @@
 
             }
-            //TODO: killer vs piggy
+            // killer vs piggy
             else if (source==killer &&target==piggy)		//party and colour switch	
             {
@@ -260,5 +248,5 @@
             return;
         playerParty_[player]=chaser;		//Set playerparty
-        numberOf[chaser]++; const std::string& message = std::string(" Chasers ") + multi_cast<std::string>(numberOf[chaser]); COUT(0) << message << std::endl; Host::Broadcast(message);
+        numberOf[chaser]++;
         Gametype::playerEntered(player);
         const std::string& message6 = player->getName() + " entered the game";
@@ -290,11 +278,8 @@
     }
 
-   
-
-    
 
     void Dynamicmatch::tick(float dt)
     {
-        SUPER(Dynamicmatch, tick, dt);//TODO - was bedeutet diese Zeile
+        SUPER(Dynamicmatch, tick, dt);
 
         if (this->hasStarted() && !gameEnded_)
@@ -336,4 +321,7 @@
     {
         //durch alle Spieler iterieren
+        /*std::string message("Game started!");
+            COUT(0) << message << std::endl;
+            Host::Broadcast(message);*/
         // allen Spielern mit der Pig-party frags++
         ;
@@ -369,7 +357,5 @@
         //chasers: there are more chasers than killers + pigs
         if (numberOf[piggy]+numberOf[killer] > numberOf[chaser]) {notEnoughChasers=true;}
-        else {notEnoughChasers=false; const std::string& message = "Players Evaluated";COUT(0) << message << std::endl; Host::Broadcast(message);}
-	const std::string& messagetest = multi_cast<std::string>(numberOf[piggy]+numberOf[chaser]+numberOf[killer]) + "   players!";
-        COUT(0) << messagetest << std::endl; Host::Broadcast(messagetest);	
+        else {notEnoughChasers=false;}	
     }
 
@@ -440,5 +426,5 @@
         COUT(0) << message << std::endl;
         Host::Broadcast(message);
-	/*for (std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)
+	/*for (std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)
                 {
                     if (it->first->getClientID() == CLIENTID_UNKNOWN)
@@ -451,4 +437,43 @@
                 }*/
     }
+    SpawnPoint* Dynamicmatch::getBestSpawnPoint(PlayerInfo* player) const
+    {
+        int desiredTeamNr = -1;
+        std::map<PlayerInfo*, int>::const_iterator it_player = this->playerParty_.find(player);
+        if (it_player != this->playerParty_.end())
+            desiredTeamNr = it_player->second;
+
+        // Only use spawnpoints of the own team (or non-team-spawnpoints)
+        std::set<SpawnPoint*> teamSpawnPoints = this->spawnpoints_;
+        for (std::set<SpawnPoint*>::iterator it = teamSpawnPoints.begin(); it != teamSpawnPoints.end(); )
+        {
+            if ((*it)->isA(Class(TeamSpawnPoint)))
+            {
+                TeamSpawnPoint* tsp = orxonox_cast<TeamSpawnPoint*>(*it);
+                if (tsp && static_cast<int>(tsp->getTeamNumber()) != desiredTeamNr)//getTeamNumber!!
+                {
+                    teamSpawnPoints.erase(it++);
+                    continue;
+                }
+            }
+
+            ++it;
+        }
+
+        if (teamSpawnPoints.size() > 0)
+        {
+            unsigned int randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(teamSpawnPoints.size())));
+            unsigned int index = 0;
+            for (std::set<SpawnPoint*>::const_iterator it = teamSpawnPoints.begin(); it != teamSpawnPoints.end(); ++it)
+            {
+                if (index == randomspawn)
+                    return (*it);
+
+                ++index;
+            }
+        }
+
+        return 0;
+    }
 
 }
Index: code/branches/dynamicmatch/src/orxonox/gametypes/Dynamicmatch.h
===================================================================
--- code/branches/dynamicmatch/src/orxonox/gametypes/Dynamicmatch.h	(revision 6847)
+++ code/branches/dynamicmatch/src/orxonox/gametypes/Dynamicmatch.h	(revision 6848)
@@ -64,5 +64,6 @@
             void resetSpeedFactor(WeakPtr<Engine>* ptr);  
             void tick (float dt);// used to end the game
-            //three different parties	TODO const machen!	
+            SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const;
+            //three different parties	
             int chaser;
             int piggy;
@@ -78,5 +79,5 @@
             unsigned int numberOf[3]; //array to count number of chasers, pigs, killers
             float pointsPerTime;
-            float gameTime_;   // from UnderAttack better: use gametype interface!!!
+            float gameTime_;   // from UnderAttack
             bool gameEnded_; // true if game is over
             int timesequence_; //used for countdown
