mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-21 12:06:49 +02:00
Fix crash on losing a hero
This commit is contained in:
parent
1fc0267ad1
commit
dfff1eae26
@ -219,7 +219,12 @@ void PlayerLocalState::removeWanderingHero(const CGHeroInstance * hero)
|
|||||||
if (hero == currentSelection)
|
if (hero == currentSelection)
|
||||||
{
|
{
|
||||||
auto const * nextHero = getNextWanderingHero(hero);
|
auto const * nextHero = getNextWanderingHero(hero);
|
||||||
|
if (nextHero)
|
||||||
setSelection(nextHero);
|
setSelection(nextHero);
|
||||||
|
else if (!ownedTowns.empty())
|
||||||
|
setSelection(ownedTowns.front());
|
||||||
|
else
|
||||||
|
setSelection(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
vstd::erase(wanderingHeroes, hero);
|
vstd::erase(wanderingHeroes, hero);
|
||||||
@ -334,6 +339,7 @@ void PlayerLocalState::serialize(JsonNode & dest) const
|
|||||||
dest["spellbook"]["tabBattle"].Integer() = spellbookSettings.spellbookLastTabBattle;
|
dest["spellbook"]["tabBattle"].Integer() = spellbookSettings.spellbookLastTabBattle;
|
||||||
dest["spellbook"]["tabAdvmap"].Integer() = spellbookSettings.spellbookLastTabAdvmap;
|
dest["spellbook"]["tabAdvmap"].Integer() = spellbookSettings.spellbookLastTabAdvmap;
|
||||||
|
|
||||||
|
if (currentSelection)
|
||||||
dest["currentSelection"].Integer() = currentSelection->id;
|
dest["currentSelection"].Integer() = currentSelection->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user