[Scummvm-git-logs] scummvm master -> 930aefbaa94bd2fad514dc23fe63cd84efd71792

sev- sev at scummvm.org
Thu Jul 8 13:05:44 UTC 2021


This automated email contains information about 9 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
375d8dc4a4 EVENTRECORDER: changed event recorder format and added more events
5ae72dc190 EVENTRECORDER: removed unused variable
f35cc92aaf EVENTRECORDER: ignore other event sources when playing back a record
36afa639a4 EVENTRECORDER: skip some getMillis for the event recorder
70167d8423 EVENTRECORDER: debug logging
2a658b9d65 EVENTRECORDER: quit scummvm after end of recorder file was reached.
669e3fcba3 EVENTRECORDER: don't skip events by calling getMillis() during processMillis()
f1d9fd2c8a TWINE: debug logging
930aefbaa9 EVENTRECORDER: fixed missing events in eventQueue of DefaultEventManager


Commit: 375d8dc4a4354a72ab4b2331233c602f27f029f9
    https://github.com/scummvm/scummvm/commit/375d8dc4a4354a72ab4b2331233c602f27f029f9
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-07-08T15:05:35+02:00

Commit Message:
EVENTRECORDER: changed event recorder format and added more events

the custom engine events were missing and the default event manager transforms the backend events
. Which means that the event recorder is not persisting the low level key press/release events
but the already transformed custom engine events of the keymapper

Changed paths:
    common/recorderfile.cpp


