mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-16 10:19:47 +02:00
fix crash on heroRoles.clear()
This commit is contained in:
parent
7ae7c13964
commit
ca3d81f047
@ -126,20 +126,23 @@ void HeroManager::update()
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::sort(myHeroes.begin(), myHeroes.end(), scoreSort);
|
std::sort(myHeroes.begin(), myHeroes.end(), scoreSort);
|
||||||
heroRoles.clear();
|
|
||||||
|
std::map<HeroPtr, HeroRole> newHeroRoles;
|
||||||
|
|
||||||
for(auto hero : myHeroes)
|
for(auto hero : myHeroes)
|
||||||
{
|
{
|
||||||
if(hero->patrol.patrolling)
|
if(hero->patrol.patrolling)
|
||||||
{
|
{
|
||||||
heroRoles[hero] = HeroRole::MAIN;
|
newHeroRoles[hero] = HeroRole::MAIN;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
heroRoles[hero] = (globalMainCount--) > 0 ? HeroRole::MAIN : HeroRole::SCOUT;
|
newHeroRoles[hero] = (globalMainCount--) > 0 ? HeroRole::MAIN : HeroRole::SCOUT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
heroRoles = std::move(newHeroRoles);
|
||||||
|
|
||||||
for(auto hero : myHeroes)
|
for(auto hero : myHeroes)
|
||||||
{
|
{
|
||||||
logAi->trace("Hero %s has role %s", hero->getNameTranslated(), heroRoles[hero] == HeroRole::MAIN ? "main" : "scout");
|
logAi->trace("Hero %s has role %s", hero->getNameTranslated(), heroRoles[hero] == HeroRole::MAIN ? "main" : "scout");
|
||||||
|
Loading…
Reference in New Issue
Block a user