Index: code/branches/presentation2012merge/src/orxonox/LevelInfo.cc
===================================================================
--- code/branches/presentation2012merge/src/orxonox/LevelInfo.cc	(revision 9269)
+++ code/branches/presentation2012merge/src/orxonox/LevelInfo.cc	(revision 9281)
@@ -42,5 +42,5 @@
 
     // LevelInfoItem
-    
+
     //! The list of allowed tags.
     /*static*/ std::set<std::string> LevelInfoItem::possibleTags_s = std::set<std::string>();
@@ -107,5 +107,5 @@
         SubString substr = SubString(tags, ",", " "); // Split the string into tags.
         const std::vector<std::string>& strings = substr.getAllStrings();
-        for(std::vector<std::string>::const_iterator it = strings.begin(); it != strings.end(); it++)
+        for (std::vector<std::string>::const_iterator it = strings.begin(); it != strings.end(); it++)
             this->addTag(*it, false);
 
@@ -118,12 +118,12 @@
         A comma-seperated string of all the allowed ship models for the shipselection.
     */
-    void LevelInfoItem::setShips(const std::string& ships)
+    void LevelInfoItem::setStartingShips(const std::string& ships)
     {
         SubString substr = SubString(ships, ",", " "); // Split the string into tags.
         const std::vector<std::string>& strings = substr.getAllStrings();
         for(std::vector<std::string>::const_iterator it = strings.begin(); it != strings.end(); it++)
-            this->addShip(*it, false);
-
-        this->shipsUpdated();
+            this->addStartingShip(*it, false);
+
+        this->startingshipsUpdated();
     }
 
@@ -161,10 +161,10 @@
         Returns true if the ship was successfully added, if the ship was already present it returns false.
     */
-    bool LevelInfoItem::addShip(const std::string& ship, bool update)
-    {
-        bool success = this->ships_.insert(ship).second;
+    bool LevelInfoItem::addStartingShip(const std::string& ship, bool update)
+    {
+        bool success = this->startingShips_.insert(ship).second;
         if(update && success)
-            this->shipsUpdated();
-            
+            this->startingshipsUpdated();
+
         return success;
     }
@@ -195,12 +195,12 @@
         Updates the comma-seperated string of all ships, if the set of tags has changed.
     */
-    void LevelInfoItem::shipsUpdated(void)
+    void LevelInfoItem::startingshipsUpdated(void)
     {
         std::stringstream stream;
         std::set<std::string>::iterator temp;
-        for(std::set<std::string>::iterator it = this->ships_.begin(); it != this->ships_.end(); )
+        for(std::set<std::string>::iterator it = this->startingShips_.begin(); it != this->startingShips_.end(); )
         {
             temp = it;
-            if(++it == this->ships_.end()) // If this is the last ship we don't add a comma.
+            if(++it == this->startingShips_.end()) // If this is the last ship we don't add a comma.
                 stream << *temp;
             else
@@ -210,4 +210,34 @@
         this->startingShipsString_ = std::string(stream.str());
     }
+
+    void LevelInfoItem::changeStartingShip(const std::string& model)
+    {
+        static std::string shipSelectionTag = "shipselection";
+        //HACK: Read Level XML File, find "shipselection", replace with ship model
+        std::string levelPath = "../levels/";
+        levelPath.append(this->getXMLFilename());
+        std::string tempPath = "../levels/";
+        tempPath.append("_temp.oxw");
+        orxout(user_status) << levelPath << endl;
+        orxout(user_status) << tempPath << endl;
+        std::ifstream myLevel (levelPath.c_str());
+        std::ofstream tempLevel (tempPath.c_str());
+        while(!myLevel.eof())
+        {
+            std::string buff;
+            std::getline(myLevel, buff);
+            std::string pawndesignString = "pawndesign=";
+            size_t found = buff.find(pawndesignString.append(shipSelectionTag));
+            if (found!= std::string::npos)
+                buff = buff.substr(0, found + 11) + model + buff.substr(found+11+shipSelectionTag.length(), std::string::npos);
+            tempLevel.write(buff.c_str(), buff.length());
+            tempLevel << std::endl;
+        }
+        myLevel.close();
+        tempLevel.close();
+        orxout(user_status) << "done" << endl;
+    }
+
+
     // LevelInfo
 
@@ -247,5 +277,5 @@
         XMLPortParam(LevelInfo, "screenshot", setScreenshot, getScreenshot, xmlelement, mode);
         XMLPortParam(LevelInfo, "tags", setTags, getTags, xmlelement, mode);
-        XMLPortParam(LevelInfo, "startingships", setShips, getShips, xmlelement, mode);
+        XMLPortParam(LevelInfo, "startingships", setStartingShips, getStartingShips, xmlelement, mode);
     }
 
@@ -263,5 +293,5 @@
         info->setScreenshot(this->getScreenshot());
         info->setTags(this->getTags());
-        info->setShips(this->getShips());
+        info->setStartingShips(this->getStartingShips());
         return info;
     }
