aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBendegúz Nagy2016-08-18 17:50:56 +0200
committerBendegúz Nagy2016-08-26 23:02:22 +0200
commitbcb067698efe6e18be02a23eb48499ed8e0e714f (patch)
tree6a056d32fecbf7ce1fad0f27f45c1f81e083e295
parent4442b0b302f107013e88120c69d8cf41aaec0ecc (diff)
downloadscummvm-rg350-bcb067698efe6e18be02a23eb48499ed8e0e714f.tar.gz
scummvm-rg350-bcb067698efe6e18be02a23eb48499ed8e0e714f.tar.bz2
scummvm-rg350-bcb067698efe6e18be02a23eb48499ed8e0e714f.zip
DM: Add support for loading from launcher
-rw-r--r--engines/dm/detection.cpp69
-rw-r--r--engines/dm/dm.cpp15
-rw-r--r--engines/dm/dm.h3
-rw-r--r--engines/dm/loadsave.cpp2
4 files changed, 79 insertions, 10 deletions
diff --git a/engines/dm/detection.cpp b/engines/dm/detection.cpp
index 200a81fe97..7f506ac478 100644
--- a/engines/dm/detection.cpp
+++ b/engines/dm/detection.cpp
@@ -32,6 +32,8 @@
#include "common/fs.h"
#include "engines/advancedDetector.h"
+#include <common/system.h>
+
namespace DM {
static const PlainGameDescriptor DMGames[] = {
{"dm", "Dungeon Master"},
@@ -46,7 +48,7 @@ static const ADGameDescription gameDescriptions[] = {
{"Dungeon.dat", 0, "43a213da8eda413541dd12f90ce202f6", 25006},
AD_LISTEND
},
- Common::EN_ANY, Common::kPlatformAmiga, ADGF_NO_FLAGS, GUIO1(GUIO_NONE)
+ Common::EN_ANY, Common::kPlatformAmiga, ADGF_NO_FLAGS, GUIO1(GUIO_NONE)
},
{
"dm", "Atari ???v English",
@@ -94,13 +96,72 @@ public:
virtual const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const { return gameDescriptions; }
virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
- if(desc)
+ if (desc)
*engine = new DM::DMEngine(syst, desc);
return desc != nullptr;
}
+
+ virtual bool hasFeature(MetaEngineFeature f) const {
+ return
+ (f == kSupportsListSaves) ||
+ (f == kSupportsLoadingDuringStartup) ||
+ (f == kSavesSupportThumbnail) ||
+ (f == kSavesSupportMetaInfo) ||
+ (f == kSavesSupportCreationDate);
+ }
+
virtual int getMaximumSaveSlot() const { return 99; }
- virtual SaveStateList listSaves(const char *target) const { return SaveStateList(); }
- SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const { return SaveStateDescriptor(); }
+
+ virtual SaveStateList listSaves(const char *target) const {
+ Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
+ SaveGameHeader header;
+ Common::String pattern = target;
+ pattern += ".###";
+
+ Common::StringArray filenames;
+ filenames = saveFileMan->listSavefiles(pattern.c_str());
+
+ SaveStateList saveList;
+
+ for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
+ // Obtain the last 3 digits of the filename, since they correspond to the save slot
+ int slotNum = atoi(file->c_str() + file->size() - 3);
+
+ if ((slotNum >= 0) && (slotNum <= 999)) {
+ Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str());
+ if (in) {
+ if (DM::readSaveGameHeader(in, &header))
+ saveList.push_back(SaveStateDescriptor(slotNum, header._descr.getDescription()));
+ delete in;
+ }
+ }
+ }
+
+ // Sort saves based on slot number.
+ Common::sort(saveList.begin(), saveList.end(), SaveStateDescriptorSlotComparator());
+ return saveList;
+ }
+
+ SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const {
+ Common::String filename = Common::String::format("%s.%03u", target, slot);
+ Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(filename.c_str());
+
+ if (in) {
+ DM::SaveGameHeader header;
+
+ bool successfulRead = DM::readSaveGameHeader(in, &header);
+ delete in;
+
+ if (successfulRead) {
+ SaveStateDescriptor desc(slot, header._descr.getDescription());
+
+ return header._descr;
+ }
+ }
+
+ return SaveStateDescriptor();
+ }
+
virtual void removeSaveState(const char *target, int slot) const {}
};
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index e22a41dee6..655fb09c4f 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -25,6 +25,7 @@
* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
*/
+#include "common/config-manager.h"
#include "common/scummsys.h"
#include "common/system.h"
@@ -262,11 +263,17 @@ void DMEngine::f463_initializeGame() {
_textMan->f54_textInitialize();
_objectMan->loadObjectNames();
_eventMan->initMouse();
+
+ int16 saveSlot = 1;
do {
- f441_processEntrance();
- if (_engineShouldQuit)
- return;
- } while (f435_loadgame(1) != k1_LoadgameSuccess);
+ if (ConfMan.hasKey("save_slot")) {
+ saveSlot = ConfMan.getInt("save_slot");
+ } else {
+ f441_processEntrance();
+ if (_engineShouldQuit)
+ return;
+ }
+ } while (f435_loadgame(saveSlot) != k1_LoadgameSuccess);
_displayMan->f466_loadIntoBitmap(k11_MenuSpellAreLinesIndice, _menuMan->_gK73_bitmapSpellAreaLines); // @ F0396_MENUS_LoadSpellAreaLinesBitmap
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 9b39f6ee9a..1187db803c 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -212,7 +212,6 @@ class DMEngine : public Engine {
void initArrays();
Common::String getSavefileName(uint16 slot);
void writeSaveGameHeader(Common::OutSaveFile *out, const Common::String &saveName);
- bool readSaveGameHeader(Common::InSaveFile *file, SaveGameHeader *header);
void f439_drawEntrance(); // @ F0439_STARTEND_DrawEntrance
public:
explicit DMEngine(OSystem *syst, const ADGameDescription *gameDesc);
@@ -295,6 +294,8 @@ public:
int16 _g318_waitForInputMaxVerticalBlankCount; // @ G0318_i_WaitForInputMaximumVerticalBlankCount
};
+bool readSaveGameHeader(Common::InSaveFile* in, SaveGameHeader* header);
+
} // End of namespace DM
#endif
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index 9eb0e6c601..3b4cd8070d 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -375,7 +375,7 @@ void DMEngine::writeSaveGameHeader(Common::OutSaveFile* out, const Common::Strin
}
-bool DMEngine::readSaveGameHeader(Common::InSaveFile* in, SaveGameHeader* header) {
+bool readSaveGameHeader(Common::InSaveFile* in, SaveGameHeader* header) {
uint32 id = in->readUint32BE();
// Check if it's a valid ScummVM savegame