From 213c09c211d993a6db3dfc158a091484418563db Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Sat, 27 Dec 2008 19:53:54 +0000 Subject: Adding a magic id and a version number to the PaletteLUT cache svn-id: r35582 --- graphics/dither.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/graphics/dither.cpp b/graphics/dither.cpp index baeadb72cb..ff58961a17 100644 --- a/graphics/dither.cpp +++ b/graphics/dither.cpp @@ -22,6 +22,7 @@ * $Id$ */ +#include "common/endian.h" #include "graphics/dither.h" namespace Graphics { @@ -163,6 +164,8 @@ bool PaletteLUT::save(Common::WriteStream &stream) { while (_got < _dim1) buildNext(); + stream.writeUint32BE(MKID_BE('PLUT')); // Magic + stream.writeUint32BE(0); // Version stream.writeByte(_depth1); if (stream.write(_realPal, 768) != 768) return false; @@ -180,12 +183,20 @@ bool PaletteLUT::save(Common::WriteStream &stream) { } bool PaletteLUT::load(Common::SeekableReadStream &stream) { - // _realPal + _lutPal + _lut + _depth1 - int32 needSize = 768 + 768 + _dim3 + 1; + // _realPal + _lutPal + _lut + _depth1 + magic + version + int32 needSize = 768 + 768 + _dim3 + 1 + 4 + 4; if ((stream.size() - stream.pos()) < needSize) return false; + // Magic + if (stream.readUint32BE() != MKID_BE('PLUT')) + return false; + + // Version + if (stream.readUint32BE() != 0) + return false; + byte depth1 = stream.readByte(); if (depth1 != _depth1) -- cgit v1.2.3