diff options
Diffstat (limited to 'sword1')
-rw-r--r-- | sword1/control.cpp | 25 | ||||
-rw-r--r-- | sword1/control.h | 4 | ||||
-rw-r--r-- | sword1/sword1.cpp | 2 |
3 files changed, 11 insertions, 20 deletions
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) { |