diff options
author | Alyssa Milburn | 2010-12-09 21:25:21 +0000 |
---|---|---|
committer | Alyssa Milburn | 2010-12-09 21:25:21 +0000 |
commit | 4393ef1bd5c607df678d78b56dd9c1e515dae84f (patch) | |
tree | a4debd3b20197a0f25b259f08f368b6bcc35f094 /engines/mohawk/livingbooks.cpp | |
parent | 0257f2a2171349446e820e7b21334b6d71016b3c (diff) | |
download | scummvm-rg350-4393ef1bd5c607df678d78b56dd9c1e515dae84f.tar.gz scummvm-rg350-4393ef1bd5c607df678d78b56dd9c1e515dae84f.tar.bz2 scummvm-rg350-4393ef1bd5c607df678d78b56dd9c1e515dae84f.zip |
MOHAWK: Fix LBPaletteItem to handle variable-size palettes
svn-id: r54846
Diffstat (limited to 'engines/mohawk/livingbooks.cpp')
-rw-r--r-- | engines/mohawk/livingbooks.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/engines/mohawk/livingbooks.cpp b/engines/mohawk/livingbooks.cpp index e750e2c2f2..6d93ec4151 100644 --- a/engines/mohawk/livingbooks.cpp +++ b/engines/mohawk/livingbooks.cpp @@ -2692,19 +2692,29 @@ void LBGroupItem::stop() { LBPaletteItem::LBPaletteItem(MohawkEngine_LivingBooks *vm, Common::Rect rect) : LBItem(vm, rect) { debug(3, "new LBPaletteItem"); + _fadeInStart = 0; + _palette = NULL; +} + +LBPaletteItem::~LBPaletteItem() { + delete[] _palette; } void LBPaletteItem::readData(uint16 type, uint16 size, Common::SeekableSubReadStreamEndian *stream) { switch (type) { case kLBPaletteXData: { - assert(size == 8 + 255 * 4); + assert(size >= 8); _fadeInPeriod = stream->readUint16(); _fadeInStep = stream->readUint16(); _drawStart = stream->readUint16(); _drawCount = stream->readUint16(); - stream->read(_palette, 255 * 4); + if (_drawStart + _drawCount > 256) + error("encountered palette trying to set more than 256 colours"); + assert(size == 8 + _drawCount * 4); + _palette = new byte[_drawCount * 4]; + stream->read(_palette, _drawCount * 4); } break; @@ -2728,6 +2738,9 @@ bool LBPaletteItem::togglePlaying(bool playing, bool restart) { void LBPaletteItem::update() { if (_fadeInStart) { + if (!_palette) + error("LBPaletteItem had no palette on startup"); + uint32 elapsedTime = _vm->_system->getMillis() - _fadeInStart; uint32 divTime = elapsedTime / _fadeInStep; |