Selaa lähdekoodia

Mechanic for air and land transport

nordsoft 2 vuotta sitten
vanhempi
sitoutus
3ff99a1a15
2 muutettua tiedostoa jossa 4 lisäystä ja 5 poistoa
  1. 1 1
      lib/CPathfinder.cpp
  2. 3 4
      server/CGameHandler.cpp

+ 1 - 1
lib/CPathfinder.cpp

@@ -1022,7 +1022,7 @@ bool TurnInfo::isLayerAvailable(const EPathfindingLayer & layer) const
 		if(hero && hero->boat && hero->boat->layer == EPathfindingLayer::AIR)
 			break;
 			
-		if(hasBonusOfType(Bonus::FLYING_MOVEMENT))
+		if(!hasBonusOfType(Bonus::FLYING_MOVEMENT))
 			return false;
 
 		break;

+ 3 - 4
server/CGameHandler.cpp

@@ -2263,10 +2263,9 @@ bool CGameHandler::moveHero(ObjectInstanceID hid, int3 dst, ui8 teleporting, boo
 	const TerrainTile t = *getTile(hmpos);
 	const int3 guardPos = gs->guardingCreaturePosition(hmpos);
 
+	const bool sailingBoat = h->boat && h->boat->layer == EPathfindingLayer::SAIL;
 	const bool embarking = !h->boat && !t.visitableObjects.empty() && t.visitableObjects.back()->ID == Obj::TRANSPORT;
-	const bool disembarking = h->boat
-		&& (h->boat->layer == EPathfindingLayer::SAIL && t.terType->isLand())
-		&& !t.blocked;
+	const bool disembarking = sailingBoat && t.terType->isLand() && !t.blocked;
 
 	//result structure for start - movement failed, no move points used
 	TryMoveHero tmh;
@@ -2290,7 +2289,7 @@ bool CGameHandler::moveHero(ObjectInstanceID hid, int3 dst, ui8 teleporting, boo
 			&& complain("Cannot move hero, destination tile is blocked!"))
 		|| ((!h->boat && !canWalkOnSea && !canFly && t.terType->isWater() && (t.visitableObjects.size() < 1 ||  (t.visitableObjects.back()->ID != Obj::TRANSPORT && t.visitableObjects.back()->ID != Obj::HERO)))  //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)
 			&& complain("Cannot move hero, destination tile is on water!"))
-		|| ((h->boat && t.terType->isLand() && t.blocked)
+		|| ((sailingBoat && t.terType->isLand() && t.blocked)
 			&& complain("Cannot disembark hero, tile is blocked!"))
 		|| ((distance(h->pos, dst) >= 1.5 && !teleporting)
 			&& complain("Tiles are not neighboring!"))