Animations on objects/persons setup by cutaways can still be played after the end of the cutscene. (the only ?) one room in which this is reproducable is the first time you talk to the Oracle (first c44, then c47).

As a Cutaway object is created for each cutscene, the _cutAnim member should be moved to an more "persistant" object.
Otherwise we're reading data from free'd memory...

svn-id: r13488
This commit is contained in:
Gregory Montoir 2004-04-06 20:15:19 +00:00
parent 36d667b2b5
commit 4fef6d8972
4 changed files with 20 additions and 16 deletions

View File

@ -1229,23 +1229,20 @@ void Cutaway::talk(char *nextFilename) {
int Cutaway::makeComplexAnimation(int16 currentImage, Cutaway::CutawayAnim *objAnim, int frameCount) {
int frameIndex[256];
int i;
int bobNum = objAnim[0].object;
assert(bobNum < 21);
assert(frameCount < 30);
AnimFrame cutAnim[30];
memset(frameIndex, 0, sizeof(frameIndex));
debug(6, "[Cutaway::makeComplexAnimation] currentImage = %i", currentImage);
BobSlot *bob = _vm->graphics()->bob(bobNum);
bob->xflip = objAnim[0].flip;
for (i = 0; i < frameCount; i++) {
_cutAnim[bobNum][i].frame = objAnim[i].unpackFrame;
_cutAnim[bobNum][i].speed = objAnim[i].speed;
cutAnim[i].frame = objAnim[i].unpackFrame;
cutAnim[i].speed = objAnim[i].speed;
frameIndex[objAnim[i].unpackFrame] = 1;
}
_cutAnim[bobNum][frameCount].frame = 0;
_cutAnim[bobNum][frameCount].speed = 0;
cutAnim[frameCount].frame = 0;
cutAnim[frameCount].speed = 0;
int nextFrameIndex = 1;
@ -1254,20 +1251,17 @@ int Cutaway::makeComplexAnimation(int16 currentImage, Cutaway::CutawayAnim *objA
frameIndex[i] = nextFrameIndex++;
for (i = 0; i < frameCount; i++) {
_cutAnim[bobNum][i].frame = currentImage + frameIndex[objAnim[i].unpackFrame];
//debug(6, "_cutAnim[%i][%i].frame = %i", bobNum, i, _cutAnim[bobNum][i].frame);
cutAnim[i].frame = currentImage + frameIndex[objAnim[i].unpackFrame];
}
for (i = 1; i < 256; i++) {
if (frameIndex[i]) {
currentImage++;
//debug(6, "bankUnpack(%i, %i, %i)", i, currentImage, objAnim[0].bank);
_vm->bankMan()->unpack(i, currentImage, objAnim[0].bank);
}
}
bob->animString(_cutAnim[bobNum]);
_vm->graphics()->setBobCutawayAnim(objAnim[0].object, objAnim[0].flip, cutAnim, frameCount + 1);
return currentImage;
}

View File

@ -194,8 +194,6 @@ class Cutaway {
int16 _currentImage;
AnimFrame _cutAnim[21][30];
Cutaway(const char *filename,
QueenEngine *vm);
~Cutaway();

View File

@ -600,6 +600,13 @@ void Graphics::setupNewRoom(const char *room, uint16 roomNum, int16 *furniture,
}
}
void Graphics::setBobCutawayAnim(uint16 bobNum, bool xflip, const AnimFrame *af, uint8 frameCount) {
assert(bobNum < 21 && frameCount < 30);
memcpy(_cutAnim[bobNum], af, sizeof(AnimFrame) * frameCount);
_bobs[bobNum].xflip = xflip;
_bobs[bobNum].animString(_cutAnim[bobNum]);
}
void Graphics::fillAnimBuffer(const char *anim, AnimFrame *af) {
for (;;) {
// anim frame format is "%3hu,%3hu," (frame number, frame speed)

View File

@ -115,6 +115,7 @@ public:
void setupNewRoom(const char *room, uint16 roomNum, int16 *furniture, uint16 furnitureCount);
void setBobCutawayAnim(uint16 bobNum, bool xflip, const AnimFrame *af, uint8 frameCount);
void fillAnimBuffer(const char *anim, AnimFrame *af);
uint16 countAnimFrames(const char *anim);
void setupObjectAnim(const GraphicData *gd, uint16 firstImage, uint16 bobNum, bool visible);
@ -165,8 +166,12 @@ private:
//! used to scale a BobFrame
BobFrame _shrinkBuffer;
//! in-game objects/persons animations
AnimFrame _newAnim[17][30];
//! cutaway objects/persons animations
AnimFrame _cutAnim[21][30];
uint16 _personFrames[4];
//! Number of animated furniture in current room