瀏覽代碼

CAdvMapInt: improve hero reminder by checking hero path

Dialog won't show up if movement points insufficient for first step on current path.
Arseniy Shestakov 7 年之前
父節點
當前提交
434deffb54
共有 1 個文件被更改,包括 14 次插入5 次删除
  1. 14 5
      client/windows/CAdvmapInterface.cpp

+ 14 - 5
client/windows/CAdvmapInterface.cpp

@@ -830,14 +830,23 @@ void CAdvMapInt::fendTurn()
 	if(!LOCPLINT->makingTurn)
 		return;
 
-	if ( settings["adventure"]["heroReminder"].Bool())
+	if(settings["adventure"]["heroReminder"].Bool())
 	{
-		for (int i = 0; i < LOCPLINT->wanderingHeroes.size(); i++)
-			if (!isHeroSleeping(LOCPLINT->wanderingHeroes[i]) && (LOCPLINT->wanderingHeroes[i]->movement > 0))
+		for(auto hero : LOCPLINT->wanderingHeroes)
+		{
+			if(!isHeroSleeping(hero) && hero->movement > 0)
 			{
-				LOCPLINT->showYesNoDialog(CGI->generaltexth->allTexts[55], std::bind(&CAdvMapInt::endingTurn, this), 0, false);
-				return;
+				// Only show hero reminder if conditions met:
+				// - There still movement points
+				// - Hero don't have a path or there not points for first step on path
+				auto path = LOCPLINT->getAndVerifyPath(hero);
+				if(!path || path->nodes.size() < 2 || !path->nodes[path->nodes.size()-2].turns)
+				{
+					LOCPLINT->showYesNoDialog(CGI->generaltexth->allTexts[55], std::bind(&CAdvMapInt::endingTurn, this), 0, false);
+					return;
+				}
 			}
+		}
 	}
 	endingTurn();
 }