[Orxonox-commit 7151] r11768 - in code/branches/Presentation_HS17_merge/src: modules/superorxobros orxonox

landauf at orxonox.net landauf at orxonox.net
Sun Feb 18 16:27:43 CET 2018


Author: landauf
Date: 2018-02-18 16:27:43 +0100 (Sun, 18 Feb 2018)
New Revision: 11768

Modified:
   code/branches/Presentation_HS17_merge/src/modules/superorxobros/SOBFigure.cc
   code/branches/Presentation_HS17_merge/src/orxonox/Highscore.cc
   code/branches/Presentation_HS17_merge/src/orxonox/Highscore.h
Log:
[SOBv2_HS17] fixed build (Highscopre API has changed)

Modified: code/branches/Presentation_HS17_merge/src/modules/superorxobros/SOBFigure.cc
===================================================================
--- code/branches/Presentation_HS17_merge/src/modules/superorxobros/SOBFigure.cc	2018-02-18 15:10:35 UTC (rev 11767)
+++ code/branches/Presentation_HS17_merge/src/modules/superorxobros/SOBFigure.cc	2018-02-18 15:27:43 UTC (rev 11768)
@@ -384,12 +384,11 @@
         }
         if (reachedLvlEndState_ == 4) {
             //Highscore
-            if (Highscore::exists()){
-                    int score = SOBGame->getPoints();
-                    if(score > Highscore::getInstance().getHighestScoreOfGame("Super Orxo Bros.")) 
-                        Highscore::getInstance().storeHighscore("Super Orxo Bros.",score);
-                        SOBGame->newHighscore=1;
-
+            if (Highscore::exists())
+            {
+                int score = SOBGame->getPoints();
+                bool isHighScore = Highscore::getInstance().storeScore("Super Orxo Bros.", score, this->getPlayer());
+                SOBGame->newHighscore = isHighScore;
             }
             lvlEnded_ = true;
             dead_ = true;
@@ -496,4 +495,4 @@
     SOBGame->setDone(true);
 }
 
-}
\ No newline at end of file
+}

Modified: code/branches/Presentation_HS17_merge/src/orxonox/Highscore.cc
===================================================================
--- code/branches/Presentation_HS17_merge/src/orxonox/Highscore.cc	2018-02-18 15:10:35 UTC (rev 11767)
+++ code/branches/Presentation_HS17_merge/src/orxonox/Highscore.cc	2018-02-18 15:27:43 UTC (rev 11768)
@@ -81,12 +81,16 @@
 
     /**
      * @brief stores a new highscore in the orxonox.ini file if the new score is better than the highest score so far.
+     * @returns true if the given score marks a new high score
      */
-    void Highscore::storeScore(const std::string& level, int points, PlayerInfo* player)
+    bool Highscore::storeScore(const std::string& level, int points, PlayerInfo* player)
     {
         if (points > this->getHighestScoreOfGame(level))
         {
             ModifyConfigValue(highscores_, add, player->getName() + "./." + level + "./." + multi_cast<std::string>(points));
+            return true;
         }
+        else
+            return false;
     }
 }

Modified: code/branches/Presentation_HS17_merge/src/orxonox/Highscore.h
===================================================================
--- code/branches/Presentation_HS17_merge/src/orxonox/Highscore.h	2018-02-18 15:10:35 UTC (rev 11767)
+++ code/branches/Presentation_HS17_merge/src/orxonox/Highscore.h	2018-02-18 15:27:43 UTC (rev 11768)
@@ -48,7 +48,7 @@
             Highscore();              // Constructor
             void setConfigValues(); // Inherited function
 
-            void storeScore(const std::string& level, int points, PlayerInfo* player);
+            bool storeScore(const std::string& level, int points, PlayerInfo* player);
             int getHighestScoreOfGame(const std::string& game);
 
             // tolua_begin



More information about the Orxonox-commit mailing list