diff options
author | Paul Gilbert | 2011-08-06 13:12:22 +1000 |
---|---|---|
committer | Paul Gilbert | 2011-08-06 13:16:18 +1000 |
commit | 388dadd56f0b0f35e0b617d1a8ce9ab47a0c14fc (patch) | |
tree | a98b2758a6493227ff6eb6bd6aa1d85517efc494 /engines | |
parent | bbc51fa44342f72fd74a5eeabbfad08c4d345a09 (diff) | |
download | scummvm-rg350-388dadd56f0b0f35e0b617d1a8ce9ab47a0c14fc.tar.gz scummvm-rg350-388dadd56f0b0f35e0b617d1a8ce9ab47a0c14fc.tar.bz2 scummvm-rg350-388dadd56f0b0f35e0b617d1a8ce9ab47a0c14fc.zip |
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.
Diffstat (limited to 'engines')
-rw-r--r-- | engines/cge/vga13h.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
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<BitmapPtr> 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; |