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

dreammaster paulfgilbert at gmail.com
Sun Feb 9 01:28:55 UTC 2020


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:
bba4dedf92 NUVIE: Slot 1 now allows loading original save, unless ScummVM save present


Commit: bba4dedf92f7f5188e49f38d2dd24ad25ffaf0b8
    https://github.com/scummvm/scummvm/commit/bba4dedf92f7f5188e49f38d2dd24ad25ffaf0b8
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-02-08T17:28:41-08:00

Commit Message:
NUVIE: Slot 1 now allows loading original save, unless ScummVM save present

Changed paths:
  A engines/ultima/nuvie/meta_engine.cpp
  A engines/ultima/nuvie/meta_engine.h
    engines/ultima/detection.cpp
    engines/ultima/detection.h
    engines/ultima/module.mk
    engines/ultima/nuvie/nuvie.cpp


diff --git a/engines/ultima/detection.cpp b/engines/ultima/detection.cpp
index 0a4c3c1..171b954 100644
--- a/engines/ultima/detection.cpp
+++ b/engines/ultima/detection.cpp
@@ -22,12 +22,14 @@
 
 #include "ultima/detection.h"
 #include "base/plugins.h"
+#include "common/system.h"
+#include "common/config-manager.h"
 #include "common/savefile.h"
 #include "common/str-array.h"
 #include "common/memstream.h"
-#include "common/system.h"
 #include "common/translation.h"
 #include "ultima/shared/early/ultima_early.h"
+#include "ultima/nuvie/meta_engine.h"
 #include "ultima/nuvie/nuvie.h"
 #include "ultima/ultima8/ultima8.h"
 
@@ -108,6 +110,16 @@ const char *UltimaMetaEngine::getSavegameFile(int saveGameIdx, const char *targe
 	return buffer;
 }
 
+SaveStateList UltimaMetaEngine::listSaves(const char *target) const {
+	SaveStateList saveList = AdvancedMetaEngine::listSaves(target);
+
+	Common::String gameId = ConfMan.get("gameid");
+	if (gameId == "ultima6" || gameId == "ultima6_enh")
+		Ultima::Nuvie::MetaEngine::listSaves(saveList);
+
+	return saveList;
+}
+
 #if PLUGIN_ENABLED_DYNAMIC(ULTIMA)
 REGISTER_PLUGIN_DYNAMIC(ULTIMA, PLUGIN_TYPE_ENGINE, UltimaMetaEngine);
 #else
diff --git a/engines/ultima/detection.h b/engines/ultima/detection.h
index 8fbb0c7..a69ff2e 100644
--- a/engines/ultima/detection.h
+++ b/engines/ultima/detection.h
@@ -80,6 +80,11 @@ public:
 
 	virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override;
 	virtual int getMaximumSaveSlot() const override;
+
+	/**
+	 * Return a list of all save states associated with the given target.
+	 */
+	virtual SaveStateList listSaves(const char *target) const override;
 };
 
 namespace Ultima {
diff --git a/engines/ultima/module.mk b/engines/ultima/module.mk
index 1972b55..9da51b9 100644
--- a/engines/ultima/module.mk
+++ b/engines/ultima/module.mk
@@ -131,6 +131,7 @@ MODULE_OBJS := \
 	ultima1/widgets/urban_widget.o \
 	ultima1/widgets/wench.o \
 	ultima1/game.o \
+	nuvie/meta_engine.o \
 	nuvie/nuvie.o \
 	nuvie/actors/actor.o \
 	nuvie/actors/actor_manager.o \
diff --git a/engines/ultima/nuvie/meta_engine.cpp b/engines/ultima/nuvie/meta_engine.cpp
new file mode 100644
index 0000000..8d40f93
--- /dev/null
+++ b/engines/ultima/nuvie/meta_engine.cpp
@@ -0,0 +1,46 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "ultima/nuvie/meta_engine.h"
+#include "common/translation.h"
+
+namespace Ultima {
+namespace Nuvie {
+
+void MetaEngine::listSaves(SaveStateList &saveList) {
+	// Check whether there's an entry for the original save slot
+	for (SaveStateList::iterator it = saveList.begin(); it != saveList.end(); ++it) {
+		if (it->getSaveSlot() == ORIGINAL_SAVE_SLOT)
+			return;
+	}
+
+	// Add in an entry
+	SaveStateDescriptor desc;
+	desc.setSaveSlot(ORIGINAL_SAVE_SLOT);
+	desc.setDescription(_("Original Save"));
+	saveList.push_back(desc);
+
+	Common::sort(saveList.begin(), saveList.end(), SaveStateDescriptorSlotComparator());
+}
+
+} // End of namespace Nuvie
+} // End of namespace Ultima
diff --git a/engines/ultima/nuvie/meta_engine.h b/engines/ultima/nuvie/meta_engine.h
new file mode 100644
index 0000000..7e377ae
--- /dev/null
+++ b/engines/ultima/nuvie/meta_engine.h
@@ -0,0 +1,43 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ULTIMA_ULTIMA6_META_ENGINE
+#define ULTIMA_ULTIMA6_META_ENGINE
+
+#include "engines/savestate.h"
+
+namespace Ultima {
+namespace Nuvie {
+
+enum {
+	ORIGINAL_SAVE_SLOT = 1
+};
+
+class MetaEngine {
+public:
+	static void listSaves(SaveStateList &saveList);
+};
+
+} // End of namespace Nuvie
+} // End of namespace Ultima
+
+#endif
diff --git a/engines/ultima/nuvie/nuvie.cpp b/engines/ultima/nuvie/nuvie.cpp
index 5650649..015b005 100644
--- a/engines/ultima/nuvie/nuvie.cpp
+++ b/engines/ultima/nuvie/nuvie.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "ultima/nuvie/nuvie.h"
+#include "ultima/nuvie/meta_engine.h"
 #include "ultima/nuvie/core/events.h"
 #include "ultima/nuvie/actors/actor.h"
 #include "ultima/nuvie/core/nuvie_defs.h"
@@ -43,10 +44,6 @@
 namespace Ultima {
 namespace Nuvie {
 
-#define DATA_FILENAME "ultima.dat"
-#define DATA_VERSION_MAJOR 1
-#define DATA_VERSION_MINOR 0
-
 NuvieEngine *g_engine;
 
 NuvieEngine::NuvieEngine(OSystem *syst, const Ultima::UltimaGameDescription *gameDesc) :
@@ -293,6 +290,20 @@ bool NuvieEngine::canSaveGameStateCurrently(bool isAutosave) {
 
 Common::Error NuvieEngine::loadGameState(int slot) {
 	Common::String filename = getSaveFilename(slot);
+
+	if (slot == ORIGINAL_SAVE_SLOT) {
+		// For Nuvie, unless a savegame is already present for the slot,
+		// loading it loads in the original game savegame
+		Common::InSaveFile *saveFile = _saveFileMan->openForLoading(filename);
+		bool isPresent = saveFile != nullptr;
+		delete saveFile;
+
+		if (!isPresent) {
+			_savegame->load_original();
+			return Common::kNoError;
+		}
+	}
+
 	return _savegame->load(filename) ? Common::kNoError : Common::kReadingFailed;
 }
 




More information about the Scummvm-git-logs mailing list