From 1c66cd221d07a25344a99050857255eb4b7a6922 Mon Sep 17 00:00:00 2001 From: nordsoft Date: Tue, 18 Apr 2023 19:18:44 +0400 Subject: [PATCH] Polish transport mechanics --- server/CGameHandler.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 61c138583..593bfbb95 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -2263,9 +2263,11 @@ 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 = sailingBoat && t.terType->isLand() && !t.blocked; + const bool disembarking = h->boat + && t.terType->isLand() + && (h->boat->layer == EPathfindingLayer::SAIL || dst == h->pos) + && !t.blocked; //result structure for start - movement failed, no move points used TryMoveHero tmh; @@ -2289,7 +2291,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!")) - || ((sailingBoat && t.terType->isLand() && t.blocked) + || ((h->boat && h->boat->layer == EPathfindingLayer::SAIL && t.terType->isLand() && t.blocked) && complain("Cannot disembark hero, tile is blocked!")) || ((distance(h->pos, dst) >= 1.5 && !teleporting) && complain("Tiles are not neighboring!"))