mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
[static analysis] [WIP] fix few possible bugs
CBattleAnimations.cpp,CBitmapHandler.cpp,CGameHandler.cpp Possible null pointer dereference
This commit is contained in:
@@ -691,14 +691,14 @@ void CReverseAnimation::endAnim()
|
|||||||
|
|
||||||
void CReverseAnimation::setupSecondPart()
|
void CReverseAnimation::setupSecondPart()
|
||||||
{
|
{
|
||||||
owner->creDir[stack->ID] = !owner->creDir[stack->ID];
|
|
||||||
|
|
||||||
if(!stack)
|
if(!stack)
|
||||||
{
|
{
|
||||||
endAnim();
|
endAnim();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
owner->creDir[stack->ID] = !owner->creDir[stack->ID];
|
||||||
|
|
||||||
Point coords = CClickableHex::getXYUnitAnim(hex, owner->creDir[stack->ID], stack, owner);
|
Point coords = CClickableHex::getXYUnitAnim(hex, owner->creDir[stack->ID], stack, owner);
|
||||||
myAnim()->pos.x = coords.x;
|
myAnim()->pos.x = coords.x;
|
||||||
//creAnims[stackID]->pos.y = coords.second;
|
//creAnims[stackID]->pos.y = coords.second;
|
||||||
|
@@ -139,15 +139,18 @@ SDL_Surface * BitmapHandler::loadBitmapFromDir(std::string path, std::string fna
|
|||||||
SDL_RWFromConstMem((void*)readFile.first.get(), readFile.second),
|
SDL_RWFromConstMem((void*)readFile.first.get(), readFile.second),
|
||||||
1, // mark it for auto-deleting
|
1, // mark it for auto-deleting
|
||||||
&info.getExtension()[0] + 1); //pass extension without dot (+1 character)
|
&info.getExtension()[0] + 1); //pass extension without dot (+1 character)
|
||||||
|
if (ret)
|
||||||
if (!ret)
|
|
||||||
tlog1<<"Failed to open "<<fname<<" via SDL_Image\n";
|
|
||||||
|
|
||||||
if (ret->format->palette)
|
|
||||||
{
|
{
|
||||||
//set correct value for alpha\unused channel
|
if (ret->format->palette)
|
||||||
for (int i=0; i< ret->format->palette->ncolors; i++)
|
{
|
||||||
ret->format->palette->colors[i].unused = 255;
|
//set correct value for alpha\unused channel
|
||||||
|
for (int i=0; i< ret->format->palette->ncolors; i++)
|
||||||
|
ret->format->palette->colors[i].unused = 255;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tlog1<<"Failed to open "<<fname<<" via SDL_Image\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@@ -3348,16 +3348,17 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
|
|||||||
{
|
{
|
||||||
StartAction start_action(ba);
|
StartAction start_action(ba);
|
||||||
sendAndApply(&start_action); //start movement and attack
|
sendAndApply(&start_action); //start movement and attack
|
||||||
int startingPos = stack->position;
|
|
||||||
int distance = moveStack(ba.stackNumber, ba.destinationTile);
|
|
||||||
const CStack *stackAtEnd = gs->curB->battleGetStackByPos(ba.additionalInfo);
|
|
||||||
|
|
||||||
|
const CStack *stackAtEnd = gs->curB->battleGetStackByPos(ba.additionalInfo);
|
||||||
if(!stack || !stackAtEnd)
|
if(!stack || !stackAtEnd)
|
||||||
{
|
{
|
||||||
sendAndApply(&end_action);
|
sendAndApply(&end_action);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int distance = moveStack(ba.stackNumber, ba.destinationTile);
|
||||||
|
int startingPos = stack->position;
|
||||||
|
|
||||||
tlog5 << stack->nodeName() << " will attack " << stackAtEnd->nodeName() << std::endl;
|
tlog5 << stack->nodeName() << " will attack " << stackAtEnd->nodeName() << std::endl;
|
||||||
|
|
||||||
if(stack->position != ba.destinationTile //we wasn't able to reach destination tile
|
if(stack->position != ba.destinationTile //we wasn't able to reach destination tile
|
||||||
|
Reference in New Issue
Block a user