SuperTuxKart
Loading...
Searching...
No Matches
history.hpp
1//
2// SuperTuxKart - a fun racing game with go-kart
3// Copyright (C) 2006-2015 Joerg Henrichs
4//
5// This program is free software; you can redistribute it and/or
6// modify it under the terms of the GNU General Public License
7// as published by the Free Software Foundation; either version 3
8// of the License, or (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program; if not, write to the Free Software
17// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19#ifndef HEADER_HISTORY_HPP
20#define HEADER_HISTORY_HPP
21
22
23#include "input/input.hpp"
24#include "karts/controller/kart_control.hpp"
25
26#include <string>
27#include <vector>
28
29class Kart;
30
35{
36private:
39
41 unsigned int m_event_index;
42
44 std::vector<std::string> m_kart_ident;
45
46 // ------------------------------------------------------------------------
48 {
49 /* Time at which this event occurred. */
50 int m_world_ticks;
57 }; // InputEvent
58 // ------------------------------------------------------------------------
59
61 std::vector<InputEvent> m_all_input_events;
62
63 void allocateMemory(int size=-1);
64public:
65 static bool m_online_history_replay;
66 History ();
67 void initRecording ();
68 void Save ();
69 void Load ();
70 void updateReplay(int world_ticks);
71 void addEvent(int kart_id, PlayerAction pa, int value);
72
73 // -------------------I-----------------------------------------------------
75 const std::string& getKartIdent(unsigned int n)
76 {
77 return m_kart_ident[n];
78 } // getKartIdent
79 // ------------------------------------------------------------------------
81 bool replayHistory() const { return m_replay_history; }
82 // ------------------------------------------------------------------------
85};
86
87extern History* history;
88
89#endif
Definition: history.hpp:35
void setReplayHistory(bool b)
Set if replay is enabled or not.
Definition: history.hpp:84
bool m_replay_history
True if a history should be replayed,.
Definition: history.hpp:38
void Load()
Loads a history from history.dat in the current directory.
Definition: history.cpp:191
void updateReplay(int world_ticks)
Sets the kart position and controls to the recorded history value.
Definition: history.cpp:95
bool replayHistory() const
Returns if a history is replayed, i.e.
Definition: history.hpp:81
unsigned int m_event_index
Points to the last used input event index.
Definition: history.hpp:41
std::vector< std::string > m_kart_ident
The identities of the karts to use.
Definition: history.hpp:44
void addEvent(int kart_id, PlayerAction pa, int value)
Stores an input event (e.g.
Definition: history.cpp:78
void initRecording()
Initialise the history for a new recording.
Definition: history.cpp:49
void allocateMemory(int size=-1)
Allocates memory for the history.
Definition: history.cpp:61
const std::string & getKartIdent(unsigned int n)
Returns the identifier of the n-th kart.
Definition: history.hpp:75
void Save()
Saves the history stored in the internal data structures into a file called history....
Definition: history.cpp:133
std::vector< InputEvent > m_all_input_events
All input events.
Definition: history.hpp:61
History()
Initialises the history object and sets the mode to none.
Definition: history.cpp:40
The main kart class.
Definition: kart.hpp:69
PlayerAction
types of input events / what actions the players can do
Definition: input.hpp:117
Definition: history.hpp:48
int m_value
The value to use.
Definition: history.hpp:56
int m_kart_index
For which kart the event was.
Definition: history.hpp:52
PlayerAction m_action
Which action it was.
Definition: history.hpp:54