[Scummvm-git-logs] scummvm master -> c095cb31d1d3ce41e10fa82c66f1d9fe37c66bf3

criezy criezy at scummvm.org
Sun Apr 23 00:59:10 CEST 2017


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:
c095cb31d1 DRASCULA: Add possibility to load and save games using GMM


Commit: c095cb31d1d3ce41e10fa82c66f1d9fe37c66bf3
    https://github.com/scummvm/scummvm/commit/c095cb31d1d3ce41e10fa82c66f1d9fe37c66bf3
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2017-04-22T23:53:10+01:00

Commit Message:
DRASCULA: Add possibility to load and save games using GMM

Changed paths:
    NEWS
    engines/drascula/drascula.cpp
    engines/drascula/drascula.h
    engines/drascula/saveload.cpp


diff --git a/NEWS b/NEWS
index b2717c03..8ca46d0 100644
--- a/NEWS
+++ b/NEWS
@@ -35,8 +35,9 @@ For a more comprehensive changelog of the latest experimental code, see:
    - Added save/load from General Main Menu.
 
 Drascula:
-  - Add handling of the master volume and fix volume synchronization between
+  - Added handling of the master volume and fix volume synchronization between
     the game and ScummVM options.
+  - Added possibility to load and save games using GMM.
 
 1.9.1 (YYYY-MM-DD)
  General:
diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp
index 655af48..56a2d63 100644
--- a/engines/drascula/drascula.cpp
+++ b/engines/drascula/drascula.cpp
@@ -76,7 +76,8 @@ DrasculaEngine::DrasculaEngine(OSystem *syst, const DrasculaGameDescription *gam
     framesWithoutAction = 0;
 	term_int = 0;
 	currentChapter = 0;
-	_loadedDifferentChapter = 0;
+	_loadedDifferentChapter = false;
+	_canSaveLoad  = false;
 	musicStopped = 0;
 	FrameSSN = 0;
 	globalSpeed = 0;
@@ -230,7 +231,7 @@ DrasculaEngine::~DrasculaEngine() {
 
 bool DrasculaEngine::hasFeature(EngineFeature f) const {
 	return
-		(f == kSupportsRTL);
+		(f == kSupportsRTL || f == kSupportsLoadingDuringRuntime || f == kSupportsSavingDuringRuntime);
 }
 
 Common::Error DrasculaEngine::run() {
@@ -575,6 +576,7 @@ bool DrasculaEngine::runCurrentChapter() {
 				playMusic(roomMusic);
 		}
 
+		_canSaveLoad = true;
 		delay(25);
 #ifndef _WIN32_WCE
 		// FIXME
@@ -585,6 +587,9 @@ bool DrasculaEngine::runCurrentChapter() {
 		// events in the wince port.
 		updateEvents();
 #endif
+		_canSaveLoad = false;
+		if (_loadedDifferentChapter)
+			return true;
 
 		if (!_menuScreen && takeObject == 1)
 			checkObjects();
@@ -663,7 +668,11 @@ bool DrasculaEngine::runCurrentChapter() {
 
 		_menuBar = (_mouseY < 24 && !_menuScreen) ? true : false;
 
+		_canSaveLoad = true;
 		Common::KeyCode key = getScan();
+		_canSaveLoad = false;
+		if (_loadedDifferentChapter)
+			return true;
 		if (key == Common::KEYCODE_F1 && !_menuScreen) {
 			selectVerb(kVerbLook);
 		} else if (key == Common::KEYCODE_F2 && !_menuScreen) {
@@ -881,7 +890,7 @@ void DrasculaEngine::delay(int ms) {
 		_system->delayMillis(10);
 		updateEvents();
 		_system->updateScreen();
-	} while (_system->getMillis() < end && !shouldQuit());
+	} while (_system->getMillis() < end && !shouldQuit() && !_loadedDifferentChapter);
 }
 
 void DrasculaEngine::pause(int duration) {
diff --git a/engines/drascula/drascula.h b/engines/drascula/drascula.h
index 5265324..2f8fc86 100644
--- a/engines/drascula/drascula.h
+++ b/engines/drascula/drascula.h
@@ -327,6 +327,11 @@ public:
 
 	virtual void syncSoundSettings();
 
+	virtual Common::Error loadGameState(int slot);
+	virtual bool canLoadGameStateCurrently();
+	virtual Common::Error saveGameState(int slot, const Common::String &desc);
+	virtual bool canSaveGameStateCurrently();
+
 	Common::RandomSource *_rnd;
 	const DrasculaGameDescription *_gameDescription;
 	uint32 getFeatures() const;
@@ -457,6 +462,7 @@ public:
 	int currentChapter;
 	bool _loadedDifferentChapter;
 	int _currentSaveSlot;
+	bool _canSaveLoad;
 	int _color;
 	int musicStopped;
 	int _mouseX, _mouseY, _leftMouseButton, _rightMouseButton;
@@ -497,10 +503,10 @@ public:
 	bool scummVMSaveLoadDialog(bool isSave);
 	Common::String enterName(Common::String &selectedName);
 	void loadSaveNames();
-	void saveGame(int slot, Common::String &desc);
+	void saveGame(int slot, const Common::String &desc);
 	bool loadGame(int slot);
 	void checkForOldSaveGames();
-	void convertSaveGame(int slot, Common::String &desc);
+	void convertSaveGame(int slot, const Common::String &desc);
 
 	void print_abc(const char *, int, int);
 	void delay(int ms);
diff --git a/engines/drascula/saveload.cpp b/engines/drascula/saveload.cpp
index eb65486..f0484e2 100644
--- a/engines/drascula/saveload.cpp
+++ b/engines/drascula/saveload.cpp
@@ -138,7 +138,7 @@ SaveStateDescriptor loadMetaData(Common::ReadStream *s, int slot, bool setPlayTi
 	return desc;
 }
 
-void saveMetaData(Common::WriteStream *s, Common::String &desc) {
+void saveMetaData(Common::WriteStream *s, const Common::String &desc) {
 	TimeDate curTime;
 	g_system->getTimeAndDate(curTime);
 
@@ -155,7 +155,7 @@ void saveMetaData(Common::WriteStream *s, Common::String &desc) {
 	s->writeUint32LE(playTime);
 }
 
-void DrasculaEngine::convertSaveGame(int slot, Common::String &desc) {
+void DrasculaEngine::convertSaveGame(int slot, const Common::String &desc) {
 	Common::String oldFileName = Common::String::format("%s%02d", _targetName.c_str(), slot);
 	Common::String newFileName = Common::String::format("%s.%03d", _targetName.c_str(), slot);
 	Common::InSaveFile *oldFile = _saveFileMan->openForLoading(oldFileName);
@@ -188,6 +188,26 @@ void DrasculaEngine::convertSaveGame(int slot, Common::String &desc) {
 	_saveFileMan->removeSavefile(oldFileName);
 }
 
+Common::Error DrasculaEngine::loadGameState(int slot) {
+	// The boolean returned by loadGame() indicates if loading is in the same
+	// chapter or in a different one. Thus it does not indicate an error.
+	loadGame(slot);
+	return Common::kNoError;
+}
+
+bool DrasculaEngine::canLoadGameStateCurrently() {
+	return _canSaveLoad;
+}
+
+Common::Error DrasculaEngine::saveGameState(int slot, const Common::String &desc) {
+	saveGame(slot, desc);
+	return Common::kNoError;
+}
+
+bool DrasculaEngine::canSaveGameStateCurrently() {
+	return _canSaveLoad;
+}
+
 /**
  * Loads the first 10 save names, to be used in Drascula's save/load screen
  */
@@ -205,7 +225,7 @@ void DrasculaEngine::loadSaveNames() {
 	}
 }
 
-void DrasculaEngine::saveGame(int slot, Common::String &desc) {
+void DrasculaEngine::saveGame(int slot, const Common::String &desc) {
 	Common::OutSaveFile *out;
 	int l;
 





More information about the Scummvm-git-logs mailing list