Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11717


Ignore:
Timestamp:
Jan 7, 2018, 10:01:00 PM (7 years ago)
Author:
landauf
Message:

[Highscore_HS16] added license, added include guard, fixed formatting

Location:
code/trunk/src/orxonox
Files:
2 edited

Legend:

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

    r11716 r11717  
     1/*
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *                    > www.orxonox.net <
     4 *
     5 *
     6 *   License notice:
     7 *
     8 *   This program is free software; you can redistribute it and/or
     9 *   modify it under the terms of the GNU General Public License
     10 *   as published by the Free Software Foundation; either version 2
     11 *   of the License, or (at your option) any later version.
     12 *
     13 *   This program is distributed in the hope that it will be useful,
     14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 *   GNU General Public License for more details.
     17 *
     18 *   You should have received a copy of the GNU General Public License
     19 *   along with this program; if not, write to the Free Software
     20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     21 *
     22 *   Author:
     23 *      kappenh
     24 *   Co-authors:
     25 *      ...
     26 *
     27 */
     28
    129#include "Highscore.h"
    230
     
    1038{
    1139    ManageScopedSingleton(Highscore, ScopeID::ROOT, false);
    12         RegisterClassNoArgs(Highscore);
     40    RegisterClassNoArgs(Highscore);
    1341
    14         Highscore::Highscore()
     42    Highscore::Highscore()
    1543    {
    1644        RegisterObject(Highscore);
     
    3058     * Else returns -1.
    3159     */
    32     int Highscore::getHighestScoreOfGame(const std::string& game){
     60    int Highscore::getHighestScoreOfGame(const std::string& game)
     61    {
    3362        const std::string delimiter = "./."; //score save as "Playername./.game./.score"
    3463        int best = -1;
     
    3867            //filter the game string from given highscore
    3968            score.erase(0, score.find(delimiter) + delimiter.length());
    40             if(game.compare(score.substr(0,score.find(delimiter))) == 0){
     69            if (game.compare(score.substr(0,score.find(delimiter))) == 0)
     70            {
    4171                score.erase(0, score.find(delimiter) + delimiter.length());
    4272                int possibleBest = multi_cast<int>(score);
    43                 if(possibleBest > best) best = possibleBest;
     73                if (possibleBest > best)
     74                    best = possibleBest;
    4475            }
    4576        }
     
    5283     * @brief stores a new highscore in the orxonox.ini file if the new score is better than the highest score so far.
    5384     */
    54     void Highscore::storeScore(const std::string& level, int points, PlayerInfo* player){
    55         if (points > this->getHighestScoreOfGame(level)) {
     85    void Highscore::storeScore(const std::string& level, int points, PlayerInfo* player)
     86    {
     87        if (points > this->getHighestScoreOfGame(level))
     88        {
    5689            ModifyConfigValue(highscores_, add, player->getName() + "./." + level + "./." + multi_cast<std::string>(points));
    5790        }
  • code/trunk/src/orxonox/Highscore.h

    r11716 r11717  
     1/*
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *                    > www.orxonox.net <
     4 *
     5 *
     6 *   License notice:
     7 *
     8 *   This program is free software; you can redistribute it and/or
     9 *   modify it under the terms of the GNU General Public License
     10 *   as published by the Free Software Foundation; either version 2
     11 *   of the License, or (at your option) any later version.
     12 *
     13 *   This program is distributed in the hope that it will be useful,
     14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 *   GNU General Public License for more details.
     17 *
     18 *   You should have received a copy of the GNU General Public License
     19 *   along with this program; if not, write to the Free Software
     20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     21 *
     22 *   Author:
     23 *      kappenh
     24 *   Co-authors:
     25 *      ...
     26 *
     27 */
     28
     29#ifndef _Highscore_H__
     30#define _Highscore_H__
     31
    132#include <string>
    233#include <vector>
     
    940namespace orxonox
    1041{
    11 class _OrxonoxExport Highscore
    12 // tolua_end
    13  : public Singleton<Highscore>, public Configurable
    14 { //tolua_export
    15     friend class Singleton<Highscore>;
    16     public:
    17         Highscore();              // Constructor
    18         void setConfigValues(); // Inherited function
     42    class _OrxonoxExport Highscore
     43    // tolua_end
     44     : public Singleton<Highscore>, public Configurable
     45    { //tolua_export
     46        friend class Singleton<Highscore>;
     47        public:
     48            Highscore();              // Constructor
     49            void setConfigValues(); // Inherited function
    1950
    20         void storeScore(const std::string& level, int points, PlayerInfo* player);
    21         int getHighestScoreOfGame(const std::string& game);
     51            void storeScore(const std::string& level, int points, PlayerInfo* player);
     52            int getHighestScoreOfGame(const std::string& game);
    2253
    23         // tolua_begin
    24         inline unsigned int getNumberOfHighscores()
    25             { return this->highscores_.size(); }
    26         inline const std::string& getHighscore(unsigned int index)
    27             { return this->highscores_[index]; }
     54            // tolua_begin
     55            inline unsigned int getNumberOfHighscores()
     56                { return this->highscores_.size(); }
     57            inline const std::string& getHighscore(unsigned int index)
     58                { return this->highscores_[index]; }
    2859
    29         static Highscore& getInstance()
    30             { return Singleton<Highscore>::getInstance(); }
    31         // tolua_end
     60            static Highscore& getInstance()
     61                { return Singleton<Highscore>::getInstance(); }
     62            // tolua_end
    3263
    33     private:
    34         std::vector<std::string> highscores_;
    35         static Highscore* singletonPtr_s;
    36 }; //tolua_export
    37 
     64        private:
     65            std::vector<std::string> highscores_;
     66            static Highscore* singletonPtr_s;
     67    }; //tolua_export
    3868
    3969} //tolua_export
     70
     71#endif /* _Highscore_H__ */
Note: See TracChangeset for help on using the changeset viewer.