1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-25 21:38:59 +02:00

Fixed crash on ending battle with a draw

This commit is contained in:
Ivan Savenko 2023-07-22 22:04:12 +03:00
parent a912770e29
commit 5aa2492a90

@ -2205,25 +2205,31 @@ void BattleResultAccepted::applyGs(CGameState * gs) const
for(auto & res : heroResult)
{
if(res.hero)
res.hero->removeBonusesRecursive(Bonus::OneBattle);
}
// Grow up growing artifacts
if(const auto hero = heroResult[winnerSide].hero)
{
if(hero->commander && hero->commander->alive)
{
for(auto & art : hero->commander->artifactsWorn)
art.second.artifact->growingUp();
}
for(auto & art : hero->artifactsWorn)
{
art.second.artifact->growingUp();
}
}
if(VLC->settings()->getBoolean(EGameSettings::MODULE_STACK_EXPERIENCE))
{
if(heroResult[0].army)
res.hero->removeBonusesRecursive(Bonus::OneBattle);
}
if(winnerSide != 2)
{
// Grow up growing artifacts
const auto hero = heroResult[winnerSide].hero;
if (hero)
{
if(hero->commander && hero->commander->alive)
{
for(auto & art : hero->commander->artifactsWorn)
art.second.artifact->growingUp();
}
for(auto & art : hero->artifactsWorn)
{
art.second.artifact->growingUp();
}
}
}
if(VLC->settings()->getBoolean(EGameSettings::MODULE_STACK_EXPERIENCE))
{
if(heroResult[0].army)
heroResult[0].army->giveStackExp(heroResult[0].exp);
if(heroResult[1].army)
heroResult[1].army->giveStackExp(heroResult[1].exp);