SuperTuxKart
Public Types | Public Member Functions | Private Types | Private Attributes | List of all members
Highscores Class Reference

Represents one highscore entry, i.e. More...

#include <highscores.hpp>

Public Types

typedef std::string HighscoreType
 

Public Member Functions

 Highscores (const Highscores::HighscoreType &highscore_type, int num_karts, const RaceManager::Difficulty &difficulty, const std::string &trackName, const int number_of_laps, const bool reverse)
 Creates a new entry.
 
 Highscores (const XMLNode &node)
 Creates an entry from a file.
 
void readEntry (const XMLNode &node)
 
void writeEntry (UTFWriter &writer)
 Writes the highscores in this entry to the writer. More...
 
int matches (const HighscoreType &highscore_type, int num_karts, const RaceManager::Difficulty &difficulty, const std::string &track, const int number_of_laps, const bool reverse)
 
int addData (const std::string &kart_name, const irr::core::stringw &name, const float time)
 Inserts the data into the highscore list. More...
 
int getNumberEntries () const
 
void getEntry (int number, std::string &kart_name, irr::core::stringw &name, float *const time) const
 

Private Types

enum  { HIGHSCORE_LEN = 5 }
 

Private Attributes

std::string m_track
 
HighscoreType m_highscore_type
 
int m_number_of_karts
 
int m_difficulty
 
int m_number_of_laps
 
bool m_reverse
 
std::string m_kart_name [HIGHSCORE_LEN]
 
irr::core::stringw m_name [HIGHSCORE_LEN]
 
float m_time [HIGHSCORE_LEN]
 

Detailed Description

Represents one highscore entry, i.e.

the (atm up to three) highscores for a particular setting (track, #karts, difficulty etc).

Member Function Documentation

◆ addData()

int Highscores::addData ( const std::string &  kart_name,
const irr::core::stringw &  name,
const float  time 
)

Inserts the data into the highscore list.

If the new entry is fast enough to be in the highscore list, the new position (1-HIGHSCORE_LEN) is returned, otherwise a 0.

◆ writeEntry()

void Highscores::writeEntry ( UTFWriter writer)

Writes the highscores in this entry to the writer.

It will only write anything if there is actually a highscore recored (i.e. time >=0). Empty entries are created e.g. when changing the number of laps in the GUI, resulting in empty entries here.

Parameters
writerThe file stream to write the data to.

The documentation for this class was generated from the following files: