mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
TerrainTile now uses identifiers instead of pointers to VLC
This commit is contained in:
@@ -830,9 +830,8 @@ bool CGameHandler::moveHero(ObjectInstanceID hid, int3 dst, EMovementMode moveme
|
||||
|
||||
const bool embarking = !h->boat && objectToVisit && objectToVisit->ID == Obj::BOAT;
|
||||
const bool disembarking = h->boat
|
||||
&& t.terType->isLand()
|
||||
&& (dst == h->pos
|
||||
|| (h->boat->layer == EPathfindingLayer::SAIL && !t.blocked));
|
||||
&& t.isLand()
|
||||
&& (dst == h->pos || (h->boat->layer == EPathfindingLayer::SAIL && !t.blocked()));
|
||||
|
||||
//result structure for start - movement failed, no move points used
|
||||
TryMoveHero tmh;
|
||||
@@ -850,9 +849,9 @@ bool CGameHandler::moveHero(ObjectInstanceID hid, int3 dst, EMovementMode moveme
|
||||
const bool canWalkOnSea = pathfinderHelper->hasBonusOfType(BonusType::WATER_WALKING) || (h->boat && h->boat->layer == EPathfindingLayer::WATER);
|
||||
const int cost = pathfinderHelper->getMovementCost(h->visitablePos(), hmpos, nullptr, nullptr, h->movementPointsRemaining());
|
||||
|
||||
const bool movingOntoObstacle = t.blocked && !t.visitable;
|
||||
const bool movingOntoObstacle = t.blocked() && !t.visitable();
|
||||
const bool objectCoastVisitable = objectToVisit && objectToVisit->isCoastVisitable();
|
||||
const bool movingOntoWater = !h->boat && t.terType->isWater() && !objectCoastVisitable;
|
||||
const bool movingOntoWater = !h->boat && t.isWater() && !objectCoastVisitable;
|
||||
|
||||
const auto complainRet = [&](const std::string & message)
|
||||
{
|
||||
@@ -876,14 +875,14 @@ bool CGameHandler::moveHero(ObjectInstanceID hid, int3 dst, EMovementMode moveme
|
||||
|
||||
//it's a rock or blocked and not visitable tile
|
||||
//OR hero is on land and dest is water and (there is not present only one object - boat)
|
||||
if (!t.terType->isPassable() || (movingOntoObstacle && !canFly))
|
||||
if (!t.getTerrain()->isPassable() || (movingOntoObstacle && !canFly))
|
||||
return complainRet("Cannot move hero, destination tile is blocked!");
|
||||
|
||||
//hero is not on boat/water walking and dst water tile doesn't contain boat/hero (objs visitable from land) -> we test back cause boat may be on top of another object (#276)
|
||||
if(movingOntoWater && !canFly && !canWalkOnSea)
|
||||
return complainRet("Cannot move hero, destination tile is on water!");
|
||||
|
||||
if(h->boat && h->boat->layer == EPathfindingLayer::SAIL && t.terType->isLand() && t.blocked)
|
||||
if(h->boat && h->boat->layer == EPathfindingLayer::SAIL && t.isLand() && t.blocked())
|
||||
return complainRet("Cannot disembark hero, tile is blocked!");
|
||||
|
||||
if(distance(h->pos, dst) >= 1.5 && movementMode == EMovementMode::STANDARD)
|
||||
@@ -895,7 +894,7 @@ bool CGameHandler::moveHero(ObjectInstanceID hid, int3 dst, EMovementMode moveme
|
||||
if(h->movementPointsRemaining() < cost && dst != h->pos && movementMode == EMovementMode::STANDARD)
|
||||
return complainRet("Hero doesn't have any movement points left!");
|
||||
|
||||
if (transit && !canFly && !(canWalkOnSea && t.terType->isWater()) && !CGTeleport::isTeleport(objectToVisit))
|
||||
if (transit && !canFly && !(canWalkOnSea && t.isWater()) && !CGTeleport::isTeleport(objectToVisit))
|
||||
return complainRet("Hero cannot transit over this tile!");
|
||||
|
||||
//several generic blocks of code
|
||||
@@ -1017,7 +1016,7 @@ bool CGameHandler::moveHero(ObjectInstanceID hid, int3 dst, EMovementMode moveme
|
||||
if (CGTeleport::isTeleport(objectToVisit))
|
||||
visitDest = DONT_VISIT_DEST;
|
||||
|
||||
if (canFly || (canWalkOnSea && t.terType->isWater()))
|
||||
if (canFly || (canWalkOnSea && t.isWater()))
|
||||
{
|
||||
lookForGuards = IGNORE_GUARDS;
|
||||
visitDest = DONT_VISIT_DEST;
|
||||
|
||||
Reference in New Issue
Block a user