diff options
Diffstat (limited to 'scumm/script_v5.cpp')
-rw-r--r-- | scumm/script_v5.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
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 |