diff --git a/client/HeroMovementController.cpp b/client/HeroMovementController.cpp index 89b5153b2..e5bf1a9c8 100644 --- a/client/HeroMovementController.cpp +++ b/client/HeroMovementController.cpp @@ -335,11 +335,43 @@ bool HeroMovementController::canHeroStopAtNode(const CGPathNode & node) const void HeroMovementController::requestMovementStart(const CGHeroInstance * h, const CGPath & path) { assert(duringMovement == false); - duringMovement = true; - currentlyMovingHero = h; - CCS->curh->hide(); - moveOnce(h, path); + int heroMovementSpeed = settings["adventure"]["heroMoveTime"].Integer(); + bool heroMovementInterruptible = heroMovementSpeed != 0; + + if (heroMovementInterruptible) + { + duringMovement = true; + currentlyMovingHero = h; + + CCS->curh->hide(); + moveOnce(h, path); + } + else + { + moveInstant(h, path); + } +} + +void HeroMovementController::moveInstant(const CGHeroInstance * h, const CGPath & path) +{ + stopMovementSound(); + for (auto const & node : boost::adaptors::reverse(path.nodes)) + { + if (node.coord == h->visitablePos()) + continue; // first node, ignore - this is hero current position + + if(node.isTeleportAction()) + return; // pause after monolith / subterra gates + + if (node.turns != 0) + return; // ran out of MP + + int3 coord = h->convertFromVisitablePos(node.coord); + + bool useTransit = node.layer == EPathfindingLayer::AIR || node.layer == EPathfindingLayer::WATER; + LOCPLINT->cb->moveHero(h, coord, useTransit); + } } void HeroMovementController::moveOnce(const CGHeroInstance * h, const CGPath & path) diff --git a/client/HeroMovementController.h b/client/HeroMovementController.h index 53314afd8..0064d4620 100644 --- a/client/HeroMovementController.h +++ b/client/HeroMovementController.h @@ -45,6 +45,8 @@ class HeroMovementController /// Moves hero 1 tile / path node void moveOnce(const CGHeroInstance * h, const CGPath & path); + void moveInstant(const CGHeroInstance * h, const CGPath & path); + void endMove(const CGHeroInstance * h); AudioPath getMovementSoundFor(const CGHeroInstance * hero, int3 posPrev, int3 posNext, EPathNodeAction moveType);