Changeset 11715 for code/trunk/src/orxonox/Highscore.cc
- Timestamp:
- Jan 7, 2018, 9:16:52 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/Highscore.cc
r11356 r11715 1 1 #include "Highscore.h" 2 2 3 #include <vector>4 3 #include "core/CoreIncludes.h" 5 4 #include "core/config/ConfigValueIncludes.h" 6 5 #include "core/singleton/ScopedSingletonIncludes.h" 6 #include "infos/PlayerInfo.h" 7 #include "util/Convert.h" 7 8 8 9 namespace orxonox 9 10 { 10 11 11 ManageScopedSingleton(Highscore, ScopeID::ROOT, false); 12 12 RegisterClassNoArgs(Highscore); … … 17 17 this->setConfigValues(); 18 18 } 19 19 20 /** 20 21 * @brief set the config values in the orxonox.ini file … … 23 24 { 24 25 SetConfigValue(highscores_, std::vector<std::string>()).description("Highscores saved as vector"); 25 SetConfigValue(playerName_, "Player").description("Name of the player");26 26 } 27 27 28 /** 28 29 * @brief Returns highest score of given game, if exists. 29 30 * Else returns -1. 30 31 */ 31 int Highscore::getHighestScoreOfGame( std::stringgame){32 std::string delimiter = "./."; //score save as "Playername./.game./.score"32 int Highscore::getHighestScoreOfGame(const std::string& game){ 33 const std::string delimiter = "./."; //score save as "Playername./.game./.score" 33 34 int best = -1; 34 35 //check for the highest Score of given game … … 39 40 if(game.compare(score.substr(0,score.find(delimiter))) == 0){ 40 41 score.erase(0, score.find(delimiter) + delimiter.length()); 41 int possibleBest = std::stoi(score);42 int possibleBest = multi_cast<int>(score); 42 43 if(possibleBest > best) best = possibleBest; 43 44 } 44 45 46 45 } 47 46 … … 49 48 50 49 } 50 51 51 /** 52 52 * @brief stores a new highscore in the orxonox.ini file 53 53 */ 54 void Highscore::storeHighscore( std::string level, int points){55 ModifyConfigValue(highscores_, add, player Name_+"./."+level+"./."+std::to_string(points));54 void Highscore::storeHighscore(const std::string& level, int points, PlayerInfo* player){ 55 ModifyConfigValue(highscores_, add, player->getName() + "./." + level + "./." + multi_cast<std::string>(points)); 56 56 } 57 58 57 }
Note: See TracChangeset
for help on using the changeset viewer.