Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
RecorderClass Class Reference

#include <Recorder.h>

Inherits SubsystemInterface.

Classes

struct  ReplayHeader
 

Public Member Functions

 RecorderClass ()
 Constructor.
 
virtual ~RecorderClass ()
 Destructor.
 
void init ()
 Initialize TheRecorder.
 
void reset ()
 Reset the state of TheRecorder.
 
void update ()
 General purpose update function.
 
void updateRecord ()
 The update function for recording.
 
void updatePlayback ()
 The update function for playing back a file.
 
Bool playbackFile (AsciiString filename)
 Starts playback of the specified file.
 
Bool testVersionPlayback (AsciiString filename)
 Returns if the playback is a valid playback file for this version or not.
 
AsciiString getCurrentReplayFilename (void)
 valid during playback only
 
void stopPlayback ()
 Stops playback. Its fine to call this even if not playing back a file.
 
void handleCRCMessage (UnsignedInt newCRC, Int playerIndex, Bool fromPlayback)
 
Bool readReplayHeader (ReplayHeader &header)
 
RecorderModeType getMode ()
 Returns the current operating mode.
 
void initControls ()
 Show or Hide the Replay controls.
 
AsciiString getReplayDir ()
 Returns the directory that holds the replay files.
 
AsciiString getReplayExtention ()
 Returns the file extention for replay files.
 
AsciiString getLastReplayFileName ()
 Returns the filename used for the default replay.
 
GameInfogetGameInfo (void)
 Returns the slot list for playback game start.
 
Bool isMultiplayer (void)
 is this a multiplayer game (record OR playback)?
 
Int getGameMode (void)
 
void logPlayerDisconnect (UnicodeString player, Int slot)
 
void logCRCMismatch (void)
 
void cleanUpReplayFile (void)
 after a crash, send replay/debug info to a central repository
 
void stopRecording ()
 Stop recording and close m_file.
 
- Public Member Functions inherited from SubsystemInterface
 SubsystemInterface ()
 
virtual ~SubsystemInterface ()
 
virtual void postProcessLoad ()
 
virtual void draw (void)
 
void UPDATE (void)
 
void DRAW (void)
 
AsciiString getName (void)
 
void setName (AsciiString name)
 

Protected Member Functions

void startRecording (GameDifficulty diff, Int originalGameMode, Int rankPoints, Int maxFPS)
 Start recording to m_file.
 
void writeToFile (GameMessage *msg)
 Write this GameMessage to m_file.
 
void logGameStart (AsciiString options)
 
void logGameEnd (void)
 
AsciiString readAsciiString ()
 Read the next string from m_file using ascii characters.
 
UnicodeString readUnicodeString ()
 Read the next string from m_file using unicode characters.
 
void readNextFrame ()
 Read the next frame number to execute a command on.
 
void appendNextCommand ()
 Read the next GameMessage and append it to TheCommandList.
 
void writeArgument (GameMessageArgumentDataType type, const GameMessageArgumentType arg)
 
void readArgument (GameMessageArgumentDataType type, GameMessage *msg)
 
void cullBadCommands ()
 prevent the user from giving mouse commands that he shouldn't be able to do during playback.
 

Protected Attributes

CRCInfom_crcInfo
 
FILE * m_file
 
AsciiString m_fileName
 
Int m_currentFilePosition
 
RecorderModeType m_mode
 
AsciiString m_currentReplayFilename
 valid during playback only
 
ReplayGameInfo m_gameInfo
 
Bool m_wasDesync
 
Bool m_doingAnalysis
 
Int m_originalGameMode
 
UnsignedInt m_nextFrame
 The Frame that the next message is to be executed on. This can be -1.
 
- Protected Attributes inherited from SubsystemInterface
AsciiString m_name
 

Detailed Description

Definition at line 56 of file Recorder.h.

Constructor & Destructor Documentation

◆ RecorderClass()

RecorderClass::RecorderClass ( )

Constructor.

Constructor

Definition at line 364 of file Recorder.cpp.

◆ ~RecorderClass()

RecorderClass::~RecorderClass ( )
virtual

Destructor.

Destructor

Definition at line 384 of file Recorder.cpp.

Member Function Documentation

◆ appendNextCommand()

void RecorderClass::appendNextCommand ( )
protected

Read the next GameMessage and append it to TheCommandList.

This reads the next command from the replay file and appends it to TheCommandList.

Definition at line 1236 of file Recorder.cpp.

◆ cleanUpReplayFile()

