mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-25 21:38:59 +02:00
[static analysis] [WIP] fix few possible bugs
CBattleAnimations.cpp,CBitmapHandler.cpp,CGameHandler.cpp Possible null pointer dereference
This commit is contained in:
parent
554a98dbd7
commit
2b2b02cccc
@ -691,14 +691,14 @@ void CReverseAnimation::endAnim()
|
||||
|
||||
void CReverseAnimation::setupSecondPart()
|
||||
{
|
||||
owner->creDir[stack->ID] = !owner->creDir[stack->ID];
|
||||
|
||||
if(!stack)
|
||||
{
|
||||
endAnim();
|
||||
return;
|
||||
}
|
||||
|
||||
owner->creDir[stack->ID] = !owner->creDir[stack->ID];
|
||||
|
||||
Point coords = CClickableHex::getXYUnitAnim(hex, owner->creDir[stack->ID], stack, owner);
|
||||
myAnim()->pos.x = coords.x;
|
||||
//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),
|
||||
1, // mark it for auto-deleting
|
||||
&info.getExtension()[0] + 1); //pass extension without dot (+1 character)
|
||||
|
||||
if (!ret)
|
||||
tlog1<<"Failed to open "<<fname<<" via SDL_Image\n";
|
||||
|
||||
if (ret->format->palette)
|
||||
if (ret)
|
||||
{
|
||||
//set correct value for alpha\unused channel
|
||||
for (int i=0; i< ret->format->palette->ncolors; i++)
|
||||
ret->format->palette->colors[i].unused = 255;
|
||||
if (ret->format->palette)
|
||||
{
|
||||
//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;
|
||||
|
@ -3348,16 +3348,17 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
|
||||
{
|
||||
StartAction start_action(ba);
|
||||
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)
|
||||
{
|
||||
sendAndApply(&end_action);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
int distance = moveStack(ba.stackNumber, ba.destinationTile);
|
||||
int startingPos = stack->position;
|
||||
|
||||
tlog5 << stack->nodeName() << " will attack " << stackAtEnd->nodeName() << std::endl;
|
||||
|
||||
if(stack->position != ba.destinationTile //we wasn't able to reach destination tile
|
||||
|
Loading…
x
Reference in New Issue
Block a user