diff options
author | Max Horn | 2009-05-31 17:00:07 +0000 |
---|---|---|
committer | Max Horn | 2009-05-31 17:00:07 +0000 |
commit | 78a887490357393b420e288a3318d94497e59293 (patch) | |
tree | 20c78127702af0dd6b02e2a7af0fcfe5d074a586 /engines/gob/save/savehandler.cpp | |
parent | 400d2b10af56093e4a4aea650da392bd2c152af8 (diff) | |
download | scummvm-rg350-78a887490357393b420e288a3318d94497e59293.tar.gz scummvm-rg350-78a887490357393b420e288a3318d94497e59293.tar.bz2 scummvm-rg350-78a887490357393b420e288a3318d94497e59293.zip |
GOB: Untangled SlotFileIndexed and SlotFileStatic (ATTENTION: This uncovered something which seems to me a bug in SaveLoad_v4::ScreenPropsHandler::getSize)
svn-id: r41078
Diffstat (limited to 'engines/gob/save/savehandler.cpp')
-rw-r--r-- | engines/gob/save/savehandler.cpp | 64 |
1 files changed, 21 insertions, 43 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); } |