void RecorderClass::cleanUpReplayFile ( void )

after a crash, send replay/debug info to a central repository

Definition at line 289 of file Recorder.cpp.

◆ cullBadCommands()

void RecorderClass::cullBadCommands ( )
protected

prevent the user from giving mouse commands that he shouldn't be able to do during playback.

This needs to be called for every frame during playback. Basically it prevents the user from inserting.

Definition at line 1460 of file Recorder.cpp.

◆ getCurrentReplayFilename()

AsciiString RecorderClass::getCurrentReplayFilename ( void )

valid during playback only

Definition at line 918 of file Recorder.cpp.

◆ getGameInfo()

GameInfo * RecorderClass::getGameInfo ( void )
inline

Returns the slot list for playback game start.

Definition at line 115 of file Recorder.h.

◆ getGameMode()

Int RecorderClass::getGameMode ( void )
inline

Definition at line 119 of file Recorder.h.

◆ getLastReplayFileName()

AsciiString RecorderClass::getLastReplayFileName ( )

Returns the filename used for the default replay.

returns the file name used for the replay file that is recorded to.

Definition at line 1502 of file Recorder.cpp.

◆ getMode()

RecorderModeType RecorderClass::getMode ( )

Returns the current operating mode.

Show or Hide the Replay controls.

return the current operating mode of TheRecorder.

Definition at line 1571 of file Recorder.cpp.

◆ getReplayDir()

AsciiString RecorderClass::getReplayDir ( )

Returns the directory that holds the replay files.

returns the directory that holds the replay files.

Definition at line 1483 of file Recorder.cpp.

◆ getReplayExtention()

AsciiString RecorderClass::getReplayExtention ( )

Returns the file extention for replay files.

returns the file extention for the replay files.

Definition at line 1495 of file Recorder.cpp.

◆ handleCRCMessage()

void RecorderClass::handleCRCMessage ( UnsignedInt newCRC,
Int playerIndex,
Bool fromPlayback )

Definition at line 981 of file Recorder.cpp.

◆ init()

void RecorderClass::init ( void )
virtual

Initialize TheRecorder.

Initialization The recorder will record by default since every game will be recorded. Obviously a game that is being played back will not be recorded. Since the playback is done through a special interface, that interface will set the recorder mode to RECORDERMODETYPE_PLAYBACK.

Implements SubsystemInterface.

Definition at line 394 of file Recorder.cpp.

◆ initControls()

void RecorderClass::initControls ( )

Show or Hide the Replay controls.

is this a multiplayer game (record OR playback)?

Definition at line 1576 of file Recorder.cpp.

◆ isMultiplayer()

Bool RecorderClass::isMultiplayer ( void )

is this a multiplayer game (record OR playback)?

< slots default to closed for non-networked games

Definition at line 1589 of file Recorder.cpp.

◆ logCRCMismatch()

void RecorderClass::logCRCMismatch ( void )

Definition at line 173 of file Recorder.cpp.

◆ logGameEnd()

void RecorderClass::logGameEnd ( void )
protected

Definition at line 219 of file Recorder.cpp.

◆ logGameStart()

void RecorderClass::logGameStart ( AsciiString options)
protected

Definition at line 67 of file Recorder.cpp.

◆ logPlayerDisconnect()

void RecorderClass::logPlayerDisconnect ( UnicodeString player,
Int slot )

Definition at line 123 of file Recorder.cpp.

◆ playbackFile()

Bool RecorderClass::playbackFile ( AsciiString filename)

Starts playback of the specified file.

Start playback of the file. Return true or false depending on if the file is a valid replay file or not.

Definition at line 1053 of file Recorder.cpp.

◆ readArgument()

void RecorderClass::readArgument ( GameMessageArgumentDataType type,
GameMessage * msg )
protected

Definition at line 1342 of file Recorder.cpp.

◆ readAsciiString()

AsciiString RecorderClass::readAsciiString ( )
protected

Read the next string from m_file using ascii characters.

Read an ascii string from the current file position. The string is assumed to be 0-terminated.

Definition at line 1195 of file Recorder.cpp.

◆ readNextFrame()

void RecorderClass::readNextFrame ( )
protected

Read the next frame number to execute a command on.

Read the frame number for the next command in the playback file. If the end of the file is reached, the playback is stopped and the next frame is said to be -1.

Definition at line 1224 of file Recorder.cpp.

◆ readReplayHeader()

Bool RecorderClass::readReplayHeader ( ReplayHeader & header)

