OpenTTD Source  20241121-master-g67a0fccfad
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 */
Types related to companies.
void ShowHighscoreTable(int difficulty=SP_CUSTOM, int8_t rank=-1)
Show the highscore table for a given difficulty.
void LoadFromHighScore()
Initialize the highscore table to 0 and if any file exists, load in values.
Definition: highscore.cpp:143
std::array< HighScores, SP_HIGHSCORE_END > HighScoresTable
Record high score for each of the difficulty levels.
Definition: highscore.h:24
int8_t SaveHighScoreValueNetwork()
Save the highscores in a network game when it has ended.
Definition: highscore.cpp:89
void SaveToHighScore()
Save HighScore table to file.
Definition: highscore.cpp:120
std::array< HighScore, 5 > HighScores
Record 5 high scores.
Definition: highscore.h:23
HighScoresTable _highscore_table
Table with all the high scores.
Definition: highscore.cpp:23
int8_t SaveHighScoreValue(const Company *c)
Save the highscore for the company.
Definition: highscore.cpp:57
Types related to global configuration settings.
@ SP_CUSTOM
No profile, special "custom" highscore.
Definition: settings_type.h:46
Types related to strings.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
Definition: strings_type.h:17
std::string name
The name of the companyy and president.
Definition: highscore.h:18
uint16_t score
The score for this high score. Do NOT change type, will break hs.dat.
Definition: highscore.h:20
StringID title
NOSAVE, has troubles with changing string-numbers.
Definition: highscore.h:19