[Scummvm-cvs-logs] scummvm master -> d6881100dd5613c8573f8f8235b93772ae513e49

bgK bastien.bouclet at gmail.com
Mon Feb 22 10:00:58 CET 2016


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

Summary:
becbe41527 MOHAWK: Continue to poll the events when playing blocking sounds
d6881100dd MOHAWK: Only allow saving/loading from the main event loop


Commit: becbe41527eeb293fb23b7b1be7224f12d4af893
    https://github.com/scummvm/scummvm/commit/becbe41527eeb293fb23b7b1be7224f12d4af893
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2016-02-22T09:57:24+01:00

Commit Message:
MOHAWK: Continue to poll the events when playing blocking sounds

Changed paths:
    engines/mohawk/sound.cpp



diff --git a/engines/mohawk/sound.cpp b/engines/mohawk/sound.cpp
index 74796c3..a2c08d4 100644
--- a/engines/mohawk/sound.cpp
+++ b/engines/mohawk/sound.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "common/debug.h"
+#include "common/events.h"
 #include "common/system.h"
 #include "common/util.h"
 #include "common/textconsole.h"
@@ -163,8 +164,26 @@ Audio::SoundHandle *Sound::replaceSoundMyst(uint16 id, byte volume, bool loop) {
 void Sound::playSoundBlocking(uint16 id, byte volume) {
 	Audio::SoundHandle *handle = playSound(id, volume);
 
-	while (_vm->_mixer->isSoundHandleActive(*handle))
+	while (_vm->_mixer->isSoundHandleActive(*handle) && !_vm->shouldQuit()) {
+		Common::Event event;
+		while (_vm->_system->getEventManager()->pollEvent(event)) {
+			switch (event.type) {
+				case Common::EVENT_KEYDOWN:
+					switch (event.kbd.keycode) {
+						case Common::KEYCODE_SPACE:
+							_vm->pauseGame();
+							break;
+						default:
+							break;
+					}
+				default:
+					break;
+			}
+		}
+
+		// Cut down on CPU usage
 		_vm->_system->delayMillis(10);
+	}
 }
 
 void Sound::playMidi(uint16 id) {


Commit: d6881100dd5613c8573f8f8235b93772ae513e49
    https://github.com/scummvm/scummvm/commit/d6881100dd5613c8573f8f8235b93772ae513e49
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2016-02-22T09:58:41+01:00

Commit Message:
MOHAWK: Only allow saving/loading from the main event loop

Changed paths:
    engines/mohawk/myst.cpp
    engines/mohawk/myst.h



diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp
index 5337a5e..ad803cc 100644
--- a/engines/mohawk/myst.cpp
+++ b/engines/mohawk/myst.cpp
@@ -76,6 +76,7 @@ MohawkEngine_Myst::MohawkEngine_Myst(OSystem *syst, const MohawkGameDescription
 	_showResourceRects = false;
 	_curCard = 0;
 	_needsUpdate = false;
+	_canSafelySaveLoad = false;
 	_curResource = -1;
 	_hoverResource = nullptr;
 
@@ -267,7 +268,7 @@ Common::Error MohawkEngine_Myst::run() {
 		_needsUpdate = _video->updateMovies();
 		_scriptParser->runPersistentScripts();
 
-		while (_eventMan->pollEvent(event)) {
+		while (pollEvent(event)) {
 			switch (event.type) {
 			case Common::EVENT_MOUSEMOVE: {
 				_needsUpdate = true;
@@ -312,7 +313,9 @@ Common::Error MohawkEngine_Myst::run() {
 					_needsShowMap = false;
 					_needsShowDemoMenu = false;
 
+					_canSafelySaveLoad = true;
 					runDialog(*_optionsDialog);
+					_canSafelySaveLoad = false;
 
 					if (_needsPageDrop) {
 						dropPage();
@@ -350,6 +353,15 @@ Common::Error MohawkEngine_Myst::run() {
 	return Common::kNoError;
 }
 
+bool MohawkEngine_Myst::pollEvent(Common::Event &event) {
+	// Saving / Loading is allowed from the GMM only when the main event loop is running
+	_canSafelySaveLoad = true;
+	bool eventReturned =  _eventMan->pollEvent(event);
+	_canSafelySaveLoad = false;
+
+	return eventReturned;
+}
+
 bool MohawkEngine_Myst::skippableWait(uint32 duration) {
 	uint32 end = _system->getMillis() + duration;
 	bool skipped = false;
@@ -1083,10 +1095,14 @@ Common::Error MohawkEngine_Myst::saveGameState(int slot, const Common::String &d
 
 bool MohawkEngine_Myst::canLoadGameStateCurrently() {
 	// No loading in the demo/makingof
-	return !(getFeatures() & GF_DEMO) && getGameType() != GType_MAKINGOF;
+	return _canSafelySaveLoad && !(getFeatures() & GF_DEMO) && getGameType() != GType_MAKINGOF;
 }
 
 bool MohawkEngine_Myst::canSaveGameStateCurrently() {
+	if (!_canSafelySaveLoad) {
+		return false;
+	}
+
 	// There's a limited number of stacks the game can save in
 	switch (_curStack) {
 	case kChannelwoodStack:
diff --git a/engines/mohawk/myst.h b/engines/mohawk/myst.h
index 4b4ceb4..79bd081 100644
--- a/engines/mohawk/myst.h
+++ b/engines/mohawk/myst.h
@@ -28,6 +28,7 @@
 #include "mohawk/resource_cache.h"
 #include "mohawk/myst_scripts.h"
 
+#include "common/events.h"
 #include "common/random.h"
 
 namespace Mohawk {
@@ -240,6 +241,13 @@ private:
 
 	bool _runExitScript;
 
+	/**
+	 * Saving / Loading is only allowed from the main event loop
+	 */
+	bool _canSafelySaveLoad;
+
+	bool pollEvent(Common::Event &event);
+
 	void dropPage();
 
 	void loadCard();






More information about the Scummvm-git-logs mailing list