1
0
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:
Xilmi
2024-10-02 00:10:45 +02:00
parent f2b8b40925
commit c19d885603
2 changed files with 4 additions and 4 deletions

View File

@@ -964,7 +964,7 @@ std::vector<ObjectInstanceID> CGameInfoCallback::getVisibleTeleportObjects(std::
vstd::erase_if(ids, [&](const ObjectInstanceID & id) -> bool vstd::erase_if(ids, [&](const ObjectInstanceID & id) -> bool
{ {
const auto * obj = getObj(id, false); 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; return ids;
} }

View File

@@ -602,13 +602,13 @@ void CGSubterraneanGate::postInit(IGameCallback * cb) //matches subterranean gat
auto * hlp = dynamic_cast<CGSubterraneanGate *>(cb->gameState()->getObjInstance(obj->id)); auto * hlp = dynamic_cast<CGSubterraneanGate *>(cb->gameState()->getObjInstance(obj->id));
if(hlp) if(hlp)
gatesSplit[hlp->pos.z].push_back(hlp); gatesSplit[hlp->visitablePos().z].push_back(hlp);
} }
//sort by position //sort by position
std::sort(gatesSplit[0].begin(), gatesSplit[0].end(), [](const CGObjectInstance * a, const CGObjectInstance * b) 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) auto assignToChannel = [&](CGSubterraneanGate * obj)
@@ -631,7 +631,7 @@ void CGSubterraneanGate::postInit(IGameCallback * cb) //matches subterranean gat
CGSubterraneanGate *checked = gatesSplit[1][j]; CGSubterraneanGate *checked = gatesSplit[1][j];
if(checked->channel != TeleportChannelID()) if(checked->channel != TeleportChannelID())
continue; continue;
si32 hlp = checked->pos.dist2dSQ(objCurrent->pos); si32 hlp = checked->visitablePos().dist2dSQ(objCurrent->visitablePos());
if(hlp < best.second) if(hlp < best.second)
{ {
best.first = j; best.first = j;