Skip to content

[GEN][ZH] Refactor the recorder class to use a ramfile for replay playback. #1233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions Generals/Code/GameEngine/Include/Common/Recorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include "Common/MessageStream.h"
#include "GameNetwork/GameInfo.h"

class File;

/**
* The ReplayGameInfo class holds information about the replay game and
* the contents of its slot list for reconstructing multiplayer games.
Expand Down Expand Up @@ -89,7 +91,7 @@ class RecorderClass : public SubsystemInterface {
CRCInfo *m_crcInfo;
public:

// read in info relating to a replay, conditionally setting up m_file for playback
// read in info relating to a replay, conditionally setting up m_replayFile for playback
struct ReplayHeader
{
AsciiString filename;
Expand Down Expand Up @@ -131,16 +133,16 @@ class RecorderClass : public SubsystemInterface {
Bool sawCRCMismatch() const;
void cleanUpReplayFile( void ); ///< after a crash, send replay/debug info to a central repository

void stopRecording(); ///< Stop recording and close m_file.
void stopRecording(); ///< Stop recording and close m_recordingFile.
protected:
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 startRecording(GameDifficulty diff, Int originalGameMode, Int rankPoints, Int maxFPS); ///< Start recording to m_recordingFile.
void writeToFile(GameMessage *msg); ///< Write this GameMessage to m_recordingFile.

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.
AsciiString readAsciiString(); ///< Read the next string from m_replayFile using ascii characters.
UnicodeString readUnicodeString(); ///< Read the next string from m_replayFile 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);
Expand All @@ -154,7 +156,8 @@ class RecorderClass : public SubsystemInterface {

CullBadCommandsResult cullBadCommands(); ///< prevent the user from giving mouse commands that he shouldn't be able to do during playback.

FILE *m_file;
File* m_replayFile;
FILE *m_recordingFile;
AsciiString m_fileName;
Int m_currentFilePosition;
RecorderModeType m_mode;
Expand Down
Loading
Loading