[Scummvm-devel] Savefile changes (ATTN porters)

Max Horn max at quendi.de
Sun Feb 18 03:40:00 CET 2007


Hi folks,

as you may have noticed, I made two changes to the savefile system  
today:

1) I introduced OutSaveFile::finalize(). This method is supposed to  
be called just before client code disposes a OutSaveFile --  
essentially in the spot were you would have called flush. In fact the  
default implementation of this method just calls flush().

The reason behind this is mainly to clarify the semantics (helpful  
for OutSaveFile implementations): If finalize() is called, you can  
assume that no further writes will occur. With flush(), this is *not*  
the case (although some implementation behaved as if it was. Which,  
by luck, worked so far).


2) More importantly, I rewrote the code for gzipped savegames. Short  
version: It now works as a wrapper around arbitrary savegame  
implementations. Thus, any port can get it for free now, provided  
zlib is available.

Long version: The old implementation used the gzopen/gzread/etc. API  
in zlib, which in turn was strictly tied to fopen/fread/etc.. Plus,  
it was not really to lift that code, even if gzread was available on  
your port.
With the new code, it should hopefully be a piece of cake for all  
ports to add support for gzipped savegames, provided zlib is  
available: Just include "backends/saves/compressed/compressed- 
saves.h", and then use the wrapInSaveFile() / wrapOutSaveFile()  
functions. They are even documented *gasp*, and should actually be  
fairly obvious to use. But you can also find a usage example in  
"backends/saves/default/default-saves.cpp".


What I am hoping for is that as many ports as possible make use of  
this, for maximal portability of savegames. If some ports can't do  
that, I'd be curious to learn the reasons. No zlib available? Code  
uses too many resources? Something else making it not work? Please  
tell me why you can't use it, and I'll be happy to work with you on  
removing those obstacles, if possible

Finally, note that some ports (in particular, the PS2 and the DC  
port) already implement custom savegame formats. I'd would be nice if  
we could switch those over, too.
The DC port justs uses zlib's (un)compress -- with some luck, the new  
compression code can already open such savegames (in theory it should  
be able to load both the gzip and the zlib format...). Alas, I can't  
test that.


Cheers,
Max





More information about the Scummvm-devel mailing list