1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

CBattleInterface: avoid crashes on gate state changes. Fix issue 2415

This commit is contained in:
Arseniy Shestakov 2016-03-14 10:37:43 +03:00
parent 605962019b
commit af05b025e7

View File

@ -2760,7 +2760,9 @@ void CBattleInterface::gateStateChanged(const EGateState state)
break;
}
SDL_FreeSurface(siegeH->walls[SiegeHelper::GATE]);
if(oldState != EGateState::CLOSED && oldState != EGateState::BLOCKED)
SDL_FreeSurface(siegeH->walls[SiegeHelper::GATE]);
if(stateId != EWallState::NONE)
siegeH->walls[SiegeHelper::GATE] = BitmapHandler::loadBitmap(siegeH->getSiegeName(SiegeHelper::GATE, stateId));
if(playSound)
@ -2827,7 +2829,8 @@ CBattleInterface::SiegeHelper::SiegeHelper(const CGTownInstance *siegeTown, cons
{
for(int g = 0; g < ARRAY_COUNT(walls); ++g)
{
walls[g] = BitmapHandler::loadBitmap(getSiegeName(g));
if(g != SiegeHelper::GATE)
walls[g] = BitmapHandler::loadBitmap(getSiegeName(g));
}
}