[Scummvm-cvs-logs] SF.net SVN: scummvm:[41078] scummvm/trunk/engines/gob/save

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sun May 31 19:00:07 CEST 2009


Revision: 41078
          http://scummvm.svn.sourceforge.net/scummvm/?rev=41078&view=rev
Author:   fingolfin
Date:     2009-05-31 17:00:07 +0000 (Sun, 31 May 2009)

Log Message:
-----------
GOB: Untangled SlotFileIndexed and SlotFileStatic (ATTENTION: This uncovered something which seems to me a bug in SaveLoad_v4::ScreenPropsHandler::getSize)

Modified Paths:
--------------
    scummvm/trunk/engines/gob/save/savehandler.cpp
    scummvm/trunk/engines/gob/save/savehandler.h
    scummvm/trunk/engines/gob/save/saveload_v4.cpp

Modified: scummvm/trunk/engines/gob/save/savehandler.cpp
===================================================================
--- scummvm/trunk/engines/gob/save/savehandler.cpp	2009-05-31 16:59:45 UTC (rev 41077)
+++ scummvm/trunk/engines/gob/save/savehandler.cpp	2009-05-31 17:00:07 UTC (rev 41078)
@@ -50,7 +50,7 @@
 	return _base;
 }
 
-uint32 SlotFile::getSlotMax() const {
+uint32 SlotFileIndexed::getSlotMax() const {
 	Common::SaveFileManager *saveMan = g_system->getSavefileManager();
 	Common::InSaveFile *in;
 
@@ -73,7 +73,7 @@
 	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 @@
 	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 @@
 	}
 }
 
-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 @@
 	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 @@
 	return -1;
 }
 
-char *SlotFileStatic::build(int slot) const {
-	return 0;
-}
-
 char *SlotFileStatic::build() const {
 	return strdupcat(_base, _ext);
 }

Modified: scummvm/trunk/engines/gob/save/savehandler.h
===================================================================
--- scummvm/trunk/engines/gob/save/savehandler.h	2009-05-31 16:59:45 UTC (rev 41077)
+++ scummvm/trunk/engines/gob/save/savehandler.h	2009-05-31 17:00:07 UTC (rev 41078)
@@ -56,10 +56,22 @@
 	/** Calculates the slot remainder, for error checking. */
 	virtual int getSlotRemainder(int32 offset) const = 0;
 
+protected:
+	GobEngine *_vm;
+	char *_base;
+
+	uint32 _slotCount;
+};
+
+/** An indexed slot file ("foobar.s00", "foobar.s01", ...). */
+class SlotFileIndexed : public SlotFile {
+public:
+	SlotFileIndexed(GobEngine *vm, uint32 slotCount, const char *base,
+			const char *extStub);
+	~SlotFileIndexed();
+
 	/** Build the save file name. */
-	virtual char *build(int slot) const = 0;
-	/** Build the save file name. */
-	virtual char *build() const = 0;
+	char *build(int slot) const;
 
 	/** Returns the highest filled slot number. */
 	virtual uint32 getSlotMax() const;
@@ -71,36 +83,11 @@
 	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;
-
-	uint32 _slotCount;
-};
-
-/** An indexed slot file ("foobar.s00", "foobar.s01", ...). */
-class SlotFileIndexed : public SlotFile {
-public:
-	SlotFileIndexed(GobEngine *vm, uint32 slotCount, const char *base,
-			const char *extStub);
-	~SlotFileIndexed();
-
-	char *build(int slot) const;
-	char *build() const;
-
-protected:
 	char *_ext;
 };
 
@@ -113,9 +100,13 @@
 	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;
 };

Modified: scummvm/trunk/engines/gob/save/saveload_v4.cpp
===================================================================
--- scummvm/trunk/engines/gob/save/saveload_v4.cpp	2009-05-31 16:59:45 UTC (rev 41077)
+++ scummvm/trunk/engines/gob/save/saveload_v4.cpp	2009-05-31 17:00:07 UTC (rev 41078)
@@ -459,8 +459,12 @@
 }
 
 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;
 }


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list