Bladeren bron

Fix dismissing heroes on map with "Capture town" victory condition

Ivan Savenko 2 jaren geleden
bovenliggende
commit
397c4c7595
1 gewijzigde bestanden met toevoegingen van 10 en 7 verwijderingen
  1. 10 7
      lib/mapObjects/CGHeroInstance.cpp

+ 10 - 7
lib/mapObjects/CGHeroInstance.cpp

@@ -1718,22 +1718,25 @@ bool CGHeroInstance::isMissionCritical() const
 {
 	for(const TriggeredEvent & event : IObjectInterface::cb->getMapHeader()->triggeredEvents)
 	{
-		if(event.trigger.test([&](const EventCondition & condition)
+		if (event.effect.type != EventEffect::DEFEAT)
+			continue;
+
+		auto const & testFunctor = [&](const EventCondition & condition)
 		{
 			if ((condition.condition == EventCondition::CONTROL || condition.condition == EventCondition::HAVE_0) && condition.object)
 			{
 				const auto * hero = dynamic_cast<const CGHeroInstance *>(condition.object);
 				return (hero != this);
 			}
-			else if(condition.condition == EventCondition::IS_HUMAN)
-			{
+
+			if(condition.condition == EventCondition::IS_HUMAN)
 				return true;
-			}
+
 			return false;
-		}))
-		{
+		};
+
+		if(event.trigger.test(testFunctor))
 			return true;
-		}
 	}
 	return false;
 }