#include <ReplayReader.h>
Inheritance diagram for Engine::ReplayReader:
Public Member Functions | |
ReplayReader (std::istream &data) | |
Replay from a stream. | |
virtual | ~ReplayReader () |
virtual void | posttick () |
Process any events that happen next tick. | |
void | operator() (GameScene *) |
Called by LoadScene when it has finished loading. | |
Scene * | get_scene () |
Return the scene that will show the replay. | |
Protected Member Functions | |
void | ReadEvents (std::istream &data) |
Read the events in the file into replay_events. | |
Protected Attributes | |
std::vector< ReplayEvent > | replay_events |
The list of events in the replay, sorted in time order. | |
std::vector< ReplayEvent >::iterator | current_iterator |
Iterator to the next event to process. | |
std::vector< boost::shared_ptr< InputDeviceReplay > > | devices |
Input devices to relay the events through. There is one per player. | |
std::map< long unsigned int, Engine::InputHandler::iterator > | input_map |
Map identifiers found in the replay data to InputDeviceReplays. | |
std::vector< std::pair< Engine::InputHandler::iterator, unsigned int > > | game_scene_devices_list |
LoadScene< GameScene, ReplayReader > * | load_scene |
The scene used to load the track. | |
GameScene * | scene |
The scene the replay takes place in. | |
Classes | |
struct | ReplayEvent |
The replay is stored as some metadata, plus a series of timestamped events recorded from input devices. When created it reads the metadata. It can explain the metadata, and create an appropriate scene. As the scene runs, it will report the events at the correct time so that the same things happen.
For this method to work, we require that all physics, game logic, and AI is deterministic, i.e. when presented with the same events with the same timings, things turn out just as before.
The alternative would be to store a set of states. This has the following disadvantages:
With just the input, we only need to have a list of InputReport objects saved and timestamped, and determinstic state determined only from an input.
Definition at line 49 of file ReplayReader.h.
Engine::ReplayReader::ReplayReader | ( | std::istream & | data | ) |
Replay from a stream.
This expects some game identifying metadata, and a list of events in a scene.
data | The stream to take input from. |
Definition at line 19 of file ReplayReader.cpp.
Engine::ReplayReader::~ReplayReader | ( | ) | [virtual] |
Definition at line 65 of file ReplayReader.cpp.
Scene * Engine::ReplayReader::get_scene | ( | ) |
void Engine::ReplayReader::operator() | ( | GameScene * | ) |
void Engine::ReplayReader::posttick | ( | ) | [virtual] |
Process any events that happen next tick.
Implements Engine::Physics::TickObserver.
Definition at line 75 of file ReplayReader.cpp.
void Engine::ReplayReader::ReadEvents | ( | std::istream & | data | ) | [protected] |
std::vector<ReplayEvent>::iterator Engine::ReplayReader::current_iterator [protected] |
std::vector<boost::shared_ptr<InputDeviceReplay> > Engine::ReplayReader::devices [protected] |
Input devices to relay the events through. There is one per player.
Definition at line 88 of file ReplayReader.h.
std::vector<std::pair<Engine::InputHandler::iterator, unsigned int> > Engine::ReplayReader::game_scene_devices_list [protected] |
Definition at line 91 of file ReplayReader.h.
std::map<long unsigned int, Engine::InputHandler::iterator> Engine::ReplayReader::input_map [protected] |
Map identifiers found in the replay data to InputDeviceReplays.
Definition at line 90 of file ReplayReader.h.
LoadScene<GameScene, ReplayReader>* Engine::ReplayReader::load_scene [protected] |
std::vector<ReplayEvent> Engine::ReplayReader::replay_events [protected] |
The list of events in the replay, sorted in time order.
Definition at line 82 of file ReplayReader.h.
GameScene* Engine::ReplayReader::scene [protected] |
Generated at Mon Sep 6 00:41:17 2010 by Doxygen version 1.4.7 for Racer version svn335.