[Orxonox-commit 7098] r11715 - in code/trunk/src: modules/dodgerace modules/invader modules/jump modules/tetris modules/towerdefense orxonox

landauf at orxonox.net landauf at orxonox.net
Sun Jan 7 21:16:52 CET 2018


Author: landauf
Date: 2018-01-07 21:16:52 +0100 (Sun, 07 Jan 2018)
New Revision: 11715

Modified:
   code/trunk/src/modules/dodgerace/DodgeRace.cc
   code/trunk/src/modules/invader/Invader.cc
   code/trunk/src/modules/jump/Jump.cc
   code/trunk/src/modules/tetris/Tetris.cc
   code/trunk/src/modules/towerdefense/TowerDefense.cc
   code/trunk/src/orxonox/Highscore.cc
   code/trunk/src/orxonox/Highscore.h
Log:
[Highscore_HS16] removed playerName from Highscore because the player already has a name (see HumanPlayer.nick)

Modified: code/trunk/src/modules/dodgerace/DodgeRace.cc
===================================================================
--- code/trunk/src/modules/dodgerace/DodgeRace.cc	2018-01-07 19:03:19 UTC (rev 11714)
+++ code/trunk/src/modules/dodgerace/DodgeRace.cc	2018-01-07 20:16:52 UTC (rev 11715)
@@ -227,7 +227,7 @@
         if (Highscore::exists()){
                     int score = this->getPoints();
                     if(score > Highscore::getInstance().getHighestScoreOfGame("Dodge Race")) 
-                        Highscore::getInstance().storeHighscore("Dodge Race",score);
+                        Highscore::getInstance().storeHighscore("Dodge Race",score,this->getPlayer()->getPlayer());
 
           }
         GSLevel::startMainMenu();

Modified: code/trunk/src/modules/invader/Invader.cc
===================================================================
--- code/trunk/src/modules/invader/Invader.cc	2018-01-07 19:03:19 UTC (rev 11714)
+++ code/trunk/src/modules/invader/Invader.cc	2018-01-07 20:16:52 UTC (rev 11715)
@@ -191,7 +191,7 @@
         if (Highscore::exists()){
                     int score = this->getPoints();
                     if(score > Highscore::getInstance().getHighestScoreOfGame("Orxonox Arcade")) 
-                        Highscore::getInstance().storeHighscore("Orxonox Arcade",score);
+                        Highscore::getInstance().storeHighscore("Orxonox Arcade",score,this->getPlayer()->getPlayer());
 
           }
         GSLevel::startMainMenu();

Modified: code/trunk/src/modules/jump/Jump.cc
===================================================================
--- code/trunk/src/modules/jump/Jump.cc	2018-01-07 19:03:19 UTC (rev 11714)
+++ code/trunk/src/modules/jump/Jump.cc	2018-01-07 20:16:52 UTC (rev 11715)
@@ -314,7 +314,7 @@
         if (Highscore::exists()){
                     int score = this->getScore(this->getPlayer());
                     if(score > Highscore::getInstance().getHighestScoreOfGame("Jump")) 
-                        Highscore::getInstance().storeHighscore("Jump",score);
+                        Highscore::getInstance().storeHighscore("Jump",score,this->getPlayer());
 
           }
         Deathmatch::end();

Modified: code/trunk/src/modules/tetris/Tetris.cc
===================================================================
--- code/trunk/src/modules/tetris/Tetris.cc	2018-01-07 19:03:19 UTC (rev 11714)
+++ code/trunk/src/modules/tetris/Tetris.cc	2018-01-07 20:16:52 UTC (rev 11715)
@@ -330,7 +330,7 @@
          if (Highscore::exists()){
                     int score = this->getScore(this->getPlayer());
                     if(score > Highscore::getInstance().getHighestScoreOfGame("Tetris")) 
-                        Highscore::getInstance().storeHighscore("Tetris",score);
+                        Highscore::getInstance().storeHighscore("Tetris",score,this->getPlayer());
 
           }
         this->cleanup();

Modified: code/trunk/src/modules/towerdefense/TowerDefense.cc
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefense.cc	2018-01-07 19:03:19 UTC (rev 11714)
+++ code/trunk/src/modules/towerdefense/TowerDefense.cc	2018-01-07 20:16:52 UTC (rev 11715)
@@ -200,7 +200,7 @@
         if (Highscore::exists()){
                     int score = this->getWaveNumber();
                     if(score > Highscore::getInstance().getHighestScoreOfGame("Tower Defense")) 
-                        Highscore::getInstance().storeHighscore("Tower Defense",score);
+                        Highscore::getInstance().storeHighscore("Tower Defense",score,this->getPlayer());
 
           }
         TeamDeathmatch::end();

