diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/hdb/hdb.h | 2 | ||||
-rw-r--r-- | engines/hdb/lua-script.cpp | 4 | ||||
-rw-r--r-- | engines/hdb/lua-script.h | 2 | ||||
-rw-r--r-- | engines/hdb/menu.cpp | 10 | ||||
-rw-r--r-- | engines/hdb/saveload.cpp | 15 |
5 files changed, 19 insertions, 14 deletions
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h index 77e7610dcc..3b42c262bd 100644 --- a/engines/hdb/hdb.h +++ b/engines/hdb/hdb.h @@ -180,6 +180,8 @@ public: void saveGame(Common::OutSaveFile *out); void loadGame(Common::InSaveFile *in); + Common::String genSaveFileName(uint slot, bool lua); + void saveWhenReady(int slot) { _saveInfo.active = true; _saveInfo.slot = slot; diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp index b82b7af8c8..1b62081cc6 100644 --- a/engines/hdb/lua-script.cpp +++ b/engines/hdb/lua-script.cpp @@ -154,7 +154,7 @@ void LuaScript::purgeGlobals() { _globals.clear(); } -void LuaScript::save(Common::OutSaveFile *out, const char *targetName, int slot) { +void LuaScript::save(Common::OutSaveFile *out, int slot) { out->writeUint32LE(_globals.size()); // Save Globals @@ -165,7 +165,7 @@ void LuaScript::save(Common::OutSaveFile *out, const char *targetName, int slot) out->write(_globals[i]->string, 32); } - Common::String saveLuaName = Common::String::format("%s.l.%03d", targetName, slot); + Common::String saveLuaName = g_hdb->genSaveFileName(slot, true); lua_printstack(_state); lua_getglobal(_state, "SaveState"); diff --git a/engines/hdb/lua-script.h b/engines/hdb/lua-script.h index 5124ac2638..4dab94efaf 100644 --- a/engines/hdb/lua-script.h +++ b/engines/hdb/lua-script.h @@ -59,7 +59,7 @@ public: void saveGlobalString(const char *global, const char *string); void loadGlobal(const char *global); void purgeGlobals(); - void save(Common::OutSaveFile *out, const char *targetName, int slot); + void save(Common::OutSaveFile *out, int slot); void loadSaveFile(Common::InSaveFile *in, const char *fName); bool init(); diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp index 6ea70ea823..ade6156248 100644 --- a/engines/hdb/menu.cpp +++ b/engines/hdb/menu.cpp @@ -928,15 +928,11 @@ void Menu::drawTitle() { } void Menu::fillSavegameSlots() { - int i; - int max = kNumSaveSlots; - - Common::InSaveFile *in; Common::String saveGameFile; - for (i = 0; i < max; i++) { - saveGameFile = Common::String::format("%s.%03d", g_hdb->getTargetName()->c_str(), i); - in = g_system->getSavefileManager()->openForLoading(saveGameFile); + for (int i = 0; i < kNumSaveSlots; i++) { + saveGameFile = g_hdb->genSaveFileName(i, false); + Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(saveGameFile); if (!in) { memset(&_saveGames[i], 0, sizeof(Save)); diff --git a/engines/hdb/saveload.cpp b/engines/hdb/saveload.cpp index acda89222e..5c59619aba 100644 --- a/engines/hdb/saveload.cpp +++ b/engines/hdb/saveload.cpp @@ -32,7 +32,7 @@ Common::Error HDBGame::saveGameState(int slot, const Common::String &desc) { Common::OutSaveFile *out; - Common::String saveFileName = Common::String::format("%s.%03d", _targetName.c_str(), slot); + Common::String saveFileName = genSaveFileName(slot, false); if (!(out = _saveFileMan->openForSaving(saveFileName))) error("Unable to open save file"); @@ -45,7 +45,7 @@ Common::Error HDBGame::saveGameState(int slot, const Common::String &desc) { // Actual Save Data saveGame(out); - _lua->save(out, _targetName.c_str(), slot); + _lua->save(out, slot); out->finalize(); if (out->err()) @@ -59,7 +59,7 @@ Common::Error HDBGame::saveGameState(int slot, const Common::String &desc) { Common::Error HDBGame::loadGameState(int slot) { Common::InSaveFile *in; - Common::String saveFileName = Common::String::format("%s.%03d", _targetName.c_str(), slot); + Common::String saveFileName = genSaveFileName(slot, false); if (!(in = _saveFileMan->openForLoading(saveFileName))) { warning("missing savegame file %s", saveFileName.c_str()); if (g_hdb->_map->isLoaded()) @@ -76,7 +76,7 @@ Common::Error HDBGame::loadGameState(int slot) { _lua->loadLua(_currentLuaName); // load the Lua code FIRST! (if no file, it's ok) - saveFileName = Common::String::format("%s.l.%03d", _targetName.c_str(), slot); + saveFileName = genSaveFileName(slot, true); _lua->loadSaveFile(in, saveFileName.c_str()); delete in; @@ -340,5 +340,12 @@ void AIEntity::load(Common::InSaveFile *in) { aiDraw = drawf; } +Common::String HDBGame::genSaveFileName(uint slot, bool lua) { + if (!lua) + return Common::String::format("%s.%03d", _targetName.c_str(), slot); + + return Common::String::format("%s.l.%03d", _targetName.c_str(), slot); +} + } // End of Namespace |