diff --git a/common/recorderfile.cpp b/common/recorderfile.cpp
index 5d6c38d6dd..5fba1f38eb 100644
--- a/common/recorderfile.cpp
+++ b/common/recorderfile.cpp
@@ -370,6 +370,8 @@ void PlaybackFile::readEvent(RecorderEvent& event) {
 		event.type = (EventType)_tmpPlaybackFile.readUint32LE();
 		switch (event.type) {
 		case EVENT_KEYDOWN:
+			event.kbdRepeat = _tmpPlaybackFile.readByte();
+			// fallthrough
 		case EVENT_KEYUP:
 			event.time = _tmpPlaybackFile.readUint32LE();
 			event.kbd.keycode = (KeyCode)_tmpPlaybackFile.readSint32LE();
@@ -393,6 +395,21 @@ void PlaybackFile::readEvent(RecorderEvent& event) {
 			event.mouse.x = _tmpPlaybackFile.readSint16LE();
 			event.mouse.y = _tmpPlaybackFile.readSint16LE();
 			break;
+		case EVENT_CUSTOM_BACKEND_ACTION_START:
+		case EVENT_CUSTOM_BACKEND_ACTION_END:
+		case EVENT_CUSTOM_ENGINE_ACTION_START:
+		case EVENT_CUSTOM_ENGINE_ACTION_END:
+			event.time = _tmpPlaybackFile.readUint32LE();
+			event.customType = _tmpPlaybackFile.readUint32LE();
+			break;
+		case EVENT_JOYAXIS_MOTION:
+		case EVENT_JOYBUTTON_UP:
+		case EVENT_JOYBUTTON_DOWN:
+			event.time = _tmpPlaybackFile.readUint32LE();
+			event.joystick.axis = _tmpPlaybackFile.readByte();
+			event.joystick.button = _tmpPlaybackFile.readByte();
+			event.joystick.position = _tmpPlaybackFile.readSint16LE();
+			break;
 		default:
 			event.time = _tmpPlaybackFile.readUint32LE();
 			break;
@@ -529,6 +546,8 @@ void PlaybackFile::writeEvent(const RecorderEvent &event) {
 		_tmpRecordFile.writeUint32LE((uint32)event.type);
 		switch(event.type) {
 		case EVENT_KEYDOWN:
+			_tmpRecordFile.writeByte(event.kbdRepeat);
+			// fallthrough
 		case EVENT_KEYUP:
 			_tmpRecordFile.writeUint32LE(event.time);
 			_tmpRecordFile.writeSint32LE(event.kbd.keycode);
@@ -552,6 +571,21 @@ void PlaybackFile::writeEvent(const RecorderEvent &event) {
 			_tmpRecordFile.writeSint16LE(event.mouse.x);
 			_tmpRecordFile.writeSint16LE(event.mouse.y);
 			break;
+		case EVENT_CUSTOM_BACKEND_ACTION_START:
+		case EVENT_CUSTOM_BACKEND_ACTION_END:
+		case EVENT_CUSTOM_ENGINE_ACTION_START:
+		case EVENT_CUSTOM_ENGINE_ACTION_END:
+			_tmpRecordFile.writeUint32LE(event.time);
+			_tmpRecordFile.writeUint32LE(event.customType);
+			break;
+		case EVENT_JOYAXIS_MOTION:
+		case EVENT_JOYBUTTON_UP:
+		case EVENT_JOYBUTTON_DOWN:
+			_tmpRecordFile.writeUint32LE(event.time);
+			_tmpRecordFile.writeByte(event.joystick.axis);
+			_tmpRecordFile.writeByte(event.joystick.button);
+			_tmpRecordFile.writeSint16LE(event.joystick.position);
+			break;
 		default:
 			_tmpRecordFile.writeUint32LE(event.time);
 			break;


Commit: 5ae72dc190be92f0a232edad645e98999a62ebeb
    https://github.com/scummvm/scummvm/commit/5ae72dc190be92f0a232edad645e98999a62ebeb
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-07-08T15:05:35+02:00

Commit Message:
EVENTRECORDER: removed unused variable

Changed paths:
    common/recorderfile.cpp


diff --git a/common/recorderfile.cpp b/common/recorderfile.cpp
index 5fba1f38eb..5e0d421d26 100644
--- a/common/recorderfile.cpp
+++ b/common/recorderfile.cpp
@@ -112,7 +112,6 @@ void PlaybackFile::close() {
 }
 
 bool PlaybackFile::parseHeader() {
-	PlaybackFileHeader result;
 	ChunkHeader nextChunk;
 	_playbackParseState = kFileStateCheckFormat;
 	if (!readChunkHeader(nextChunk)) {


Commit: f35cc92aaf79809e784655f199fb669f58e8d063
    https://github.com/scummvm/scummvm/commit/f35cc92aaf79809e784655f199fb669f58e8d063
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-07-08T15:05:35+02:00

Commit Message:
EVENTRECORDER: ignore other event sources when playing back a record

Changed paths:
    common/events.cpp
    common/events.h
    gui/EventRecorder.cpp


diff --git a/common/events.cpp b/common/events.cpp
index 242a00e8ea..5450b06423 100644
--- a/common/events.cpp
+++ b/common/events.cpp
@@ -71,6 +71,8 @@ void EventDispatcher::dispatch() {
 	dispatchPoll();
 
 	for (List<SourceEntry>::iterator i = _sources.begin(); i != _sources.end(); ++i) {
+		if (i->ignore)
+			continue;
 		while (i->source->pollEvent(event)) {
 			// We only try to process the events via the setup event mapper, when
 			// we have a setup mapper and when the event source allows mapping.
@@ -102,6 +104,8 @@ void EventDispatcher::clearEvents() {
 	Event event;
 
 	for (List<SourceEntry>::iterator i = _sources.begin(); i != _sources.end(); ++i) {
+		if (i->ignore)
+			continue;
 		while (i->source->pollEvent(event)) {}
 	}
 }
@@ -117,6 +121,7 @@ void EventDispatcher::registerSource(EventSource *source, bool autoFree) {
 
 	newEntry.source = source;
 	newEntry.autoFree = autoFree;
+	newEntry.ignore = false;
 
 	_sources.push_back(newEntry);
 }
@@ -133,6 +138,12 @@ void EventDispatcher::unregisterSource(EventSource *source) {
 	}
 }
 
+void EventDispatcher::ignoreSources(bool ignore) {
+	for (List<SourceEntry>::iterator i = _sources.begin(); i != _sources.end(); ++i) {
+		i->ignore = ignore;
+	}
+}
+
 void EventDispatcher::registerObserver(EventObserver *obs, uint priority, bool autoFree, bool notifyPoll) {
 	ObserverEntry newEntry;
 
diff --git a/common/events.h b/common/events.h
index a392611e05..6338817859 100644
--- a/common/events.h
+++ b/common/events.h
@@ -402,6 +402,12 @@ public:
 	 */
 	void unregisterSource(EventSource *source);
 
+	/**
+	 * Ignore some event sources and don't poll them. This is useful for e.g. the EventRecorder
+	 * where you don't want the other EventSource instances to interfer with the serialized events.
+	 */
+	void ignoreSources(bool ignore);
+
 	/**
 	 * Register a new EventObserver with the Dispatcher.
 	 *
@@ -421,6 +427,7 @@ private:
 
 	struct Entry {
 		bool autoFree;
+		bool ignore;
 	};
 
 	struct SourceEntry : public Entry {
diff --git a/gui/EventRecorder.cpp b/gui/EventRecorder.cpp
index bc15a37652..6075c410bd 100644
--- a/gui/EventRecorder.cpp
+++ b/gui/EventRecorder.cpp
@@ -107,7 +107,9 @@ void EventRecorder::deinit() {
 	_controlPanel->close();
 	delete _controlPanel;
 	debugC(1, kDebugLevelEventRec, "playback:action=stopplayback");
-	g_system->getEventManager()->getEventDispatcher()->unregisterSource(this);
+	Common::EventDispatcher *eventDispater = g_system->getEventManager()->getEventDispatcher();
+	eventDispater->unregisterSource(this);
+	eventDispater->ignoreSources(false);
 	_recordMode = kPassthrough;
 	_playbackFile->close();
 	delete _playbackFile;
@@ -271,8 +273,11 @@ void EventRecorder::init(const Common::String &recordFileName, RecordMode mode)
 	}
 	if (_recordMode == kRecorderPlayback) {
 		debugC(1, kDebugLevelEventRec, "playback:action=\"Load file\" filename=%s", recordFileName.c_str());
+		Common::EventDispatcher *eventDispater = g_system->getEventManager()->getEventDispatcher();
+		eventDispater->clearEvents();
+		eventDispater->ignoreSources(true);
+		eventDispater->registerSource(this, false);
 	}
-	g_system->getEventManager()->getEventDispatcher()->registerSource(this, false);
 	_screenshotPeriod = ConfMan.getInt("screenshot_period");
 	if (_screenshotPeriod == 0) {
 		_screenshotPeriod = kDefaultScreenshotPeriod;
@@ -304,9 +309,8 @@ void EventRecorder::init(const Common::String &recordFileName, RecordMode mode)
 /**
  * Opens or creates file depend of recording mode.
  *
- *@param id of recording or playing back game
- *@return true in case of success, false in case of error
- *
+ * @param id of recording or playing back game
+ * @return true in case of success, false in case of error
  */
 bool EventRecorder::openRecordFile(const Common::String &fileName) {
 	bool result;


Commit: 36afa639a45730fc42b2d1a08e687a478dcd88d3
    https://github.com/scummvm/scummvm/commit/36afa639a45730fc42b2d1a08e687a478dcd88d3
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-07-08T15:05:35+02:00

Commit Message:
EVENTRECORDER: skip some getMillis for the event recorder

they are running as event source and would bring the event recorder into an out-of-sync state

Changed paths:
    backends/cloud/cloudicon.cpp
    backends/keymapper/keymapper.cpp
    common/osd_message_queue.cpp


diff --git a/backends/cloud/cloudicon.cpp b/backends/cloud/cloudicon.cpp
index 708bd24f32..9dee1eb6a7 100644
--- a/backends/cloud/cloudicon.cpp
+++ b/backends/cloud/cloudicon.cpp
@@ -75,12 +75,12 @@ CloudIcon::Type CloudIcon::getShownType() const {
 }
 
 bool CloudIcon::needsUpdate() const {
-	uint32 delaySinceLastUpdate = g_system->getMillis() - _lastUpdateTime;
+	uint32 delaySinceLastUpdate = g_system->getMillis(true) - _lastUpdateTime;
 	return delaySinceLastUpdate >= UPDATE_DELAY_MIN_MILLIS;
 }
 
 void CloudIcon::update() {
-	uint32 currentTime = g_system->getMillis();
+	uint32 currentTime = g_system->getMillis(true);
 	uint32 delaySinceLastUpdate = currentTime - _lastUpdateTime;
 	_lastUpdateTime = currentTime;
 
diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp
index 1be29220d8..ab7137d4ea 100644
--- a/backends/keymapper/keymapper.cpp
+++ b/backends/keymapper/keymapper.cpp
@@ -427,7 +427,7 @@ bool DelayedEventSource::pollEvent(Event &event) {
 		return false;
 	}
 
-	uint32 now = g_system->getMillis();
+	uint32 now = g_system->getMillis(true);
 
 	if (now >= _delayedEffectiveTime) {
 		event = _delayedEvents.pop().event;
diff --git a/common/osd_message_queue.cpp b/common/osd_message_queue.cpp
index 431ce90d18..56a94a005a 100644
--- a/common/osd_message_queue.cpp
+++ b/common/osd_message_queue.cpp
@@ -47,7 +47,7 @@ void OSDMessageQueue::addMessage(const Common::U32String &msg) {
 bool OSDMessageQueue::pollEvent(Common::Event &event) {
 	_mutex.lock();
 	if (!_messages.empty()) {
-		uint t = g_system->getMillis();
+		uint t = g_system->getMillis(true);
 		if (t - _lastUpdate >= kMinimumDelay) {
 			_lastUpdate = t;
 			Common::U32String msg = _messages.pop();


Commit: 70167d8423e874615eeedf1c2a0a3d42c8172c49
    https://github.com/scummvm/scummvm/commit/70167d8423e874615eeedf1c2a0a3d42c8172c49
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-07-08T15:05:35+02:00

Commit Message:
EVENTRECORDER: debug logging

Changed paths:
    common/recorderfile.cpp


diff --git a/common/recorderfile.cpp b/common/recorderfile.cpp
index 5e0d421d26..e1f33b7e79 100644
--- a/common/recorderfile.cpp
+++ b/common/recorderfile.cpp
@@ -415,7 +415,7 @@ void PlaybackFile::readEvent(RecorderEvent& event) {
 		}
 		break;
 	}
-	event.kbdRepeat = true;
+	debug(3, "read event of type: %i (time: %u, systemmillis: %u)", event.type, event.time, g_system->getMillis(true));
 }
 
 void PlaybackFile::readEventsToBuffer(uint32 size) {
@@ -594,6 +594,7 @@ void PlaybackFile::writeEvent(const RecorderEvent &event) {
 	if (_recordCount == kMaxBufferedRecords) {
 		dumpRecordsToFile();
 	}
+	debug(3, "write event of type: %i (time: %u, systemmillis: %u)", event.type, event.time, g_system->getMillis(true));
 }
 
 void PlaybackFile::writeGameSettings() {


Commit: 2a658b9d653f732e0cbd533cf26b9b69437cebd0
    https://github.com/scummvm/scummvm/commit/2a658b9d653f732e0cbd533cf26b9b69437cebd0
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-07-08T15:05:35+02:00

Commit Message:
EVENTRECORDER: quit scummvm after end of recorder file was reached.

This might also become a return to launcher, but I've somehere read the hint that
the event recorder was only meant to play back one game per session. We'll see.

Changed paths:
    common/recorderfile.cpp
    common/recorderfile.h


diff --git a/common/recorderfile.cpp b/common/recorderfile.cpp
index e1f33b7e79..77f02f83e8 100644
--- a/common/recorderfile.cpp
+++ b/common/recorderfile.cpp
@@ -319,9 +319,19 @@ bool PlaybackFile::readSaveRecord() {
 	return true;
 }
 
-
+bool PlaybackFile::hasNextEvent() const {
+	if (_readStream->err()) {
+		return false;
+	}
+	return !_readStream->eos();
+}
 
 RecorderEvent PlaybackFile::getNextEvent() {
+	if (!hasNextEvent()) {
+		debug(3, "end of recorder file reached.");
+		g_system->quit();
+	}
+
 	assert(_mode == kRead);
 	if (isEventsBufferEmpty()) {
 		PlaybackFile::ChunkHeader header;
diff --git a/common/recorderfile.h b/common/recorderfile.h
index 0396dbd68f..3cabb3f0a2 100644
--- a/common/recorderfile.h
+++ b/common/recorderfile.h
@@ -127,6 +127,7 @@ public:
 	bool openRead(const String &fileName);
 	void close();
 
+	bool hasNextEvent() const;
 	RecorderEvent getNextEvent();
 	void writeEvent(const RecorderEvent &event);
 


Commit: 669e3fcba361242aacfa0b3cd8df7badd585b869
    https://github.com/scummvm/scummvm/commit/669e3fcba361242aacfa0b3cd8df7badd585b869
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-07-08T15:05:35+02:00

Commit Message:
EVENTRECORDER: don't skip events by calling getMillis() during processMillis()

If for some reason getMillis() was called in any of the functions that are called
inside of processMillis() the getNextEvent would skip events. To prevent this we
detect recursive calls to processMillis() now and assume that no further millisecond
has passed since the initial call.

Changed paths:
    gui/EventRecorder.cpp
    gui/EventRecorder.h


diff --git a/gui/EventRecorder.cpp b/gui/EventRecorder.cpp
index 6075c410bd..a47549fbe4 100644
--- a/gui/EventRecorder.cpp
+++ b/gui/EventRecorder.cpp
@@ -75,6 +75,7 @@ EventRecorder::EventRecorder() {
 	_fakeMixerManager = nullptr;
 	_initialized = false;
 	_needRedraw = false;
+	_processingMillis = false;
 	_fastPlayback = false;
 
 	_fakeTimer = 0;
@@ -122,10 +123,11 @@ void EventRecorder::processMillis(uint32 &millis, bool skipRecord) {
 	if (!_initialized) {
 		return;
 	}
-	if (skipRecord) {
+	if (skipRecord || _processingMillis) {
 		millis = _fakeTimer;
 		return;
 	}
+	// to prevent calling this recursively
 	if (_recordMode == kRecorderPlaybackPause) {
 		millis = _fakeTimer;
 	}
@@ -151,14 +153,19 @@ void EventRecorder::processMillis(uint32 &millis, bool skipRecord) {
 			// are querying the millis by themselves, too. If the EventRecorder::poll
 			// is registered and thus dispatched after those EventSource instances, it
 			// might look like it ran out-of-sync.
+			millis = _fakeTimer;
 			return;
 		}
-		updateSubsystems();
+		_processingMillis = true;
 		_fakeTimer = _nextEvent.time;
+		millis = _fakeTimer;
+		debug(3, "millis event: %u", millis);
+
+		updateSubsystems();
 		_nextEvent = _playbackFile->getNextEvent();
 		_timerManager->handler();
-		millis = _fakeTimer;
 		_controlPanel->setReplayedTime(_fakeTimer);
+		_processingMillis = false;
 		break;
 	case kRecorderPlaybackPause:
 		millis = _fakeTimer;
diff --git a/gui/EventRecorder.h b/gui/EventRecorder.h
index 7412ede64c..e100371647 100644
--- a/gui/EventRecorder.h
+++ b/gui/EventRecorder.h
@@ -230,6 +230,7 @@ private:
 	Common::String _recordFileName;
 	bool _fastPlayback;
 	bool _needRedraw;
+	bool _processingMillis;
 };
 
 } // End of namespace GUI


Commit: f1d9fd2c8a90b816a45a2742980c58015acd2227
    https://github.com/scummvm/scummvm/commit/f1d9fd2c8a90b816a45a2742980c58015acd2227
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-07-08T15:05:35+02:00

Commit Message:
TWINE: debug logging

Changed paths:
    engines/twine/input.cpp


diff --git a/engines/twine/input.cpp b/engines/twine/input.cpp
index d9dd746765..ce7e09ec4d 100644
--- a/engines/twine/input.cpp
+++ b/engines/twine/input.cpp
@@ -138,10 +138,12 @@ void Input::processCustomEngineEventStart(const Common::Event &event) {
 	} else {
 		actionStates[event.customType] = 1 + event.kbdRepeat;
 	}
+	debug(3, "twine custom event type start: %i", event.customType);
 }
 
 void Input::processCustomEngineEventEnd(const Common::Event &event) {
 	actionStates[event.customType] = 0;
+	debug(3, "twine custom event type end: %i", event.customType);
 }
 
 void Input::readKeys() {


Commit: 930aefbaa94bd2fad514dc23fe63cd84efd71792
    https://github.com/scummvm/scummvm/commit/930aefbaa94bd2fad514dc23fe63cd84efd71792
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-07-08T15:05:35+02:00

Commit Message:
EVENTRECORDER: fixed missing events in eventQueue of DefaultEventManager

due to the fact that we aborted every event that wasn't a key-repeat event, we never filled the event queue

Changed paths:
    gui/EventRecorder.cpp


diff --git a/gui/EventRecorder.cpp b/gui/EventRecorder.cpp
index a47549fbe4..b015577543 100644
--- a/gui/EventRecorder.cpp
+++ b/gui/EventRecorder.cpp
@@ -454,9 +454,6 @@ bool EventRecorder::notifyEvent(const Common::Event &ev) {
 	evt.mouse.y = evt.mouse.y * (g_system->getOverlayHeight() / g_system->getHeight());
 	switch (_recordMode) {
 	case kRecorderPlayback:
-		if (!ev.kbdRepeat) {
-			return true;
-		}
 		return false;
 	case kRecorderRecord:
 		g_gui.processEvent(evt, _controlPanel);




More information about the Scummvm-git-logs mailing list