Last part of patch #1163026 (Thumbnails for ScummEngine)

svn-id: r17982
This commit is contained in:
Max Horn 2005-05-09 00:09:01 +00:00
parent 20c8944189
commit c33cc2ce85
7 changed files with 320 additions and 10 deletions

View file

@ -83,6 +83,7 @@ bool ScummEngine::saveState(int slot, bool compat) {
hdr.ver = TO_LE_32(CURRENT_VER);
out->write(&hdr, sizeof(hdr));
saveThumbnail(out);
Serializer ser(0, out, CURRENT_VER);
saveOrLoad(&ser, CURRENT_VER);
@ -126,6 +127,18 @@ bool ScummEngine::loadState(int slot, bool compat) {
delete in;
return false;
}
// Sine version 52 a thumbnail is saved directly after the header
if (hdr.ver >= VER(52)) {
uint32 type = in->readUint32BE();
if (type != MKID('THMB')) {
warning("Can not load thumbnail");
delete in;
return false;
}
uint32 size = in->readUint32BE();
in->skip(size - 8);
}
// Due to a bug in scummvm up to and including 0.3.0, save games could be saved
// in the V8/V9 format but were tagged with a V7 mark. Ouch. So we just pretend V7 == V8 here
@ -387,6 +400,36 @@ bool ScummEngine::getSavegameName(int slot, char *desc) {
return true;
}
Graphics::Surface *ScummEngine::loadThumbnailFromSlot(int slot) {
char filename[256];
InSaveFile *in;
SaveGameHeader hdr;
int len;
makeSavegameName(filename, slot, false);
if (!(in = _saveFileMan->openForLoading(filename))) {
return 0;
}
len = in->read(&hdr, sizeof(hdr));
if (len != sizeof(hdr) || hdr.type != MKID('SCVM')) {
delete in;
return 0;
}
if (hdr.ver > CURRENT_VER)
hdr.ver = TO_LE_32(hdr.ver);
if (hdr.ver < VER(52)) {
delete in;
return 0;
}
Graphics::Surface *thumb = loadThumbnail(in);
delete in;
return thumb;
}
void ScummEngine::saveOrLoad(Serializer *s, uint32 savegameVersion) {
const SaveLoadEntry objectEntries[] = {
MKLINE(ObjectData, OBIMoffset, sleUint32, VER(8)),