From 388dadd56f0b0f35e0b617d1a8ce9ab47a0c14fc Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 6 Aug 2011 13:12:22 +1000 Subject: CGE: Changed sprite shape list loading to exceed size specified by _shpCnt This fixes the problem that was happening with the new English archive, which had a bigger shape list for one of the items in the first scene. --- engines/cge/vga13h.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'engines/cge') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index de28794f3f..f34211c360 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -25,6 +25,7 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ +#include "common/array.h" #include "common/rect.h" #include "graphics/palette.h" #include "cge/general.h" @@ -358,7 +359,9 @@ Sprite *Sprite::expand() { if (*_file) { static const char *Comd[] = { "Name", "Phase", "Seq", "Near", "Take", NULL }; char line[kLineMax], fname[kPathMax]; - BitmapPtr *shplist = new BitmapPtr[_shpCnt + 1]; + + Common::Array shplist; + for (int i = 0; i < _shpCnt + 1; ++i) shplist.push_back(NULL); Seq *seq = NULL; int shpcnt = 0, seqcnt = 0, @@ -382,13 +385,18 @@ Sprite *Sprite::expand() { if (len == 0 || *line == '.') continue; - assert(shpcnt <= _shpCnt); switch (takeEnum(Comd, strtok(line, " =\t"))) { case 0 : { // Name setName(strtok(NULL, "")); break; } case 1 : { // Phase + // In case the shape index gets too high, increase the array size + while ((shpcnt + 1) >= (int)shplist.size()) { + shplist.push_back(NULL); + ++_shpCnt; + } + shplist[shpcnt++] = new Bitmap(strtok(NULL, " \t,;/"), true); break; } @@ -456,7 +464,12 @@ Sprite *Sprite::expand() { } else setSeq(getConstantSeq(_shpCnt == 1)); - setShapeList(shplist); + // Set the shape list + BitmapPtr *shapeList = new BitmapPtr[shplist.size()]; + for (uint i = 0; i < shplist.size(); ++i) + shapeList[i] = shplist[i]; + + setShapeList(shapeList); if (nea) nea[neacnt - 1]._ptr = _ext->_near = nea; -- cgit v1.2.3