SCUMM: HE: Another attempt at fixing Coverity #1544404

This time without returning pointers for local variables within another function...
This commit is contained in:
AndywinXp 2024-04-29 23:14:50 +02:00
parent 947ac79356
commit 502a0df328
3 changed files with 13 additions and 17 deletions

View File

@ -1671,21 +1671,6 @@ void Sprite::buildActiveSpriteList() {
}
}
WizSimpleBitmap *Sprite::getSimpleBitmapForSprite(const SpriteInfo *spritePtr) {
WizSimpleBitmap simpleBitmap;
int image = spritePtr->image;
int group = spritePtr->group;
int groupImage = _groupTable[group].image;
if (image != 0 && group != 0 && groupImage != 0) {
if (_vm->_wiz->dwSetSimpleBitmapStructFromImage(groupImage, 0, &simpleBitmap)) {
return &simpleBitmap;
}
}
return nullptr;
}
void Sprite::renderSprites(bool negativeOrPositiveRender) {
int image, group, shadow, state, angle;
int sourceImage, scale, destImageNumber;
@ -1952,9 +1937,17 @@ void Sprite::renderSprites(bool negativeOrPositiveRender) {
}
WizSimpleBitmap *bitmapPtr = nullptr;
WizSimpleBitmap simpleBitmap;
if (_vm->_game.heversion >= 95) {
bitmapPtr = getSimpleBitmapForSprite(spritePtr[i]);
// This was originally an inlined function, getSimpleBitmapForSprite().
// I got fed up with the fact it returned the address of a local WizSimpleBitmap variable,
// and it was used here and only here, so I decided to get rid of it and just unroll it...
if (spritePtr[i]->image != 0 && spritePtr[i]->group != 0 && _groupTable[group].image != 0) {
if (_vm->_wiz->dwSetSimpleBitmapStructFromImage(_groupTable[group].image, 0, &simpleBitmap)) {
bitmapPtr = &simpleBitmap;
}
}
}
if (simpleDraw) {

View File

@ -237,7 +237,6 @@ public:
bool doesRectIntersectUpdateAreas(const Common::Rect *rectPtr);
void checkForForcedRedraws(bool checkOnlyPositivePriority);
void buildActiveSpriteList();
WizSimpleBitmap *getSimpleBitmapForSprite(const SpriteInfo *spritePtr);
void renderSprites(bool negativeOrPositiveRender);
void runSpriteEngines();

View File

@ -268,6 +268,10 @@ struct WizSimpleBitmap {
WizRawPixel *bufferPtr;
int32 bitmapWidth;
int32 bitmapHeight;
WizSimpleBitmap() {
}
};
struct WizMultiTypeBitmap {