aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/PalmOS/Src/palmsave.cpp7
-rw-r--r--backends/dc/vmsave.cpp10
-rw-r--r--backends/ps2/savefile.h11
-rw-r--r--common/savefile.cpp24
-rw-r--r--common/savefile.h54
-rw-r--r--queen/queen.cpp10
-rw-r--r--queen/queen.h4
-rw-r--r--scumm/saveload.cpp36
-rw-r--r--scumm/saveload.h16
-rw-r--r--scumm/script_v5.cpp10
-rw-r--r--simon/saveload.cpp18
-rw-r--r--sky/control.cpp24
-rw-r--r--sword1/control.cpp28
-rw-r--r--sword2/save_rest.cpp16
14 files changed, 166 insertions, 102 deletions
diff --git a/backends/PalmOS/Src/palmsave.cpp b/backends/PalmOS/Src/palmsave.cpp
index b2d8840020..760460f369 100644
--- a/backends/PalmOS/Src/palmsave.cpp
+++ b/backends/PalmOS/Src/palmsave.cpp
@@ -126,6 +126,13 @@ uint32 PalmSaveFile::write(const void *buf, uint32 size) {
class PalmSaveFileManager : public SaveFileManager {
public:
+ virtual OutSaveFile *openForSaving(const char *filename) {
+ return openSavefile(filename, true);
+ }
+ virtual InSaveFile *openForLoading(const char *filename) {
+ return openSavefile(filename, false);
+ }
+
SaveFile *openSavefile(const char *filename, bool saveOrLoad);
void listSavefiles(const char *prefix, bool *marks, int num);
diff --git a/backends/dc/vmsave.cpp b/backends/dc/vmsave.cpp
index 4dd43e9373..ae40cf7ae6 100644
--- a/backends/dc/vmsave.cpp
+++ b/backends/dc/vmsave.cpp
@@ -258,7 +258,15 @@ public:
class VMSaveManager : public SaveFileManager {
public:
- virtual SaveFile *openSavefile(const char *filename, bool saveOrLoad);
+
+ virtual OutSaveFile *openForSaving(const char *filename) {
+ return openSavefile(filename, true);
+ }
+ virtual IntSaveFile *openForLoading(const char *filename) {
+ return openSavefile(filename, false);
+ }
+
+ SaveFile *openSavefile(const char *filename, bool saveOrLoad);
virtual void listSavefiles(const char *prefix, bool *marks, int num);
};
diff --git a/backends/ps2/savefile.h b/backends/ps2/savefile.h
index 56b485d82e..25133e90dc 100644
--- a/backends/ps2/savefile.h
+++ b/backends/ps2/savefile.h
@@ -38,7 +38,14 @@ public:
Ps2SaveFileManager(const char *path, SaveMode mode, Gs2dScreen *screen);
virtual ~Ps2SaveFileManager();
- virtual SaveFile *openSavefile(const char *filename, bool saveOrLoad);
+
+ virtual SaveFile *openForSaving(const char *filename) {
+ return openSavefile(filename, true);
+ }
+ virtual SaveFile *openForLoading(const char *filename) {
+ return openSavefile(filename, false);
+ }
+
virtual void listSavefiles(const char * /* prefix */, bool *marks, int num);
/** Get the path to the save game directory. */
@@ -59,6 +66,8 @@ private:
static const iconIVECTOR _bgcolor[4];
static const iconFVECTOR _lightdir[3], _lightcol[3], _ambient;
+
+ SaveFile *openSavefile(const char *filename, bool saveOrLoad);
};
#endif // __PS2_SAVEFILE__
diff --git a/common/savefile.cpp b/common/savefile.cpp
index 03b2eaa4e2..b6d4cf47b9 100644
--- a/common/savefile.cpp
+++ b/common/savefile.cpp
@@ -134,15 +134,16 @@ static void join_paths(const char *filename, const char *directory,
strncat(buf, filename, bufsize-1);
}
-SaveFile *DefaultSaveFileManager::openSavefile(const char *filename, bool saveOrLoad) {
+OutSaveFile *DefaultSaveFileManager::openForSaving(const char *filename) {
char buf[256];
join_paths(filename, getSavePath(), buf, sizeof(buf));
- SaveFile *sf = makeSaveFile(buf, saveOrLoad);
- if (!sf->isOpen()) {
- delete sf;
- sf = 0;
- }
- return sf;
+ return makeSaveFile(buf, true);
+}
+
+InSaveFile *DefaultSaveFileManager::openForLoading(const char *filename) {
+ char buf[256];
+ join_paths(filename, getSavePath(), buf, sizeof(buf));
+ return makeSaveFile(buf, false);
}
void DefaultSaveFileManager::listSavefiles(const char * /* prefix */, bool *marks, int num) {
@@ -151,8 +152,13 @@ void DefaultSaveFileManager::listSavefiles(const char * /* prefix */, bool *mark
SaveFile *DefaultSaveFileManager::makeSaveFile(const char *filename, bool saveOrLoad) {
#ifdef USE_ZLIB
- return new GzipSaveFile(filename, saveOrLoad);
+ GzipSaveFile *sf = new GzipSaveFile(filename, saveOrLoad);
#else
- return new StdioSaveFile(filename, saveOrLoad);
+ StdioSaveFile *sf = new StdioSaveFile(filename, saveOrLoad);
#endif
+ if (!sf->isOpen()) {
+ delete sf;
+ sf = 0;
+ }
+ return sf;
}
diff --git a/common/savefile.h b/common/savefile.h
index ba2c2c9885..4b4771daa9 100644
--- a/common/savefile.h
+++ b/common/savefile.h
@@ -27,11 +27,38 @@
#include "common/stream.h"
-class SaveFile : public Common::ReadStream, public Common::WriteStream {
+/**
+ * A class which allows game engines to load game state data.
+ * That typically means "save games", but also includes things like the
+ * IQ points in Indy3.
+ *
+ * @todo Add error checking abilities.
+ * @todo Change base class to SeekableReadStream; or alternatively,
+ * add a simple 'skip()' method which would allow skipping
+ * a number of bytes in the savefile.
+ */
+class InSaveFile : public Common::ReadStream {
public:
- virtual ~SaveFile() {}
+ virtual ~InSaveFile() {}
+};
- virtual bool isOpen() const = 0;
+/**
+ * A class which allows game engines to save game state data.
+ * That typically means "save games", but also includes things like the
+ * IQ points in Indy3.
+ *
+ * @todo Add error checking abilities.
+ */
+class OutSaveFile : public Common::WriteStream {
+public:
+ virtual ~OutSaveFile() {}
+};
+
+/**
+ * Convenience intermediate class, to be removed.
+ */
+class SaveFile : public InSaveFile, public OutSaveFile {
+public:
};
class SaveFileManager {
@@ -40,13 +67,19 @@ public:
virtual ~SaveFileManager() {}
/**
- * Open the file with name filename in the given directory for saving or loading.
+ * Open the file with name filename in the given directory for saving.
* @param filename the filename
- * @param directory the directory
- * @param saveOrLoad true for saving, false for loading
- * @return pointer to a SaveFile object
+ * @return pointer to a SaveFile object, or NULL if an error occured.
*/
- virtual SaveFile *openSavefile(const char *filename, bool saveOrLoad) = 0;
+ virtual OutSaveFile *openForSaving(const char *filename) = 0;
+
+ /**
+ * Open the file with name filename in the given directory for loading.
+ * @param filename the filename
+ * @return pointer to a SaveFile object, or NULL if an error occured.
+ */
+ virtual InSaveFile *openForLoading(const char *filename) = 0;
+
virtual void listSavefiles(const char * /* prefix */, bool *marks, int num) = 0;
/** Get the path to the save game directory. */
@@ -55,11 +88,12 @@ public:
class DefaultSaveFileManager : public SaveFileManager {
public:
- virtual SaveFile *openSavefile(const char *filename, bool saveOrLoad);
+ virtual OutSaveFile *openForSaving(const char *filename);
+ virtual InSaveFile *openForLoading(const char *filename);
virtual void listSavefiles(const char * /* prefix */, bool *marks, int num);
protected:
- virtual SaveFile *makeSaveFile(const char *filename, bool saveOrLoad);
+ SaveFile *makeSaveFile(const char *filename, bool saveOrLoad);
};
#endif
diff --git a/queen/queen.cpp b/queen/queen.cpp
index 70f2f038cd..4a3f045a4d 100644
--- a/queen/queen.cpp
+++ b/queen/queen.cpp
@@ -252,7 +252,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->openSavefile(name, true);
+ OutSaveFile *file = _saveFileMan->openForSaving(name);
if (file) {
// save data
byte *saveData = new byte[30000];
@@ -287,7 +287,7 @@ void QueenEngine::saveGameState(uint16 slot, const char *desc) {
void QueenEngine::loadGameState(uint16 slot) {
debug(3, "Loading game from slot %d", slot);
GameStateHeader header;
- SaveFile *file = readGameStateHeader(slot, &header);
+ InSaveFile *file = readGameStateHeader(slot, &header);
if (file && header.dataSize != 0) {
byte *saveData = new byte[header.dataSize];
byte *p = saveData;
@@ -308,10 +308,10 @@ void QueenEngine::loadGameState(uint16 slot) {
}
}
-SaveFile *QueenEngine::readGameStateHeader(uint16 slot, GameStateHeader *gsh) {
+InSaveFile *QueenEngine::readGameStateHeader(uint16 slot, GameStateHeader *gsh) {
char name[20];
makeGameStateName(slot, name);
- SaveFile *file = _saveFileMan->openSavefile(name, false);
+ InSaveFile *file = _saveFileMan->openForLoading(name);
if (file && file->readUint32BE() == 'SCVM') {
gsh->version = file->readUint32BE();
gsh->flags = file->readUint32BE();
@@ -340,7 +340,7 @@ void QueenEngine::findGameStateDescriptions(char descriptions[100][32]) {
for (int i = 0; i < SAVESTATE_MAX; ++i) {
if (marks[i]) {
GameStateHeader header;
- SaveFile *f = readGameStateHeader(i, &header);
+ InSaveFile *f = readGameStateHeader(i, &header);
strcpy(descriptions[i], header.description);
delete f;
}
diff --git a/queen/queen.h b/queen/queen.h
index 51ead870de..d947469ae8 100644
--- a/queen/queen.h
+++ b/queen/queen.h
@@ -25,7 +25,7 @@
#include "base/engine.h"
class GameDetector;
-class SaveFile;
+class InSaveFile;
#if defined(_WIN32_WCE) && (_WIN32_WCE <= 300)
@@ -114,7 +114,7 @@ public:
void loadGameState(uint16 slot);
void makeGameStateName(uint16 slot, char *buf);
void findGameStateDescriptions(char descriptions[100][32]);
- SaveFile *readGameStateHeader(uint16 slot, GameStateHeader *gsh);
+ InSaveFile *readGameStateHeader(uint16 slot, GameStateHeader *gsh);
enum {
SAVESTATE_CUR_VER = 1,
diff --git a/scumm/saveload.cpp b/scumm/saveload.cpp
index f63b0e667f..e41e6df51c 100644
--- a/scumm/saveload.cpp
+++ b/scumm/saveload.cpp
@@ -68,12 +68,12 @@ void ScummEngine::requestLoad(int slot) {
bool ScummEngine::saveState(int slot, bool compat) {
char filename[256];
- SaveFile *out;
+ OutSaveFile *out;
SaveGameHeader hdr;
makeSavegameName(filename, slot, compat);
- if (!(out = _saveFileMan->openSavefile(filename, true)))
+ if (!(out = _saveFileMan->openForSaving(filename)))
return false;
memcpy(hdr.name, _saveLoadName, sizeof(hdr.name));
@@ -84,7 +84,7 @@ bool ScummEngine::saveState(int slot, bool compat) {
out->write(&hdr, sizeof(hdr));
- Serializer ser(out, true, CURRENT_VER);
+ Serializer ser(0, out, CURRENT_VER);
saveOrLoad(&ser, CURRENT_VER);
delete out;
debug(1, "State saved as '%s'", filename);
@@ -93,14 +93,14 @@ bool ScummEngine::saveState(int slot, bool compat) {
bool ScummEngine::loadState(int slot, bool compat) {
char filename[256];
- SaveFile *in;
+ InSaveFile *in;
int i, j;
SaveGameHeader hdr;
int sb, sh;
byte *roomptr;
makeSavegameName(filename, slot, compat);
- if (!(in = _saveFileMan->openSavefile(filename, false)))
+ if (!(in = _saveFileMan->openForLoading(filename)))
return false;
in->read(&hdr, sizeof(hdr));
@@ -179,7 +179,7 @@ bool ScummEngine::loadState(int slot, bool compat) {
//
// Now do the actual loading
//
- Serializer ser(in, false, hdr.ver);
+ Serializer ser(in, 0, hdr.ver);
saveOrLoad(&ser, hdr.ver);
delete in;
@@ -349,17 +349,17 @@ void ScummEngine::listSavegames(bool *marks, int num) {
bool ScummEngine::getSavegameName(int slot, char *desc) {
char filename[256];
- SaveFile *out;
+ InSaveFile *in;
SaveGameHeader hdr;
int len;
makeSavegameName(filename, slot, false);
- if (!(out = _saveFileMan->openSavefile(filename, false))) {
+ if (!(in = _saveFileMan->openForLoading(filename))) {
strcpy(desc, "");
return false;
}
- len = out->read(&hdr, sizeof(hdr));
- delete out;
+ len = in->read(&hdr, sizeof(hdr));
+ delete in;
if (len != sizeof(hdr) || hdr.type != MKID('SCVM')) {
strcpy(desc, "Invalid savegame");
@@ -1010,35 +1010,35 @@ void ScummEngine::loadResource(Serializer *ser, int type, int idx) {
}
void Serializer::saveBytes(void *b, int len) {
- _saveLoadStream->write(b, len);
+ _saveStream->write(b, len);
}
void Serializer::loadBytes(void *b, int len) {
- _saveLoadStream->read(b, len);
+ _loadStream->read(b, len);
}
void Serializer::saveUint32(uint32 d) {
- _saveLoadStream->writeUint32LE(d);
+ _saveStream->writeUint32LE(d);
}
void Serializer::saveUint16(uint16 d) {
- _saveLoadStream->writeUint16LE(d);
+ _saveStream->writeUint16LE(d);
}
void Serializer::saveByte(byte b) {
- _saveLoadStream->writeByte(b);
+ _saveStream->writeByte(b);
}
uint32 Serializer::loadUint32() {
- return _saveLoadStream->readUint32LE();
+ return _loadStream->readUint32LE();
}
uint16 Serializer::loadUint16() {
- return _saveLoadStream->readUint16LE();
+ return _loadStream->readUint16LE();
}
byte Serializer::loadByte() {
- return _saveLoadStream->readByte();
+ return _loadStream->readByte();
}
void Serializer::saveArrayOf(void *b, int len, int datasize, byte filetype) {
diff --git a/scumm/saveload.h b/scumm/saveload.h
index bc6cfa8522..2d9fbced8f 100644
--- a/scumm/saveload.h
+++ b/scumm/saveload.h
@@ -24,7 +24,8 @@
#include "common/scummsys.h"
-class SaveFile;
+class InSaveFile;
+class OutSaveFile;
namespace Scumm {
@@ -94,9 +95,8 @@ typedef void *SerializerLoadReference(void *me, byte type, int ref);
class Serializer {
public:
- Serializer(SaveFile *stream, bool saveOrLoad, uint32 savegameVersion)
- : _save_ref(0), _load_ref(0), _ref_me(0),
- _saveLoadStream(stream), _saveOrLoad(saveOrLoad),
+ Serializer(InSaveFile *in, OutSaveFile *out, uint32 savegameVersion)
+ : _loadStream(in), _saveStream(out), _save_ref(0), _load_ref(0), _ref_me(0),
_savegameVersion(savegameVersion)
{ }
@@ -108,8 +108,8 @@ public:
void saveLoadArrayOf(void *b, int num, int datasize, const SaveLoadEntry *sle);
void saveLoadEntries(void *d, const SaveLoadEntry *sle);
- bool isSaving() { return _saveOrLoad; }
- bool isLoading() { return !_saveOrLoad; }
+ bool isSaving() { return (_saveStream != 0); }
+ bool isLoading() { return (_loadStream != 0); }
uint32 getVersion() { return _savegameVersion; }
void saveUint32(uint32 d);
@@ -124,8 +124,8 @@ public:
void loadBytes(void *b, int len);
protected:
- SaveFile *_saveLoadStream;
- bool _saveOrLoad;
+ InSaveFile *_loadStream;
+ OutSaveFile *_saveStream;
uint32 _savegameVersion;
void saveArrayOf(void *b, int len, int datasize, byte filetype);
diff --git a/scumm/script_v5.cpp b/scumm/script_v5.cpp
index 5e4a45ede5..71b006ff00 100644
--- a/scumm/script_v5.cpp
+++ b/scumm/script_v5.cpp
@@ -1176,7 +1176,7 @@ void ScummEngine_v5::o5_saveLoadGame() {
listSavegames(avail_saves, ARRAYSIZE(avail_saves));
makeSavegameName(filename, slot, false);
- if (avail_saves[slot] && (_saveFileMan->openSavefile(filename, false)))
+ if (avail_saves[slot] && (_saveFileMan->openForLoading(filename)))
result = 6; // save file exists
else
result = 7; // save file does not exist
@@ -1948,14 +1948,14 @@ void ScummEngine_v5::o5_roomOps() {
case 13: // SO_SAVE_STRING
{
- SaveFile *file;
+ OutSaveFile *file;
char filename[256], *s;
a = getVarOrDirectByte(PARAM_1);
s = filename;
while ((*s++ = fetchScriptByte()));
- file = _saveFileMan->openSavefile(filename, true);
+ file = _saveFileMan->openForSaving(filename);
if (file != NULL) {
byte *ptr;
ptr = getResourceAddress(rtString, a);
@@ -1967,14 +1967,14 @@ void ScummEngine_v5::o5_roomOps() {
}
case 14: // SO_LOAD_STRING
{
- SaveFile *file;
+ InSaveFile *file;
char filename[256], *s;
a = getVarOrDirectByte(PARAM_1);
s = filename;
while ((*s++ = fetchScriptByte()));
- file = _saveFileMan->openSavefile(filename, false);
+ file = _saveFileMan->openForLoading(filename);
if (file != NULL) {
byte *ptr;
int len = 256, cnt = 0;
diff --git a/simon/saveload.cpp b/simon/saveload.cpp
index 4e68368a10..cebc5add06 100644
--- a/simon/saveload.cpp
+++ b/simon/saveload.cpp
@@ -48,7 +48,7 @@ void SimonEngine::o_load_game() {
}
int SimonEngine::count_savegames() {
- SaveFile *f;
+ InSaveFile *f;
uint i = 1;
bool marks[256];
@@ -58,7 +58,7 @@ int SimonEngine::count_savegames() {
while (i < 256) {
if (marks[i] &&
- (f = _saveFileMan->openSavefile(gen_savename(i), false))) {
+ (f = _saveFileMan->openForLoading(gen_savename(i)))) {
i++;
delete f;
} else
@@ -69,7 +69,7 @@ int SimonEngine::count_savegames() {
int SimonEngine::display_savegame_list(int curpos, bool load, char *dst) {
int slot, last_slot;
- SaveFile *in;
+ InSaveFile *in;
showMessageFormat("\xC");
@@ -78,7 +78,7 @@ int SimonEngine::display_savegame_list(int curpos, bool load, char *dst) {
slot = curpos;
while (curpos + 6 > slot) {
- if(!(in = _saveFileMan->openSavefile(gen_savename(slot), false)))
+ if(!(in = _saveFileMan->openForLoading(gen_savename(slot))))
break;
in->read(dst, 18);
@@ -102,7 +102,7 @@ int SimonEngine::display_savegame_list(int curpos, bool load, char *dst) {
}
} else {
if (curpos + 6 == slot) {
- if((in = _saveFileMan->openSavefile(gen_savename(slot), false))) {
+ if((in = _saveFileMan->openForLoading(gen_savename(slot)))) {
slot++;
delete in;
}
@@ -407,7 +407,7 @@ loop:;
}
bool SimonEngine::save_game(uint slot, char *caption) {
- SaveFile *f;
+ OutSaveFile *f;
uint item_index, num_item, i, j;
TimeEvent *te;
@@ -418,7 +418,7 @@ bool SimonEngine::save_game(uint slot, char *caption) {
#endif
- f = _saveFileMan->openSavefile(gen_savename(slot), true);
+ f = _saveFileMan->openForSaving(gen_savename(slot));
if (f == NULL) {
_lock_word &= ~0x100;
return false;
@@ -509,7 +509,7 @@ char *SimonEngine::gen_savename(int slot) {
bool SimonEngine::load_game(uint slot) {
char ident[18];
- SaveFile *f;
+ InSaveFile *f;
uint num, item_index, i, j;
_lock_word |= 0x100;
@@ -519,7 +519,7 @@ bool SimonEngine::load_game(uint slot) {
#endif
- f = _saveFileMan->openSavefile(gen_savename(slot), false);
+ f = _saveFileMan->openForLoading(gen_savename(slot));
if (f == NULL) {
_lock_word &= ~0x100;
return false;
diff --git a/sky/control.cpp b/sky/control.cpp
index a6179f48bf..4272ffe558 100644
--- a/sky/control.cpp
+++ b/sky/control.cpp
@@ -784,14 +784,14 @@ uint16 Control::shiftUp(uint8 speed) {
bool Control::autoSaveExists(void) {
bool test = false;
- SaveFile *f;
+ InSaveFile *f;
char fName[20];
if (SkyEngine::isCDVersion())
strcpy(fName, "SKY-VM-CD.ASD");
else
sprintf(fName, "SKY-VM%03d.ASD", SkyEngine::_systemVars.gameVersion);
- f = _saveFileMan->openSavefile(fName, false);
+ f = _saveFileMan->openForLoading(fName);
if (f != NULL) {
test = true;
delete f;
@@ -1012,8 +1012,8 @@ void Control::loadDescriptions(uint8 *destBuf) {
memset(destBuf, 0, MAX_SAVE_GAMES * MAX_TEXT_LEN);
- SaveFile *inf;
- inf = _saveFileMan->openSavefile("SKY-VM.SAV", false);
+ InSaveFile *inf;
+ inf = _saveFileMan->openForLoading("SKY-VM.SAV");
if (inf != NULL) {
uint8 *tmpBuf = (uint8 *)malloc(MAX_SAVE_GAMES * MAX_TEXT_LEN);
inf->read(tmpBuf, MAX_SAVE_GAMES * MAX_TEXT_LEN);
@@ -1084,9 +1084,9 @@ void Control::saveDescriptions(uint8 *srcBuf) {
tmpPos++;
srcPos += MAX_TEXT_LEN;
}
- SaveFile *outf;
+ OutSaveFile *outf;
- outf = _saveFileMan->openSavefile("SKY-VM.SAV", true);
+ outf = _saveFileMan->openForSaving("SKY-VM.SAV");
if (outf != NULL) {
outf->write(tmpBuf, tmpPos - tmpBuf);
delete outf;
@@ -1100,9 +1100,9 @@ void Control::doAutoSave(void) {
strcpy(fName, "SKY-VM-CD.ASD");
else
sprintf(fName, "SKY-VM%03d.ASD", SkyEngine::_systemVars.gameVersion);
- SaveFile *outf;
+ OutSaveFile *outf;
- outf = _saveFileMan->openSavefile(fName, true);
+ outf = _saveFileMan->openForSaving(fName);
if (outf == NULL) {
displayMessage(0, "Unable to create autosave file '%s' in directory '%s'", fName, _saveFileMan->getSavePath());
return;
@@ -1121,8 +1121,8 @@ uint16 Control::saveGameToFile(void) {
char fName[20];
sprintf(fName,"SKY-VM.%03d", _selectedGame);
- SaveFile *outf;
- outf = _saveFileMan->openSavefile(fName, true);
+ OutSaveFile *outf;
+ outf = _saveFileMan->openForSaving(fName);
if (outf == NULL) {
return NO_DISK_SPACE;
}
@@ -1396,8 +1396,8 @@ uint16 Control::restoreGameFromFile(bool autoSave) {
} else
sprintf(fName,"SKY-VM.%03d", _selectedGame);
- SaveFile *inf;
- inf = _saveFileMan->openSavefile(fName, false);
+ InSaveFile *inf;
+ inf = _saveFileMan->openForLoading(fName);
if (inf == NULL) {
return RESTORE_FAILED;
}
diff --git a/sword1/control.cpp b/sword1/control.cpp
index d8d95a0571..d1bbc9c32a 100644
--- a/sword1/control.cpp
+++ b/sword1/control.cpp
@@ -669,11 +669,11 @@ bool Control::restoreFromFile(void) {
}
void Control::readSavegameDescriptions(void) {
- SaveFile *inf;
- inf = _saveFileMan->openSavefile("SAVEGAME.INF", SAVEFILE_READ);
+ InSaveFile *inf;
+ inf = _saveFileMan->openForLoading("SAVEGAME.INF");
_saveScrollPos = _saveFiles = 0;
_selectedSavegame = 255;
- if (inf && inf->isOpen()) {
+ if (inf) {
uint8 curFileNum = 0;
uint8 ch;
do {
@@ -712,8 +712,8 @@ int Control::displayMessage(const char *altButton, const char *message, ...) {
}
void Control::writeSavegameDescriptions(void) {
- SaveFile *outf;
- outf = _saveFileMan->openSavefile("SAVEGAME.INF", SAVEFILE_WRITE);
+ OutSaveFile *outf;
+ outf = _saveFileMan->openForSaving("SAVEGAME.INF");
if (!outf) {
// Display an error message, and do nothing
@@ -737,9 +737,9 @@ void Control::writeSavegameDescriptions(void) {
bool Control::savegamesExist(void) {
bool retVal = false;
- SaveFile *inf;
- inf = _saveFileMan->openSavefile("SAVEGAME.INF", SAVEFILE_READ);
- if (inf && inf->isOpen())
+ InSaveFile *inf;
+ inf = _saveFileMan->openForLoading("SAVEGAME.INF");
+ if (inf)
retVal = true;
delete inf;
return retVal;
@@ -894,9 +894,9 @@ void Control::saveGameToFile(uint8 slot) {
uint16 cnt;
sprintf(fName, "SAVEGAME.%03d", slot);
uint16 liveBuf[TOTAL_SECTIONS];
- SaveFile *outf;
- outf = _saveFileMan->openSavefile(fName, SAVEFILE_WRITE);
- if (!outf || !outf->isOpen()) {
+ OutSaveFile *outf;
+ outf = _saveFileMan->openForSaving(fName);
+ if (!outf) {
// Display an error message, and do nothing
displayMessage(0, "Unable to create file '%s' in directory '%s'", fName, _saveFileMan->getSavePath());
return;
@@ -927,9 +927,9 @@ bool Control::restoreGameFromFile(uint8 slot) {
char fName[15];
uint16 cnt;
sprintf(fName, "SAVEGAME.%03d", slot);
- SaveFile *inf;
- inf = _saveFileMan->openSavefile(fName, SAVEFILE_READ);
- if (!inf || !inf->isOpen()) {
+ InSaveFile *inf;
+ inf = _saveFileMan->openForLoading(fName);
+ if (!inf) {
// Display an error message, and do nothing
displayMessage(0, "Can't open file '%s' in directory '%s'", fName, _saveFileMan->getSavePath());
return false;
diff --git a/sword2/save_rest.cpp b/sword2/save_rest.cpp
index fc159faf2a..610b50435d 100644
--- a/sword2/save_rest.cpp
+++ b/sword2/save_rest.cpp
@@ -183,9 +183,9 @@ uint32 Sword2Engine::saveData(uint16 slotNo, byte *buffer, uint32 bufferSize) {
sprintf(saveFileName, "%s.%.3d", _targetName.c_str(), slotNo);
- SaveFile *out;
+ OutSaveFile *out;
- if (!(out = _saveFileMan->openSavefile(saveFileName, true))) {
+ if (!(out = _saveFileMan->openForSaving(saveFileName))) {
return SR_ERR_FILEOPEN;
}
@@ -261,9 +261,9 @@ uint32 Sword2Engine::restoreData(uint16 slotNo, byte *buffer, uint32 bufferSize)
sprintf(saveFileName, "%s.%.3d", _targetName.c_str(), slotNo);
- SaveFile *in;
+ InSaveFile *in;
- if (!(in = _saveFileMan->openSavefile(saveFileName, false))) {
+ if (!(in = _saveFileMan->openForLoading(saveFileName))) {
// error: couldn't open file
return SR_ERR_FILEOPEN;
}
@@ -405,9 +405,9 @@ uint32 Sword2Engine::getSaveDescription(uint16 slotNo, byte *description) {
sprintf(saveFileName, "%s.%.3d", _targetName.c_str(), slotNo);
- SaveFile *in;
+ InSaveFile *in;
- if (!(in = _saveFileMan->openSavefile(saveFileName, false))) {
+ if (!(in = _saveFileMan->openForLoading(saveFileName))) {
return SR_ERR_FILEOPEN;
}
@@ -432,9 +432,9 @@ bool Sword2Engine::saveExists(uint16 slotNo) {
sprintf(saveFileName, "%s.%.3d", _targetName.c_str(), slotNo);
- SaveFile *in;
+ InSaveFile *in;
- if (!(in = _saveFileMan->openSavefile(saveFileName, false))) {
+ if (!(in = _saveFileMan->openForLoading(saveFileName))) {
return false;
}