1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

Send packs for all reachable parts of a path if movement set to instant

This commit is contained in:
Ivan Savenko 2024-04-17 18:18:28 +03:00
parent 9f47a2e6aa
commit 49a28355a9
2 changed files with 38 additions and 4 deletions

View File

@ -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)

View File

@ -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);