mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-17 01:32:21 +02:00
Fix diagonal paths if we need to use them
This commit is contained in:
@ -121,17 +121,13 @@ bool RoadPlacer::createRoad(const int3 & dst)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ret = dst.dist2d(src);
|
float weight = dst.dist2dSQ(src);
|
||||||
|
auto ret = weight * weight; // Still prefer straight paths
|
||||||
|
|
||||||
if (visitableTiles.contains(src) || visitableTiles.contains(dst))
|
if (visitableTiles.contains(src) || visitableTiles.contains(dst))
|
||||||
{
|
{
|
||||||
ret *= VISITABLE_PENALTY;
|
ret *= VISITABLE_PENALTY;
|
||||||
}
|
}
|
||||||
float dist = border.distance(dst);
|
|
||||||
if(dist > 1)
|
|
||||||
{
|
|
||||||
ret /= dist;
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
res = path.search(dst, false, desperateRoutig);
|
res = path.search(dst, false, desperateRoutig);
|
||||||
|
Reference in New Issue
Block a user