Преглед изворни кода

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

Ivan Savenko пре 1 година
родитељ
комит
49a28355a9
2 измењених фајлова са 38 додато и 4 уклоњено
  1. 36 4
      client/HeroMovementController.cpp
  2. 2 0
      client/HeroMovementController.h

+ 36 - 4
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)

+ 2 - 0
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);