OpenTTD Source: src/highscore.h Source File

OpenTTD Source 15.3

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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
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;
19 StringID title = INVALID_STRING_ID;
20 uint16_t score = 0;
21};
22
23 using HighScores = std::array<HighScore, 5>;
24 using HighScoresTable = std::array<HighScores, SP_HIGHSCORE_END>;
25extern HighScoresTable _highscore_table;
26
27void SaveToHighScore();
28void LoadFromHighScore();
29int8_t SaveHighScoreValue(const Company *c);
30int8_t SaveHighScoreValueNetwork();
31 StringID EndGameGetPerformanceTitleFromValue(uint value);
32void ShowHighscoreTable(int difficulty = SP_CUSTOM, int8_t rank = -1);
33
34#endif /* HIGHSCORE_H */
company_type.h
Types related to companies.
ShowHighscoreTable
void ShowHighscoreTable(int difficulty=SP_CUSTOM, int8_t rank=-1)
Show the highscore table for a given difficulty.
Definition highscore_gui.cpp:243
LoadFromHighScore
void LoadFromHighScore()
Initialize the highscore table to 0 and if any file exists, load in values.
Definition highscore.cpp:139
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:88
SaveToHighScore
void SaveToHighScore()
Save HighScore table to file.
Definition highscore.cpp:116
HighScores
std::array< HighScore, 5 > HighScores
Record 5 high scores.
Definition highscore.h:23
_highscore_table
HighScoresTable _highscore_table
Table with all the high scores.
Definition highscore.cpp:24
SaveHighScoreValue
int8_t SaveHighScoreValue(const Company *c)
Save the highscore for the company.
Definition highscore.cpp:58
settings_type.h
Types related to global configuration settings.
SP_CUSTOM
@ SP_CUSTOM
No profile, special "custom" highscore.
Definition settings_type.h:47
strings_type.h
Types related to strings.
StringID
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Definition strings_type.h:19
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:20
Company
Definition company_base.h:127
HighScore
Definition highscore.h:17
HighScore::name
std::string name
The name of the company and president.
Definition highscore.h:18
HighScore::score
uint16_t score
The score for this high score. Do NOT change type, will break hs.dat.
Definition highscore.h:20
HighScore::title
StringID title
NOSAVE, has troubles with changing string-numbers.
Definition highscore.h:19