OpenTTD Source  20240919-master-gdf0233f4c2
highscore.h
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6  */
7 
10 #ifndef HIGHSCORE_H
11 #define HIGHSCORE_H
12 
13 #include "strings_type.h"
14 #include "company_type.h"
15 #include "settings_type.h"
16 
17 struct HighScore {
18  std::string name;
20  uint16_t score = 0;
21 };
22 
23 using HighScores = std::array<HighScore, 5>;
24 using HighScoresTable = std::array<HighScores, SP_HIGHSCORE_END>;
26 
27 void SaveToHighScore();
28 void LoadFromHighScore();
29 int8_t SaveHighScoreValue(const Company *c);
31 StringID EndGameGetPerformanceTitleFromValue(uint value);
32 void ShowHighscoreTable(int difficulty = SP_CUSTOM, int8_t rank = -1);
33 
34 #endif /* HIGHSCORE_H */
HighScore
Definition: highscore.h:17
StringID
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
strings_type.h
HighScore::title
StringID title
NOSAVE, has troubles with changing string-numbers.
Definition: highscore.h:19
_highscore_table
HighScoresTable _highscore_table
Table with all the high scores.
Definition: highscore.cpp:23
SP_CUSTOM
@ SP_CUSTOM
No profile, special "custom" highscore.
Definition: settings_type.h:46
HighScore::score
uint16_t score
The score for this high score. Do NOT change type, will break hs.dat.
Definition: highscore.h:20
SaveHighScoreValue
int8_t SaveHighScoreValue(const Company *c)
Save the highscore for the company.
Definition: highscore.cpp:57
settings_type.h
HighScore::name
std::string name
The name of the companyy and president.
Definition: highscore.h:18
ShowHighscoreTable
void ShowHighscoreTable(int difficulty=SP_CUSTOM, int8_t rank=-1)
Show the highscore table for a given difficulty.
Definition: highscore_gui.cpp:236
SaveToHighScore
void SaveToHighScore()
Save HighScore table to file.
Definition: highscore.cpp:123
LoadFromHighScore
void LoadFromHighScore()
Initialize the highscore table to 0 and if any file exists, load in values.
Definition: highscore.cpp:146
HighScores
std::array< HighScore, 5 > HighScores
Record 5 high scores.
Definition: highscore.h:23
HighScoresTable
std::array< HighScores, SP_HIGHSCORE_END > HighScoresTable
Record high score for each of the difficulty levels.
Definition: highscore.h:24
SaveHighScoreValueNetwork
int8_t SaveHighScoreValueNetwork()
Save the highscores in a network game when it has ended.
Definition: highscore.cpp:92
Company
Definition: company_base.h:133
company_type.h
INVALID_STRING_ID
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
Definition: strings_type.h:17