aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorLittleboy2012-08-27 23:29:09 -0400
committerLittleboy2012-08-27 23:30:23 -0400
commit6ab8db638e4a1d547ee67db067b5d6c3d6c940a4 (patch)
tree981fed8e6621957dde6ba8f5ec90c67ca36d50f1 /engines
parentee8581b778b83bc01af0f26bc8b3680ebc266700 (diff)
downloadscummvm-rg350-6ab8db638e4a1d547ee67db067b5d6c3d6c940a4.tar.gz
scummvm-rg350-6ab8db638e4a1d547ee67db067b5d6c3d6c940a4.tar.bz2
scummvm-rg350-6ab8db638e4a1d547ee67db067b5d6c3d6c940a4.zip
LASTEXPRESS: Implement more savegame loading
- Rename existing function to load the last saved game - Remove loadgame debugger command
Diffstat (limited to 'engines')
-rw-r--r--engines/lastexpress/debug.cpp25
-rw-r--r--engines/lastexpress/debug.h1
-rw-r--r--engines/lastexpress/game/savegame.cpp30
-rw-r--r--engines/lastexpress/game/savegame.h4
-rw-r--r--engines/lastexpress/menu/menu.cpp4
5 files changed, 30 insertions, 34 deletions
diff --git a/engines/lastexpress/debug.cpp b/engines/lastexpress/debug.cpp
index 3994cb0bcb..db3a3e3962 100644
--- a/engines/lastexpress/debug.cpp
+++ b/engines/lastexpress/debug.cpp
@@ -85,7 +85,6 @@ Debugger::Debugger(LastExpressEngine *engine) : _engine(engine), _command(NULL),
DCmd_Register("entity", WRAP_METHOD(Debugger, cmdEntity));
// Misc
- DCmd_Register("loadgame", WRAP_METHOD(Debugger, cmdLoadGame));
DCmd_Register("chapter", WRAP_METHOD(Debugger, cmdSwitchChapter));
DCmd_Register("clear", WRAP_METHOD(Debugger, cmdClear));
@@ -1119,30 +1118,6 @@ label_error:
}
/**
- * Command: loads a game
- *
- * @param argc The argument count.
- * @param argv The values.
- *
- * @return true if it was handled, false otherwise
- */
-bool Debugger::cmdLoadGame(int argc, const char **argv) {
- if (argc == 2) {
- int id = getNumber(argv[1]);
-
- if (id == 0 || id > 6)
- goto error;
-
- getSaveLoad()->loadGame((GameId)(id - 1));
- } else {
-error:
- DebugPrintf("Syntax: loadgame <id> (id=1-6)\n");
- }
-
- return true;
-}
-
-/**
* Command: switch to a specific chapter
*
* @param argc The argument count.
diff --git a/engines/lastexpress/debug.h b/engines/lastexpress/debug.h
index a9f0443af9..532cb83717 100644
--- a/engines/lastexpress/debug.h
+++ b/engines/lastexpress/debug.h
@@ -79,7 +79,6 @@ private:
bool cmdShow(int argc, const char **argv);
bool cmdEntity(int argc, const char **argv);
- bool cmdLoadGame(int argc, const char **argv);
bool cmdSwitchChapter(int argc, const char **argv);
bool cmdClear(int argc, const char **argv);
diff --git a/engines/lastexpress/game/savegame.cpp b/engines/lastexpress/game/savegame.cpp
index 7efce0007b..021dc40bb9 100644
--- a/engines/lastexpress/game/savegame.cpp
+++ b/engines/lastexpress/game/savegame.cpp
@@ -482,10 +482,10 @@ void SaveLoad::clear(bool clearStream) {
// Save & Load
//////////////////////////////////////////////////////////////////////////
-// Load game
-void SaveLoad::loadGame(GameId id) {
+// Load last saved game
+void SaveLoad::loadLastGame() {
if (!_savegame)
- error("[SaveLoad::loadGame] No savegame stream present");
+ error("[SaveLoad::loadLastGame] No savegame stream present");
// Rewind current savegame
_savegame->seek(0);
@@ -522,7 +522,29 @@ void SaveLoad::loadGame(GameId id) {
}
// Load a specific game entry
-void SaveLoad::loadGame(GameId id, uint32 index) {
+void SaveLoad::loadGame(uint32 index) {
+ if (!_savegame)
+ error("[SaveLoad::loadLastGame] No savegame stream present");
+
+ // Rewind current savegame
+ _savegame->seek(0);
+
+ // Write main header (with selected index)
+ SavegameMainHeader header;
+ header.count = index;
+ header.brightness = getState()->brightness;
+ header.volume = getState()->volume;
+
+ Common::Serializer ser(NULL, _savegame);
+ header.saveLoadWithSerializer(ser);
+
+ // TODO
+ // Go to the entry
+ // Load the entry
+ // Get offset (main and entry)
+ // Write main header again with correct entry offset
+ // Setup game and start
+
error("[SaveLoad::loadGame] Not implemented! (only loading the last entry is working for now)");
}
diff --git a/engines/lastexpress/game/savegame.h b/engines/lastexpress/game/savegame.h
index 8656b2ee86..361957227e 100644
--- a/engines/lastexpress/game/savegame.h
+++ b/engines/lastexpress/game/savegame.h
@@ -153,8 +153,8 @@ public:
uint32 init(GameId id, bool resetHeaders);
// Save & Load
- void loadGame(GameId id);
- void loadGame(GameId id, uint32 index);
+ void loadLastGame();
+ void loadGame(uint32 index);
void saveGame(SavegameType type, EntityIndex entity, uint32 value);
void loadVolumeBrightness();
diff --git a/engines/lastexpress/menu/menu.cpp b/engines/lastexpress/menu/menu.cpp
index 6a453aee99..c48e55bb55 100644
--- a/engines/lastexpress/menu/menu.cpp
+++ b/engines/lastexpress/menu/menu.cpp
@@ -916,13 +916,13 @@ void Menu::startGame() {
if (_lastIndex == _index) {
setGlobalTimer(0);
if (_index) {
- getSaveLoad()->loadGame(_gameId);
+ getSaveLoad()->loadLastGame();
} else {
getLogic()->resetState();
getEntities()->setup(true, kEntityPlayer);
}
} else {
- getSaveLoad()->loadGame(_gameId, _index);
+ getSaveLoad()->loadGame(_index);
}
}