OpenTTD Source: src/highscore.h File Reference

OpenTTD Source 15.0-beta1

Data Structures | Typedefs | Functions | Variables
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.
int8_t | SaveHighScoreValueNetwork ()
| Save the highscores in a network game when it has ended.
StringID | EndGameGetPerformanceTitleFromValue (uint value)
void | ShowHighscoreTable (int difficulty=SP_CUSTOM, int8_t rank=-1)
| Show the highscore table for a given difficulty.

## 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.

## Typedef Documentation

## ◆ HighScores

using HighScores = std::array<HighScore, 5>

Record 5 high scores.

Definition at line 23 of file highscore.h.

## ◆ HighScoresTable

using HighScoresTable = std::array<HighScores, SP_HIGHSCORE_END>

Record high score for each of the difficulty levels.

Definition at line 24 of file highscore.h.

## Function Documentation

## ◆ EndGameGetPerformanceTitleFromValue()

StringID EndGameGetPerformanceTitleFromValue | ( | uint | value | ) |

Definition at line 45 of file highscore.cpp.

## ◆ LoadFromHighScore()

void LoadFromHighScore | ( |  | ) |

Initialize the highscore table to 0 and if any file exists, load in values.

Definition at line 143 of file highscore.cpp.

References _highscore_file, _highscore_table, Debug, FileHandle::Open(), SP_SAVED_HIGHSCORE_END, and StrMakeValid().

Referenced by AfterNewGRFScan::OnNewGRFsScanned().

## ◆ SaveHighScoreValue()

int8_t SaveHighScoreValue | ( | const Company * | c | ) |

Save the highscore for the company.

Parameters

  c | The 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, GetString(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, CompanyProperties::old_economy, CompanyEconomyEntry::performance_history, SetDParam(), and SP_CUSTOM.

## ◆ SaveHighScoreValueNetwork()

int8_t SaveHighScoreValueNetwork | ( |  | ) |

Save the highscores in a network game when it has ended.

Returns
  Position of the local company in the highscore list.

Definition at line 89 of file highscore.cpp.

References _highscore_table, _local_company, GetString(), HighScoreSorter(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Iterate(), MAX_COMPANIES, CompanyProperties::old_economy, CompanyEconomyEntry::performance_history, SetDParam(), and SP_MULTIPLAYER.

## ◆ SaveToHighScore()

void SaveToHighScore | ( |  | ) |

Save HighScore table to file.

Definition at line 120 of file highscore.cpp.

References _highscore_file, _highscore_table, Debug, FileHandle::Open(), and SP_SAVED_HIGHSCORE_END.

## ◆ 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.

Referenced by EndGameWindow::Close(), MenuClickGraphsOrLeague(), and SelectGameWindow::OnClick().

## Variable Documentation

## ◆ _highscore_table

HighScoresTable _highscore_table
| extern

Table with all the high scores.

Definition at line 23 of file highscore.cpp.

Referenced by LoadFromHighScore(), HighScoreWindow::OnPaint(), SaveHighScoreValue(), SaveHighScoreValueNetwork(), and SaveToHighScore().