From 5ba36c8216e1a63064b699c6e404514dca180024 Mon Sep 17 00:00:00 2001 From: Arnaud Boutonné Date: Sat, 13 Feb 2010 21:59:45 +0000 Subject: Fascination: - Fix a potential bug in winDraw - Add a hack (and a todo) to work around the missing texts and windows in Amiga, Atari and early PC floppy version. svn-id: r48053 --- engines/gob/draw.cpp | 2 +- engines/gob/resources.cpp | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'engines/gob') diff --git a/engines/gob/draw.cpp b/engines/gob/draw.cpp index 5a385f5a64..75177ff02d 100644 --- a/engines/gob/draw.cpp +++ b/engines/gob/draw.cpp @@ -974,7 +974,7 @@ void Draw::winDraw(int16 fct) { case DRAW_LOADSPRITE: // 5 - Uncompress and load a sprite // TODO: check the implementation, currently dirty cut and paste of DRAW_SPRITE code - resource = _vm->_game->_resources->getResource((uint16) _spriteLeft, + resource = _vm->_game->_resources->getResource((_spriteLeft & 0x3FFF), &_spriteRight, &_spriteBottom); if (!resource) { diff --git a/engines/gob/resources.cpp b/engines/gob/resources.cpp index 9e2817e4bc..ee36a1f7ce 100644 --- a/engines/gob/resources.cpp +++ b/engines/gob/resources.cpp @@ -277,6 +277,7 @@ bool Resources::loadTOTResourceTable() { _totResStart = totProps.scriptEnd; _totSize = stream->size() - _totResStart; + if (_totSize <= 0) return false; @@ -571,8 +572,14 @@ TextItem *Resources::getTextItem(uint16 id) const { if ((totItem.offset == 0xFFFF) || (totItem.size == 0)) return 0; - if ((totItem.offset + totItem.size) > (_totTextTable->size)) - return 0; + if ((totItem.offset + totItem.size) > (_totTextTable->size)) { +// HACK: Some Fascination versions (Amiga, Atari and first PC floppies) have a different header, which is a problem here. +// TODO: Handle that in a proper way + if ((_vm->getGameType() == kGameTypeFascination) & (_totTextTable->size < 0)) + warning("totTextTable with negative size id:%d offset:%d in file %s : (size: %d)", id, totItem.offset, totItem.size, _totFile.c_str(), _totTextTable->size); + else + return 0; + } return new TextItem(_totTextTable->data + totItem.offset, totItem.size); } @@ -701,8 +708,10 @@ byte *Resources::getTOTData(TOTResourceItem &totItem) const { int32 offset = _totResourceTable->dataOffset + totItem.offset - _totResStart; - if ((offset < 0) || (((uint32) (offset + totItem.size)) > _totSize)) + if ((offset < 0) || (((uint32) (offset + totItem.size)) > _totSize)) { + warning("Skipping data id:%d offset:%d size :%d in file %s : out of _totTextTable", totItem.index, totItem.offset, totItem.size, _totFile.c_str()); return 0; + } return _totData + offset; } -- cgit v1.2.3