EVENTRECORDER: Remove backwards compatibility

This commit is contained in:
Scott Percival 2021-09-07 00:52:15 +08:00 committed by Martin Gerhardy
parent fb421a0ca7
commit 666f241d29
3 changed files with 24 additions and 52 deletions

View File

@ -30,7 +30,7 @@
#include "graphics/surface.h"
#include "graphics/scaler.h"
#define RECORD_VERSION 2
#define RECORD_VERSION 1
namespace Common {
@ -47,7 +47,6 @@ PlaybackFile::PlaybackFile()
_headerDumped = false;
_recordCount = 0;
_eventsSize = 0;
_trackScreenUpdate = true;
_version = RECORD_VERSION;
memset(_tmpBuffer.data(), 1, kRecordBuffSize);
@ -134,10 +133,7 @@ bool PlaybackFile::parseHeader() {
bool PlaybackFile::checkPlaybackFileVersion() {
_version = _readStream->readUint32BE();
switch (_version) {
case 2:
break;
case 1:
_trackScreenUpdate = false;
break;
default:
warning("Unknown playback file version %d. Maximum supported version is %d.", _version, RECORD_VERSION);

View File

@ -160,7 +160,6 @@ public:
void addSaveFile(const String &fileName, InSaveFile *saveStream);
uint32 getVersion() const {return _version;}
bool hasTrackScreenUpdate() {return _trackScreenUpdate;}
private:
Array<byte> _tmpBuffer;
WriteStream *_recordFile;
@ -176,7 +175,6 @@ private:
uint32 _eventsSize;
PlaybackFileHeader _header;
PlaybackFileState _playbackParseState;
bool _trackScreenUpdate;
uint32 _version;
void skipHeader();

View File

@ -50,25 +50,6 @@ namespace GUI {
const int kMaxRecordsNames = 0x64;
const int kDefaultScreenshotPeriod = 60000;
uint32 readTime(Common::ReadStream *inFile) {
uint32 d = inFile->readByte();
if (d == 0xff) {
d = inFile->readUint32LE();
}
return d;
}
void writeTime(Common::WriteStream *outFile, uint32 d) {
//Simple RLE compression
if (d >= 0xff) {
outFile->writeByte(0xff);
outFile->writeUint32LE(d);
} else {
outFile->writeByte(d);
}
}
EventRecorder::EventRecorder() {
_timerManager = nullptr;
_recordMode = kPassthrough;
@ -276,35 +257,32 @@ void EventRecorder::processScreenUpdate() {
break;
case kRecorderUpdate: // fallthrough
case kRecorderPlayback:
if (_playbackFile->hasTrackScreenUpdate()) {
// if the file has screen update support, but the next event
// isn't a screen update, fast forward until we find one.
if (_nextEvent.recordedtype != Common::kRecorderEventTypeScreenUpdate) {
int numSkipped = 0;
while (true) {
_nextEvent = _playbackFile->getNextEvent();
numSkipped += 1;
if (_nextEvent.recordedtype == Common::kRecorderEventTypeScreenUpdate) {
warning("Skipped %d events to get to the next screen update at %d", numSkipped, _nextEvent.time);
break;
}
// if the next event isn't a screen update, fast forward until we find one.
if (_nextEvent.recordedtype != Common::kRecorderEventTypeScreenUpdate) {
int numSkipped = 0;
while (true) {
_nextEvent = _playbackFile->getNextEvent();
numSkipped += 1;
if (_nextEvent.recordedtype == Common::kRecorderEventTypeScreenUpdate) {
warning("Skipped %d events to get to the next screen update at %d", numSkipped, _nextEvent.time);
break;
}
}
_processingMillis = true;
_fakeTimer = _nextEvent.time;
updateSubsystems();
_nextEvent = _playbackFile->getNextEvent();
if (_recordMode == kRecorderUpdate) {
// write event to the updated file and update screenshot if necessary
screenUpdateEvent.recordedtype = Common::kRecorderEventTypeScreenUpdate;
screenUpdateEvent.time = _fakeTimer;
_recordFile->writeEvent(screenUpdateEvent);
takeScreenshot();
}
_timerManager->handler();
_controlPanel->setReplayedTime(_fakeTimer);
_processingMillis = false;
}
_processingMillis = true;
_fakeTimer = _nextEvent.time;
updateSubsystems();
_nextEvent = _playbackFile->getNextEvent();
if (_recordMode == kRecorderUpdate) {
// write event to the updated file and update screenshot if necessary
screenUpdateEvent.recordedtype = Common::kRecorderEventTypeScreenUpdate;
screenUpdateEvent.time = _fakeTimer;
_recordFile->writeEvent(screenUpdateEvent);
takeScreenshot();
}
_timerManager->handler();
_controlPanel->setReplayedTime(_fakeTimer);
_processingMillis = false;
break;
default:
break;