Engine::ReplayReader Class Reference

Show a replay from a stream. More...

#include <ReplayReader.h>

Inheritance diagram for Engine::ReplayReader:

Engine::Physics::TickObserver List of all members.

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.
Sceneget_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< ReplayEventreplay_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.
GameScenescene
 The scene the replay takes place in.

Classes

struct  ReplayEvent

Detailed Description

Show a replay from a stream.

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.


Constructor & Destructor Documentation

Engine::ReplayReader::ReplayReader ( std::istream &  data  ) 

Replay from a stream.

This expects some game identifying metadata, and a list of events in a scene.

Parameters:
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.


Member Function Documentation

Scene * Engine::ReplayReader::get_scene (  ) 

Return the scene that will show the replay.

Definition at line 70 of file ReplayReader.cpp.

void Engine::ReplayReader::operator() ( GameScene  ) 

Called by LoadScene when it has finished loading.

Definition at line 54 of file ReplayReader.cpp.

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]

Read the events in the file into replay_events.

Definition at line 105 of file ReplayReader.cpp.


Member Data Documentation

std::vector<ReplayEvent>::iterator Engine::ReplayReader::current_iterator [protected]

Iterator to the next event to process.

Definition at line 85 of file ReplayReader.h.

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]

The scene used to load the track.

Definition at line 94 of file ReplayReader.h.

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]

The scene the replay takes place in.

Definition at line 96 of file ReplayReader.h.


The documentation for this class was generated from the following files:
Get Racer at SourceForge.net. Fast, secure and Free Open Source software downloads

Generated at Mon Sep 6 00:41:17 2010 by Doxygen version 1.4.7 for Racer version svn335.