[Scummvm-cvs-logs] SF.net SVN: scummvm:[33291] scummvm/branches/gsoc2008-rtl/engines/lure
cpage88 at users.sourceforge.net
cpage88 at users.sourceforge.net
Fri Jul 25 21:41:18 CEST 2008
Revision: 33291
http://scummvm.svn.sourceforge.net/scummvm/?rev=33291&view=rev
Author: cpage88
Date: 2008-07-25 19:41:17 +0000 (Fri, 25 Jul 2008)
Log Message:
-----------
Added -x and --list-saves support for LURE
Modified Paths:
--------------
scummvm/branches/gsoc2008-rtl/engines/lure/detection.cpp
scummvm/branches/gsoc2008-rtl/engines/lure/game.cpp
scummvm/branches/gsoc2008-rtl/engines/lure/lure.cpp
scummvm/branches/gsoc2008-rtl/engines/lure/lure.h
Modified: scummvm/branches/gsoc2008-rtl/engines/lure/detection.cpp
===================================================================
--- scummvm/branches/gsoc2008-rtl/engines/lure/detection.cpp 2008-07-25 16:08:10 UTC (rev 33290)
+++ scummvm/branches/gsoc2008-rtl/engines/lure/detection.cpp 2008-07-25 19:41:17 UTC (rev 33291)
@@ -26,6 +26,7 @@
#include "base/plugins.h"
#include "common/advancedDetector.h"
+#include "common/savefile.h"
#include "lure/lure.h"
@@ -185,6 +186,7 @@
}
virtual bool createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const;
+ virtual SaveStateList listSaves(const char *target) const;
};
bool LureMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const {
@@ -195,6 +197,34 @@
return gd != 0;
}
+SaveStateList LureMetaEngine::listSaves(const char *target) const {
+ Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
+ Common::StringList filenames;
+ Common::String saveDesc;
+ Common::String pattern = target;
+ pattern += ".???";
+
+ filenames = saveFileMan->listSavefiles(pattern.c_str());
+ sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)
+
+ SaveStateList saveList;
+ for (Common::StringList::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) {
+ saveDesc = Lure::getSaveName(in);
+ saveList.push_back(SaveStateDescriptor(slotNum, saveDesc, *file));
+ delete in;
+ }
+ }
+ }
+
+ return saveList;
+}
+
#if PLUGIN_ENABLED_DYNAMIC(LURE)
REGISTER_PLUGIN_DYNAMIC(LURE, PLUGIN_TYPE_ENGINE, LureMetaEngine);
#else
Modified: scummvm/branches/gsoc2008-rtl/engines/lure/game.cpp
===================================================================
--- scummvm/branches/gsoc2008-rtl/engines/lure/game.cpp 2008-07-25 16:08:10 UTC (rev 33290)
+++ scummvm/branches/gsoc2008-rtl/engines/lure/game.cpp 2008-07-25 19:41:17 UTC (rev 33291)
@@ -138,9 +138,17 @@
screen.empty();
screen.setPaletteEmpty();
+
+ bool _loadSavegame = false;
+
+ if (engine.gameToLoad() != -1)
+ _loadSavegame = engine.loadGame(engine.gameToLoad());
+
+ if (!_loadSavegame) {
+ // Flag for starting game
+ setState(GS_RESTART);
+ }
- // Flag for starting game
- setState(GS_RESTART);
bool initialRestart = true;
while (!engine.quit()) {
Modified: scummvm/branches/gsoc2008-rtl/engines/lure/lure.cpp
===================================================================
--- scummvm/branches/gsoc2008-rtl/engines/lure/lure.cpp 2008-07-25 16:08:10 UTC (rev 33290)
+++ scummvm/branches/gsoc2008-rtl/engines/lure/lure.cpp 2008-07-25 19:41:17 UTC (rev 33291)
@@ -92,6 +92,7 @@
_room = new Room();
_fights = new FightsManager();
+ _gameToLoad = -1;
_initialised = true;
return 0;
}
@@ -121,27 +122,34 @@
}
int LureEngine::go() {
-
- if (ConfMan.getBool("copy_protection")) {
- CopyProtectionDialog *dialog = new CopyProtectionDialog();
- bool result = dialog->show();
- delete dialog;
- if (quit())
- return _eventMan->shouldRTL();
-
- if (!result)
- error("Sorry - copy protection failed");
+ Game *gameInstance = new Game();
+
+ // If requested, load a savegame instead of showing the intro
+ if (ConfMan.hasKey("save_slot")) {
+ _gameToLoad = ConfMan.getInt("save_slot");
+ if (_gameToLoad < 0 || _gameToLoad > 999)
+ _gameToLoad = -1;
}
+
+ if (_gameToLoad == -1) {
+ if (ConfMan.getBool("copy_protection")) {
+ CopyProtectionDialog *dialog = new CopyProtectionDialog();
+ bool result = dialog->show();
+ delete dialog;
+ if (quit())
+ return _eventMan->shouldRTL();
- Game *gameInstance = new Game();
+ if (!result)
+ error("Sorry - copy protection failed");
+ }
- if (ConfMan.getInt("boot_param") == 0) {
- // Show the introduction
- Sound.loadSection(Sound.isRoland() ? ROLAND_INTRO_SOUND_RESOURCE_ID : ADLIB_INTRO_SOUND_RESOURCE_ID);
-
- Introduction *intro = new Introduction();
- intro->show();
- delete intro;
+ if (ConfMan.getInt("boot_param") == 0) {
+ // Show the introduction
+ Sound.loadSection(Sound.isRoland() ? ROLAND_INTRO_SOUND_RESOURCE_ID : ADLIB_INTRO_SOUND_RESOURCE_ID);
+ Introduction *intro = new Introduction();
+ intro->show();
+ delete intro;
+ }
}
// Play the game
@@ -278,4 +286,23 @@
return result;
}
+Common::String getSaveName(Common::InSaveFile *in) {
+ // Check for header
+ char saveName[MAX_DESC_SIZE];
+ char buffer[5];
+ in->read(&buffer[0], 5);
+ if (memcmp(&buffer[0], "lure", 5) == 0) {
+ // Check language version
+ in->readByte();
+ in->readByte();
+ char *p = saveName;
+ int decCtr = MAX_DESC_SIZE - 1;
+ while ((decCtr > 0) && ((*p++ = in->readByte()) != 0)) --decCtr;
+ *p = '\0';
+
+ }
+
+ return Common::String(saveName);
+}
+
} // End of namespace Lure
Modified: scummvm/branches/gsoc2008-rtl/engines/lure/lure.h
===================================================================
--- scummvm/branches/gsoc2008-rtl/engines/lure/lure.h 2008-07-25 16:08:10 UTC (rev 33290)
+++ scummvm/branches/gsoc2008-rtl/engines/lure/lure.h 2008-07-25 19:41:17 UTC (rev 33291)
@@ -30,6 +30,7 @@
#include "common/rect.h"
#include "sound/mixer.h"
#include "common/file.h"
+#include "common/savefile.h"
#include "lure/disk.h"
#include "lure/res.h"
@@ -47,6 +48,7 @@
class LureEngine : public Engine {
private:
bool _initialised;
+ int _gameToLoad;
uint8 _saveVersion;
Disk *_disk;
Resources *_resources;
@@ -74,6 +76,7 @@
Disk &disk() { return *_disk; }
+ int gameToLoad() { return _gameToLoad; }
bool loadGame(uint8 slotNumber);
bool saveGame(uint8 slotNumber, Common::String &caption);
Common::String *detectSave(int slotNumber);
@@ -85,7 +88,7 @@
Common::Platform getPlatform() const;
bool isEGA() const { return (getFeatures() & GF_EGA) != 0; }
};
-
+ Common::String getSaveName(Common::InSaveFile *in);
} // End of namespace Lure
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list