Browse Source

VCAI compareArtifacts: consider that art with highest price is best

That is suboptimal way as well, but let us avoid infinite loop there. Fix issue 2461
Arseniy Shestakov 9 years ago
parent
commit
78a560767b
1 changed files with 4 additions and 2 deletions
  1. 4 2
      AI/VCAI/AIUtility.cpp

+ 4 - 2
AI/VCAI/AIUtility.cpp

@@ -509,8 +509,10 @@ bool compareArtifacts(const CArtifactInstance *a1, const CArtifactInstance *a2)
 	auto art1 = a1->artType;
 	auto art2 = a2->artType;
 
-	if (art1->valOfBonuses(Bonus::PRIMARY_SKILL) > art2->valOfBonuses(Bonus::PRIMARY_SKILL))
+	if(art1->price == art2->price)
+		return art1->valOfBonuses(Bonus::PRIMARY_SKILL) > art2->valOfBonuses(Bonus::PRIMARY_SKILL);
+	else if(art1->price > art2->price)
 		return true;
 	else
-		return art1->price > art2->price;
+		return false;
 }