aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/gob/save/savehandler.cpp64
-rw-r--r--engines/gob/save/savehandler.h49
-rw-r--r--engines/gob/save/saveload_v4.cpp4
3 files changed, 45 insertions, 72 deletions
diff --git a/engines/gob/save/savehandler.cpp b/engines/gob/save/savehandler.cpp
index 744b839653..965ddea4b3 100644
--- a/engines/gob/save/savehandler.cpp
+++ b/engines/gob/save/savehandler.cpp
@@ -50,7 +50,7 @@ const char *SlotFile::getBase() const {
return _base;
}
-uint32 SlotFile::getSlotMax() const {
+uint32 SlotFileIndexed::getSlotMax() const {
Common::SaveFileManager *saveMan = g_system->getSavefileManager();
Common::InSaveFile *in;
@@ -73,7 +73,7 @@ uint32 SlotFile::getSlotMax() const {
return 0;
}
-int32 SlotFile::tallyUpFiles(uint32 slotSize, uint32 indexSize) const {
+int32 SlotFileIndexed::tallyUpFiles(uint32 slotSize, uint32 indexSize) const {
uint32 maxSlot = getSlotMax();
if (maxSlot == 0)
@@ -82,7 +82,7 @@ int32 SlotFile::tallyUpFiles(uint32 slotSize, uint32 indexSize) const {
return ((maxSlot * slotSize) + indexSize);
}
-void SlotFile::buildIndex(byte *buffer, SavePartInfo &info,
+void SlotFileIndexed::buildIndex(byte *buffer, SavePartInfo &info,
SaveConverter *converter) const {
uint32 descLength = info.getDescMaxLength();
@@ -114,69 +114,56 @@ void SlotFile::buildIndex(byte *buffer, SavePartInfo &info,
}
}
-bool SlotFile::exists(const char *name) const {
- Common::InSaveFile *in = openRead(name);
- bool result = (in != 0);
- delete in;
- return result;
-}
-
-bool SlotFile::exists(int slot) const {
+bool SlotFileIndexed::exists(int slot) const {
Common::InSaveFile *in = openRead(slot);
bool result = (in != 0);
delete in;
return result;
}
-bool SlotFile::exists() const {
+bool SlotFileStatic::exists() const {
Common::InSaveFile *in = openRead();
bool result = (in != 0);
delete in;
return result;
}
-Common::InSaveFile *SlotFile::openRead(const char *name) const {
+Common::InSaveFile *SlotFileIndexed::openRead(int slot) const {
+ char *name = build(slot);
if (!name)
return 0;
-
Common::SaveFileManager *saveMan = g_system->getSavefileManager();
-
- return saveMan->openForLoading(name);
-}
-
-Common::InSaveFile *SlotFile::openRead(int slot) const {
- char *name = build(slot);
- Common::InSaveFile *result = openRead(name);
+ Common::InSaveFile *result = saveMan->openForLoading(name);
delete[] name;
return result;
}
-Common::InSaveFile *SlotFile::openRead() const {
+Common::InSaveFile *SlotFileStatic::openRead() const {
char *name = build();
- Common::InSaveFile *result = openRead(name);
+ if (!name)
+ return 0;
+ Common::SaveFileManager *saveMan = g_system->getSavefileManager();
+ Common::InSaveFile *result = saveMan->openForLoading(name);
delete[] name;
return result;
}
-Common::OutSaveFile *SlotFile::openWrite(const char *name) const {
+Common::OutSaveFile *SlotFileIndexed::openWrite(int slot) const {
+ char *name = build(slot);
if (!name)
return 0;
-
Common::SaveFileManager *saveMan = g_system->getSavefileManager();
-
- return saveMan->openForSaving(name);
-}
-
-Common::OutSaveFile *SlotFile::openWrite(int slot) const {
- char *name = build(slot);
- Common::OutSaveFile *result = openWrite(name);
+ Common::OutSaveFile *result = saveMan->openForSaving(name);
delete[] name;
return result;
}
-Common::OutSaveFile *SlotFile::openWrite() const {
+Common::OutSaveFile *SlotFileStatic::openWrite() const {
char *name = build();
- Common::OutSaveFile *result = openWrite(name);
+ if (!name)
+ return 0;
+ Common::SaveFileManager *saveMan = g_system->getSavefileManager();
+ Common::OutSaveFile *result = saveMan->openForSaving(name);
delete[] name;
return result;
}
@@ -205,11 +192,6 @@ char *SlotFileIndexed::build(int slot) const {
return slotFile;
}
-char *SlotFileIndexed::build() const {
- return 0;
-}
-
-
SlotFileStatic::SlotFileStatic(GobEngine *vm, const char *base,
const char *ext) : SlotFile(vm, 1, base) {
@@ -228,10 +210,6 @@ int SlotFileStatic::getSlotRemainder(int32 offset) const {
return -1;
}
-char *SlotFileStatic::build(int slot) const {
- return 0;
-}
-
char *SlotFileStatic::build() const {
return strdupcat(_base, _ext);
}
diff --git a/engines/gob/save/savehandler.h b/engines/gob/save/savehandler.h
index 06c6c39cf8..7ddb4c2711 100644
--- a/engines/gob/save/savehandler.h
+++ b/engines/gob/save/savehandler.h
@@ -56,33 +56,6 @@ public:
/** Calculates the slot remainder, for error checking. */
virtual int getSlotRemainder(int32 offset) const = 0;
- /** Build the save file name. */
- virtual char *build(int slot) const = 0;
- /** Build the save file name. */
- virtual char *build() const = 0;
-
- /** Returns the highest filled slot number. */
- virtual uint32 getSlotMax() const;
-
- /** Returns the size of all existing slots + the index. */
- virtual int32 tallyUpFiles(uint32 slotSize, uint32 indexSize) const;
-
- /** Creates an index in buffer. */
- virtual void buildIndex(byte *buffer, SavePartInfo &info,
- SaveConverter *converter = 0) const;
-
- virtual bool exists(const char *name) const;
- virtual bool exists(int slot) const;
- virtual bool exists() const;
-
- virtual Common::InSaveFile *openRead(const char *name) const;
- virtual Common::InSaveFile *openRead(int slot) const;
- virtual Common::InSaveFile *openRead() const;
-
- virtual Common::OutSaveFile *openWrite(const char *name) const;
- virtual Common::OutSaveFile *openWrite(int slot) const;
- virtual Common::OutSaveFile *openWrite() const;
-
protected:
GobEngine *_vm;
char *_base;
@@ -97,8 +70,22 @@ public:
const char *extStub);
~SlotFileIndexed();
+ /** Build the save file name. */
char *build(int slot) const;
- char *build() const;
+
+ /** Returns the highest filled slot number. */
+ virtual uint32 getSlotMax() const;
+
+ /** Returns the size of all existing slots + the index. */
+ virtual int32 tallyUpFiles(uint32 slotSize, uint32 indexSize) const;
+
+ /** Creates an index in buffer. */
+ virtual void buildIndex(byte *buffer, SavePartInfo &info,
+ SaveConverter *converter = 0) const;
+
+ virtual bool exists(int slot) const;
+ virtual Common::InSaveFile *openRead(int slot) const;
+ virtual Common::OutSaveFile *openWrite(int slot) const;
protected:
char *_ext;
@@ -113,9 +100,13 @@ public:
int getSlot(int32 offset) const;
int getSlotRemainder(int32 offset) const;
- char *build(int slot) const;
+ /** Build the save file name. */
char *build() const;
+ virtual bool exists() const;
+ virtual Common::InSaveFile *openRead() const;
+ virtual Common::OutSaveFile *openWrite() const;
+
protected:
char *_ext;
};
diff --git a/engines/gob/save/saveload_v4.cpp b/engines/gob/save/saveload_v4.cpp
index 07b2300732..e73b745aae 100644
--- a/engines/gob/save/saveload_v4.cpp
+++ b/engines/gob/save/saveload_v4.cpp
@@ -459,8 +459,12 @@ SaveLoad_v4::ScreenPropsHandler::~ScreenPropsHandler() {
}
int32 SaveLoad_v4::ScreenPropsHandler::getSize() {
+ // FIXME: It makes no sense to call exists() here, since
+ // _file is a SlotFileIndexed file
+/*
if (_file->exists())
return 256000;
+*/
return 0;
}