1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-06 09:09:40 +02:00

Fixed movement through teleporters by AI

This commit is contained in:
Ivan Savenko
2023-09-20 22:48:48 +03:00
parent a9dbd08dec
commit 3ea807fb8d
2 changed files with 5 additions and 5 deletions

View File

@@ -372,7 +372,7 @@ ObjectInstanceID CGTeleport::getRandomExit(const CGHeroInstance * h) const
bool CGTeleport::isTeleport(const CGObjectInstance * obj) bool CGTeleport::isTeleport(const CGObjectInstance * obj)
{ {
return ((dynamic_cast<const CGTeleport *>(obj))); return dynamic_cast<const CGTeleport *>(obj) != nullptr;
} }
bool CGTeleport::isConnected(const CGTeleport * src, const CGTeleport * dst) bool CGTeleport::isConnected(const CGTeleport * src, const CGTeleport * dst)

View File

@@ -1163,7 +1163,7 @@ bool CGameHandler::moveHero(ObjectInstanceID hid, int3 dst, ui8 teleporting, boo
if(h->movementPointsRemaining() < cost && dst != h->pos && !teleporting) if(h->movementPointsRemaining() < cost && dst != h->pos && !teleporting)
complainRet("Hero doesn't have any movement points left!"); complainRet("Hero doesn't have any movement points left!");
if (transit && !canFly && !(canWalkOnSea && t.terType->isWater())) if (transit && !canFly && !(canWalkOnSea && t.terType->isWater()) && !CGTeleport::isTeleport(objectToVisit))
complainRet("Hero cannot transit over this tile!"); complainRet("Hero cannot transit over this tile!");
//several generic blocks of code //several generic blocks of code
@@ -1195,7 +1195,7 @@ bool CGameHandler::moveHero(ObjectInstanceID hid, int3 dst, ui8 teleporting, boo
tmh.result = result; tmh.result = result;
sendAndApply(&tmh); sendAndApply(&tmh);
if (visitDest == VISIT_DEST && t.topVisitableObj() && t.topVisitableObj()->id == h->id) if (visitDest == VISIT_DEST && objectToVisit && objectToVisit->id == h->id)
{ // Hero should be always able to visit any object he staying on even if there guards around { // Hero should be always able to visit any object he staying on even if there guards around
visitObjectOnTile(t, h); visitObjectOnTile(t, h);
} }
@@ -1279,7 +1279,7 @@ bool CGameHandler::moveHero(ObjectInstanceID hid, int3 dst, ui8 teleporting, boo
EVisitDest visitDest = VISIT_DEST; EVisitDest visitDest = VISIT_DEST;
if (transit) if (transit)
{ {
if (CGTeleport::isTeleport(t.topVisitableObj())) if (CGTeleport::isTeleport(objectToVisit))
visitDest = DONT_VISIT_DEST; visitDest = DONT_VISIT_DEST;
if (canFly || (canWalkOnSea && t.terType->isWater())) if (canFly || (canWalkOnSea && t.terType->isWater()))