From 3569b496622a61eb7d82c3033b188c4cd0426ae6 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 23 Jun 2010 11:22:44 +0000 Subject: Changed some asserts to warnings svn-id: r50175 --- engines/m4/assets.cpp | 7 ++++++- engines/m4/graphics.cpp | 6 ++++-- engines/m4/sprite.cpp | 5 ++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/engines/m4/assets.cpp b/engines/m4/assets.cpp index 1f3cf278ae..c329373add 100644 --- a/engines/m4/assets.cpp +++ b/engines/m4/assets.cpp @@ -320,7 +320,12 @@ void SpriteAsset::loadFrameHeader(SpriteAssetFrame &frameHeader, bool isBigEndia } M4Sprite *SpriteAsset::getFrame(int frameIndex) { - return _frames[frameIndex].frame; + if ((uint)frameIndex < _frames.size()) { + return _frames[frameIndex].frame; + } else { + warning("SpriteAsset::getFrame: Invalid frame %d, out of %d", frameIndex, _frames.size()); + return _frames[_frames.size() - 1].frame; + } } void SpriteAsset::loadStreamingFrame(M4Sprite *frame, int frameIndex, int destX, int destY) { diff --git a/engines/m4/graphics.cpp b/engines/m4/graphics.cpp index b0bc8bbc0c..85d138328d 100644 --- a/engines/m4/graphics.cpp +++ b/engines/m4/graphics.cpp @@ -920,8 +920,10 @@ void M4Surface::translate(RGBList *list, bool isTransparent) { for (int i = 0; i < width() * height(); ++i, ++p) { if (!isTransparent || (*p != TRANSPARENT_COLOUR_INDEX)) { - assert(*p < list->size()); - *p = palIndexes[*p]; + if (*p < list->size()) { + warning("Pal pointer exceeds list size"); + *p = palIndexes[*p]; + } } } diff --git a/engines/m4/sprite.cpp b/engines/m4/sprite.cpp index 553b27dd9a..55de6714d1 100644 --- a/engines/m4/sprite.cpp +++ b/engines/m4/sprite.cpp @@ -182,7 +182,10 @@ void M4Sprite::loadMadsSprite(Common::SeekableReadStream* source) { // Check if we need to scan forward to find the end of the line if (!newLine) { do { - assert(!source->eos()); + if (source->eos()) { + warning("M4Sprite::loadMadsSprite: unexpected end of data"); + break; + } } while (source->readByte() != 0xff); } } -- cgit v1.2.3