1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Nullkiller: fix freeze on accessing guarded object

This commit is contained in:
Andrii Danylchenko
2021-05-16 14:56:21 +03:00
committed by Andrii Danylchenko
parent 5bfe71c8f3
commit 645c393e25
9 changed files with 45 additions and 14 deletions

View File

@@ -25,6 +25,12 @@ extern boost::thread_specific_ptr<VCAI> ai;
using namespace Goals;
#if AI_TRACE_LEVEL >= 1
#define MAXPASS 1000000
#else
#define MAXPASS 30
#endif
Nullkiller::Nullkiller()
{
memory.reset(new AIMemory());
@@ -152,7 +158,7 @@ void Nullkiller::resetAiState()
dangerHitMap->reset();
}
void Nullkiller::updateAiState()
void Nullkiller::updateAiState(int pass)
{
auto start = boost::chrono::high_resolution_clock::now();
@@ -174,7 +180,10 @@ void Nullkiller::updateAiState()
activeHeroes[hero] = heroManager->getHeroRole(hero);
}
pathfinder->updatePaths(activeHeroes, true);
PathfinderSettings cfg;
cfg.useHeroChain = true;
pathfinder->updatePaths(activeHeroes, cfg);
armyManager->update();
@@ -226,9 +235,9 @@ void Nullkiller::makeTurn()
{
resetAiState();
while(true)
for(int i = 1; i <= MAXPASS; i++)
{
updateAiState();
updateAiState(i);
Goals::TTaskVec bestTasks = {
choseBestTask(sptr(BuyArmyBehavior())),