OpenTTD Source 20241224-master-gf74b0cf984
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
17struct HighScore {
18 std::string name;
20 uint16_t score = 0;
21};
22
23using HighScores = std::array<HighScore, 5>;
24using HighScoresTable = std::array<HighScores, SP_HIGHSCORE_END>;
26
27void SaveToHighScore();
29int8_t SaveHighScoreValue(const Company *c);
31StringID EndGameGetPerformanceTitleFromValue(uint value);
32void 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.
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.
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.
Types related to strings.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
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