static SaveGameHeader LoadSaveGameHeader(BinaryReader reader)
{
var hdr = new SaveGameHeader();
hdr.Type = ScummHelper.SwapBytes(reader.ReadUInt32());
if (hdr.Type != ScummHelper.MakeTag('S', 'C', 'V', 'M'))
throw new NotSupportedException("Invalid savegame");
hdr.Size = reader.ReadUInt32();
hdr.Version = reader.ReadUInt32();
// In older versions of ScummVM, the header version was not endian safe.
// We account for that by retrying once with swapped byte order in case
// we see a version that is higher than anything we'd expect...
if (hdr.Version > 0xFFFFFF)
hdr.Version = ScummHelper.SwapBytes(hdr.Version);
// Reject save games which are too old or too new. Note that
// We do not really support V7 games, but still accept them here
// to work around a bug from the stone age (see below for more
// information).
if (hdr.Version < 7 || hdr.Version > CurrentVersion)
{
throw new NotSupportedException("Invalid version");
}
hdr.Name = reader.ReadBytes(32).GetText();
// Since version 52 a thumbnail is saved directly after the header.
if (hdr.Version >= 52)
{
// Prior to version 75 we always required an thumbnail to be present
if (hdr.Version <= 74)
{
if (!CheckThumbnailHeader(reader))
{
throw new NotSupportedException("Cannot load thumbnail");
}
}
SkipThumbnail(reader);
}
return hdr;
}