mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	CPathfinder: fix special movement boundary check
Forgot to fix it for water walking after fe12b8f664
			
			
This commit is contained in:
		| @@ -59,16 +59,21 @@ CPathfinder::CPathfinder(CPathsInfo & _out, CGameState * _gs, const CGHeroInstan | ||||
|  | ||||
| void CPathfinder::calculatePaths() | ||||
| { | ||||
| 	auto passOneTurnLimitCheck = [&](bool shouldCheck) -> bool | ||||
| 	auto passOneTurnLimitCheck = [&]() -> bool | ||||
| 	{ | ||||
| 		if(options.oneTurnSpecialLayersLimit && shouldCheck) | ||||
| 		if(!options.oneTurnSpecialLayersLimit) | ||||
| 			return true; | ||||
|  | ||||
| 		if(cp->layer == ELayer::WATER) | ||||
| 			return false; | ||||
| 		if(cp->layer == ELayer::AIR) | ||||
| 		{ | ||||
| 			if((cp->layer == ELayer::AIR || cp->layer == ELayer::WATER) | ||||
| 				&& cp->accessible != CGPathNode::ACCESSIBLE) | ||||
| 			{ | ||||
| 			if(options.originalMovementRules && cp->accessible == CGPathNode::ACCESSIBLE) | ||||
| 				return true; | ||||
| 			else | ||||
| 				return false; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		return true; | ||||
| 	}; | ||||
|  | ||||
| @@ -104,7 +109,7 @@ void CPathfinder::calculatePaths() | ||||
| 		{ | ||||
| 			hlp->updateTurnInfo(++turn); | ||||
| 			movement = hlp->getMaxMovePoints(cp->layer); | ||||
| 			if(!passOneTurnLimitCheck(true)) | ||||
| 			if(!passOneTurnLimitCheck()) | ||||
| 				continue; | ||||
| 		} | ||||
| 		ct = &gs->map->getTile(cp->coord); | ||||
| @@ -155,8 +160,8 @@ void CPathfinder::calculatePaths() | ||||
| 					remains = moveAtNextTile - cost; | ||||
| 				} | ||||
|  | ||||
| 				if(isBetterWay(remains, turnAtNextTile) | ||||
| 					&& passOneTurnLimitCheck(cp->turns != turnAtNextTile || !remains)) | ||||
| 				if(isBetterWay(remains, turnAtNextTile) && | ||||
| 					((cp->turns == turnAtNextTile && remains) || passOneTurnLimitCheck())) | ||||
| 				{ | ||||
| 					assert(dp != cp->theNodeBefore); //two tiles can't point to each other | ||||
| 					dp->moveRemains = remains; | ||||
|   | ||||
| @@ -135,6 +135,9 @@ private: | ||||
| 		/// | ||||
| 		/// Following imitation is default H3 mechanics, but someone may want to disable it in mods. | ||||
| 		/// After all this limit should benefit performance on maps with tons of water or blocked tiles. | ||||
| 		/// | ||||
| 		/// TODO: | ||||
| 		/// - Behavior when option is disabled not implemented and will lead to crashes. | ||||
| 		bool oneTurnSpecialLayersLimit; | ||||
|  | ||||
| 		/// VCMI have different movement rules to solve flaws original engine has. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user