[Scummvm-git-logs] scummvm master -> 023a587b5b2c8aad5c8770b3619e15bc35f0271f

dreammaster paulfgilbert at gmail.com
Sun Nov 17 03:47:22 CET 2019


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:
023a587b5b GLK: ARCHETYPE: Allowing savegames from launcher


Commit: 023a587b5b2c8aad5c8770b3619e15bc35f0271f
    https://github.com/scummvm/scummvm/commit/023a587b5b2c8aad5c8770b3619e15bc35f0271f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2019-11-16T18:47:16-08:00

Commit Message:
GLK: ARCHETYPE: Allowing savegames from launcher

Changed paths:
    engines/glk/archetype/archetype.cpp
    engines/glk/archetype/archetype.h
    engines/glk/archetype/sys_object.cpp


diff --git a/engines/glk/archetype/archetype.cpp b/engines/glk/archetype/archetype.cpp
index 204bd9f..fb1d277 100644
--- a/engines/glk/archetype/archetype.cpp
+++ b/engines/glk/archetype/archetype.cpp
@@ -87,6 +87,9 @@ bool Archetype::initialize() {
 	_mainWindow = glk_window_open(0, 0, 0, wintype_TextBuffer);
 	glk_set_window(_mainWindow);
 
+	// Check for savegame to load
+	_saveSlot = ConfMan.hasKey("save_slot") ? ConfMan.getInt("save_slot") : -1;
+
 	return true;
 }
 
@@ -104,6 +107,12 @@ Common::Error Archetype::writeGameData(Common::WriteStream *ws) {
 	return Common::kNoError;
 }
 
+Common::Error Archetype::loadLauncherSavegame() {
+	Common::Error result = loadGameState(_saveSlot);
+	_saveSlot = -2;
+	return result;
+}
+
 void Archetype::interpret() {
 	Translating = false;
 	bool success = load_game(&_gameFile);
@@ -130,7 +139,9 @@ void Archetype::write(const String fmt, ...) {
 	va_end(ap);
 
 	_lastOutputText = s;
-	glk_put_buffer(s.c_str(), s.size());
+
+	if (!loadingSavegame())
+		glk_put_buffer(s.c_str(), s.size());
 }
 
 void Archetype::writeln(const String fmt, ...) {
@@ -141,7 +152,9 @@ void Archetype::writeln(const String fmt, ...) {
 
 	s += '\n';
 	_lastOutputText = s;
-	glk_put_buffer(s.c_str(), s.size());
+
+	if (!loadingSavegame())
+		glk_put_buffer(s.c_str(), s.size());
 }
 
 String Archetype::readLine() {
@@ -153,6 +166,14 @@ String Archetype::readLine() {
 	if (text.contains("save") || text.contains("load")) {
 		writeln();
 		return "";
+	
+	} else if (loadingSavegame()) {
+		// Automatically trigger a load action if a savegame needs loading from the launcher
+		return String("load");
+	
+	} else if (_saveSlot == -2) {
+		_saveSlot = -1;
+		return String("look");
 	}
 
 	event_t ev;
diff --git a/engines/glk/archetype/archetype.h b/engines/glk/archetype/archetype.h
index beb67b6..643f5e0 100644
--- a/engines/glk/archetype/archetype.h
+++ b/engines/glk/archetype/archetype.h
@@ -159,10 +159,15 @@ public:
 	 * Returns true if a savegame is being loaded directly from the ScummVM launcher
 	 */
 	bool loadingSavegame() const {
-		return _saveSlot != -1;
+		return _saveSlot >= 0;
 	}
 
 	/**
+	 * Handles loading the savegame specified in the ScummVM launcher
+	 */
+	Common::Error loadLauncherSavegame();
+
+	/**
 	 * Write some text to the screen
 	 */
 	void write(const String fmt, ...);
diff --git a/engines/glk/archetype/sys_object.cpp b/engines/glk/archetype/sys_object.cpp
index 784d9a4..ec98038 100644
--- a/engines/glk/archetype/sys_object.cpp
+++ b/engines/glk/archetype/sys_object.cpp
@@ -282,7 +282,11 @@ void send_to_system(int transport, String &strmsg, ResultType &result, ContextTy
 			break;
 
 		case LOAD_STATE: {
-			Common::ErrorCode errCode = g_vm->loadGame().getCode();
+			Common::ErrorCode errCode;
+			if (g_vm->loadingSavegame())
+				errCode = g_vm->loadLauncherSavegame().getCode();
+			else
+				errCode = g_vm->loadGame().getCode();
 
 			if (errCode == Common::kNoError) {
 				result._kind = RESERVED;





More information about the Scummvm-git-logs mailing list