1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

moveHero: add transit validation and avoid embarking on transit

Hero shouldn't embark into boat when attempt to transit over air layer.
This commit is contained in:
ArseniyShestakov 2015-11-05 10:50:47 +03:00
parent c188ff0a92
commit 62dc070c0a

View File

@ -1794,6 +1794,8 @@ bool CGameHandler::moveHero( ObjectInstanceID hid, int3 dst, ui8 teleporting, bo
&& complain("Can not move garrisoned hero!"))
|| ((h->movement < cost && dst != h->pos && !teleporting)
&& complain("Hero doesn't have any movement points left!"))
|| ((transit && !h->canFly() && !CGTeleport::isTeleport(t.topVisitableObj()))
&& complain("Hero cannot transit over this tile!"))
/*|| (states.checkFlag(h->tempOwner, &PlayerStatus::engagedIntoBattle)
&& complain("Cannot move hero during the battle"))*/)
{
@ -1866,7 +1868,7 @@ bool CGameHandler::moveHero( ObjectInstanceID hid, int3 dst, ui8 teleporting, bo
};
if(embarking)
if(!transit && embarking)
{
tmh.movePoints = h->movementPointsAfterEmbark(h->movement, cost, false);
return doMove(TryMoveHero::EMBARK, IGNORE_GUARDS, DONT_VISIT_DEST, LEAVING_TILE);