diff options
Diffstat (limited to 'scumm')
-rw-r--r-- | scumm/dialogs.cpp | 10 | ||||
-rw-r--r-- | scumm/script_v5.cpp | 15 | ||||
-rw-r--r-- | scumm/script_v8.cpp | 8 |
3 files changed, 19 insertions, 14 deletions
diff --git a/scumm/dialogs.cpp b/scumm/dialogs.cpp index d21d5ac86f..b4cf20869f 100644 --- a/scumm/dialogs.cpp +++ b/scumm/dialogs.cpp @@ -44,6 +44,8 @@ #include "backends/wince/CEKeysDialog.h" #endif +#include <memory> + using GUI::CommandSender; using GUI::StaticTextWidget; using GUI::kButtonWidth; @@ -255,19 +257,17 @@ Common::StringList generateSavegameList(ScummEngine *scumm, bool saveMode) { uint i = saveMode ? 1 : 0; bool avail_saves[81]; - SaveFileManager *mgr = OSystem::instance()->get_savefile_manager(); + const std::auto_ptr<SaveFileManager> mgr(OSystem::instance()->get_savefile_manager()); - scumm->listSavegames(avail_saves, ARRAYSIZE(avail_saves), mgr); + scumm->listSavegames(avail_saves, ARRAYSIZE(avail_saves), mgr.get()); for (; i < ARRAYSIZE(avail_saves); i++) { if (avail_saves[i]) - scumm->getSavegameName(i, name, mgr); + scumm->getSavegameName(i, name, mgr.get()); else name[0] = 0; l.push_back(name); } - delete mgr; - return l; } diff --git a/scumm/script_v5.cpp b/scumm/script_v5.cpp index 762ba2a678..a5d465d48a 100644 --- a/scumm/script_v5.cpp +++ b/scumm/script_v5.cpp @@ -29,6 +29,8 @@ #include "scumm/sound.h" #include "scumm/verbs.h" +#include <memory> + namespace Scumm { #define OPCODE(x) { &ScummEngine_v5::x, #x } @@ -1172,8 +1174,9 @@ void ScummEngine_v5::o5_saveLoadGame() { case 0xC0: // test if save exists bool avail_saves[100]; char filename[256]; - SaveFileManager *mgr = _system->get_savefile_manager(); - listSavegames(avail_saves, ARRAYSIZE(avail_saves), mgr); + const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager()); + + listSavegames(avail_saves, ARRAYSIZE(avail_saves), mgr.get()); makeSavegameName(filename, slot, false); if (avail_saves[slot] && (mgr->open_savefile(filename, getSavePath(), false))) result = 6; // save file exists @@ -1938,7 +1941,8 @@ void ScummEngine_v5::o5_roomOps() { s = filename; while ((*s++ = fetchScriptByte())); - SaveFileManager *mgr = _system->get_savefile_manager(); + const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager()); + file = mgr->open_savefile(filename, getSavePath(), true); if (file != NULL) { byte *ptr; @@ -1946,7 +1950,6 @@ void ScummEngine_v5::o5_roomOps() { file->write(ptr, resStrLen(ptr) + 1); delete file; } - delete mgr; break; } case 14: // SO_LOAD_STRING @@ -1958,7 +1961,8 @@ void ScummEngine_v5::o5_roomOps() { s = filename; while ((*s++ = fetchScriptByte())); - SaveFileManager *mgr = _system->get_savefile_manager(); + const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager()); + file = mgr->open_savefile(filename, getSavePath(), false); if (file != NULL) { byte *ptr; @@ -1974,7 +1978,6 @@ void ScummEngine_v5::o5_roomOps() { free(ptr); delete file; } - delete mgr; break; } case 15: // SO_ROOM_TRANSFORM diff --git a/scumm/script_v8.cpp b/scumm/script_v8.cpp index 7fa51a71cf..94c26b920f 100644 --- a/scumm/script_v8.cpp +++ b/scumm/script_v8.cpp @@ -34,6 +34,7 @@ #include "scumm/smush/smush_player.h" #include "sound/mixer.h" +#include <memory> namespace Scumm { @@ -1322,7 +1323,7 @@ void ScummEngine_v8::o8_kernelSetFunctions() { warning("o8_kernelSetFunctions: clearTextQueue()"); break; case 25: { // saveGameReadName - SaveFileManager *mgr = _system->get_savefile_manager(); + const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager()); char *address = (char*)getStringAddress(args[2]); char name[30]; @@ -1330,13 +1331,14 @@ void ScummEngine_v8::o8_kernelSetFunctions() { warning("o8_kernelSetFunctions: saveGameReadName failed finding slot string %d", args[2]); break; } - getSavegameName(args[1] - 1, name, mgr); + getSavegameName(args[1] - 1, name, mgr.get()); if (strlen(name) > 0 && strlen(name) < 30) strcpy(address, name); break; } case 26: { // saveGame? - //SaveFileManager *mgr = _system->get_savefile_manager(); + //const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager()); + //char *address = (char*)getStringAddress(args[2]); char address[30]; warning("o8_kernelSetFunctions: saveGame?(%d, %s)", args[1], address); |