Skip to content

Commit 42d5c3a

Browse files
authored
[GEN][ZH] Fix logical errors with RecorderClass::testVersionPlayback() (#989)
1 parent 0bef4c9 commit 42d5c3a

File tree

6 files changed

+34
-22
lines changed

6 files changed

+34
-22
lines changed

Generals/Code/GameEngine/Include/Common/Recorder.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ enum RecorderModeType CPP_11(: Int) {
5454
class CRCInfo;
5555

5656
class RecorderClass : public SubsystemInterface {
57+
public:
58+
struct ReplayHeader;
59+
5760
public:
5861
RecorderClass(); ///< Constructor.
5962
virtual ~RecorderClass(); ///< Destructor.
@@ -68,7 +71,8 @@ class RecorderClass : public SubsystemInterface {
6871
// Methods dealing with playback.
6972
void updatePlayback(); ///< The update function for playing back a file.
7073
Bool playbackFile(AsciiString filename); ///< Starts playback of the specified file.
71-
Bool testVersionPlayback(AsciiString filename); ///< Returns if the playback is a valid playback file for this version or not.
74+
Bool replayMatchesGameVersion(AsciiString filename); ///< Returns true if the playback is a valid playback file for this version.
75+
static Bool replayMatchesGameVersion(const ReplayHeader& header); ///< Returns true if the playback is a valid playback file for this version.
7276
AsciiString getCurrentReplayFilename( void ); ///< valid during playback only
7377
void stopPlayback(); ///< Stops playback. Its fine to call this even if not playing back a file.
7478
#if defined RTS_DEBUG || defined RTS_INTERNAL

Generals/Code/GameEngine/Source/Common/Recorder.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,19 +1064,22 @@ void RecorderClass::handleCRCMessage(UnsignedInt newCRC, Int playerIndex, Bool f
10641064
}
10651065

10661066
/**
1067-
* Return true if this version of the file is the same as our version of the game
1067+
* Returns true if this version of the file is the same as our version of the game
10681068
*/
1069-
Bool RecorderClass::testVersionPlayback(AsciiString filename)
1069+
Bool RecorderClass::replayMatchesGameVersion(AsciiString filename)
10701070
{
1071-
10721071
ReplayHeader header;
10731072
header.forPlayback = TRUE;
10741073
header.filename = filename;
1075-
Bool success = readReplayHeader( header );
1076-
if (!success)
1074+
if ( readReplayHeader( header ) )
10771075
{
1078-
return FALSE;
1076+
return replayMatchesGameVersion( header );
10791077
}
1078+
return FALSE;
1079+
}
1080+
1081+
Bool RecorderClass::replayMatchesGameVersion(const ReplayHeader& header)
1082+
{
10801083
Bool versionStringDiff = header.versionString != TheVersion->getUnicodeVersion();
10811084
Bool versionTimeStringDiff = header.versionTimeString != TheVersion->getUnicodeBuildTime();
10821085
Bool versionNumberDiff = header.versionNumber != TheVersion->getVersionNumber();
@@ -1086,10 +1089,9 @@ Bool RecorderClass::testVersionPlayback(AsciiString filename)
10861089

10871090
if(exeDifferent || iniDifferent)
10881091
{
1089-
return TRUE;
1092+
return FALSE;
10901093
}
1091-
return FALSE;
1092-
1094+
return TRUE;
10931095
}
10941096

10951097
/**

Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ static void loadReplay(UnicodeString filename)
449449
AsciiString asciiFilename;
450450
asciiFilename.translate(filename);
451451

452-
if(TheRecorder->testVersionPlayback(asciiFilename))
452+
if(!TheRecorder->replayMatchesGameVersion(asciiFilename))
453453
{
454454
MessageBoxOkCancel(TheGameText->fetch("GUI:OlderReplayVersionTitle"), TheGameText->fetch("GUI:OlderReplayVersion"), reallyLoadReplay, NULL);
455455
}

GeneralsMD/Code/GameEngine/Include/Common/Recorder.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ enum RecorderModeType CPP_11(: Int) {
5454
class CRCInfo;
5555

5656
class RecorderClass : public SubsystemInterface {
57+
public:
58+
struct ReplayHeader;
59+
5760
public:
5861
RecorderClass(); ///< Constructor.
5962
virtual ~RecorderClass(); ///< Destructor.
@@ -68,7 +71,8 @@ class RecorderClass : public SubsystemInterface {
6871
// Methods dealing with playback.
6972
void updatePlayback(); ///< The update function for playing back a file.
7073
Bool playbackFile(AsciiString filename); ///< Starts playback of the specified file.
71-
Bool testVersionPlayback(AsciiString filename); ///< Returns if the playback is a valid playback file for this version or not.
74+
Bool replayMatchesGameVersion(AsciiString filename); ///< Returns true if the playback is a valid playback file for this version.
75+
static Bool replayMatchesGameVersion(const ReplayHeader& header); ///< Returns true if the playback is a valid playback file for this version.
7276
AsciiString getCurrentReplayFilename( void ); ///< valid during playback only
7377
void stopPlayback(); ///< Stops playback. Its fine to call this even if not playing back a file.
7478
#if defined RTS_DEBUG || defined RTS_INTERNAL

GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,19 +1067,22 @@ void RecorderClass::handleCRCMessage(UnsignedInt newCRC, Int playerIndex, Bool f
10671067
}
10681068

10691069
/**
1070-
* Return true if this version of the file is the same as our version of the game
1070+
* Returns true if this version of the file is the same as our version of the game
10711071
*/
1072-
Bool RecorderClass::testVersionPlayback(AsciiString filename)
1072+
Bool RecorderClass::replayMatchesGameVersion(AsciiString filename)
10731073
{
1074-
10751074
ReplayHeader header;
10761075
header.forPlayback = TRUE;
10771076
header.filename = filename;
1078-
Bool success = readReplayHeader( header );
1079-
if (!success)
1077+
if ( readReplayHeader( header ) )
10801078
{
1081-
return FALSE;
1079+
return replayMatchesGameVersion( header );
10821080
}
1081+
return FALSE;
1082+
}
1083+
1084+
Bool RecorderClass::replayMatchesGameVersion(const ReplayHeader& header)
1085+
{
10831086
Bool versionStringDiff = header.versionString != TheVersion->getUnicodeVersion();
10841087
Bool versionTimeStringDiff = header.versionTimeString != TheVersion->getUnicodeBuildTime();
10851088
Bool versionNumberDiff = header.versionNumber != TheVersion->getVersionNumber();
@@ -1089,10 +1092,9 @@ Bool RecorderClass::testVersionPlayback(AsciiString filename)
10891092

10901093
if(exeDifferent || iniDifferent)
10911094
{
1092-
return TRUE;
1095+
return FALSE;
10931096
}
1094-
return FALSE;
1095-
1097+
return TRUE;
10961098
}
10971099

10981100
/**

GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ static void loadReplay(UnicodeString filename)
449449
AsciiString asciiFilename;
450450
asciiFilename.translate(filename);
451451

452-
if(TheRecorder->testVersionPlayback(asciiFilename))
452+
if(!TheRecorder->replayMatchesGameVersion(asciiFilename))
453453
{
454454
MessageBoxOkCancel(TheGameText->fetch("GUI:OlderReplayVersionTitle"), TheGameText->fetch("GUI:OlderReplayVersion"), reallyLoadReplay, NULL);
455455
}

0 commit comments

Comments
 (0)