[Scummvm-git-logs] scummvm master -> a0c237f7b933b444e7fa297e090266a92aca45a8
mgerhardy
martin.gerhardy at gmail.com
Fri Jul 9 17:23:25 UTC 2021
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
a0c237f7b9 EVENTRECORDER: added new event for OSystem::getTimeAndDate
Commit: a0c237f7b933b444e7fa297e090266a92aca45a8
https://github.com/scummvm/scummvm/commit/a0c237f7b933b444e7fa297e090266a92aca45a8
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-07-09T19:23:21+02:00
Commit Message:
EVENTRECORDER: added new event for OSystem::getTimeAndDate
Changed paths:
backends/platform/3ds/osystem.cpp
backends/platform/3ds/osystem.h
backends/platform/android/android.cpp
backends/platform/android/android.h
backends/platform/android3d/android.cpp
backends/platform/android3d/android.h
backends/platform/dc/dc.h
backends/platform/dc/dcmain.cpp
backends/platform/ds/osystem_ds.cpp
backends/platform/ds/osystem_ds.h
backends/platform/ios7/ios7_osys_main.cpp
backends/platform/ios7/ios7_osys_main.h
backends/platform/iphone/osys_main.cpp
backends/platform/iphone/osys_main.h
backends/platform/n64/osys_n64.h
backends/platform/n64/osys_n64_base.cpp
backends/platform/null/null.cpp
backends/platform/psp/osys_psp.cpp
backends/platform/psp/osys_psp.h
backends/platform/sdl/sdl.cpp
backends/platform/sdl/sdl.h
backends/platform/wii/osystem.cpp
backends/platform/wii/osystem.h
common/recorderfile.cpp
common/recorderfile.h
common/system.h
gui/EventRecorder.cpp
gui/EventRecorder.h
diff --git a/backends/platform/3ds/osystem.cpp b/backends/platform/3ds/osystem.cpp
index 6e32bf191e..d7e3c6d405 100644
--- a/backends/platform/3ds/osystem.cpp
+++ b/backends/platform/3ds/osystem.cpp
@@ -169,7 +169,7 @@ void OSystem_3DS::delayMillis(uint msecs) {
svcSleepThread(msecs * 1000000);
}
-void OSystem_3DS::getTimeAndDate(TimeDate& td) const {
+void OSystem_3DS::getTimeAndDate(TimeDate& td, bool skipRecord) const {
time_t curTime = time(0);
struct tm t = *localtime(&curTime);
td.tm_sec = t.tm_sec;
diff --git a/backends/platform/3ds/osystem.h b/backends/platform/3ds/osystem.h
index 5a8f43a722..991f342351 100644
--- a/backends/platform/3ds/osystem.h
+++ b/backends/platform/3ds/osystem.h
@@ -115,7 +115,7 @@ public:
virtual uint32 getMillis(bool skipRecord = false);
virtual void delayMillis(uint msecs);
- virtual void getTimeAndDate(TimeDate &t) const;
+ virtual void getTimeAndDate(TimeDate &td, bool skipRecord = false) const;
virtual MutexRef createMutex();
virtual void lockMutex(MutexRef mutex);
diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp
index 8314293e17..6f471fffb4 100644
--- a/backends/platform/android/android.cpp
+++ b/backends/platform/android/android.cpp
@@ -575,7 +575,7 @@ Audio::Mixer *OSystem_Android::getMixer() {
return _mixer;
}
-void OSystem_Android::getTimeAndDate(TimeDate &td) const {
+void OSystem_Android::getTimeAndDate(TimeDate &td, bool skipRecord) const {
struct tm tm;
const time_t curTime = time(0);
diff --git a/backends/platform/android/android.h b/backends/platform/android/android.h
index cacd16aef1..a07f7b5507 100644
--- a/backends/platform/android/android.h
+++ b/backends/platform/android/android.h
@@ -135,7 +135,7 @@ public:
virtual void setWindowCaption(const Common::U32String &caption) override;
virtual Audio::Mixer *getMixer() override;
- virtual void getTimeAndDate(TimeDate &t) const override;
+ virtual void getTimeAndDate(TimeDate &td, bool skipRecord = false) const override;
virtual void logMessage(LogMessageType::Type type, const char *message) override;
virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0) override;
virtual bool openUrl(const Common::String &url) override;
diff --git a/backends/platform/android3d/android.cpp b/backends/platform/android3d/android.cpp
index eabe7b7bb5..fe5e230631 100644
--- a/backends/platform/android3d/android.cpp
+++ b/backends/platform/android3d/android.cpp
@@ -505,7 +505,7 @@ Audio::Mixer *OSystem_Android::getMixer() {
return _mixer;
}
-void OSystem_Android::getTimeAndDate(TimeDate &td) const {
+void OSystem_Android::getTimeAndDate(TimeDate &td, bool skipRecord) const {
struct tm tm;
const time_t curTime = time(0);
diff --git a/backends/platform/android3d/android.h b/backends/platform/android3d/android.h
index ab65f84329..149d3782ce 100644
--- a/backends/platform/android3d/android.h
+++ b/backends/platform/android3d/android.h
@@ -179,7 +179,7 @@ public:
virtual void showVirtualKeyboard(bool enable);
virtual Audio::Mixer *getMixer();
- virtual void getTimeAndDate(TimeDate &t) const;
+ virtual void getTimeAndDate(TimeDate &td, bool skipRecord = false) const;
virtual void logMessage(LogMessageType::Type type, const char *message);
virtual void addSysArchivesToSearchSet(Common::SearchSet &s,
int priority = 0);
diff --git a/backends/platform/dc/dc.h b/backends/platform/dc/dc.h
index 36a8a1f40f..d411eef4b2 100644
--- a/backends/platform/dc/dc.h
+++ b/backends/platform/dc/dc.h
@@ -142,7 +142,7 @@ public:
void delayMillis(uint msecs);
// Get the current time and date. Correspond to time()+localtime().
- void getTimeAndDate(TimeDate &t) const;
+ void getTimeAndDate(TimeDate &td, bool skipRecord = false) const;
// Get the next event.
// Returns true if an event was retrieved.
diff --git a/backends/platform/dc/dcmain.cpp b/backends/platform/dc/dcmain.cpp
index c58eafcbc7..885b53b0df 100644
--- a/backends/platform/dc/dcmain.cpp
+++ b/backends/platform/dc/dcmain.cpp
@@ -218,7 +218,7 @@ bool OSystem_Dreamcast::getFeatureState(Feature f)
}
}
-void OSystem_Dreamcast::getTimeAndDate(TimeDate &td) const {
+void OSystem_Dreamcast::getTimeAndDate(TimeDate &td, bool skipRecord) const {
time_t curTime;
time(&curTime);
struct tm t = *localtime(&curTime);
diff --git a/backends/platform/ds/osystem_ds.cpp b/backends/platform/ds/osystem_ds.cpp
index 81d7722a32..2c2c0d32a8 100644
--- a/backends/platform/ds/osystem_ds.cpp
+++ b/backends/platform/ds/osystem_ds.cpp
@@ -117,7 +117,7 @@ void OSystem_DS::doTimerCallback(int interval) {
}
}
-void OSystem_DS::getTimeAndDate(TimeDate &td) const {
+void OSystem_DS::getTimeAndDate(TimeDate &td, bool skipRecord) const {
time_t curTime = time(0);
struct tm t = *localtime(&curTime);
td.tm_sec = t.tm_sec;
diff --git a/backends/platform/ds/osystem_ds.h b/backends/platform/ds/osystem_ds.h
index 2213e0cf81..e3c83e6bb0 100644
--- a/backends/platform/ds/osystem_ds.h
+++ b/backends/platform/ds/osystem_ds.h
@@ -125,7 +125,7 @@ public:
virtual uint32 getMillis(bool skipRecord = false);
virtual void delayMillis(uint msecs);
- virtual void getTimeAndDate(TimeDate &t) const;
+ virtual void getTimeAndDate(TimeDate &td, bool skipRecord = false) const;
void doTimerCallback(int interval = 10);
virtual Common::EventSource *getDefaultEventSource() { return _eventSource; }
diff --git a/backends/platform/ios7/ios7_osys_main.cpp b/backends/platform/ios7/ios7_osys_main.cpp
index 491e741a5a..016db083a6 100644
--- a/backends/platform/ios7/ios7_osys_main.cpp
+++ b/backends/platform/ios7/ios7_osys_main.cpp
@@ -314,7 +314,7 @@ void OSystem_iOS7::setTimerCallback(TimerProc callback, int interval) {
void OSystem_iOS7::quit() {
}
-void OSystem_iOS7::getTimeAndDate(TimeDate &td) const {
+void OSystem_iOS7::getTimeAndDate(TimeDate &td, bool skipRecord) const {
time_t curTime = time(0);
struct tm t = *localtime(&curTime);
td.tm_sec = t.tm_sec;
diff --git a/backends/platform/ios7/ios7_osys_main.h b/backends/platform/ios7/ios7_osys_main.h
index 538d6504b9..a9c1713e58 100644
--- a/backends/platform/ios7/ios7_osys_main.h
+++ b/backends/platform/ios7/ios7_osys_main.h
@@ -185,7 +185,7 @@ public:
virtual void quit() override;
virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0) override;
- virtual void getTimeAndDate(TimeDate &t) const override;
+ virtual void getTimeAndDate(TimeDate &td, bool skipRecord = false) const override;
virtual Audio::Mixer *getMixer() override;
diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp
index a715769236..42db5221bc 100644
--- a/backends/platform/iphone/osys_main.cpp
+++ b/backends/platform/iphone/osys_main.cpp
@@ -198,7 +198,7 @@ void OSystem_IPHONE::setTimerCallback(TimerProc callback, int interval) {
void OSystem_IPHONE::quit() {
}
-void OSystem_IPHONE::getTimeAndDate(TimeDate &td) const {
+void OSystem_IPHONE::getTimeAndDate(TimeDate &td, bool skipRecord) const {
time_t curTime = time(0);
struct tm t = *localtime(&curTime);
td.tm_sec = t.tm_sec;
diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h
index 3060434894..139b301559 100644
--- a/backends/platform/iphone/osys_main.h
+++ b/backends/platform/iphone/osys_main.h
@@ -173,7 +173,7 @@ public:
virtual void quit();
virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0);
- virtual void getTimeAndDate(TimeDate &t) const;
+ virtual void getTimeAndDate(TimeDate &td, bool skipRecord = false) const;
virtual Audio::Mixer *getMixer();
diff --git a/backends/platform/n64/osys_n64.h b/backends/platform/n64/osys_n64.h
index 2d40c0fea5..31de4563d6 100644
--- a/backends/platform/n64/osys_n64.h
+++ b/backends/platform/n64/osys_n64.h
@@ -195,7 +195,7 @@ public:
virtual void quit();
virtual Audio::Mixer *getMixer();
- virtual void getTimeAndDate(TimeDate &t) const;
+ virtual void getTimeAndDate(TimeDate &t, bool skipRecord = false) const;
virtual void setTimerCallback(TimerProc callback, int interval);
virtual void logMessage(LogMessageType::Type type, const char *message);
diff --git a/backends/platform/n64/osys_n64_base.cpp b/backends/platform/n64/osys_n64_base.cpp
index 8f25e7072f..3d237d1bd4 100644
--- a/backends/platform/n64/osys_n64_base.cpp
+++ b/backends/platform/n64/osys_n64_base.cpp
@@ -838,7 +838,7 @@ Audio::Mixer *OSystem_N64::getMixer() {
return _mixer;
}
-void OSystem_N64::getTimeAndDate(TimeDate &t) const {
+void OSystem_N64::getTimeAndDate(TimeDate &t, bool skipRecord) const {
// No RTC inside the N64, read mips timer to simulate
// passing of time, not a perfect solution, but can't think
// of anything better.
diff --git a/backends/platform/null/null.cpp b/backends/platform/null/null.cpp
index 9ca41f1731..4507d3d114 100644
--- a/backends/platform/null/null.cpp
+++ b/backends/platform/null/null.cpp
@@ -87,7 +87,7 @@ public:
virtual uint32 getMillis(bool skipRecord = false);
virtual void delayMillis(uint msecs);
- virtual void getTimeAndDate(TimeDate &t) const;
+ virtual void getTimeAndDate(TimeDate &td, bool skipRecord = false) const;
virtual void quit();
@@ -208,7 +208,7 @@ void OSystem_NULL::delayMillis(uint msecs) {
#endif
}
-void OSystem_NULL::getTimeAndDate(TimeDate &td) const {
+void OSystem_NULL::getTimeAndDate(TimeDate &td, bool skipRecord) const {
time_t curTime = time(0);
struct tm t = *localtime(&curTime);
td.tm_sec = t.tm_sec;
diff --git a/backends/platform/psp/osys_psp.cpp b/backends/platform/psp/osys_psp.cpp
index a39ec7c1c0..13dc14756b 100644
--- a/backends/platform/psp/osys_psp.cpp
+++ b/backends/platform/psp/osys_psp.cpp
@@ -429,7 +429,7 @@ void OSystem_PSP::logMessage(LogMessageType::Type type, const char *message) {
PspDebugTrace(false, "%s", message); // write to file
}
-void OSystem_PSP::getTimeAndDate(TimeDate &td) const {
+void OSystem_PSP::getTimeAndDate(TimeDate &td, bool skipRecord) const {
time_t curTime = time(0);
struct tm t = *localtime(&curTime);
td.tm_sec = t.tm_sec;
diff --git a/backends/platform/psp/osys_psp.h b/backends/platform/psp/osys_psp.h
index 5de0233f77..e203616356 100644
--- a/backends/platform/psp/osys_psp.h
+++ b/backends/platform/psp/osys_psp.h
@@ -138,7 +138,7 @@ public:
// Misc
FilesystemFactory *getFilesystemFactory() { return &PSPFilesystemFactory::instance(); }
- void getTimeAndDate(TimeDate &t) const;
+ void getTimeAndDate(TimeDate &td, bool skipRecord = false) const;
virtual void engineDone();
void quit();
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index b024f61594..f59dd30d23 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -638,7 +638,7 @@ void OSystem_SDL::delayMillis(uint msecs) {
SDL_Delay(msecs);
}
-void OSystem_SDL::getTimeAndDate(TimeDate &td) const {
+void OSystem_SDL::getTimeAndDate(TimeDate &td, bool skipRecord) const {
time_t curTime = time(0);
struct tm t = *localtime(&curTime);
td.tm_sec = t.tm_sec;
@@ -648,6 +648,10 @@ void OSystem_SDL::getTimeAndDate(TimeDate &td) const {
td.tm_mon = t.tm_mon;
td.tm_year = t.tm_year;
td.tm_wday = t.tm_wday;
+
+#ifdef ENABLE_EVENTRECORDER
+ g_eventRec.processTimeAndDate(td, skipRecord);
+#endif
}
MixerManager *OSystem_SDL::getMixerManager() {
diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h
index cd95be7b0f..fb34014d4c 100644
--- a/backends/platform/sdl/sdl.h
+++ b/backends/platform/sdl/sdl.h
@@ -83,7 +83,7 @@ public:
virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0) override;
virtual uint32 getMillis(bool skipRecord = false) override;
virtual void delayMillis(uint msecs) override;
- virtual void getTimeAndDate(TimeDate &td) const override;
+ virtual void getTimeAndDate(TimeDate &td, bool skipRecord = false) const override;
virtual MixerManager *getMixerManager() override;
virtual Common::TimerManager *getTimerManager() override;
virtual Common::SaveFileManager *getSavefileManager() override;
diff --git a/backends/platform/wii/osystem.cpp b/backends/platform/wii/osystem.cpp
index 52c9f599b7..f5c90fb0d5 100644
--- a/backends/platform/wii/osystem.cpp
+++ b/backends/platform/wii/osystem.cpp
@@ -266,7 +266,7 @@ FilesystemFactory *OSystem_Wii::getFilesystemFactory() {
return &WiiFilesystemFactory::instance();
}
-void OSystem_Wii::getTimeAndDate(TimeDate &td) const {
+void OSystem_Wii::getTimeAndDate(TimeDate &td, bool skipRecord) const {
time_t curTime = time(0);
struct tm t = *localtime(&curTime);
td.tm_sec = t.tm_sec;
diff --git a/backends/platform/wii/osystem.h b/backends/platform/wii/osystem.h
index f40871b96c..a76f5cc132 100644
--- a/backends/platform/wii/osystem.h
+++ b/backends/platform/wii/osystem.h
@@ -208,7 +208,7 @@ public:
virtual Audio::Mixer *getMixer() override;
virtual FilesystemFactory *getFilesystemFactory() override;
- virtual void getTimeAndDate(TimeDate &t) const override;
+ virtual void getTimeAndDate(TimeDate &td, bool skipRecord = false) const override;
virtual void logMessage(LogMessageType::Type type, const char *message) override;
diff --git a/common/recorderfile.cpp b/common/recorderfile.cpp
index 77f02f83e8..bb2e1116a1 100644
--- a/common/recorderfile.cpp
+++ b/common/recorderfile.cpp
@@ -373,6 +373,15 @@ void PlaybackFile::readEvent(RecorderEvent& event) {
case kRecorderEventTypeTimer:
event.time = _tmpPlaybackFile.readUint32LE();
break;
+ case kRecorderEventTypeTimeDate:
+ event.timeDate.tm_sec = _tmpPlaybackFile.readSint32LE();
+ event.timeDate.tm_min = _tmpPlaybackFile.readSint32LE();
+ event.timeDate.tm_hour = _tmpPlaybackFile.readSint32LE();
+ event.timeDate.tm_mday = _tmpPlaybackFile.readSint32LE();
+ event.timeDate.tm_mon = _tmpPlaybackFile.readSint32LE();
+ event.timeDate.tm_year = _tmpPlaybackFile.readSint32LE();
+ event.timeDate.tm_wday = _tmpPlaybackFile.readSint32LE();
+ break;
default:
// fallthrough intended
case kRecorderEventTypeNormal:
@@ -549,6 +558,15 @@ void PlaybackFile::writeEvent(const RecorderEvent &event) {
case kRecorderEventTypeTimer:
_tmpRecordFile.writeUint32LE(event.time);
break;
+ case kRecorderEventTypeTimeDate:
+ _tmpRecordFile.writeSint32LE(event.timeDate.tm_sec);
+ _tmpRecordFile.writeSint32LE(event.timeDate.tm_min);
+ _tmpRecordFile.writeSint32LE(event.timeDate.tm_hour);
+ _tmpRecordFile.writeSint32LE(event.timeDate.tm_mday);
+ _tmpRecordFile.writeSint32LE(event.timeDate.tm_mon);
+ _tmpRecordFile.writeSint32LE(event.timeDate.tm_year);
+ _tmpRecordFile.writeSint32LE(event.timeDate.tm_wday);
+ break;
default:
// fallthrough intended
case kRecorderEventTypeNormal:
diff --git a/common/recorderfile.h b/common/recorderfile.h
index 3cabb3f0a2..ad501ce1c6 100644
--- a/common/recorderfile.h
+++ b/common/recorderfile.h
@@ -38,21 +38,39 @@ namespace Common {
enum RecorderEventType {
kRecorderEventTypeNormal = 0,
- kRecorderEventTypeTimer = 1
+ kRecorderEventTypeTimer = 1,
+ kRecorderEventTypeTimeDate = 2
};
struct RecorderEvent : Event {
RecorderEventType recordedtype;
- uint32 time;
+ union {
+ uint32 time;
+ TimeDate timeDate;
+ };
RecorderEvent() {
recordedtype = kRecorderEventTypeNormal;
time = 0;
+ timeDate.tm_sec = 0;
+ timeDate.tm_min = 0;
+ timeDate.tm_hour = 0;
+ timeDate.tm_mday = 0;
+ timeDate.tm_mon = 0;
+ timeDate.tm_year = 0;
+ timeDate.tm_wday = 0;
}
RecorderEvent(const Event &e) : Event(e) {
recordedtype = kRecorderEventTypeNormal;
time = 0;
+ timeDate.tm_sec = 0;
+ timeDate.tm_min = 0;
+ timeDate.tm_hour = 0;
+ timeDate.tm_mday = 0;
+ timeDate.tm_mon = 0;
+ timeDate.tm_year = 0;
+ timeDate.tm_wday = 0;
}
};
diff --git a/common/system.h b/common/system.h
index 3137d36b14..02ed5cf772 100644
--- a/common/system.h
+++ b/common/system.h
@@ -1368,7 +1368,7 @@ public:
* On many systems, this corresponds to the combination of time()
* and localtime().
*/
- virtual void getTimeAndDate(TimeDate &t) const = 0;
+ virtual void getTimeAndDate(TimeDate &td, bool skipRecord = false) const = 0;
/**
* Return the timer manager singleton.
diff --git a/gui/EventRecorder.cpp b/gui/EventRecorder.cpp
index d348a781a3..2a0eef8dac 100644
--- a/gui/EventRecorder.cpp
+++ b/gui/EventRecorder.cpp
@@ -77,6 +77,13 @@ EventRecorder::EventRecorder() {
_needRedraw = false;
_processingMillis = false;
_fastPlayback = false;
+ _lastTimeDate.tm_sec = 0;
+ _lastTimeDate.tm_min = 0;
+ _lastTimeDate.tm_hour = 0;
+ _lastTimeDate.tm_mday = 0;
+ _lastTimeDate.tm_mon = 0;
+ _lastTimeDate.tm_year = 0;
+ _lastTimeDate.tm_wday = 0;
_fakeTimer = 0;
_savedState = false;
@@ -119,6 +126,42 @@ void EventRecorder::deinit() {
DebugMan.disableDebugChannel("EventRec");
}
+void EventRecorder::processTimeAndDate(TimeDate &td, bool skipRecord) {
+ if (!_initialized) {
+ return;
+ }
+ if (skipRecord) {
+ td = _lastTimeDate;
+ return;
+ }
+ Common::RecorderEvent timeDateEvent;
+ switch (_recordMode) {
+ case kRecorderRecord:
+ timeDateEvent.recordedtype = Common::kRecorderEventTypeTimeDate;
+ timeDateEvent.timeDate = td;
+ _lastTimeDate = td;
+ _playbackFile->writeEvent(timeDateEvent);
+ break;
+ case kRecorderPlayback:
+ if (_nextEvent.recordedtype != Common::kRecorderEventTypeTimeDate) {
+ // just re-use any previous date time value
+ td = _lastTimeDate;
+ return;
+ }
+ _lastTimeDate = _nextEvent.timeDate;
+ td = _lastTimeDate;
+ debug(3, "timedate event");
+
+ _nextEvent = _playbackFile->getNextEvent();
+ break;
+ case kRecorderPlaybackPause:
+ td = _lastTimeDate;
+ break;
+ default:
+ break;
+ }
+}
+
void EventRecorder::processMillis(uint32 &millis, bool skipRecord) {
if (!_initialized) {
return;
diff --git a/gui/EventRecorder.h b/gui/EventRecorder.h
index e100371647..614fdcc9ff 100644
--- a/gui/EventRecorder.h
+++ b/gui/EventRecorder.h
@@ -81,6 +81,7 @@ public:
void deinit();
bool processDelayMillis();
uint32 getRandomSeed(const Common::String &name);
+ void processTimeAndDate(TimeDate &td, bool skipRecord);
void processMillis(uint32 &millis, bool skipRecord);
void processGameDescription(const ADGameDescription *desc);
Common::SeekableReadStream *processSaveStream(const Common::String & fileName);
@@ -178,6 +179,7 @@ private:
bool notifyEvent(const Common::Event &event) override;
bool _initialized;
volatile uint32 _fakeTimer;
+ TimeDate _lastTimeDate;
bool _savedState;
bool _needcontinueGame;
int _temporarySlot;
More information about the Scummvm-git-logs
mailing list