Moved Engine::getSavePath() to class SaveFileManager; removed the 'directory' parameter from SaveFileManager::openSavefile and listSavefiles (they always use getSavePath() now, which is what we did anyway)
svn-id: r15901
This commit is contained in:
parent
d56cd17183
commit
876e738dce
17 changed files with 101 additions and 106 deletions
|
@ -126,17 +126,17 @@ uint32 PalmSaveFile::write(const void *buf, uint32 size) {
|
|||
|
||||
class PalmSaveFileManager : public SaveFileManager {
|
||||
public:
|
||||
SaveFile *open_savefile(const char *filename, const char *directory, bool saveOrLoad);
|
||||
void list_savefiles(const char *prefix, const char *directory, bool *marks, int num);
|
||||
SaveFile *openSavefile(const char *filename, bool saveOrLoad);
|
||||
void listSavefiles(const char *prefix, bool *marks, int num);
|
||||
|
||||
protected:
|
||||
SaveFile *makeSaveFile(const char *filename, bool saveOrLoad);
|
||||
};
|
||||
|
||||
SaveFile *PalmSaveFileManager::open_savefile(const char *filename, const char *directory, bool saveOrLoad) {
|
||||
SaveFile *PalmSaveFileManager::openSavefile(const char *filename, bool saveOrLoad) {
|
||||
char buf[256];
|
||||
|
||||
strncpy(buf, directory, sizeof(buf));
|
||||
strncpy(buf, getSavePath(), sizeof(buf));
|
||||
strncat(buf, filename, sizeof(buf));
|
||||
|
||||
SaveFile *sf = makeSaveFile(buf, saveOrLoad);
|
||||
|
@ -148,10 +148,10 @@ SaveFile *PalmSaveFileManager::open_savefile(const char *filename, const char *d
|
|||
return sf;
|
||||
}
|
||||
|
||||
void PalmSaveFileManager::list_savefiles(const char *prefix, const char *directory, bool *marks, int num) {
|
||||
void PalmSaveFileManager::listSavefiles(const char *prefix, bool *marks, int num) {
|
||||
FileRef fileRef;
|
||||
// try to open the dir
|
||||
Err e = VFSFileOpen(gVars->volRefNum, directory, vfsModeRead, &fileRef);
|
||||
Err e = VFSFileOpen(gVars->volRefNum, getSavePath(), vfsModeRead, &fileRef);
|
||||
memset(marks, false, num*sizeof(bool));
|
||||
|
||||
if (e != errNone)
|
||||
|
|
|
@ -258,12 +258,11 @@ public:
|
|||
|
||||
class VMSaveManager : public SaveFileManager {
|
||||
public:
|
||||
virtual SaveFile *open_savefile(const char *filename, const char *directory, bool saveOrLoad);
|
||||
virtual void list_savefiles(const char *prefix, const char *directory, bool *marks, int num);
|
||||
virtual SaveFile *openSavefile(const char *filename, bool saveOrLoad);
|
||||
virtual void listSavefiles(const char *prefix, bool *marks, int num);
|
||||
};
|
||||
|
||||
SaveFile *VMSaveManager::open_savefile(const char *filename, const char *directory,
|
||||
bool saveOrLoad)
|
||||
SaveFile *VMSaveManager::openSavefile(const char *filename, bool saveOrLoad)
|
||||
{
|
||||
VMSave *s = new VMSave(filename, saveOrLoad);
|
||||
if(saveOrLoad)
|
||||
|
@ -332,8 +331,7 @@ uint32 VMSave::write(const void *buf, uint32 cnt)
|
|||
}
|
||||
|
||||
|
||||
void VMSaveManager::list_savefiles(const char *prefix, const char *directory,
|
||||
bool *marks, int num)
|
||||
void VMSaveManager::listSavefiles(const char *prefix, bool *marks, int num)
|
||||
{
|
||||
memset(marks, false, num*sizeof(bool));
|
||||
|
||||
|
|
|
@ -81,42 +81,6 @@ void Engine::initCommonGFX(GameDetector &detector) {
|
|||
_system->setFeatureState(OSystem::kFeatureFullscreenMode, ConfMan.getBool("fullscreen"));
|
||||
}
|
||||
|
||||
const char *Engine::getSavePath() const {
|
||||
|
||||
#if defined(__PALM_OS__)
|
||||
return SCUMMVM_SAVEPATH;
|
||||
#else
|
||||
|
||||
const char *dir = NULL;
|
||||
|
||||
#if !defined(MACOS_CARBON) && !defined(_WIN32_WCE)
|
||||
dir = getenv("SCUMMVM_SAVEPATH");
|
||||
#endif
|
||||
|
||||
// If SCUMMVM_SAVEPATH was not specified, try to use game specific savepath from config
|
||||
if (!dir || dir[0] == 0) {
|
||||
dir = ConfMan.get("savepath").c_str();
|
||||
|
||||
// Work around a bug (#999122) in the original 0.6.1 release of
|
||||
// ScummVM, which would insert a bad savepath value into config files.
|
||||
if (0 == strcmp(dir, "None")) {
|
||||
ConfMan.removeKey("savepath", ConfMan.getActiveDomain());
|
||||
ConfMan.flushToDisk();
|
||||
dir = ConfMan.get("savepath").c_str();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
if (dir[0] == 0)
|
||||
dir = _gameDataPath.c_str();
|
||||
#endif
|
||||
|
||||
assert(dir);
|
||||
|
||||
return dir;
|
||||
#endif
|
||||
}
|
||||
|
||||
const char *Engine::getGameDataPath() const {
|
||||
return _gameDataPath.c_str();
|
||||
}
|
||||
|
|
|
@ -57,9 +57,6 @@ public:
|
|||
*/
|
||||
virtual int go() = 0;
|
||||
|
||||
/** Get the path to the save game directory. */
|
||||
virtual const char *getSavePath() const;
|
||||
|
||||
/** Get the path to the game data directory. */
|
||||
virtual const char *getGameDataPath() const;
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "stdafx.h"
|
||||
#include "common/util.h"
|
||||
#include "common/config-manager.h"
|
||||
#include "common/savefile.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -30,6 +31,42 @@
|
|||
#include <zlib.h>
|
||||
#endif
|
||||
|
||||
const char *SaveFileManager::getSavePath() const {
|
||||
|
||||
#if defined(__PALM_OS__)
|
||||
return SCUMMVM_SAVEPATH;
|
||||
#else
|
||||
|
||||
const char *dir = NULL;
|
||||
|
||||
#if !defined(MACOS_CARBON) && !defined(_WIN32_WCE)
|
||||
dir = getenv("SCUMMVM_SAVEPATH");
|
||||
#endif
|
||||
|
||||
// If SCUMMVM_SAVEPATH was not specified, try to use game specific savepath from config
|
||||
if (!dir || dir[0] == 0) {
|
||||
dir = ConfMan.get("savepath").c_str();
|
||||
|
||||
// Work around a bug (#999122) in the original 0.6.1 release of
|
||||
// ScummVM, which would insert a bad savepath value into config files.
|
||||
if (0 == strcmp(dir, "None")) {
|
||||
ConfMan.removeKey("savepath", ConfMan.getActiveDomain());
|
||||
ConfMan.flushToDisk();
|
||||
dir = ConfMan.get("savepath").c_str();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
if (dir[0] == 0)
|
||||
dir = _gameDataPath.c_str();
|
||||
#endif
|
||||
|
||||
assert(dir);
|
||||
|
||||
return dir;
|
||||
#endif
|
||||
}
|
||||
|
||||
class StdioSaveFile : public SaveFile {
|
||||
private:
|
||||
FILE *fh;
|
||||
|
@ -103,9 +140,9 @@ static void join_paths(const char *filename, const char *directory,
|
|||
strncat(buf, filename, bufsize-1);
|
||||
}
|
||||
|
||||
SaveFile *DefaultSaveFileManager::open_savefile(const char *filename, const char *directory, bool saveOrLoad) {
|
||||
SaveFile *DefaultSaveFileManager::openSavefile(const char *filename, bool saveOrLoad) {
|
||||
char buf[256];
|
||||
join_paths(filename, directory, buf, sizeof(buf));
|
||||
join_paths(filename, getSavePath(), buf, sizeof(buf));
|
||||
SaveFile *sf = makeSaveFile(buf, saveOrLoad);
|
||||
if (!sf->isOpen()) {
|
||||
delete sf;
|
||||
|
@ -114,7 +151,7 @@ SaveFile *DefaultSaveFileManager::open_savefile(const char *filename, const char
|
|||
return sf;
|
||||
}
|
||||
|
||||
void DefaultSaveFileManager::list_savefiles(const char * /* prefix */, const char *directory, bool *marks, int num) {
|
||||
void DefaultSaveFileManager::listSavefiles(const char * /* prefix */, bool *marks, int num) {
|
||||
memset(marks, true, num * sizeof(bool));
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ public:
|
|||
};
|
||||
|
||||
class SaveFileManager {
|
||||
|
||||
public:
|
||||
virtual ~SaveFileManager() {}
|
||||
|
||||
|
@ -46,14 +47,17 @@ public:
|
|||
* @param saveOrLoad true for saving, false for loading
|
||||
* @return pointer to a SaveFile object
|
||||
*/
|
||||
virtual SaveFile *open_savefile(const char *filename, const char *directory, bool saveOrLoad) = 0;
|
||||
virtual void list_savefiles(const char * /* prefix */, const char *directory, bool *marks, int num) = 0;
|
||||
virtual SaveFile *openSavefile(const char *filename, bool saveOrLoad) = 0;
|
||||
virtual void listSavefiles(const char * /* prefix */, bool *marks, int num) = 0;
|
||||
|
||||
/** Get the path to the save game directory. */
|
||||
virtual const char *getSavePath() const;
|
||||
};
|
||||
|
||||
class DefaultSaveFileManager : public SaveFileManager {
|
||||
public:
|
||||
virtual SaveFile *open_savefile(const char *filename, const char *directory, bool saveOrLoad);
|
||||
virtual void list_savefiles(const char * /* prefix */, const char *directory, bool *marks, int num);
|
||||
virtual SaveFile *openSavefile(const char *filename, bool saveOrLoad);
|
||||
virtual void listSavefiles(const char * /* prefix */, bool *marks, int num);
|
||||
|
||||
protected:
|
||||
virtual SaveFile *makeSaveFile(const char *filename, bool saveOrLoad);
|
||||
|
|
|
@ -195,7 +195,7 @@ void QueenEngine::saveGameState(uint16 slot, const char *desc) {
|
|||
debug(3, "Saving game to slot %d", slot);
|
||||
char name[20];
|
||||
makeGameStateName(slot, name);
|
||||
SaveFile *file = _saveFileMan->open_savefile(name, getSavePath(), true);
|
||||
SaveFile *file = _saveFileMan->openSavefile(name, true);
|
||||
if (file) {
|
||||
// save data
|
||||
byte *saveData = new byte[30000];
|
||||
|
@ -252,7 +252,7 @@ void QueenEngine::loadGameState(uint16 slot) {
|
|||
SaveFile *QueenEngine::readGameStateHeader(uint16 slot, GameStateHeader *gsh) {
|
||||
char name[20];
|
||||
makeGameStateName(slot, name);
|
||||
SaveFile *file = _saveFileMan->open_savefile(name, getSavePath(), false);
|
||||
SaveFile *file = _saveFileMan->openSavefile(name, false);
|
||||
if (file && file->readUint32BE() == 'SCVM') {
|
||||
gsh->version = file->readUint32BE();
|
||||
gsh->flags = file->readUint32BE();
|
||||
|
@ -273,7 +273,7 @@ void QueenEngine::findGameStateDescriptions(char descriptions[100][32]) {
|
|||
makeGameStateName(0, filename);
|
||||
filename[strlen(filename) - 2] = 0;
|
||||
bool marks[SAVESTATE_MAX];
|
||||
_saveFileMan->list_savefiles(filename, getSavePath(), marks, SAVESTATE_MAX);
|
||||
_saveFileMan->listSavefiles(filename, marks, SAVESTATE_MAX);
|
||||
for (int i = 0; i < SAVESTATE_MAX; ++i) {
|
||||
if (marks[i]) {
|
||||
GameStateHeader header;
|
||||
|
|
|
@ -69,7 +69,7 @@ bool ScummEngine::saveState(int slot, bool compat) {
|
|||
|
||||
makeSavegameName(filename, slot, compat);
|
||||
|
||||
if (!(out = _saveFileMan->open_savefile(filename, getSavePath(), true)))
|
||||
if (!(out = _saveFileMan->openSavefile(filename, true)))
|
||||
return false;
|
||||
|
||||
memcpy(hdr.name, _saveLoadName, sizeof(hdr.name));
|
||||
|
@ -96,7 +96,7 @@ bool ScummEngine::loadState(int slot, bool compat) {
|
|||
byte *roomptr;
|
||||
|
||||
makeSavegameName(filename, slot, compat);
|
||||
if (!(in = _saveFileMan->open_savefile(filename, getSavePath(), false)))
|
||||
if (!(in = _saveFileMan->openSavefile(filename, false)))
|
||||
return false;
|
||||
|
||||
in->read(&hdr, sizeof(hdr));
|
||||
|
@ -329,7 +329,7 @@ void ScummEngine::listSavegames(bool *marks, int num) {
|
|||
char prefix[256];
|
||||
makeSavegameName(prefix, 99, false);
|
||||
prefix[strlen(prefix)-2] = 0;
|
||||
_saveFileMan->list_savefiles(prefix, getSavePath(), marks, num);
|
||||
_saveFileMan->listSavefiles(prefix, marks, num);
|
||||
}
|
||||
|
||||
bool ScummEngine::getSavegameName(int slot, char *desc) {
|
||||
|
@ -339,7 +339,7 @@ bool ScummEngine::getSavegameName(int slot, char *desc) {
|
|||
int len;
|
||||
|
||||
makeSavegameName(filename, slot, false);
|
||||
if (!(out = _saveFileMan->open_savefile(filename, getSavePath(), false))) {
|
||||
if (!(out = _saveFileMan->openSavefile(filename, false))) {
|
||||
strcpy(desc, "");
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1167,7 +1167,7 @@ void ScummEngine_v5::o5_saveLoadGame() {
|
|||
|
||||
listSavegames(avail_saves, ARRAYSIZE(avail_saves));
|
||||
makeSavegameName(filename, slot, false);
|
||||
if (avail_saves[slot] && (_saveFileMan->open_savefile(filename, getSavePath(), false)))
|
||||
if (avail_saves[slot] && (_saveFileMan->openSavefile(filename, false)))
|
||||
result = 6; // save file exists
|
||||
else
|
||||
result = 7; // save file does not exist
|
||||
|
@ -1943,7 +1943,7 @@ void ScummEngine_v5::o5_roomOps() {
|
|||
s = filename;
|
||||
while ((*s++ = fetchScriptByte()));
|
||||
|
||||
file = _saveFileMan->open_savefile(filename, getSavePath(), true);
|
||||
file = _saveFileMan->openSavefile(filename, true);
|
||||
if (file != NULL) {
|
||||
byte *ptr;
|
||||
ptr = getResourceAddress(rtString, a);
|
||||
|
@ -1962,7 +1962,7 @@ void ScummEngine_v5::o5_roomOps() {
|
|||
s = filename;
|
||||
while ((*s++ = fetchScriptByte()));
|
||||
|
||||
file = _saveFileMan->open_savefile(filename, getSavePath(), false);
|
||||
file = _saveFileMan->openSavefile(filename, false);
|
||||
if (file != NULL) {
|
||||
byte *ptr;
|
||||
int len = 256, cnt = 0;
|
||||
|
|
|
@ -2733,12 +2733,11 @@ int SimonEngine::count_savegames() {
|
|||
|
||||
char *prefix = gen_savename(999);
|
||||
prefix[strlen(prefix)-3] = '\0';
|
||||
_saveFileMan->list_savefiles(prefix, getSavePath(), marks, 256);
|
||||
_saveFileMan->listSavefiles(prefix, marks, 256);
|
||||
|
||||
while (i < 256) {
|
||||
if (marks[i] &&
|
||||
(f = _saveFileMan->open_savefile(gen_savename(i), getSavePath(),
|
||||
false))) {
|
||||
(f = _saveFileMan->openSavefile(gen_savename(i), false))) {
|
||||
i++;
|
||||
delete f;
|
||||
} else
|
||||
|
@ -2758,7 +2757,7 @@ int SimonEngine::display_savegame_list(int curpos, bool load, char *dst) {
|
|||
slot = curpos;
|
||||
|
||||
while (curpos + 6 > slot) {
|
||||
if(!(in = _saveFileMan->open_savefile(gen_savename(slot), getSavePath(), false)))
|
||||
if(!(in = _saveFileMan->openSavefile(gen_savename(slot), false)))
|
||||
break;
|
||||
|
||||
in->read(dst, 18);
|
||||
|
@ -2782,7 +2781,7 @@ int SimonEngine::display_savegame_list(int curpos, bool load, char *dst) {
|
|||
}
|
||||
} else {
|
||||
if (curpos + 6 == slot) {
|
||||
if((in = _saveFileMan->open_savefile(gen_savename(slot), getSavePath(), false))) {
|
||||
if((in = _saveFileMan->openSavefile(gen_savename(slot), false))) {
|
||||
slot++;
|
||||
delete in;
|
||||
}
|
||||
|
@ -4917,7 +4916,7 @@ bool SimonEngine::save_game(uint slot, char *caption) {
|
|||
#endif
|
||||
|
||||
|
||||
f = _saveFileMan->open_savefile(gen_savename(slot), getSavePath(), true);
|
||||
f = _saveFileMan->openSavefile(gen_savename(slot), true);
|
||||
if (f == NULL) {
|
||||
_lock_word &= ~0x100;
|
||||
return false;
|
||||
|
@ -5018,7 +5017,7 @@ bool SimonEngine::load_game(uint slot) {
|
|||
#endif
|
||||
|
||||
|
||||
f = _saveFileMan->open_savefile(gen_savename(slot), getSavePath(), false);
|
||||
f = _saveFileMan->openSavefile(gen_savename(slot), false);
|
||||
if (f == NULL) {
|
||||
_lock_word &= ~0x100;
|
||||
return false;
|
||||
|
|
|
@ -191,7 +191,7 @@ void ControlStatus::drawToScreen(void) {
|
|||
_statusText->drawToScreen(WITH_MASK);
|
||||
}
|
||||
|
||||
Control::Control(SaveFileManager *saveFileMan, 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) {
|
||||
_saveFileMan = saveFileMan;
|
||||
|
||||
_skyScreen = screen;
|
||||
|
@ -202,7 +202,6 @@ Control::Control(SaveFileManager *saveFileMan, Screen *screen, Disk *disk, Mouse
|
|||
_skyLogic = logic;
|
||||
_skySound = sound;
|
||||
_system = system;
|
||||
_savePath = savePath;
|
||||
_memListRoot = NULL;
|
||||
}
|
||||
|
||||
|
@ -788,7 +787,7 @@ bool Control::autoSaveExists(void) {
|
|||
else
|
||||
sprintf(fName, "SKY-VM%03d.ASD", SkyEngine::_systemVars.gameVersion);
|
||||
|
||||
f = _saveFileMan->open_savefile(fName, _savePath, false);
|
||||
f = _saveFileMan->openSavefile(fName, false);
|
||||
if (f != NULL) {
|
||||
test = true;
|
||||
delete f;
|
||||
|
@ -887,7 +886,7 @@ uint16 Control::saveRestorePanel(bool allowSave) {
|
|||
refreshNames = true;
|
||||
}
|
||||
if (clickRes == NO_DISK_SPACE) {
|
||||
displayMessage(0, "Could not save game in directory '%s'", _savePath);
|
||||
displayMessage(0, "Could not save game in directory '%s'", _saveFileMan->getSavePath());
|
||||
quitPanel = true;
|
||||
}
|
||||
if ((clickRes == CANCEL_PRESSED) || (clickRes == GAME_RESTORED))
|
||||
|
@ -1010,7 +1009,7 @@ void Control::loadDescriptions(uint8 *destBuf) {
|
|||
memset(destBuf, 0, MAX_SAVE_GAMES * MAX_TEXT_LEN);
|
||||
|
||||
SaveFile *inf;
|
||||
inf = _saveFileMan->open_savefile("SKY-VM.SAV",_savePath,false);
|
||||
inf = _saveFileMan->openSavefile("SKY-VM.SAV", false);
|
||||
if (inf != NULL) {
|
||||
uint8 *tmpBuf = (uint8 *)malloc(MAX_SAVE_GAMES * MAX_TEXT_LEN);
|
||||
inf->read(tmpBuf, MAX_SAVE_GAMES * MAX_TEXT_LEN);
|
||||
|
@ -1087,7 +1086,7 @@ void Control::saveDescriptions(uint8 *srcBuf) {
|
|||
}
|
||||
SaveFile *outf;
|
||||
|
||||
outf = _saveFileMan->open_savefile("SKY-VM.SAV", _savePath, true);
|
||||
outf = _saveFileMan->openSavefile("SKY-VM.SAV", true);
|
||||
if (outf != NULL) {
|
||||
outf->write(tmpBuf, tmpPos - tmpBuf);
|
||||
delete outf;
|
||||
|
@ -1103,16 +1102,16 @@ void Control::doAutoSave(void) {
|
|||
sprintf(fName, "SKY-VM%03d.ASD", SkyEngine::_systemVars.gameVersion);
|
||||
SaveFile *outf;
|
||||
|
||||
outf = _saveFileMan->open_savefile(fName, _savePath, true);
|
||||
outf = _saveFileMan->openSavefile(fName, true);
|
||||
if (outf == NULL) {
|
||||
displayMessage(0, "Unable to create autosave file '%s' in directory '%s'", fName, _savePath);
|
||||
displayMessage(0, "Unable to create autosave file '%s' in directory '%s'", fName, _saveFileMan->getSavePath());
|
||||
return;
|
||||
}
|
||||
uint8 *saveData = (uint8 *)malloc(0x20000);
|
||||
uint32 fSize = prepareSaveData(saveData);
|
||||
|
||||
if (outf->write(saveData, fSize) != fSize)
|
||||
displayMessage(0, "Unable to write autosave file '%s' in directory '%s'. Disk full?", fName, _savePath);
|
||||
displayMessage(0, "Unable to write autosave file '%s' in directory '%s'. Disk full?", fName, _saveFileMan->getSavePath());
|
||||
|
||||
delete outf;
|
||||
free(saveData);
|
||||
|
@ -1124,7 +1123,7 @@ uint16 Control::saveGameToFile(void) {
|
|||
sprintf(fName,"SKY-VM.%03d", _selectedGame);
|
||||
|
||||
SaveFile *outf;
|
||||
outf = _saveFileMan->open_savefile(fName, _savePath, true);
|
||||
outf = _saveFileMan->openSavefile(fName, true);
|
||||
if (outf == NULL) {
|
||||
return NO_DISK_SPACE;
|
||||
}
|
||||
|
@ -1529,7 +1528,7 @@ uint16 Control::restoreGameFromFile(bool autoSave) {
|
|||
sprintf(fName,"SKY-VM.%03d", _selectedGame);
|
||||
|
||||
SaveFile *inf;
|
||||
inf = _saveFileMan->open_savefile(fName, _savePath, false);
|
||||
inf = _saveFileMan->openSavefile(fName, false);
|
||||
if (inf == NULL) {
|
||||
return RESTORE_FAILED;
|
||||
}
|
||||
|
|
|
@ -175,7 +175,7 @@ private:
|
|||
|
||||
class Control {
|
||||
public:
|
||||
Control(SaveFileManager *saveFileMan, 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);
|
||||
void doControlPanel(void);
|
||||
void doLoadSavePanel(void);
|
||||
void restartGame(void);
|
||||
|
@ -230,7 +230,6 @@ private:
|
|||
void lodsStr(uint8 **srcPos, uint16 *src);
|
||||
uint16 parseSaveData(uint8 *srcBuf);
|
||||
|
||||
const char *_savePath;
|
||||
uint16 *lz77decode(uint16 *data);
|
||||
void applyDiff(uint16 *data, uint16 *diffData, uint16 len);
|
||||
static Compact *_saveLoadCpts[833]; //-----------------
|
||||
|
|
|
@ -303,7 +303,7 @@ int SkyEngine::init(GameDetector &detector) {
|
|||
// initialize timer *after* _skyScreen has been initialized.
|
||||
_timer->installTimerProc(&timerHandler, 1000000 / 50, this); //call 50 times per second
|
||||
|
||||
_skyControl = new Control(_saveFileMan, _skyScreen, _skyDisk, _skyMouse, _skyText, _skyMusic, _skyLogic, _skySound, _system, getSavePath());
|
||||
_skyControl = new Control(_saveFileMan, _skyScreen, _skyDisk, _skyMouse, _skyText, _skyMusic, _skyLogic, _skySound, _system);
|
||||
_skyLogic->useControlInstance(_skyControl);
|
||||
|
||||
if (_systemVars.gameVersion == 288)
|
||||
|
|
|
@ -156,7 +156,7 @@ void ControlButton::setSelected(uint8 selected) {
|
|||
draw();
|
||||
}
|
||||
|
||||
Control::Control(SaveFileManager *saveFileMan, 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) {
|
||||
_saveFileMan = saveFileMan;
|
||||
_resMan = pResMan;
|
||||
_objMan = pObjMan;
|
||||
|
@ -164,7 +164,6 @@ Control::Control(SaveFileManager *saveFileMan, ResMan *pResMan, ObjectMan *pObjM
|
|||
_mouse = pMouse;
|
||||
_music = pMusic;
|
||||
_sound = pSound;
|
||||
strcpy(_savePath, savePath);
|
||||
_lStrings = _languageStrings + SwordEngine::_systemVars.language * 20;
|
||||
}
|
||||
|
||||
|
@ -670,7 +669,7 @@ bool Control::restoreFromFile(void) {
|
|||
|
||||
void Control::readSavegameDescriptions(void) {
|
||||
SaveFile *inf;
|
||||
inf = _saveFileMan->open_savefile("SAVEGAME.INF", _savePath, SAVEFILE_READ);
|
||||
inf = _saveFileMan->openSavefile("SAVEGAME.INF", SAVEFILE_READ);
|
||||
_saveScrollPos = _saveFiles = 0;
|
||||
_selectedSavegame = 255;
|
||||
if (inf && inf->isOpen()) {
|
||||
|
@ -713,11 +712,11 @@ int Control::displayMessage(const char *altButton, const char *message, ...) {
|
|||
|
||||
void Control::writeSavegameDescriptions(void) {
|
||||
SaveFile *outf;
|
||||
outf = _saveFileMan->open_savefile("SAVEGAME.INF", _savePath, SAVEFILE_WRITE);
|
||||
outf = _saveFileMan->openSavefile("SAVEGAME.INF", SAVEFILE_WRITE);
|
||||
|
||||
if (!outf) {
|
||||
// Display an error message, and do nothing
|
||||
displayMessage(0, "Unable to write to path '%s'", _savePath);
|
||||
displayMessage(0, "Unable to write to path '%s'", _saveFileMan->getSavePath());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -738,7 +737,7 @@ void Control::writeSavegameDescriptions(void) {
|
|||
bool Control::savegamesExist(void) {
|
||||
bool retVal = false;
|
||||
SaveFile *inf;
|
||||
inf = _saveFileMan->open_savefile("SAVEGAME.INF", _savePath, SAVEFILE_READ);
|
||||
inf = _saveFileMan->openSavefile("SAVEGAME.INF", SAVEFILE_READ);
|
||||
if (inf && inf->isOpen())
|
||||
retVal = true;
|
||||
delete inf;
|
||||
|
@ -895,10 +894,10 @@ void Control::saveGameToFile(uint8 slot) {
|
|||
sprintf(fName, "SAVEGAME.%03d", slot);
|
||||
uint16 liveBuf[TOTAL_SECTIONS];
|
||||
SaveFile *outf;
|
||||
outf = _saveFileMan->open_savefile(fName, _savePath, SAVEFILE_WRITE);
|
||||
outf = _saveFileMan->openSavefile(fName, 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);
|
||||
displayMessage(0, "Unable to create file '%s' in directory '%s'", fName, _saveFileMan->getSavePath());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -928,10 +927,10 @@ bool Control::restoreGameFromFile(uint8 slot) {
|
|||
uint16 cnt;
|
||||
sprintf(fName, "SAVEGAME.%03d", slot);
|
||||
SaveFile *inf;
|
||||
inf = _saveFileMan->open_savefile(fName, _savePath, SAVEFILE_READ);
|
||||
inf = _saveFileMan->openSavefile(fName, 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);
|
||||
displayMessage(0, "Can't open file '%s' in directory '%s'", fName, _saveFileMan->getSavePath());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ struct ButtonInfo {
|
|||
|
||||
class Control {
|
||||
public:
|
||||
Control(SaveFileManager *saveFileMan, 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);
|
||||
uint8 runPanel(void);
|
||||
void doRestore(void);
|
||||
void askForCd(void);
|
||||
|
@ -126,7 +126,6 @@ private:
|
|||
Mouse *_mouse;
|
||||
Music *_music;
|
||||
Sound *_sound;
|
||||
char _savePath[256];
|
||||
uint8 *_font, *_redFont;
|
||||
uint8 *_screenBuf;
|
||||
uint8 _keyPressed;
|
||||
|
|
|
@ -201,7 +201,7 @@ int SwordEngine::init(GameDetector &detector) {
|
|||
_logic->initialize();
|
||||
_objectMan->initialize();
|
||||
_mouse->initialize();
|
||||
_control = new Control(_saveFileMan, _resMan, _objectMan, _system, _mouse, _sound, _music, getSavePath());
|
||||
_control = new Control(_saveFileMan, _resMan, _objectMan, _system, _mouse, _sound, _music);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -167,7 +167,7 @@ uint32 Sword2Engine::saveData(uint16 slotNo, byte *buffer, uint32 bufferSize) {
|
|||
|
||||
SaveFile *out;
|
||||
|
||||
if (!(out = _saveFileMan->open_savefile(saveFileName, getSavePath(), true))) {
|
||||
if (!(out = _saveFileMan->openSavefile(saveFileName, true))) {
|
||||
return SR_ERR_FILEOPEN;
|
||||
}
|
||||
|
||||
|
@ -214,7 +214,7 @@ uint32 Sword2Engine::restoreData(uint16 slotNo, byte *buffer, uint32 bufferSize)
|
|||
|
||||
SaveFile *in;
|
||||
|
||||
if (!(in = _saveFileMan->open_savefile(saveFileName, getSavePath(), false))) {
|
||||
if (!(in = _saveFileMan->openSavefile(saveFileName, false))) {
|
||||
// error: couldn't open file
|
||||
return SR_ERR_FILEOPEN;
|
||||
}
|
||||
|
@ -359,7 +359,7 @@ uint32 Sword2Engine::getSaveDescription(uint16 slotNo, byte *description) {
|
|||
|
||||
SaveFile *in;
|
||||
|
||||
if (!(in = _saveFileMan->open_savefile(saveFileName, getSavePath(), false))) {
|
||||
if (!(in = _saveFileMan->openSavefile(saveFileName, false))) {
|
||||
return SR_ERR_FILEOPEN;
|
||||
}
|
||||
|
||||
|
@ -386,7 +386,7 @@ bool Sword2Engine::saveExists(uint16 slotNo) {
|
|||
|
||||
SaveFile *in;
|
||||
|
||||
if (!(in = _saveFileMan->open_savefile(saveFileName, getSavePath(), false))) {
|
||||
if (!(in = _saveFileMan->openSavefile(saveFileName, false))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue