[Scummvm-cvs-logs] SF.net SVN: scummvm: [25660] scummvm/trunk
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Sat Feb 17 19:55:52 CET 2007
Revision: 25660
http://scummvm.svn.sourceforge.net/scummvm/?rev=25660&view=rev
Author: fingolfin
Date: 2007-02-17 10:55:51 -0800 (Sat, 17 Feb 2007)
Log Message:
-----------
Added finalize() method to Common::OutSaveFile (which by default just flushes the stream), changed engines to call that before deleting OutSaveFile instances (instead of just flushing)
Modified Paths:
--------------
scummvm/trunk/common/savefile.h
scummvm/trunk/engines/agi/savegame.cpp
scummvm/trunk/engines/agos/saveload.cpp
scummvm/trunk/engines/gob/gob.cpp
scummvm/trunk/engines/kyra/saveload.cpp
scummvm/trunk/engines/queen/queen.cpp
scummvm/trunk/engines/saga/saveload.cpp
scummvm/trunk/engines/scumm/saveload.cpp
scummvm/trunk/engines/sky/control.cpp
scummvm/trunk/engines/sword1/control.cpp
scummvm/trunk/engines/sword2/saveload.cpp
scummvm/trunk/engines/touche/saveload.cpp
Modified: scummvm/trunk/common/savefile.h
===================================================================
--- scummvm/trunk/common/savefile.h 2007-02-17 18:52:21 UTC (rev 25659)
+++ scummvm/trunk/common/savefile.h 2007-02-17 18:55:51 UTC (rev 25660)
@@ -41,7 +41,20 @@
* That typically means "save games", but also includes things like the
* IQ points in Indy3.
*/
-class OutSaveFile : public WriteStream {};
+class OutSaveFile : public WriteStream {
+public:
+ /**
+ * Close this savefile, to be called right before destruction of this
+ * savefile. The idea is that this ways, I/O errors that occur
+ * during closing/flushing of the file can still be handled by the
+ * game engine.
+ *
+ * By default, this just flushes the stream.
+ */
+ virtual void finalize() {
+ flush();
+ }
+};
/**
* Convenience intermediate class, to be removed.
Modified: scummvm/trunk/engines/agi/savegame.cpp
===================================================================
--- scummvm/trunk/engines/agi/savegame.cpp 2007-02-17 18:52:21 UTC (rev 25659)
+++ scummvm/trunk/engines/agi/savegame.cpp 2007-02-17 18:55:51 UTC (rev 25660)
@@ -200,7 +200,7 @@
}
out->writeByte(0);
- out->flush();
+ out->finalize();
if (out->ioFailed())
warning("Can't write file '%s'. (Disk full?)", fileName);
else
Modified: scummvm/trunk/engines/agos/saveload.cpp
===================================================================
--- scummvm/trunk/engines/agos/saveload.cpp 2007-02-17 18:52:21 UTC (rev 25659)
+++ scummvm/trunk/engines/agos/saveload.cpp 2007-02-17 18:55:51 UTC (rev 25660)
@@ -649,7 +649,7 @@
}
bool AGOSEngine::saveGame_e1(const char *filename) {
- Common::WriteStream *f;
+ Common::OutSaveFile *f;
uint item_index, num_item, i;
TimeEvent *te;
uint32 curTime = 0;
@@ -717,7 +717,7 @@
f->writeUint16BE(readVariable(i));
}
- f->flush();
+ f->finalize();
bool result = !f->ioFailed();
delete f;
@@ -873,7 +873,7 @@
}
bool AGOSEngine::saveGame(uint slot, const char *caption) {
- Common::WriteStream *f;
+ Common::OutSaveFile *f;
uint item_index, num_item, i, j;
TimeEvent *te;
uint32 curTime = 0;
@@ -988,7 +988,7 @@
f->writeUint16BE(_superRoomNumber);
}
- f->flush();
+ f->finalize();
bool result = !f->ioFailed();
delete f;
Modified: scummvm/trunk/engines/gob/gob.cpp
===================================================================
--- scummvm/trunk/engines/gob/gob.cpp 2007-02-17 18:52:21 UTC (rev 25659)
+++ scummvm/trunk/engines/gob/gob.cpp 2007-02-17 18:55:51 UTC (rev 25660)
@@ -295,7 +295,7 @@
retSize = writeDataEndian(*out, buf, _global->_inter_variablesSizes + dataVar, size);
- out->flush();
+ out->finalize();
if (out->ioFailed() || (retSize != size))
warning("Can't write file \"%s\"", sName);
@@ -329,7 +329,7 @@
}
writeDataEndian(*out, _saveIndex + saveSlot * 40, _saveIndexSizes + saveSlot * 40, 40);
writeDataEndian(*out, varBuf, sizeBuf, size);
- out->flush();
+ out->finalize();
if (out->ioFailed()) {
warning("Can't save to slot %d", saveSlot);
return false;
Modified: scummvm/trunk/engines/kyra/saveload.cpp
===================================================================
--- scummvm/trunk/engines/kyra/saveload.cpp 2007-02-17 18:52:21 UTC (rev 25659)
+++ scummvm/trunk/engines/kyra/saveload.cpp 2007-02-17 18:55:51 UTC (rev 25660)
@@ -362,7 +362,7 @@
out->writeByte(_curSfxFile);
- out->flush();
+ out->finalize();
// check for errors
if (out->ioFailed())
Modified: scummvm/trunk/engines/queen/queen.cpp
===================================================================
--- scummvm/trunk/engines/queen/queen.cpp 2007-02-17 18:52:21 UTC (rev 25659)
+++ scummvm/trunk/engines/queen/queen.cpp 2007-02-17 18:55:51 UTC (rev 25660)
@@ -249,7 +249,7 @@
// write save data
file->write(saveData, dataSize);
- file->flush();
+ file->finalize();
// check for errors
if (file->ioFailed()) {
Modified: scummvm/trunk/engines/saga/saveload.cpp
===================================================================
--- scummvm/trunk/engines/saga/saveload.cpp 2007-02-17 18:52:21 UTC (rev 25659)
+++ scummvm/trunk/engines/saga/saveload.cpp 2007-02-17 18:55:51 UTC (rev 25660)
@@ -211,7 +211,7 @@
out->writeSint16LE(_isoMap->getMapPosition().x);
out->writeSint16LE(_isoMap->getMapPosition().y);
- out->flush();
+ out->finalize();
// TODO: Check out->ioFailed()
Modified: scummvm/trunk/engines/scumm/saveload.cpp
===================================================================
--- scummvm/trunk/engines/scumm/saveload.cpp 2007-02-17 18:52:21 UTC (rev 25659)
+++ scummvm/trunk/engines/scumm/saveload.cpp 2007-02-17 18:55:51 UTC (rev 25660)
@@ -109,7 +109,7 @@
Serializer ser(0, out, CURRENT_VER);
saveOrLoad(&ser);
- out->flush();
+ out->finalize();
if (out->ioFailed()) {
delete out;
debug(1, "State save as '%s' FAILED", filename);
Modified: scummvm/trunk/engines/sky/control.cpp
===================================================================
--- scummvm/trunk/engines/sky/control.cpp 2007-02-17 18:52:21 UTC (rev 25659)
+++ scummvm/trunk/engines/sky/control.cpp 2007-02-17 18:55:51 UTC (rev 25660)
@@ -1138,7 +1138,7 @@
bool ioFailed = true;
if (outf) {
outf->write(tmpBuf, tmpPos - tmpBuf);
- outf->flush();
+ outf->finalize();
if (!outf->ioFailed())
ioFailed = false;
delete outf;
@@ -1165,7 +1165,7 @@
uint32 fSize = prepareSaveData(saveData);
outf->write(saveData, fSize);
- outf->flush();
+ outf->finalize();
if (outf->ioFailed())
displayMessage(0, "Unable to write autosave file '%s' in directory '%s'. Disk full?", fName, _saveFileMan->getSavePath());
@@ -1187,7 +1187,7 @@
uint32 fSize = prepareSaveData(saveData);
uint32 writeRes = outf->write(saveData, fSize);
- outf->flush();
+ outf->finalize();
if (outf->ioFailed())
writeRes = 0;
free(saveData);
Modified: scummvm/trunk/engines/sword1/control.cpp
===================================================================
--- scummvm/trunk/engines/sword1/control.cpp 2007-02-17 18:52:21 UTC (rev 25659)
+++ scummvm/trunk/engines/sword1/control.cpp 2007-02-17 18:55:51 UTC (rev 25660)
@@ -763,7 +763,7 @@
else
outf->writeByte(255);
}
- outf->flush();
+ outf->finalize();
if (outf->ioFailed())
displayMessage(0, "Can't write to SAVEGAME.INF in directory '%s'. Device full?", _saveFileMan->getSavePath());
delete outf;
@@ -958,7 +958,7 @@
uint32 *playerRaw = (uint32*)cpt;
for (uint32 cnt2 = 0; cnt2 < playerSize; cnt2++)
outf->writeUint32LE(playerRaw[cnt2]);
- outf->flush();
+ outf->finalize();
if (outf->ioFailed())
displayMessage(0, "Couldn't write to file '%s' in directory '%s'. Device full?", fName, _saveFileMan->getSavePath());
delete outf;
Modified: scummvm/trunk/engines/sword2/saveload.cpp
===================================================================
--- scummvm/trunk/engines/sword2/saveload.cpp 2007-02-17 18:52:21 UTC (rev 25659)
+++ scummvm/trunk/engines/sword2/saveload.cpp 2007-02-17 18:55:51 UTC (rev 25660)
@@ -132,7 +132,7 @@
}
out->write(buffer, bufferSize);
- out->flush();
+ out->finalize();
if (!out->ioFailed()) {
delete out;
Modified: scummvm/trunk/engines/touche/saveload.cpp
===================================================================
--- scummvm/trunk/engines/touche/saveload.cpp 2007-02-17 18:52:21 UTC (rev 25659)
+++ scummvm/trunk/engines/touche/saveload.cpp 2007-02-17 18:55:51 UTC (rev 25660)
@@ -344,7 +344,7 @@
strncpy(headerDescription, description, kGameStateDescriptionLen - 1);
f->write(headerDescription, kGameStateDescriptionLen);
saveGameStateData(f);
- f->flush();
+ f->finalize();
if (!f->ioFailed()) {
saveOk = true;
} else {
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