Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 7, 2018, 9:16:52 PM (7 years ago)
Author:
landauf
Message:

[Highscore_HS16] removed playerName from Highscore because the player already has a name (see HumanPlayer.nick)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/Highscore.cc

    r11356 r11715  
    11#include "Highscore.h"
    22
    3 #include <vector>
    43#include "core/CoreIncludes.h"
    54#include "core/config/ConfigValueIncludes.h"
    65#include "core/singleton/ScopedSingletonIncludes.h"
     6#include "infos/PlayerInfo.h"
     7#include "util/Convert.h"
    78
    89namespace orxonox
    910{
    10 
    1111    ManageScopedSingleton(Highscore, ScopeID::ROOT, false);
    1212        RegisterClassNoArgs(Highscore);
     
    1717        this->setConfigValues();
    1818    }
     19
    1920    /**
    2021     * @brief set the config values in the orxonox.ini file
     
    2324    {
    2425        SetConfigValue(highscores_, std::vector<std::string>()).description("Highscores saved as vector");
    25         SetConfigValue(playerName_, "Player").description("Name of the player");
    2626    }
     27
    2728    /**
    2829     * @brief Returns highest score of given game, if exists.
    2930     * Else returns -1.
    3031     */
    31     int Highscore::getHighestScoreOfGame(std::string game){
    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"
    3334        int best = -1;
    3435        //check for the highest Score of given game
     
    3940            if(game.compare(score.substr(0,score.find(delimiter))) == 0){
    4041                score.erase(0, score.find(delimiter) + delimiter.length());
    41                 int possibleBest = std::stoi(score);
     42                int possibleBest = multi_cast<int>(score);
    4243                if(possibleBest > best) best = possibleBest;
    4344            }
    44 
    45 
    4645        }
    4746       
     
    4948       
    5049    }
     50
    5151    /**
    5252     * @brief stores a new highscore in the orxonox.ini file
    5353     */
    54     void Highscore::storeHighscore(std::string level, int points){
    55         ModifyConfigValue(highscores_, add, playerName_+"./."+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));
    5656    }
    57    
    5857}
Note: See TracChangeset for help on using the changeset viewer.