aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorNipun Garg2019-07-07 00:03:18 +0530
committerEugene Sandulenko2019-09-03 17:17:14 +0200
commitd2df277403477be99cb22fadbc448e2c3357e53c (patch)
treec16e1e66319dd336b279d5c376d9f3900abd07d6 /engines
parent0a6d4c042f5634979104e1418f07509e37532b22 (diff)
downloadscummvm-rg350-d2df277403477be99cb22fadbc448e2c3357e53c.tar.gz
scummvm-rg350-d2df277403477be99cb22fadbc448e2c3357e53c.tar.bz2
scummvm-rg350-d2df277403477be99cb22fadbc448e2c3357e53c.zip
HDB: Add saveSlot, loadSlot, saveGame and loadGame
Diffstat (limited to 'engines')
-rw-r--r--engines/hdb/hdb.cpp78
-rw-r--r--engines/hdb/hdb.h4
2 files changed, 81 insertions, 1 deletions
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 649c4a9d3a..df82881ded 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -427,11 +427,87 @@ void HDBGame::setTargetXY(int x, int y) {
}
bool HDBGame::saveSlot(int slot) {
- warning("STUB: HDBGame::saveSlot(%d)", slot);
+
+ // If no map is loaded, don't try to save
+ if (!g_hdb->_map->isLoaded())
+ return false;
+
+ Common::OutSaveFile *out;
+
+ Common::String saveFileName = Common::String::format("%s.%03d", _targetName.c_str(), slot);
+ if (!(out = _saveFileMan->openForSaving(saveFileName)))
+ error("Unable to open save file");
+
+ warning("STUB: Save MetaData");
+ Graphics::saveThumbnail(*out);
+
+ // Actual Save Data
+ saveGame(out);
+#if 0
+ _lua->save(out, saveFileName);
+#endif
+
+ out->finalize();
+ if (out->err())
+ warning("Can't wrtie file '%s'. (Disk full?)", saveFileName.c_str());
+
+ delete out;
+
+ return true;
+}
+
+bool HDBGame::loadSlot(int slot) {
+ Common::InSaveFile *in;
+
+ Common::String saveFileName = Common::String::format("%s.%03d", _targetName.c_str(), slot);
+ if (!(in = _saveFileMan->openForLoading(saveFileName))) {
+ warning("missing savegame file %s", saveFileName.c_str());
+ if (g_hdb->_map->isLoaded())
+ g_hdb->setGameState(GAME_PLAY);
+ return false;
+ }
+
+ warning("STUB: Load MetaData");
+ Graphics::skipThumbnail(*in);
+
+ // Actual Save Data
+ loadGame(in);
+
+ delete in;
return true;
}
+void HDBGame::saveGame(Common::OutSaveFile *out) {
+
+ // Save Map Name
+ out->write(_inMapName, 32);
+
+ // Save Map Object Data
+ _map->save(out);
+
+ // Save Window Object Data
+ _window->save(out);
+
+ // Save Gfx Object Data
+ _gfx->save(out);
+
+ // Save Sound Object Data
+ _sound->save(out);
+
+ // Save Game Object Data
+ save(out);
+
+ // Save AI Object Data
+#if 0
+ _ai->save(out);
+#endif
+}
+
+void HDBGame::loadGame(Common::InSaveFile *in) {
+ warning("STUB: Add loadGame()");
+}
+
// PLAYER is trying to use this entity
void HDBGame::useEntity(AIEntity *e) {
warning("STUB: HDBGame::useEntity incomplete");
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 01ed0b96da..fcd52dab1d 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -32,6 +32,7 @@
#include "common/random.h"
#include "common/savefile.h"
#include "graphics/surface.h"
+#include "graphics/thumbnail.h"
#include "gui/debugger.h"
#include "engines/engine.h"
@@ -157,6 +158,9 @@ public:
}
bool saveSlot(int slot);
+ bool loadSlot(int slot);
+ void saveGame(Common::OutSaveFile *out);
+ void loadGame(Common::InSaveFile *in);
void saveWhenReady(int slot) {
_saveInfo.active = true;