[Orxonox-commit 7099] r11716 - 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:48:58 CET 2018
Author: landauf
Date: 2018-01-07 21:48:58 +0100 (Sun, 07 Jan 2018)
New Revision: 11716
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] moved logic to compare old an new score to Highscore; fixed formatting in Gametypes
Modified: code/trunk/src/modules/dodgerace/DodgeRace.cc
===================================================================
--- code/trunk/src/modules/dodgerace/DodgeRace.cc 2018-01-07 20:16:52 UTC (rev 11715)
+++ code/trunk/src/modules/dodgerace/DodgeRace.cc 2018-01-07 20:48:58 UTC (rev 11716)
@@ -224,12 +224,11 @@
// Deathmatch::end();
// It will misteriously crash the game!
// Instead startMainMenu, this won't crash.
- if (Highscore::exists()){
- int score = this->getPoints();
- if(score > Highscore::getInstance().getHighestScoreOfGame("Dodge Race"))
- Highscore::getInstance().storeHighscore("Dodge Race",score,this->getPlayer()->getPlayer());
-
- }
+ if (Highscore::exists())
+ {
+ int score = this->getPoints();
+ Highscore::getInstance().storeScore("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 20:16:52 UTC (rev 11715)
+++ code/trunk/src/modules/invader/Invader.cc 2018-01-07 20:48:58 UTC (rev 11716)
@@ -188,12 +188,11 @@
// Deathmatch::end();
// It will misteriously crash the game!
// Instead startMainMenu, this won't crash.
- if (Highscore::exists()){
- int score = this->getPoints();
- if(score > Highscore::getInstance().getHighestScoreOfGame("Orxonox Arcade"))
- Highscore::getInstance().storeHighscore("Orxonox Arcade",score,this->getPlayer()->getPlayer());
-
- }
+ if (Highscore::exists())
+ {
+ int score = this->getPoints();
+ Highscore::getInstance().storeScore("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 20:16:52 UTC (rev 11715)
+++ code/trunk/src/modules/jump/Jump.cc 2018-01-07 20:48:58 UTC (rev 11716)
@@ -311,12 +311,11 @@
{
cleanup();
GSLevel::startMainMenu();
- if (Highscore::exists()){
- int score = this->getScore(this->getPlayer());
- if(score > Highscore::getInstance().getHighestScoreOfGame("Jump"))
- Highscore::getInstance().storeHighscore("Jump",score,this->getPlayer());
-
- }
+ if (Highscore::exists())
+ {
+ int score = this->getScore(this->getPlayer());
+ Highscore::getInstance().storeScore("Jump", score, this->getPlayer());
+ }
Deathmatch::end();
}
Modified: code/trunk/src/modules/tetris/Tetris.cc
===================================================================
--- code/trunk/src/modules/tetris/Tetris.cc 2018-01-07 20:16:52 UTC (rev 11715)
+++ code/trunk/src/modules/tetris/Tetris.cc 2018-01-07 20:48:58 UTC (rev 11716)
@@ -327,12 +327,11 @@
{
this->player_->stopControl();
}
- if (Highscore::exists()){
- int score = this->getScore(this->getPlayer());
- if(score > Highscore::getInstance().getHighestScoreOfGame("Tetris"))
- Highscore::getInstance().storeHighscore("Tetris",score,this->getPlayer());
-
- }
+ if (Highscore::exists())
+ {
+ int score = this->getScore(this->getPlayer());
+ Highscore::getInstance().storeScore("Tetris", score, this->getPlayer());
+ }
this->cleanup();
// Call end for the parent class.
Modified: code/trunk/src/modules/towerdefense/TowerDefense.cc
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefense.cc 2018-01-07 20:16:52 UTC (rev 11715)
+++ code/trunk/src/modules/towerdefense/TowerDefense.cc 2018-01-07 20:48:58 UTC (rev 11716)
@@ -197,12 +197,11 @@
void TowerDefense::end()
{
- if (Highscore::exists()){
- int score = this->getWaveNumber();
- if(score > Highscore::getInstance().getHighestScoreOfGame("Tower Defense"))
- Highscore::getInstance().storeHighscore("Tower Defense",score,this->getPlayer());
-
- }
+ if (Highscore::exists())
+ {
+ int score = this->getWaveNumber();
+ Highscore::getInstance().storeScore("Tower Defense", score, this->getPlayer());
+ }
TeamDeathmatch::end();
ChatManager::message("Match is over! Gameover!");
Modified: code/trunk/src/orxonox/Highscore.cc
===================================================================
--- code/trunk/src/orxonox/Highscore.cc 2018-01-07 20:16:52 UTC (rev 11715)
+++ code/trunk/src/orxonox/Highscore.cc 2018-01-07 20:48:58 UTC (rev 11716)
@@ -49,9 +49,11 @@
}
/**
- * @brief stores a new highscore in the orxonox.ini file
+ * @brief stores a new highscore in the orxonox.ini file if the new score is better than the highest score so far.
*/
- void Highscore::storeHighscore(const std::string& level, int points, PlayerInfo* player){
- ModifyConfigValue(highscores_, add, player->getName() + "./." + level + "./." + multi_cast<std::string>(points));
+ void 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));
+ }
}
}
Modified: code/trunk/src/orxonox/Highscore.h
===================================================================
--- code/trunk/src/orxonox/Highscore.h 2018-01-07 20:16:52 UTC (rev 11715)
+++ code/trunk/src/orxonox/Highscore.h 2018-01-07 20:48:58 UTC (rev 11716)
@@ -17,7 +17,7 @@
Highscore(); // Constructor
void setConfigValues(); // Inherited function
- void storeHighscore(const std::string& level, int points, PlayerInfo* player);
+ void 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