Added Engine::_saveFileMan; thus was able to get rid of auto_ptr usage again
svn-id: r14058
This commit is contained in:
parent
7a8d469c66
commit
6b722ff11b
17 changed files with 52 additions and 110 deletions
|
@ -45,11 +45,14 @@ Engine::Engine(OSystem *syst)
|
||||||
File::setDefaultDirectory(_gameDataPath);
|
File::setDefaultDirectory(_gameDataPath);
|
||||||
|
|
||||||
g_debugLevel = ConfMan.getInt("debuglevel");
|
g_debugLevel = ConfMan.getInt("debuglevel");
|
||||||
|
|
||||||
|
_saveFileMan = _system->get_savefile_manager();
|
||||||
}
|
}
|
||||||
|
|
||||||
Engine::~Engine() {
|
Engine::~Engine() {
|
||||||
delete _mixer;
|
delete _mixer;
|
||||||
delete _timer;
|
delete _timer;
|
||||||
|
delete _saveFileMan;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *Engine::getSavePath() const {
|
const char *Engine::getSavePath() const {
|
||||||
|
|
|
@ -36,6 +36,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const Common::String _gameDataPath;
|
const Common::String _gameDataPath;
|
||||||
|
SaveFileManager *_saveFileMan;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Engine(OSystem *syst);
|
Engine(OSystem *syst);
|
||||||
|
|
|
@ -114,7 +114,6 @@ QueenEngine::~QueenEngine() {
|
||||||
delete _music;
|
delete _music;
|
||||||
delete _sound;
|
delete _sound;
|
||||||
delete _walk;
|
delete _walk;
|
||||||
delete _saveFileMan;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QueenEngine::registerDefaultSettings() {
|
void QueenEngine::registerDefaultSettings() {
|
||||||
|
@ -358,7 +357,6 @@ void QueenEngine::initialise(void) {
|
||||||
|
|
||||||
_sound = Sound::giveSound(_mixer, this, _resource->compression());
|
_sound = Sound::giveSound(_mixer, this, _resource->compression());
|
||||||
_walk = new Walk(this);
|
_walk = new Walk(this);
|
||||||
_saveFileMan = _system->get_savefile_manager();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // End of namespace Queen
|
} // End of namespace Queen
|
||||||
|
|
|
@ -135,7 +135,6 @@ protected:
|
||||||
Resource *_resource;
|
Resource *_resource;
|
||||||
Sound *_sound;
|
Sound *_sound;
|
||||||
Walk *_walk;
|
Walk *_walk;
|
||||||
SaveFileManager *_saveFileMan;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End of namespace Queen
|
} // End of namespace Queen
|
||||||
|
|
|
@ -44,8 +44,6 @@
|
||||||
#include "backends/wince/CEKeysDialog.h"
|
#include "backends/wince/CEKeysDialog.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
using GUI::CommandSender;
|
using GUI::CommandSender;
|
||||||
using GUI::StaticTextWidget;
|
using GUI::StaticTextWidget;
|
||||||
using GUI::kButtonWidth;
|
using GUI::kButtonWidth;
|
||||||
|
@ -257,12 +255,10 @@ Common::StringList generateSavegameList(ScummEngine *scumm, bool saveMode) {
|
||||||
uint i = saveMode ? 1 : 0;
|
uint i = saveMode ? 1 : 0;
|
||||||
bool avail_saves[81];
|
bool avail_saves[81];
|
||||||
|
|
||||||
const std::auto_ptr<SaveFileManager> mgr(OSystem::instance()->get_savefile_manager());
|
scumm->listSavegames(avail_saves, ARRAYSIZE(avail_saves));
|
||||||
|
|
||||||
scumm->listSavegames(avail_saves, ARRAYSIZE(avail_saves), mgr.get());
|
|
||||||
for (; i < ARRAYSIZE(avail_saves); i++) {
|
for (; i < ARRAYSIZE(avail_saves); i++) {
|
||||||
if (avail_saves[i])
|
if (avail_saves[i])
|
||||||
scumm->getSavegameName(i, name, mgr.get());
|
scumm->getSavegameName(i, name);
|
||||||
else
|
else
|
||||||
name[0] = 0;
|
name[0] = 0;
|
||||||
l.push_back(name);
|
l.push_back(name);
|
||||||
|
|
|
@ -38,8 +38,6 @@
|
||||||
#include "sound/audiocd.h"
|
#include "sound/audiocd.h"
|
||||||
#include "sound/mixer.h"
|
#include "sound/mixer.h"
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
namespace Scumm {
|
namespace Scumm {
|
||||||
|
|
||||||
struct SaveGameHeader {
|
struct SaveGameHeader {
|
||||||
|
@ -65,15 +63,13 @@ void ScummEngine::requestLoad(int slot) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScummEngine::saveState(int slot, bool compat) {
|
bool ScummEngine::saveState(int slot, bool compat) {
|
||||||
const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
|
|
||||||
|
|
||||||
char filename[256];
|
char filename[256];
|
||||||
SaveFile *out;
|
SaveFile *out;
|
||||||
SaveGameHeader hdr;
|
SaveGameHeader hdr;
|
||||||
|
|
||||||
makeSavegameName(filename, slot, compat);
|
makeSavegameName(filename, slot, compat);
|
||||||
|
|
||||||
if (!(out = mgr->open_savefile(filename, getSavePath(), true)))
|
if (!(out = _saveFileMan->open_savefile(filename, getSavePath(), true)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
memcpy(hdr.name, _saveLoadName, sizeof(hdr.name));
|
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) {
|
bool ScummEngine::loadState(int slot, bool compat) {
|
||||||
const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
|
|
||||||
|
|
||||||
char filename[256];
|
char filename[256];
|
||||||
SaveFile *in;
|
SaveFile *in;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
@ -101,7 +95,7 @@ bool ScummEngine::loadState(int slot, bool compat) {
|
||||||
byte *roomptr;
|
byte *roomptr;
|
||||||
|
|
||||||
makeSavegameName(filename, slot, compat);
|
makeSavegameName(filename, slot, compat);
|
||||||
if (!(in = mgr->open_savefile(filename, getSavePath(), false)))
|
if (!(in = _saveFileMan->open_savefile(filename, getSavePath(), false)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
in->read(&hdr, sizeof(hdr));
|
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);
|
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];
|
char prefix[256];
|
||||||
makeSavegameName(prefix, 99, false);
|
makeSavegameName(prefix, 99, false);
|
||||||
prefix[strlen(prefix)-2] = 0;
|
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];
|
char filename[256];
|
||||||
SaveFile *out;
|
SaveFile *out;
|
||||||
SaveGameHeader hdr;
|
SaveGameHeader hdr;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
makeSavegameName(filename, slot, false);
|
makeSavegameName(filename, slot, false);
|
||||||
if (!(out = mgr->open_savefile(filename, getSavePath(), false))) {
|
if (!(out = _saveFileMan->open_savefile(filename, getSavePath(), false))) {
|
||||||
strcpy(desc, "");
|
strcpy(desc, "");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,6 @@
|
||||||
#include "scumm/sound.h"
|
#include "scumm/sound.h"
|
||||||
#include "scumm/verbs.h"
|
#include "scumm/verbs.h"
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
namespace Scumm {
|
namespace Scumm {
|
||||||
|
|
||||||
#define OPCODE(x) { &ScummEngine_v5::x, #x }
|
#define OPCODE(x) { &ScummEngine_v5::x, #x }
|
||||||
|
@ -1174,11 +1172,10 @@ void ScummEngine_v5::o5_saveLoadGame() {
|
||||||
case 0xC0: // test if save exists
|
case 0xC0: // test if save exists
|
||||||
bool avail_saves[100];
|
bool avail_saves[100];
|
||||||
char filename[256];
|
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);
|
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
|
result = 6; // save file exists
|
||||||
else
|
else
|
||||||
result = 7; // save file does not exist
|
result = 7; // save file does not exist
|
||||||
|
@ -1941,9 +1938,7 @@ void ScummEngine_v5::o5_roomOps() {
|
||||||
s = filename;
|
s = filename;
|
||||||
while ((*s++ = fetchScriptByte()));
|
while ((*s++ = fetchScriptByte()));
|
||||||
|
|
||||||
const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
|
file = _saveFileMan->open_savefile(filename, getSavePath(), true);
|
||||||
|
|
||||||
file = mgr->open_savefile(filename, getSavePath(), true);
|
|
||||||
if (file != NULL) {
|
if (file != NULL) {
|
||||||
byte *ptr;
|
byte *ptr;
|
||||||
ptr = getResourceAddress(rtString, a);
|
ptr = getResourceAddress(rtString, a);
|
||||||
|
@ -1961,9 +1956,7 @@ void ScummEngine_v5::o5_roomOps() {
|
||||||
s = filename;
|
s = filename;
|
||||||
while ((*s++ = fetchScriptByte()));
|
while ((*s++ = fetchScriptByte()));
|
||||||
|
|
||||||
const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
|
file = _saveFileMan->open_savefile(filename, getSavePath(), false);
|
||||||
|
|
||||||
file = mgr->open_savefile(filename, getSavePath(), false);
|
|
||||||
if (file != NULL) {
|
if (file != NULL) {
|
||||||
byte *ptr;
|
byte *ptr;
|
||||||
int len = 256, cnt = 0;
|
int len = 256, cnt = 0;
|
||||||
|
|
|
@ -34,8 +34,6 @@
|
||||||
#include "scumm/smush/smush_player.h"
|
#include "scumm/smush/smush_player.h"
|
||||||
#include "sound/mixer.h"
|
#include "sound/mixer.h"
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
namespace Scumm {
|
namespace Scumm {
|
||||||
|
|
||||||
#define OPCODE(x) { &ScummEngine_v8::x, #x }
|
#define OPCODE(x) { &ScummEngine_v8::x, #x }
|
||||||
|
@ -1323,7 +1321,6 @@ void ScummEngine_v8::o8_kernelSetFunctions() {
|
||||||
warning("o8_kernelSetFunctions: clearTextQueue()");
|
warning("o8_kernelSetFunctions: clearTextQueue()");
|
||||||
break;
|
break;
|
||||||
case 25: { // saveGameReadName
|
case 25: { // saveGameReadName
|
||||||
const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
|
|
||||||
char *address = (char*)getStringAddress(args[2]);
|
char *address = (char*)getStringAddress(args[2]);
|
||||||
char name[30];
|
char name[30];
|
||||||
|
|
||||||
|
@ -1331,14 +1328,12 @@ void ScummEngine_v8::o8_kernelSetFunctions() {
|
||||||
warning("o8_kernelSetFunctions: saveGameReadName failed finding slot string %d", args[2]);
|
warning("o8_kernelSetFunctions: saveGameReadName failed finding slot string %d", args[2]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
getSavegameName(args[1] - 1, name, mgr.get());
|
getSavegameName(args[1] - 1, name);
|
||||||
if (strlen(name) > 0 && strlen(name) < 30)
|
if (strlen(name) > 0 && strlen(name) < 30)
|
||||||
strcpy(address, name);
|
strcpy(address, name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 26: { // saveGame?
|
case 26: { // saveGame?
|
||||||
//const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
|
|
||||||
|
|
||||||
//char *address = (char*)getStringAddress(args[2]);
|
//char *address = (char*)getStringAddress(args[2]);
|
||||||
char address[30];
|
char address[30];
|
||||||
warning("o8_kernelSetFunctions: saveGame?(%d, %s)", args[1], address);
|
warning("o8_kernelSetFunctions: saveGame?(%d, %s)", args[1], address);
|
||||||
|
|
|
@ -518,8 +518,8 @@ protected:
|
||||||
int getKeyState(int key);
|
int getKeyState(int key);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool getSavegameName(int slot, char *desc, SaveFileManager *mgr);
|
bool getSavegameName(int slot, char *desc);
|
||||||
void listSavegames(bool *marks, int num, SaveFileManager *mgr);
|
void listSavegames(bool *marks, int num);
|
||||||
|
|
||||||
void requestSave(int slot, const char *name, bool compatible = false);
|
void requestSave(int slot, const char *name, bool compatible = false);
|
||||||
void requestLoad(int slot);
|
void requestLoad(int slot);
|
||||||
|
|
|
@ -42,8 +42,6 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#ifdef __PALM_OS__
|
#ifdef __PALM_OS__
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -2625,15 +2623,13 @@ int SimonEngine::count_savegames() {
|
||||||
uint i = 1;
|
uint i = 1;
|
||||||
bool marks[256];
|
bool marks[256];
|
||||||
|
|
||||||
const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
|
|
||||||
|
|
||||||
char *prefix = gen_savename(999);
|
char *prefix = gen_savename(999);
|
||||||
prefix[strlen(prefix)-3] = '\0';
|
prefix[strlen(prefix)-3] = '\0';
|
||||||
mgr->list_savefiles(prefix, getSavePath(), marks, 256);
|
_saveFileMan->list_savefiles(prefix, getSavePath(), marks, 256);
|
||||||
|
|
||||||
while (i < 256) {
|
while (i < 256) {
|
||||||
if (marks[i] &&
|
if (marks[i] &&
|
||||||
(f = mgr->open_savefile(gen_savename(i), getSavePath(),
|
(f = _saveFileMan->open_savefile(gen_savename(i), getSavePath(),
|
||||||
false))) {
|
false))) {
|
||||||
i++;
|
i++;
|
||||||
delete f;
|
delete f;
|
||||||
|
@ -2653,11 +2649,8 @@ int SimonEngine::display_savegame_list(int curpos, bool load, char *dst) {
|
||||||
|
|
||||||
slot = curpos;
|
slot = curpos;
|
||||||
|
|
||||||
const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
|
|
||||||
|
|
||||||
|
|
||||||
while (curpos + 6 > slot) {
|
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;
|
break;
|
||||||
|
|
||||||
in->read(dst, 18);
|
in->read(dst, 18);
|
||||||
|
@ -2681,7 +2674,7 @@ int SimonEngine::display_savegame_list(int curpos, bool load, char *dst) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (curpos + 6 == slot) {
|
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++;
|
slot++;
|
||||||
delete in;
|
delete in;
|
||||||
}
|
}
|
||||||
|
@ -4807,10 +4800,8 @@ bool SimonEngine::save_game(uint slot, char *caption) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
|
|
||||||
|
|
||||||
|
f = _saveFileMan->open_savefile(gen_savename(slot), getSavePath(), true);
|
||||||
f = mgr->open_savefile(gen_savename(slot), getSavePath(), true);
|
|
||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
_lock_word &= ~0x100;
|
_lock_word &= ~0x100;
|
||||||
return false;
|
return false;
|
||||||
|
@ -4910,10 +4901,8 @@ bool SimonEngine::load_game(uint slot) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
|
|
||||||
|
|
||||||
|
f = _saveFileMan->open_savefile(gen_savename(slot), getSavePath(), false);
|
||||||
f = mgr->open_savefile(gen_savename(slot), getSavePath(), false);
|
|
||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
_lock_word &= ~0x100;
|
_lock_word &= ~0x100;
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -35,8 +35,6 @@
|
||||||
#include "sky/struc.h"
|
#include "sky/struc.h"
|
||||||
#include "sky/text.h"
|
#include "sky/text.h"
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
namespace Sky {
|
namespace Sky {
|
||||||
|
|
||||||
ConResource::ConResource(void *pSpData, uint32 pNSprites, uint32 pCurSprite, uint16 pX, uint16 pY, uint32 pText, uint8 pOnClick, OSystem *system, uint8 *screen) {
|
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);
|
_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;
|
_skyScreen = screen;
|
||||||
_skyDisk = disk;
|
_skyDisk = disk;
|
||||||
|
@ -784,9 +783,8 @@ bool Control::autoSaveExists(void) {
|
||||||
strcpy(fName, "SKY-VM-CD.ASD");
|
strcpy(fName, "SKY-VM-CD.ASD");
|
||||||
else
|
else
|
||||||
sprintf(fName, "SKY-VM%03d.ASD", SkyEngine::_systemVars.gameVersion);
|
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) {
|
if (f != NULL) {
|
||||||
test = true;
|
test = true;
|
||||||
delete f;
|
delete f;
|
||||||
|
@ -1004,10 +1002,8 @@ void Control::loadDescriptions(uint8 *destBuf) {
|
||||||
|
|
||||||
memset(destBuf, 0, MAX_SAVE_GAMES * MAX_TEXT_LEN);
|
memset(destBuf, 0, MAX_SAVE_GAMES * MAX_TEXT_LEN);
|
||||||
|
|
||||||
const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
|
|
||||||
|
|
||||||
SaveFile *inf;
|
SaveFile *inf;
|
||||||
inf = mgr->open_savefile("SKY-VM.SAV",_savePath,false);
|
inf = _saveFileMan->open_savefile("SKY-VM.SAV",_savePath,false);
|
||||||
if (inf != NULL) {
|
if (inf != NULL) {
|
||||||
uint8 *tmpBuf = (uint8 *)malloc(MAX_SAVE_GAMES * MAX_TEXT_LEN);
|
uint8 *tmpBuf = (uint8 *)malloc(MAX_SAVE_GAMES * MAX_TEXT_LEN);
|
||||||
inf->read(tmpBuf, 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;
|
srcPos += MAX_TEXT_LEN;
|
||||||
}
|
}
|
||||||
SaveFile *outf;
|
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) {
|
if (outf != NULL) {
|
||||||
outf->write(tmpBuf, tmpPos - tmpBuf);
|
outf->write(tmpBuf, tmpPos - tmpBuf);
|
||||||
delete outf;
|
delete outf;
|
||||||
|
@ -1082,9 +1077,8 @@ void Control::doAutoSave(void) {
|
||||||
else
|
else
|
||||||
sprintf(fName, "SKY-VM%03d.ASD", SkyEngine::_systemVars.gameVersion);
|
sprintf(fName, "SKY-VM%03d.ASD", SkyEngine::_systemVars.gameVersion);
|
||||||
SaveFile *outf;
|
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) {
|
if (outf == NULL) {
|
||||||
warning("Can't create file %s for autosaving", fName);
|
warning("Can't create file %s for autosaving", fName);
|
||||||
return;
|
return;
|
||||||
|
@ -1102,10 +1096,9 @@ uint16 Control::saveGameToFile(void) {
|
||||||
|
|
||||||
char fName[20];
|
char fName[20];
|
||||||
sprintf(fName,"SKY-VM.%03d", _selectedGame);
|
sprintf(fName,"SKY-VM.%03d", _selectedGame);
|
||||||
const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
|
|
||||||
|
|
||||||
SaveFile *outf;
|
SaveFile *outf;
|
||||||
outf = mgr->open_savefile(fName, _savePath, true);
|
outf = _saveFileMan->open_savefile(fName, _savePath, true);
|
||||||
if (outf == NULL) {
|
if (outf == NULL) {
|
||||||
return NO_DISK_SPACE;
|
return NO_DISK_SPACE;
|
||||||
}
|
}
|
||||||
|
@ -1507,10 +1500,8 @@ uint16 Control::restoreGameFromFile(bool autoSave) {
|
||||||
} else
|
} else
|
||||||
sprintf(fName,"SKY-VM.%03d", _selectedGame);
|
sprintf(fName,"SKY-VM.%03d", _selectedGame);
|
||||||
|
|
||||||
const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
|
|
||||||
|
|
||||||
SaveFile *inf;
|
SaveFile *inf;
|
||||||
inf = mgr->open_savefile(fName, _savePath, false);
|
inf = _saveFileMan->open_savefile(fName, _savePath, false);
|
||||||
if (inf == NULL) {
|
if (inf == NULL) {
|
||||||
return RESTORE_FAILED;
|
return RESTORE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "common/scummsys.h"
|
#include "common/scummsys.h"
|
||||||
|
|
||||||
class OSystem;
|
class OSystem;
|
||||||
|
class SaveFileManager;
|
||||||
|
|
||||||
namespace Sky {
|
namespace Sky {
|
||||||
|
|
||||||
|
@ -174,7 +175,7 @@ private:
|
||||||
|
|
||||||
class Control {
|
class Control {
|
||||||
public:
|
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 doControlPanel(void);
|
||||||
void doLoadSavePanel(void);
|
void doLoadSavePanel(void);
|
||||||
void restartGame(void);
|
void restartGame(void);
|
||||||
|
@ -242,6 +243,7 @@ private:
|
||||||
void appendMemList(uint16 *pMem);
|
void appendMemList(uint16 *pMem);
|
||||||
void freeMemList(void);
|
void freeMemList(void);
|
||||||
|
|
||||||
|
SaveFileManager *_saveFileMan;
|
||||||
Screen *_skyScreen;
|
Screen *_skyScreen;
|
||||||
Disk *_skyDisk;
|
Disk *_skyDisk;
|
||||||
Mouse *_skyMouse;
|
Mouse *_skyMouse;
|
||||||
|
|
|
@ -296,7 +296,7 @@ void SkyEngine::initialise(void) {
|
||||||
// initialize timer *after* _skyScreen has been initialized.
|
// initialize timer *after* _skyScreen has been initialized.
|
||||||
_timer->installTimerProc(&timerHandler, 1000000 / 50, this); //call 50 times per second
|
_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);
|
_skyLogic->useControlInstance(_skyControl);
|
||||||
|
|
||||||
if (_systemVars.gameVersion == 288)
|
if (_systemVars.gameVersion == 288)
|
||||||
|
|
|
@ -37,8 +37,6 @@
|
||||||
#include "sword1/sworddefs.h"
|
#include "sword1/sworddefs.h"
|
||||||
#include "sword1/swordres.h"
|
#include "sword1/swordres.h"
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
namespace Sword1 {
|
namespace Sword1 {
|
||||||
|
|
||||||
#define SAVEFILE_WRITE true
|
#define SAVEFILE_WRITE true
|
||||||
|
@ -158,7 +156,8 @@ void ControlButton::setSelected(uint8 selected) {
|
||||||
draw();
|
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;
|
_resMan = pResMan;
|
||||||
_objMan = pObjMan;
|
_objMan = pObjMan;
|
||||||
_system = system;
|
_system = system;
|
||||||
|
@ -667,10 +666,8 @@ bool Control::restoreFromFile(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Control::readSavegameDescriptions(void) {
|
void Control::readSavegameDescriptions(void) {
|
||||||
const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
|
|
||||||
|
|
||||||
SaveFile *inf;
|
SaveFile *inf;
|
||||||
inf = mgr->open_savefile("SAVEGAME.INF", _savePath, SAVEFILE_READ);
|
inf = _saveFileMan->open_savefile("SAVEGAME.INF", _savePath, SAVEFILE_READ);
|
||||||
_saveScrollPos = _saveFiles = 0;
|
_saveScrollPos = _saveFiles = 0;
|
||||||
_selectedSavegame = 255;
|
_selectedSavegame = 255;
|
||||||
if (inf && inf->isOpen()) {
|
if (inf && inf->isOpen()) {
|
||||||
|
@ -714,10 +711,8 @@ int Control::displayMessage(const char *altButton, const char *message, ...) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Control::writeSavegameDescriptions(void) {
|
void Control::writeSavegameDescriptions(void) {
|
||||||
const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
|
|
||||||
|
|
||||||
SaveFile *outf;
|
SaveFile *outf;
|
||||||
outf = mgr->open_savefile("SAVEGAME.INF", _savePath, SAVEFILE_WRITE);
|
outf = _saveFileMan->open_savefile("SAVEGAME.INF", _savePath, SAVEFILE_WRITE);
|
||||||
|
|
||||||
if (!outf) {
|
if (!outf) {
|
||||||
// Display an error message, and do nothing
|
// Display an error message, and do nothing
|
||||||
|
@ -741,10 +736,8 @@ void Control::writeSavegameDescriptions(void) {
|
||||||
|
|
||||||
bool Control::savegamesExist(void) {
|
bool Control::savegamesExist(void) {
|
||||||
bool retVal = false;
|
bool retVal = false;
|
||||||
const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
|
|
||||||
|
|
||||||
SaveFile *inf;
|
SaveFile *inf;
|
||||||
inf = mgr->open_savefile("SAVEGAME.INF", _savePath, SAVEFILE_READ);
|
inf = _saveFileMan->open_savefile("SAVEGAME.INF", _savePath, SAVEFILE_READ);
|
||||||
if (inf && inf->isOpen())
|
if (inf && inf->isOpen())
|
||||||
retVal = true;
|
retVal = true;
|
||||||
delete inf;
|
delete inf;
|
||||||
|
@ -900,10 +893,8 @@ void Control::saveGameToFile(uint8 slot) {
|
||||||
uint16 cnt;
|
uint16 cnt;
|
||||||
sprintf(fName, "SAVEGAME.%03d", slot);
|
sprintf(fName, "SAVEGAME.%03d", slot);
|
||||||
uint16 liveBuf[TOTAL_SECTIONS];
|
uint16 liveBuf[TOTAL_SECTIONS];
|
||||||
const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
|
|
||||||
|
|
||||||
SaveFile *outf;
|
SaveFile *outf;
|
||||||
outf = mgr->open_savefile(fName, _savePath, SAVEFILE_WRITE);
|
outf = _saveFileMan->open_savefile(fName, _savePath, SAVEFILE_WRITE);
|
||||||
if (!outf || !outf->isOpen()) {
|
if (!outf || !outf->isOpen()) {
|
||||||
// Display an error message, and do nothing
|
// Display an error message, and do nothing
|
||||||
displayMessage(0, "Unable to create file '%s' in directory '%s'", fName, _savePath);
|
displayMessage(0, "Unable to create file '%s' in directory '%s'", fName, _savePath);
|
||||||
|
@ -935,10 +926,8 @@ bool Control::restoreGameFromFile(uint8 slot) {
|
||||||
char fName[15];
|
char fName[15];
|
||||||
uint16 cnt;
|
uint16 cnt;
|
||||||
sprintf(fName, "SAVEGAME.%03d", slot);
|
sprintf(fName, "SAVEGAME.%03d", slot);
|
||||||
const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
|
|
||||||
|
|
||||||
SaveFile *inf;
|
SaveFile *inf;
|
||||||
inf = mgr->open_savefile(fName, _savePath, SAVEFILE_READ);
|
inf = _saveFileMan->open_savefile(fName, _savePath, SAVEFILE_READ);
|
||||||
if (!inf || !inf->isOpen()) {
|
if (!inf || !inf->isOpen()) {
|
||||||
// Display an error message, and do nothing
|
// Display an error message, and do nothing
|
||||||
displayMessage(0, "Can't open file '%s' in directory '%s'", fName, _savePath);
|
displayMessage(0, "Can't open file '%s' in directory '%s'", fName, _savePath);
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "sworddefs.h"
|
#include "sworddefs.h"
|
||||||
|
|
||||||
class OSystem;
|
class OSystem;
|
||||||
|
class SaveFileManager;
|
||||||
|
|
||||||
namespace Sword1 {
|
namespace Sword1 {
|
||||||
|
|
||||||
|
@ -67,7 +68,7 @@ struct ButtonInfo {
|
||||||
|
|
||||||
class Control {
|
class Control {
|
||||||
public:
|
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);
|
~Control(void);
|
||||||
uint8 runPanel(void);
|
uint8 runPanel(void);
|
||||||
void doRestore(void);
|
void doRestore(void);
|
||||||
|
@ -119,6 +120,7 @@ private:
|
||||||
static const ButtonInfo _deathButtons[3], _panelButtons[7], _saveButtons[16], _volumeButtons[4];
|
static const ButtonInfo _deathButtons[3], _panelButtons[7], _saveButtons[16], _volumeButtons[4];
|
||||||
static const uint8 _languageStrings[8 * 20][43];
|
static const uint8 _languageStrings[8 * 20][43];
|
||||||
const uint8 (*_lStrings)[43];
|
const uint8 (*_lStrings)[43];
|
||||||
|
SaveFileManager *_saveFileMan;
|
||||||
ObjectMan *_objMan;
|
ObjectMan *_objMan;
|
||||||
ResMan *_resMan;
|
ResMan *_resMan;
|
||||||
OSystem *_system;
|
OSystem *_system;
|
||||||
|
|
|
@ -161,7 +161,7 @@ void SwordEngine::initialize(void) {
|
||||||
_logic->initialize();
|
_logic->initialize();
|
||||||
_objectMan->initialize();
|
_objectMan->initialize();
|
||||||
_mouse->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) {
|
void SwordEngine::reinitialize(void) {
|
||||||
|
|
|
@ -33,8 +33,6 @@
|
||||||
#include "sword2/logic.h"
|
#include "sword2/logic.h"
|
||||||
#include "sword2/resman.h"
|
#include "sword2/resman.h"
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
namespace Sword2 {
|
namespace Sword2 {
|
||||||
|
|
||||||
// A savegame consists of a header and the global variables
|
// 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);
|
sprintf(saveFileName, "%s.%.3d", _targetName, slotNo);
|
||||||
|
|
||||||
const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
|
|
||||||
|
|
||||||
SaveFile *out;
|
SaveFile *out;
|
||||||
|
|
||||||
if (!(out = mgr->open_savefile(saveFileName, getSavePath(), true))) {
|
if (!(out = _saveFileMan->open_savefile(saveFileName, getSavePath(), true))) {
|
||||||
return SR_ERR_FILEOPEN;
|
return SR_ERR_FILEOPEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,11 +210,9 @@ uint32 Sword2Engine::restoreData(uint16 slotNo, byte *buffer, uint32 bufferSize)
|
||||||
|
|
||||||
sprintf(saveFileName, "%s.%.3d", _targetName, slotNo);
|
sprintf(saveFileName, "%s.%.3d", _targetName, slotNo);
|
||||||
|
|
||||||
const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
|
|
||||||
|
|
||||||
SaveFile *in;
|
SaveFile *in;
|
||||||
|
|
||||||
if (!(in = mgr->open_savefile(saveFileName, getSavePath(), false))) {
|
if (!(in = _saveFileMan->open_savefile(saveFileName, getSavePath(), false))) {
|
||||||
// error: couldn't open file
|
// error: couldn't open file
|
||||||
return SR_ERR_FILEOPEN;
|
return SR_ERR_FILEOPEN;
|
||||||
}
|
}
|
||||||
|
@ -361,11 +355,9 @@ uint32 Sword2Engine::getSaveDescription(uint16 slotNo, byte *description) {
|
||||||
|
|
||||||
sprintf(saveFileName, "%s.%.3d", _targetName, slotNo);
|
sprintf(saveFileName, "%s.%.3d", _targetName, slotNo);
|
||||||
|
|
||||||
const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
|
|
||||||
|
|
||||||
SaveFile *in;
|
SaveFile *in;
|
||||||
|
|
||||||
if (!(in = mgr->open_savefile(saveFileName, getSavePath(), false))) {
|
if (!(in = _saveFileMan->open_savefile(saveFileName, getSavePath(), false))) {
|
||||||
return SR_ERR_FILEOPEN;
|
return SR_ERR_FILEOPEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -390,11 +382,9 @@ bool Sword2Engine::saveExists(uint16 slotNo) {
|
||||||
|
|
||||||
sprintf(saveFileName, "%s.%.3d", _targetName, slotNo);
|
sprintf(saveFileName, "%s.%.3d", _targetName, slotNo);
|
||||||
|
|
||||||
const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
|
|
||||||
|
|
||||||
SaveFile *in;
|
SaveFile *in;
|
||||||
|
|
||||||
if (!(in = mgr->open_savefile(saveFileName, getSavePath(), false))) {
|
if (!(in = _saveFileMan->open_savefile(saveFileName, getSavePath(), false))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue