Skip to content

Commit 520e42b

Browse files
DjWarmongerDjWarmonger
authored andcommitted
Fixed #2317
1 parent c47c08a commit 520e42b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

AI/VCAI/VCAI.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2481,14 +2481,13 @@ int3 VCAI::explorationBestNeighbour(int3 hpos, int radius, HeroPtr h)
24812481

24822482
int3 VCAI::explorationNewPoint(HeroPtr h)
24832483
{
2484-
//logAi->debugStream() << "Looking for an another place for exploration...";
24852484
int radius = h->getSightRadious();
2485+
CCallback * cbp = cb.get();
2486+
const CGHeroInstance * hero = h.get();
24862487

24872488
std::vector<std::vector<int3> > tiles; //tiles[distance_to_fow]
24882489
tiles.resize(radius);
24892490

2490-
CCallback * cbp = cb.get();
2491-
24922491
foreach_tile_pos([&](const int3 &pos)
24932492
{
24942493
if(!cbp->isVisible(pos))
@@ -2497,6 +2496,7 @@ int3 VCAI::explorationNewPoint(HeroPtr h)
24972496

24982497
float bestValue = 0; //discovered tile to node distance ratio
24992498
int3 bestTile(-1,-1,-1);
2499+
int3 ourPos = h->convertPosition(h->pos, false);
25002500

25012501
for (int i = 1; i < radius; i++)
25022502
{
@@ -2505,11 +2505,13 @@ int3 VCAI::explorationNewPoint(HeroPtr h)
25052505

25062506
for(const int3 &tile : tiles[i])
25072507
{
2508-
if (!cb->getPathsInfo(h.get())->getPathInfo(tile)->reachable()) //this will remove tiles that are guarded by monsters (or removable objects)
2508+
if (tile == ourPos) //shouldn't happen, but it does
2509+
continue;
2510+
if (!cb->getPathsInfo(hero)->getPathInfo(tile)->reachable()) //this will remove tiles that are guarded by monsters (or removable objects)
25092511
continue;
25102512

25112513
CGPath path;
2512-
cb->getPathsInfo(h.get())->getPath(tile, path);
2514+
cb->getPathsInfo(hero)->getPath(tile, path);
25132515
float ourValue = (float)howManyTilesWillBeDiscovered(tile, radius, cbp) / (path.nodes.size() + 1); //+1 prevents erratic jumps
25142516

25152517
if (ourValue > bestValue) //avoid costly checks of tiles that don't reveal much

0 commit comments

Comments
 (0)