SuperTuxKart
Classes | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
History Class Reference

Classes

struct  InputEvent
 

Public Member Functions

 History ()
 Initialises the history object and sets the mode to none.
 
void initRecording ()
 Initialise the history for a new recording. More...
 
void Save ()
 Saves the history stored in the internal data structures into a file called history.dat.
 
void Load ()
 Loads a history from history.dat in the current directory.
 
void updateReplay (int world_ticks)
 Sets the kart position and controls to the recorded history value. More...
 
void addEvent (int kart_id, PlayerAction pa, int value)
 Stores an input event (e.g. More...
 
const std::string & getKartIdent (unsigned int n)
 Returns the identifier of the n-th kart. More...
 
bool replayHistory () const
 Returns if a history is replayed, i.e. More...
 
void setReplayHistory (bool b)
 Set if replay is enabled or not. More...
 

Static Public Attributes

static bool m_online_history_replay = false
 

Private Member Functions

void allocateMemory (int size=-1)
 Allocates memory for the history. More...
 

Private Attributes

bool m_replay_history
 True if a history should be replayed,.
 
unsigned int m_event_index
 Points to the last used input event index. More...
 
std::vector< std::string > m_kart_ident
 The identities of the karts to use. More...
 
std::vector< InputEventm_all_input_events
 All input events. More...
 

Member Function Documentation

◆ addEvent()

void History::addEvent ( int  kart_id,
PlayerAction  pa,
int  value 
)

Stores an input event (e.g.

acceleration or steering event) into the history data for physics replay.

Parameters
kart_idThe kart index which triggered the event.
paThe action.
valueValue of the action (0=release, 32768 = pressed), in between in case of analog devices.

◆ allocateMemory()

void History::allocateMemory ( int  size = -1)
private

Allocates memory for the history.

This is used when recording as well as when replaying (since in replay the data is read into memory first).

Parameters
number_of_framesMaximum number of frames to store.

◆ getKartIdent()

const std::string& History::getKartIdent ( unsigned int  n)
inline

Returns the identifier of the n-th kart.

◆ initRecording()

void History::initRecording ( )

Initialise the history for a new recording.

It especially allocates memory to store the history.

◆ replayHistory()

bool History::replayHistory ( ) const
inline

Returns if a history is replayed, i.e.

the history mode is not none.

◆ setReplayHistory()

void History::setReplayHistory ( bool  b)
inline

Set if replay is enabled or not.

◆ updateReplay()

void History::updateReplay ( int  world_ticks)

Sets the kart position and controls to the recorded history value.

Parameters
world_ticksWOrld time in ticks.
ticksNumber of time steps.

Member Data Documentation

◆ m_all_input_events

std::vector<InputEvent> History::m_all_input_events
private

All input events.

◆ m_event_index

unsigned int History::m_event_index
private

Points to the last used input event index.

◆ m_kart_ident

std::vector<std::string> History::m_kart_ident
private

The identities of the karts to use.


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