mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-10 22:31:40 +02:00
Subterranean Gateway fix
Fixed an issue that caused pathfinding for player and AI not working when a subterranean gate was too close to the edge of the map. Fixed another issue that played into pathfinding for AI not working when a subterranean gate was too close to the edge of the map.
This commit is contained in:
@@ -964,7 +964,7 @@ std::vector<ObjectInstanceID> CGameInfoCallback::getVisibleTeleportObjects(std::
|
||||
vstd::erase_if(ids, [&](const ObjectInstanceID & id) -> bool
|
||||
{
|
||||
const auto * obj = getObj(id, false);
|
||||
return player != PlayerColor::UNFLAGGABLE && (!obj || !isVisible(obj->pos, player));
|
||||
return player != PlayerColor::UNFLAGGABLE && (!obj || !isVisible(obj->visitablePos(), player));
|
||||
});
|
||||
return ids;
|
||||
}
|
||||
|
@@ -602,13 +602,13 @@ void CGSubterraneanGate::postInit(IGameCallback * cb) //matches subterranean gat
|
||||
|
||||
auto * hlp = dynamic_cast<CGSubterraneanGate *>(cb->gameState()->getObjInstance(obj->id));
|
||||
if(hlp)
|
||||
gatesSplit[hlp->pos.z].push_back(hlp);
|
||||
gatesSplit[hlp->visitablePos().z].push_back(hlp);
|
||||
}
|
||||
|
||||
//sort by position
|
||||
std::sort(gatesSplit[0].begin(), gatesSplit[0].end(), [](const CGObjectInstance * a, const CGObjectInstance * b)
|
||||
{
|
||||
return a->pos < b->pos;
|
||||
return a->visitablePos() < b->visitablePos();
|
||||
});
|
||||
|
||||
auto assignToChannel = [&](CGSubterraneanGate * obj)
|
||||
@@ -631,7 +631,7 @@ void CGSubterraneanGate::postInit(IGameCallback * cb) //matches subterranean gat
|
||||
CGSubterraneanGate *checked = gatesSplit[1][j];
|
||||
if(checked->channel != TeleportChannelID())
|
||||
continue;
|
||||
si32 hlp = checked->pos.dist2dSQ(objCurrent->pos);
|
||||
si32 hlp = checked->visitablePos().dist2dSQ(objCurrent->visitablePos());
|
||||
if(hlp < best.second)
|
||||
{
|
||||
best.first = j;
|
||||
|
Reference in New Issue
Block a user