mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
Nullkiller: fix crash when game ends
This commit is contained in:
parent
f0ceaf5852
commit
92ac78f87d
@ -517,8 +517,17 @@ void VCAI::heroGotLevel(const CGHeroInstance * hero, PrimarySkill::PrimarySkill
|
||||
{
|
||||
LOG_TRACE_PARAMS(logAi, "queryID '%i'", queryID);
|
||||
NET_EVENT_HANDLER;
|
||||
|
||||
status.addQuery(queryID, boost::str(boost::format("Hero %s got level %d") % hero->name % hero->level));
|
||||
requestActionASAP([=](){ answerQuery(queryID, nullkiller->heroManager->selectBestSkill(hero, skills)); });
|
||||
HeroPtr hPtr = hero;
|
||||
|
||||
requestActionASAP([=]()
|
||||
{
|
||||
if(hPtr.validAndSet())
|
||||
{
|
||||
answerQuery(queryID, nullkiller->heroManager->selectBestSkill(hPtr, skills));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void VCAI::commanderGotLevel(const CCommanderInstance * commander, std::vector<ui32> skills, QueryID queryID)
|
||||
@ -566,6 +575,7 @@ void VCAI::showBlockingDialog(const std::string & text, const std::vector<Compon
|
||||
|
||||
answerQuery(askID, answer);
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -577,7 +587,8 @@ void VCAI::showBlockingDialog(const std::string & text, const std::vector<Compon
|
||||
sel = components.size();
|
||||
|
||||
// TODO: Find better way to understand it is Chest of Treasures
|
||||
if(components.size() == 2
|
||||
if(hero.validAndSet()
|
||||
&& components.size() == 2
|
||||
&& components.front().id == Component::RESOURCE
|
||||
&& nullkiller->heroManager->getHeroRole(hero) != HeroRole::MAIN)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user