aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2004-06-25 22:39:21 +0000
committerMax Horn2004-06-25 22:39:21 +0000
commit6b722ff11bcaa4622cf662245819993316eb8c5d (patch)
tree32c18fbb30a80698904e50377b5ce2b83739246d
parent7a8d469c666f162570f633ec465798e1e5720eef (diff)
downloadscummvm-rg350-6b722ff11bcaa4622cf662245819993316eb8c5d.tar.gz
scummvm-rg350-6b722ff11bcaa4622cf662245819993316eb8c5d.tar.bz2
scummvm-rg350-6b722ff11bcaa4622cf662245819993316eb8c5d.zip
Added Engine::_saveFileMan; thus was able to get rid of auto_ptr usage again
svn-id: r14058
-rw-r--r--base/engine.cpp3
-rw-r--r--base/engine.h1
-rw-r--r--queen/queen.cpp2
-rw-r--r--queen/queen.h1
-rw-r--r--scumm/dialogs.cpp8
-rw-r--r--scumm/saveload.cpp18
-rw-r--r--scumm/script_v5.cpp15
-rw-r--r--scumm/script_v8.cpp7
-rw-r--r--scumm/scumm.h4
-rw-r--r--simon/simon.cpp23
-rw-r--r--sky/control.cpp25
-rw-r--r--sky/control.h4
-rw-r--r--sky/sky.cpp2
-rw-r--r--sword1/control.cpp25
-rw-r--r--sword1/control.h4
-rw-r--r--sword1/sword1.cpp2
-rw-r--r--sword2/save_rest.cpp18
17 files changed, 52 insertions, 110 deletions
diff --git a/base/engine.cpp b/base/engine.cpp
index 2dc6b807eb..3c84837a71 100644
--- a/base/engine.cpp
+++ b/base/engine.cpp
@@ -45,11 +45,14 @@ Engine::Engine(OSystem *syst)
File::setDefaultDirectory(_gameDataPath);
g_debugLevel = ConfMan.getInt("debuglevel");
+
+ _saveFileMan = _system->get_savefile_manager();
}
Engine::~Engine() {
delete _mixer;
delete _timer;
+ delete _saveFileMan;
}
const char *Engine::getSavePath() const {
diff --git a/base/engine.h b/base/engine.h
index 1519158fc8..509d8cd526 100644
--- a/base/engine.h
+++ b/base/engine.h
@@ -36,6 +36,7 @@ public:
protected:
const Common::String _gameDataPath;
+ SaveFileManager *_saveFileMan;
public:
Engine(OSystem *syst);
diff --git a/queen/queen.cpp b/queen/queen.cpp
index 1bc8c1fba7..b94d75182a 100644
--- a/queen/queen.cpp
+++ b/queen/queen.cpp
@@ -114,7 +114,6 @@ QueenEngine::~QueenEngine() {
delete _music;
delete _sound;
delete _walk;
- delete _saveFileMan;
}
void QueenEngine::registerDefaultSettings() {
@@ -358,7 +357,6 @@ void QueenEngine::initialise(void) {
_sound = Sound::giveSound(_mixer, this, _resource->compression());
_walk = new Walk(this);
- _saveFileMan = _system->get_savefile_manager();
}
} // End of namespace Queen
diff --git a/queen/queen.h b/queen/queen.h
index b3793bb229..ddc0933b10 100644
--- a/queen/queen.h
+++ b/queen/queen.h
@@ -135,7 +135,6 @@ protected:
Resource *_resource;
Sound *_sound;
Walk *_walk;
- SaveFileManager *_saveFileMan;
};
} // End of namespace Queen
diff --git a/scumm/dialogs.cpp b/scumm/dialogs.cpp
index b4cf20869f..d2534e6b7b 100644
--- a/scumm/dialogs.cpp
+++ b/scumm/dialogs.cpp
@@ -44,8 +44,6 @@
#include "backends/wince/CEKeysDialog.h"
#endif
-#include <memory>
-
using GUI::CommandSender;
using GUI::StaticTextWidget;
using GUI::kButtonWidth;
@@ -257,12 +255,10 @@ Common::StringList generateSavegameList(ScummEngine *scumm, bool saveMode) {
uint i = saveMode ? 1 : 0;
bool avail_saves[81];
- const std::auto_ptr<SaveFileManager> mgr(OSystem::instance()->get_savefile_manager());
-
- scumm->listSavegames(avail_saves, ARRAYSIZE(avail_saves), mgr.get());
+ scumm->listSavegames(avail_saves, ARRAYSIZE(avail_saves));
for (; i < ARRAYSIZE(avail_saves); i++) {
if (avail_saves[i])
- scumm->getSavegameName(i, name, mgr.get());
+ scumm->getSavegameName(i, name);
else
name[0] = 0;
l.push_back(name);
diff --git a/scumm/saveload.cpp b/scumm/saveload.cpp
index 59567c1eac..4d70cff543 100644
--- a/scumm/saveload.cpp
+++ b/scumm/saveload.cpp
@@ -38,8 +38,6 @@
#include "sound/audiocd.h"
#include "sound/mixer.h"
-#include <memory>
-
namespace Scumm {
struct SaveGameHeader {
@@ -65,15 +63,13 @@ void ScummEngine::requestLoad(int slot) {
}
bool ScummEngine::saveState(int slot, bool compat) {
- const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
-
char filename[256];
SaveFile *out;
SaveGameHeader hdr;
makeSavegameName(filename, slot, compat);
- if (!(out = mgr->open_savefile(filename, getSavePath(), true)))
+ if (!(out = _saveFileMan->open_savefile(filename, getSavePath(), true)))
return false;
memcpy(hdr.name, _saveLoadName, sizeof(hdr.name));
@@ -92,8 +88,6 @@ bool ScummEngine::saveState(int slot, bool compat) {
}
bool ScummEngine::loadState(int slot, bool compat) {
- const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
-
char filename[256];
SaveFile *in;
int i, j;
@@ -101,7 +95,7 @@ bool ScummEngine::loadState(int slot, bool compat) {
byte *roomptr;
makeSavegameName(filename, slot, compat);
- if (!(in = mgr->open_savefile(filename, getSavePath(), false)))
+ if (!(in = _saveFileMan->open_savefile(filename, getSavePath(), false)))
return false;
in->read(&hdr, sizeof(hdr));
@@ -300,21 +294,21 @@ void ScummEngine::makeSavegameName(char *out, int slot, bool compatible) {
sprintf(out, "%s.%c%.2d", _targetName.c_str(), compatible ? 'c' : 's', slot);
}
-void ScummEngine::listSavegames(bool *marks, int num, SaveFileManager *mgr) {
+void ScummEngine::listSavegames(bool *marks, int num) {
char prefix[256];
makeSavegameName(prefix, 99, false);
prefix[strlen(prefix)-2] = 0;
- mgr->list_savefiles(prefix, getSavePath(), marks, num);
+ _saveFileMan->list_savefiles(prefix, getSavePath(), marks, num);
}
-bool ScummEngine::getSavegameName(int slot, char *desc, SaveFileManager *mgr) {
+bool ScummEngine::getSavegameName(int slot, char *desc) {
char filename[256];
SaveFile *out;
SaveGameHeader hdr;
int len;
makeSavegameName(filename, slot, false);
- if (!(out = mgr->open_savefile(filename, getSavePath(), false))) {
+ if (!(out = _saveFileMan->open_savefile(filename, getSavePath(), false))) {
strcpy(desc, "");
return false;
}
diff --git a/scumm/script_v5.cpp b/scumm/script_v5.cpp
index a5d465d48a..19438b80bf 100644
--- a/scumm/script_v5.cpp
+++ b/scumm/script_v5.cpp
@@ -29,8 +29,6 @@
#include "scumm/sound.h"
#include "scumm/verbs.h"
-#include <memory>
-
namespace Scumm {
#define OPCODE(x) { &ScummEngine_v5::x, #x }
@@ -1174,11 +1172,10 @@ void ScummEngine_v5::o5_saveLoadGame() {
case 0xC0: // test if save exists
bool avail_saves[100];
char filename[256];
- const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
- listSavegames(avail_saves, ARRAYSIZE(avail_saves), mgr.get());
+ listSavegames(avail_saves, ARRAYSIZE(avail_saves));
makeSavegameName(filename, slot, false);
- if (avail_saves[slot] && (mgr->open_savefile(filename, getSavePath(), false)))
+ if (avail_saves[slot] && (_saveFileMan->open_savefile(filename, getSavePath(), false)))
result = 6; // save file exists
else
result = 7; // save file does not exist
@@ -1941,9 +1938,7 @@ void ScummEngine_v5::o5_roomOps() {
s = filename;
while ((*s++ = fetchScriptByte()));
- const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
-
- file = mgr->open_savefile(filename, getSavePath(), true);
+ file = _saveFileMan->open_savefile(filename, getSavePath(), true);
if (file != NULL) {
byte *ptr;
ptr = getResourceAddress(rtString, a);
@@ -1961,9 +1956,7 @@ void ScummEngine_v5::o5_roomOps() {
s = filename;
while ((*s++ = fetchScriptByte()));
- const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
-
- file = mgr->open_savefile(filename, getSavePath(), false);
+ file = _saveFileMan->open_savefile(filename, getSavePath(), false);
if (file != NULL) {
byte *ptr;
int len = 256, cnt = 0;
diff --git a/scumm/script_v8.cpp b/scumm/script_v8.cpp
index 94c26b920f..df452ba62d 100644
--- a/scumm/script_v8.cpp
+++ b/scumm/script_v8.cpp
@@ -34,8 +34,6 @@
#include "scumm/smush/smush_player.h"
#include "sound/mixer.h"
-#include <memory>
-
namespace Scumm {
#define OPCODE(x) { &ScummEngine_v8::x, #x }
@@ -1323,7 +1321,6 @@ void ScummEngine_v8::o8_kernelSetFunctions() {
warning("o8_kernelSetFunctions: clearTextQueue()");
break;
case 25: { // saveGameReadName
- const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
char *address = (char*)getStringAddress(args[2]);
char name[30];
@@ -1331,14 +1328,12 @@ void ScummEngine_v8::o8_kernelSetFunctions() {
warning("o8_kernelSetFunctions: saveGameReadName failed finding slot string %d", args[2]);
break;
}
- getSavegameName(args[1] - 1, name, mgr.get());
+ getSavegameName(args[1] - 1, name);
if (strlen(name) > 0 && strlen(name) < 30)
strcpy(address, name);
break;
}
case 26: { // saveGame?
- //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);
diff --git a/scumm/scumm.h b/scumm/scumm.h
index a2fb75e561..64947b95cd 100644
--- a/scumm/scumm.h
+++ b/scumm/scumm.h
@@ -518,8 +518,8 @@ protected:
int getKeyState(int key);
public:
- bool getSavegameName(int slot, char *desc, SaveFileManager *mgr);
- void listSavegames(bool *marks, int num, SaveFileManager *mgr);
+ bool getSavegameName(int slot, char *desc);
+ void listSavegames(bool *marks, int num);
void requestSave(int slot, const char *name, bool compatible = false);
void requestLoad(int slot);
diff --git a/simon/simon.cpp b/simon/simon.cpp
index 9d30c14b47..1ef3aa8c7e 100644
--- a/simon/simon.cpp
+++ b/simon/simon.cpp
@@ -42,8 +42,6 @@
#include <errno.h>
#include <time.h>
-#include <memory>
-
#ifdef __PALM_OS__
#include "globals.h"
#endif
@@ -2625,15 +2623,13 @@ int SimonEngine::count_savegames() {
uint i = 1;
bool marks[256];
- const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
-
char *prefix = gen_savename(999);
prefix[strlen(prefix)-3] = '\0';
- mgr->list_savefiles(prefix, getSavePath(), marks, 256);
+ _saveFileMan->list_savefiles(prefix, getSavePath(), marks, 256);
while (i < 256) {
if (marks[i] &&
- (f = mgr->open_savefile(gen_savename(i), getSavePath(),
+ (f = _saveFileMan->open_savefile(gen_savename(i), getSavePath(),
false))) {
i++;
delete f;
@@ -2653,11 +2649,8 @@ int SimonEngine::display_savegame_list(int curpos, bool load, char *dst) {
slot = curpos;
- const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
-
-
while (curpos + 6 > slot) {
- if(!(in = mgr->open_savefile(gen_savename(slot), getSavePath(), false)))
+ if(!(in = _saveFileMan->open_savefile(gen_savename(slot), getSavePath(), false)))
break;
in->read(dst, 18);
@@ -2681,7 +2674,7 @@ int SimonEngine::display_savegame_list(int curpos, bool load, char *dst) {
}
} else {
if (curpos + 6 == slot) {
- if((in = mgr->open_savefile(gen_savename(slot), getSavePath(), false))) {
+ if((in = _saveFileMan->open_savefile(gen_savename(slot), getSavePath(), false))) {
slot++;
delete in;
}
@@ -4807,10 +4800,8 @@ bool SimonEngine::save_game(uint slot, char *caption) {
errno = 0;
#endif
- const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
-
- f = mgr->open_savefile(gen_savename(slot), getSavePath(), true);
+ f = _saveFileMan->open_savefile(gen_savename(slot), getSavePath(), true);
if (f == NULL) {
_lock_word &= ~0x100;
return false;
@@ -4910,10 +4901,8 @@ bool SimonEngine::load_game(uint slot) {
errno = 0;
#endif
- const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
-
- f = mgr->open_savefile(gen_savename(slot), getSavePath(), false);
+ f = _saveFileMan->open_savefile(gen_savename(slot), getSavePath(), false);
if (f == NULL) {
_lock_word &= ~0x100;
return false;
diff --git a/sky/control.cpp b/sky/control.cpp
index 6f43b3f0ea..5e30a68b3c 100644
--- a/sky/control.cpp
+++ b/sky/control.cpp
@@ -35,8 +35,6 @@
#include "sky/struc.h"
#include "sky/text.h"
-#include <memory>
-
namespace Sky {
ConResource::ConResource(void *pSpData, uint32 pNSprites, uint32 pCurSprite, uint16 pX, uint16 pY, uint32 pText, uint8 pOnClick, OSystem *system, uint8 *screen) {
@@ -191,7 +189,8 @@ void ControlStatus::drawToScreen(void) {
_statusText->drawToScreen(WITH_MASK);
}
-Control::Control(Screen *screen, Disk *disk, Mouse *mouse, Text *text, MusicBase *music, Logic *logic, Sound *sound, OSystem *system, const char *savePath) {
+Control::Control(SaveFileManager *saveFileMan, Screen *screen, Disk *disk, Mouse *mouse, Text *text, MusicBase *music, Logic *logic, Sound *sound, OSystem *system, const char *savePath) {
+ _saveFileMan = saveFileMan;
_skyScreen = screen;
_skyDisk = disk;
@@ -784,9 +783,8 @@ bool Control::autoSaveExists(void) {
strcpy(fName, "SKY-VM-CD.ASD");
else
sprintf(fName, "SKY-VM%03d.ASD", SkyEngine::_systemVars.gameVersion);
- const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
- f = mgr->open_savefile(fName, _savePath, false);
+ f = _saveFileMan->open_savefile(fName, _savePath, false);
if (f != NULL) {
test = true;
delete f;
@@ -1004,10 +1002,8 @@ void Control::loadDescriptions(uint8 *destBuf) {
memset(destBuf, 0, MAX_SAVE_GAMES * MAX_TEXT_LEN);
- const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
-
SaveFile *inf;
- inf = mgr->open_savefile("SKY-VM.SAV",_savePath,false);
+ inf = _saveFileMan->open_savefile("SKY-VM.SAV",_savePath,false);
if (inf != NULL) {
uint8 *tmpBuf = (uint8 *)malloc(MAX_SAVE_GAMES * MAX_TEXT_LEN);
inf->read(tmpBuf, MAX_SAVE_GAMES * MAX_TEXT_LEN);
@@ -1065,9 +1061,8 @@ void Control::saveDescriptions(uint8 *srcBuf) {
srcPos += MAX_TEXT_LEN;
}
SaveFile *outf;
- const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
- outf = mgr->open_savefile("SKY-VM.SAV", _savePath, true);
+ outf = _saveFileMan->open_savefile("SKY-VM.SAV", _savePath, true);
if (outf != NULL) {
outf->write(tmpBuf, tmpPos - tmpBuf);
delete outf;
@@ -1082,9 +1077,8 @@ void Control::doAutoSave(void) {
else
sprintf(fName, "SKY-VM%03d.ASD", SkyEngine::_systemVars.gameVersion);
SaveFile *outf;
- const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
- outf = mgr->open_savefile(fName, _savePath, true);
+ outf = _saveFileMan->open_savefile(fName, _savePath, true);
if (outf == NULL) {
warning("Can't create file %s for autosaving", fName);
return;
@@ -1102,10 +1096,9 @@ uint16 Control::saveGameToFile(void) {
char fName[20];
sprintf(fName,"SKY-VM.%03d", _selectedGame);
- const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
SaveFile *outf;
- outf = mgr->open_savefile(fName, _savePath, true);
+ outf = _saveFileMan->open_savefile(fName, _savePath, true);
if (outf == NULL) {
return NO_DISK_SPACE;
}
@@ -1507,10 +1500,8 @@ uint16 Control::restoreGameFromFile(bool autoSave) {
} else
sprintf(fName,"SKY-VM.%03d", _selectedGame);
- const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
-
SaveFile *inf;
- inf = mgr->open_savefile(fName, _savePath, false);
+ inf = _saveFileMan->open_savefile(fName, _savePath, false);
if (inf == NULL) {
return RESTORE_FAILED;
}
diff --git a/sky/control.h b/sky/control.h
index c670c4f5cf..8a29df20e7 100644
--- a/sky/control.h
+++ b/sky/control.h
@@ -26,6 +26,7 @@
#include "common/scummsys.h"
class OSystem;
+class SaveFileManager;
namespace Sky {
@@ -174,7 +175,7 @@ private:
class Control {
public:
- Control(Screen *screen, Disk *disk, Mouse *mouse, Text *text, MusicBase *music, Logic *logic, Sound *sound, OSystem *system, const char *savePath);
+ Control(SaveFileManager *saveFileMan, Screen *screen, Disk *disk, Mouse *mouse, Text *text, MusicBase *music, Logic *logic, Sound *sound, OSystem *system, const char *savePath);
void doControlPanel(void);
void doLoadSavePanel(void);
void restartGame(void);
@@ -242,6 +243,7 @@ private:
void appendMemList(uint16 *pMem);
void freeMemList(void);
+ SaveFileManager *_saveFileMan;
Screen *_skyScreen;
Disk *_skyDisk;
Mouse *_skyMouse;
diff --git a/sky/sky.cpp b/sky/sky.cpp
index f149e4988c..2bd538d79f 100644
--- a/sky/sky.cpp
+++ b/sky/sky.cpp
@@ -296,7 +296,7 @@ void SkyEngine::initialise(void) {
// initialize timer *after* _skyScreen has been initialized.
_timer->installTimerProc(&timerHandler, 1000000 / 50, this); //call 50 times per second
- _skyControl = new Control(_skyScreen, _skyDisk, _skyMouse, _skyText, _skyMusic, _skyLogic, _skySound, _system, getSavePath());
+ _skyControl = new Control(_saveFileMan, _skyScreen, _skyDisk, _skyMouse, _skyText, _skyMusic, _skyLogic, _skySound, _system, getSavePath());
_skyLogic->useControlInstance(_skyControl);
if (_systemVars.gameVersion == 288)
diff --git a/sword1/control.cpp b/sword1/control.cpp
index da8db4bffe..0c44945102 100644
--- a/sword1/control.cpp
+++ b/sword1/control.cpp
@@ -37,8 +37,6 @@
#include "sword1/sworddefs.h"
#include "sword1/swordres.h"
-#include <memory>
-
namespace Sword1 {
#define SAVEFILE_WRITE true
@@ -158,7 +156,8 @@ void ControlButton::setSelected(uint8 selected) {
draw();
}
-Control::Control(ResMan *pResMan, ObjectMan *pObjMan, OSystem *system, Mouse *pMouse, Sound *pSound, Music *pMusic, const char *savePath) {
+Control::Control(SaveFileManager *saveFileMan, ResMan *pResMan, ObjectMan *pObjMan, OSystem *system, Mouse *pMouse, Sound *pSound, Music *pMusic, const char *savePath) {
+ _saveFileMan = saveFileMan;
_resMan = pResMan;
_objMan = pObjMan;
_system = system;
@@ -667,10 +666,8 @@ bool Control::restoreFromFile(void) {
}
void Control::readSavegameDescriptions(void) {
- const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
-
SaveFile *inf;
- inf = mgr->open_savefile("SAVEGAME.INF", _savePath, SAVEFILE_READ);
+ inf = _saveFileMan->open_savefile("SAVEGAME.INF", _savePath, SAVEFILE_READ);
_saveScrollPos = _saveFiles = 0;
_selectedSavegame = 255;
if (inf && inf->isOpen()) {
@@ -714,10 +711,8 @@ int Control::displayMessage(const char *altButton, const char *message, ...) {
}
void Control::writeSavegameDescriptions(void) {
- const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
-
SaveFile *outf;
- outf = mgr->open_savefile("SAVEGAME.INF", _savePath, SAVEFILE_WRITE);
+ outf = _saveFileMan->open_savefile("SAVEGAME.INF", _savePath, SAVEFILE_WRITE);
if (!outf) {
// Display an error message, and do nothing
@@ -741,10 +736,8 @@ void Control::writeSavegameDescriptions(void) {
bool Control::savegamesExist(void) {
bool retVal = false;
- const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
-
SaveFile *inf;
- inf = mgr->open_savefile("SAVEGAME.INF", _savePath, SAVEFILE_READ);
+ inf = _saveFileMan->open_savefile("SAVEGAME.INF", _savePath, SAVEFILE_READ);
if (inf && inf->isOpen())
retVal = true;
delete inf;
@@ -900,10 +893,8 @@ void Control::saveGameToFile(uint8 slot) {
uint16 cnt;
sprintf(fName, "SAVEGAME.%03d", slot);
uint16 liveBuf[TOTAL_SECTIONS];
- const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
-
SaveFile *outf;
- outf = mgr->open_savefile(fName, _savePath, SAVEFILE_WRITE);
+ outf = _saveFileMan->open_savefile(fName, _savePath, SAVEFILE_WRITE);
if (!outf || !outf->isOpen()) {
// Display an error message, and do nothing
displayMessage(0, "Unable to create file '%s' in directory '%s'", fName, _savePath);
@@ -935,10 +926,8 @@ bool Control::restoreGameFromFile(uint8 slot) {
char fName[15];
uint16 cnt;
sprintf(fName, "SAVEGAME.%03d", slot);
- const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
-
SaveFile *inf;
- inf = mgr->open_savefile(fName, _savePath, SAVEFILE_READ);
+ inf = _saveFileMan->open_savefile(fName, _savePath, SAVEFILE_READ);
if (!inf || !inf->isOpen()) {
// Display an error message, and do nothing
displayMessage(0, "Can't open file '%s' in directory '%s'", fName, _savePath);
diff --git a/sword1/control.h b/sword1/control.h
index 0c111cd469..a020f477f6 100644
--- a/sword1/control.h
+++ b/sword1/control.h
@@ -26,6 +26,7 @@
#include "sworddefs.h"
class OSystem;
+class SaveFileManager;
namespace Sword1 {
@@ -67,7 +68,7 @@ struct ButtonInfo {
class Control {
public:
- Control(ResMan *pResMan, ObjectMan *pObjMan, OSystem *system, Mouse *pMouse, Sound *pSound, Music *pMusic, const char *savePath);
+ Control(SaveFileManager *saveFileMan, ResMan *pResMan, ObjectMan *pObjMan, OSystem *system, Mouse *pMouse, Sound *pSound, Music *pMusic, const char *savePath);
~Control(void);
uint8 runPanel(void);
void doRestore(void);
@@ -119,6 +120,7 @@ private:
static const ButtonInfo _deathButtons[3], _panelButtons[7], _saveButtons[16], _volumeButtons[4];
static const uint8 _languageStrings[8 * 20][43];
const uint8 (*_lStrings)[43];
+ SaveFileManager *_saveFileMan;
ObjectMan *_objMan;
ResMan *_resMan;
OSystem *_system;
diff --git a/sword1/sword1.cpp b/sword1/sword1.cpp
index ac5b8d95f8..8fceede44f 100644
--- a/sword1/sword1.cpp
+++ b/sword1/sword1.cpp
@@ -161,7 +161,7 @@ void SwordEngine::initialize(void) {
_logic->initialize();
_objectMan->initialize();
_mouse->initialize();
- _control = new Control(_resMan, _objectMan, _system, _mouse, _sound, _music, getSavePath());
+ _control = new Control(_saveFileMan, _resMan, _objectMan, _system, _mouse, _sound, _music, getSavePath());
}
void SwordEngine::reinitialize(void) {
diff --git a/sword2/save_rest.cpp b/sword2/save_rest.cpp
index a3ecbc22a2..a12d498c43 100644
--- a/sword2/save_rest.cpp
+++ b/sword2/save_rest.cpp
@@ -33,8 +33,6 @@
#include "sword2/logic.h"
#include "sword2/resman.h"
-#include <memory>
-
namespace Sword2 {
// A savegame consists of a header and the global variables
@@ -165,11 +163,9 @@ uint32 Sword2Engine::saveData(uint16 slotNo, byte *buffer, uint32 bufferSize) {
sprintf(saveFileName, "%s.%.3d", _targetName, slotNo);
- const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
-
SaveFile *out;
- if (!(out = mgr->open_savefile(saveFileName, getSavePath(), true))) {
+ if (!(out = _saveFileMan->open_savefile(saveFileName, getSavePath(), true))) {
return SR_ERR_FILEOPEN;
}
@@ -214,11 +210,9 @@ uint32 Sword2Engine::restoreData(uint16 slotNo, byte *buffer, uint32 bufferSize)
sprintf(saveFileName, "%s.%.3d", _targetName, slotNo);
- const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
-
SaveFile *in;
- if (!(in = mgr->open_savefile(saveFileName, getSavePath(), false))) {
+ if (!(in = _saveFileMan->open_savefile(saveFileName, getSavePath(), false))) {
// error: couldn't open file
return SR_ERR_FILEOPEN;
}
@@ -361,11 +355,9 @@ uint32 Sword2Engine::getSaveDescription(uint16 slotNo, byte *description) {
sprintf(saveFileName, "%s.%.3d", _targetName, slotNo);
- const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
-
SaveFile *in;
- if (!(in = mgr->open_savefile(saveFileName, getSavePath(), false))) {
+ if (!(in = _saveFileMan->open_savefile(saveFileName, getSavePath(), false))) {
return SR_ERR_FILEOPEN;
}
@@ -390,11 +382,9 @@ bool Sword2Engine::saveExists(uint16 slotNo) {
sprintf(saveFileName, "%s.%.3d", _targetName, slotNo);
- const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
-
SaveFile *in;
- if (!(in = mgr->open_savefile(saveFileName, getSavePath(), false))) {
+ if (!(in = _saveFileMan->open_savefile(saveFileName, getSavePath(), false))) {
return false;
}