Read in a replay header, for (1) populating a replay listbox or (2) starting playback. In case (2), set FILE *m_file.

Definition at line 816 of file Recorder.cpp.

◆ readUnicodeString()

UnicodeString RecorderClass::readUnicodeString ( )
protected

Read the next string from m_file using unicode characters.

Read a unicode string from the current file position. The string is assumed to be 0-terminated.

Definition at line 1167 of file Recorder.cpp.

◆ reset()

void RecorderClass::reset ( void )
virtual

Reset the state of TheRecorder.

Reset the recorder to the "initialized state."

Implements SubsystemInterface.

Definition at line 414 of file Recorder.cpp.

◆ startRecording()

void RecorderClass::startRecording ( GameDifficulty diff,
Int originalGameMode,
Int rankPoints,
Int maxFPS )
protected

Start recording to m_file.

Start a new file for recording. This will always overwrite the "LastReplay.rep" file with the new one. So don't call this unless you really mean it.

Todo
Need to write game options when there are some to be written.

Definition at line 533 of file Recorder.cpp.

◆ stopPlayback()

void RecorderClass::stopPlayback ( )

Stops playback. Its fine to call this even if not playing back a file.

Stop the currently running playback. This is probably due either to the user exiting out of the playback or reaching the end of the playback file.

Definition at line 462 of file Recorder.cpp.

◆ stopRecording()

void RecorderClass::stopRecording ( )

Stop recording and close m_file.

This will stop the current recording session and close the file. This should always be called at the end of every game.

Definition at line 703 of file Recorder.cpp.

◆ testVersionPlayback()

Bool RecorderClass::testVersionPlayback ( AsciiString filename)

Returns if the playback is a valid playback file for this version or not.

Return true if this version of the file is the same as our version of the game

Definition at line 1023 of file Recorder.cpp.

◆ update()

void RecorderClass::update ( void )
virtual

General purpose update function.

update Do the update for this frame.

Implements SubsystemInterface.

Definition at line 428 of file Recorder.cpp.

◆ updatePlayback()

void RecorderClass::updatePlayback ( )

The update function for playing back a file.

Do the update for the next frame of this playback.

Definition at line 439 of file Recorder.cpp.

◆ updateRecord()

void RecorderClass::updateRecord ( )

The update function for recording.

Update function for recording a game. Basically all the pertinant logic commands for this frame are written out to a file.

Definition at line 479 of file Recorder.cpp.

◆ writeArgument()

void RecorderClass::writeArgument ( GameMessageArgumentDataType type,
const GameMessageArgumentType arg )
protected

Definition at line 786 of file Recorder.cpp.

◆ writeToFile()

void RecorderClass::writeToFile ( GameMessage * msg)
protected

Write this GameMessage to m_file.

Write this game message to the record file. This also writes the game message's execution frame.

<

Todo
should this be in the final release?

Definition at line 724 of file Recorder.cpp.

Member Data Documentation

◆ m_crcInfo

CRCInfo* RecorderClass::m_crcInfo
protected

Definition at line 82 of file Recorder.h.

◆ m_currentFilePosition

Int RecorderClass::m_currentFilePosition
protected

Definition at line 144 of file Recorder.h.

◆ m_currentReplayFilename

AsciiString RecorderClass::m_currentReplayFilename
protected

valid during playback only

Definition at line 146 of file Recorder.h.

◆ m_doingAnalysis

Bool RecorderClass::m_doingAnalysis
protected

Definition at line 151 of file Recorder.h.

◆ m_file

FILE* RecorderClass::m_file
protected

Definition at line 142 of file Recorder.h.

◆ m_fileName

AsciiString RecorderClass::m_fileName
protected

Definition at line 143 of file Recorder.h.

◆ m_gameInfo

ReplayGameInfo RecorderClass::m_gameInfo
protected

Definition at line 148 of file Recorder.h.

◆ m_mode

RecorderModeType RecorderClass::m_mode
protected

Definition at line 145 of file Recorder.h.

◆ m_nextFrame

UnsignedInt RecorderClass::m_nextFrame
protected

The Frame that the next message is to be executed on. This can be -1.

Definition at line 155 of file Recorder.h.

◆ m_originalGameMode

Int RecorderClass::m_originalGameMode
protected

Definition at line 153 of file Recorder.h.

◆ m_wasDesync

Bool RecorderClass::m_wasDesync
protected

Definition at line 149 of file Recorder.h.


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