1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-26 22:57:00 +02:00

Nullkiller: fix crash and freeze

This commit is contained in:
Andrii Danylchenko 2021-05-16 14:58:56 +03:00 committed by Andrii Danylchenko
parent 80df879489
commit 7e88819105
3 changed files with 28 additions and 6 deletions

View File

@ -175,6 +175,11 @@ std::vector<CGPathNode *> AINodeStorage::getInitialNodes()
getOrCreateNode(actor->initialPosition, actor->layer, actor) getOrCreateNode(actor->initialPosition, actor->layer, actor)
.get(); .get();
if(!initialNode)
continue;
initialNode->inPQ = false;
initialNode->pq = nullptr;
initialNode->turns = actor->initialTurn; initialNode->turns = actor->initialTurn;
initialNode->moveRemains = actor->initialMovement; initialNode->moveRemains = actor->initialMovement;
initialNode->danger = 0; initialNode->danger = 0;
@ -254,7 +259,7 @@ void AINodeStorage::commit(
"Commited %s -> %s, cost: %f, turn: %s, mp: %d, hero: %s, mask: %x, army: %lld", "Commited %s -> %s, cost: %f, turn: %s, mp: %d, hero: %s, mask: %x, army: %lld",
source->coord.toString(), source->coord.toString(),
destination->coord.toString(), destination->coord.toString(),
destination->cost, destination->getCost(),
std::to_string(destination->turns), std::to_string(destination->turns),
destination->moveRemains, destination->moveRemains,
destination->actor->toString(), destination->actor->toString(),
@ -599,8 +604,8 @@ void AINodeStorage::addHeroChain(const std::vector<ExchangeCandidate> & result)
logAi->trace( logAi->trace(
"Exchange at %s is is not effective enough. %f < %f", "Exchange at %s is is not effective enough. %f < %f",
exchangeNode->coord.toString(), exchangeNode->coord.toString(),
exchangeNode->cost, exchangeNode->getCost(),
chainInfo.cost); chainInfo.getCost());
#endif #endif
continue; continue;
} }
@ -629,7 +634,7 @@ void AINodeStorage::addHeroChain(const std::vector<ExchangeCandidate> & result)
other->actor->toString(), other->actor->toString(),
exchangeNode->actor->toString(), exchangeNode->actor->toString(),
exchangeNode->actor->chainMask, exchangeNode->actor->chainMask,
exchangeNode->cost, exchangeNode->getCost(),
std::to_string(exchangeNode->turns), std::to_string(exchangeNode->turns),
exchangeNode->moveRemains, exchangeNode->moveRemains,
exchangeNode->actor->armyValue); exchangeNode->actor->armyValue);

View File

@ -45,6 +45,14 @@ namespace AIPathfinding
return; return;
} }
#if PATHFINDER_TRACE_LEVEL >= 2
logAi->trace(
"Movement from tile %s is blocked. Try to bypass. Action: %d, blocker: %d",
destination.coord.toString(),
(int)destination.action,
(int)blocker);
#endif
auto destGuardians = cb->getGuardingCreatures(destination.coord); auto destGuardians = cb->getGuardingCreatures(destination.coord);
bool allowBypass = false; bool allowBypass = false;
@ -56,7 +64,15 @@ namespace AIPathfinding
break; break;
case BlockingReason::DESTINATION_BLOCKVIS: case BlockingReason::DESTINATION_BLOCKVIS:
if(destination.nodeHero && destination.heroRelations != PlayerRelations::ENEMIES)
{
allowBypass = destination.heroRelations == PlayerRelations::SAME_PLAYER
&& destination.nodeHero == nodeStorage->getHero(destination.node);
}
else
{
allowBypass = destination.nodeObject && bypassRemovableObject(source, destination, pathfinderConfig, pathfinderHelper); allowBypass = destination.nodeObject && bypassRemovableObject(source, destination, pathfinderConfig, pathfinderHelper);
}
if(allowBypass && destGuardians.size()) if(allowBypass && destGuardians.size())
allowBypass = bypassDestinationGuards(destGuardians, source, destination, pathfinderConfig, pathfinderHelper); allowBypass = bypassDestinationGuards(destGuardians, source, destination, pathfinderConfig, pathfinderHelper);

View File

@ -744,10 +744,11 @@ void VCAI::makeTurn()
} }
} }
cb->sendMessage("vcmieagles");
if(cb->getDate(Date::DAY) == 1) if(cb->getDate(Date::DAY) == 1)
{ {
retrieveVisitableObjs(); retrieveVisitableObjs();
cb->sendMessage("vcmieagles");
} }
try try