OpenTTD Source  20241121-master-g67a0fccfad
highscore.h File Reference

Declaration of functions and types defined in highscore.h and highscore_gui.h. More...

#include "strings_type.h"
#include "company_type.h"
#include "settings_type.h"

Go to the source code of this file.

Data Structures

struct  HighScore
 

Typedefs

using HighScores = std::array< HighScore, 5 >
 Record 5 high scores.
 
using HighScoresTable = std::array< HighScores, SP_HIGHSCORE_END >
 Record high score for each of the difficulty levels.
 

Functions

void SaveToHighScore ()
 Save HighScore table to file.
 
void LoadFromHighScore ()
 Initialize the highscore table to 0 and if any file exists, load in values.
 
int8_t SaveHighScoreValue (const Company *c)
 Save the highscore for the company. More...
 
int8_t SaveHighScoreValueNetwork ()
 Save the highscores in a network game when it has ended. More...
 
StringID EndGameGetPerformanceTitleFromValue (uint value)
 
void ShowHighscoreTable (int difficulty=SP_CUSTOM, int8_t rank=-1)
 Show the highscore table for a given difficulty. More...
 

Variables

HighScoresTable _highscore_table
 Table with all the high scores.
 

Detailed Description

Declaration of functions and types defined in highscore.h and highscore_gui.h.

Definition in file highscore.h.

Function Documentation

◆ SaveHighScoreValue()

int8_t SaveHighScoreValue ( const Company c)

Save the highscore for the company.

Parameters
cThe company to insert.
Returns
The index the company got in the high score table, or -1 when it did not end up in the table.

Definition at line 57 of file highscore.cpp.

References _highscore_table, and SP_CUSTOM.

◆ SaveHighScoreValueNetwork()

◆ ShowHighscoreTable()

void ShowHighscoreTable ( int  difficulty,
int8_t  ranking 
)

Show the highscore table for a given difficulty.

When called from endgame ranking is set to the top5 element that was newly added and is thus highlighted

Definition at line 236 of file highscore_gui.cpp.

References CloseWindowByClass(), and WC_HIGHSCORE.