Modified: code/trunk/src/orxonox/Highscore.cc
===================================================================
--- code/trunk/src/orxonox/Highscore.cc	2018-01-07 19:03:19 UTC (rev 11714)
+++ code/trunk/src/orxonox/Highscore.cc	2018-01-07 20:16:52 UTC (rev 11715)
@@ -1,13 +1,13 @@
 #include "Highscore.h"
 
-#include <vector>
 #include "core/CoreIncludes.h"
 #include "core/config/ConfigValueIncludes.h"
 #include "core/singleton/ScopedSingletonIncludes.h"
+#include "infos/PlayerInfo.h"
+#include "util/Convert.h"
 
 namespace orxonox
 {
-
     ManageScopedSingleton(Highscore, ScopeID::ROOT, false);
 	RegisterClassNoArgs(Highscore);
 
@@ -16,6 +16,7 @@
         RegisterObject(Highscore);
         this->setConfigValues();
     }
+
     /**
      * @brief set the config values in the orxonox.ini file
      */
@@ -22,14 +23,14 @@
     void Highscore::setConfigValues()
     {
         SetConfigValue(highscores_, std::vector<std::string>()).description("Highscores saved as vector");
-        SetConfigValue(playerName_, "Player").description("Name of the player");
     }
+
     /**
      * @brief Returns highest score of given game, if exists.
      * Else returns -1.
      */
-    int Highscore::getHighestScoreOfGame(std::string game){
-        std::string delimiter = "./."; //score save as "Playername./.game./.score"
+    int Highscore::getHighestScoreOfGame(const std::string& game){
+        const std::string delimiter = "./."; //score save as "Playername./.game./.score"
         int best = -1;
         //check for the highest Score of given game
         for (std::string score : this->highscores_)
@@ -38,21 +39,19 @@
             score.erase(0, score.find(delimiter) + delimiter.length());
             if(game.compare(score.substr(0,score.find(delimiter))) == 0){
                 score.erase(0, score.find(delimiter) + delimiter.length());
-                int possibleBest = std::stoi(score);
+                int possibleBest = multi_cast<int>(score);
                 if(possibleBest > best) best = possibleBest;
             }
-
-
         }
         
         return best;
         
     }
+
     /**
      * @brief stores a new highscore in the orxonox.ini file
      */
-    void Highscore::storeHighscore(std::string level, int points){
-        ModifyConfigValue(highscores_, add, playerName_+"./."+level+"./."+std::to_string(points));
+    void Highscore::storeHighscore(const std::string& level, int points, PlayerInfo* player){
+        ModifyConfigValue(highscores_, add, player->getName() + "./." + level + "./." + multi_cast<std::string>(points));
     }
-    
 }

Modified: code/trunk/src/orxonox/Highscore.h
===================================================================
--- code/trunk/src/orxonox/Highscore.h	2018-01-07 19:03:19 UTC (rev 11714)
+++ code/trunk/src/orxonox/Highscore.h	2018-01-07 20:16:52 UTC (rev 11715)
@@ -1,7 +1,10 @@
 #include <string>
+#include <vector>
+
+#include "OrxonoxPrereqs.h"
 #include "core/config/Configurable.h"
-#include "OrxonoxPrereqs.h"
 #include "util/Singleton.h"
+
 // tolua_begin
 namespace orxonox
 {
@@ -13,27 +16,24 @@
     public:
         Highscore();              // Constructor
         void setConfigValues(); // Inherited function
-        void storeHighscore(std::string level, int points);
 
-        int getHighestScoreOfGame(std::string game);
+        void storeHighscore(const std::string& level, int points, PlayerInfo* player);
+        int getHighestScoreOfGame(const std::string& game);
+
         // tolua_begin
         inline unsigned int getNumberOfHighscores()
-                { return this->highscores_.size(); }
-            inline const std::string& getHighscore(unsigned int index)
-                { return this->highscores_[index]; }
+            { return this->highscores_.size(); }
+        inline const std::string& getHighscore(unsigned int index)
+            { return this->highscores_[index]; }
 
         static Highscore& getInstance()
-                { return Singleton<Highscore>::getInstance(); }
-
+            { return Singleton<Highscore>::getInstance(); }
         // tolua_end 
 
-
     private:
         std::vector<std::string> highscores_;
-        float version_;
-        std::string playerName_;
         static Highscore* singletonPtr_s;
 }; //tolua_export
 
 
-} //tolua_export
\ No newline at end of file
+} //tolua_export



More information about the Orxonox-commit mailing list