2
0
Эх сурвалжийг харах

Fixed secondary skill specialties

Ivan Savenko 2 жил өмнө
parent
commit
33b5bfbbd2
1 өөрчлөгдсөн 20 нэмэгдсэн , 11 устгасан
  1. 20 11
      lib/HeroBonus.cpp

+ 20 - 11
lib/HeroBonus.cpp

@@ -977,12 +977,21 @@ void CBonusSystemNode::getAllBonusesRec(BonusList &out) const
 
 	for(const auto & b : beforeUpdate)
 	{
-		auto updated = b->updater 
-			? getUpdatedBonus(b, b->updater) 
+		auto updated = b->updater
+			? getUpdatedBonus(b, b->updater)
 			: b;
 
-		//do not add bonus with same pointer
-		if(!vstd::contains(out, updated))
+		//do not add bonus with updater
+		bool bonusExists = false;
+		for (auto const & bonus : out )
+		{
+			if (bonus == updated)
+				bonusExists = true;
+			if (bonus->updater && bonus->updater == updated->updater)
+				bonusExists = true;
+		}
+
+		if (!bonusExists)
 			out.push_back(updated);
 	}
 }
@@ -1971,13 +1980,13 @@ JsonNode ILimiter::toJsonNode() const
 
 int CCreatureTypeLimiter::limit(const BonusLimitationContext &context) const
 {
-	const CCreature *c = retrieveCreature(&context.node);
-	if(!c)
-		return true;
-	return c->getId() != creature->getId() && (!includeUpgrades || !creature->isMyUpgrade(c));
-	//drop bonus if it's not our creature and (we don`t check upgrades or its not our upgrade)
-}
-
+	const CCreature *c = retrieveCreature(&context.node);
+	if(!c)
+		return true;
+	return c->getId() != creature->getId() && (!includeUpgrades || !creature->isMyUpgrade(c));
+	//drop bonus if it's not our creature and (we don`t check upgrades or its not our upgrade)
+}
+
 CCreatureTypeLimiter::CCreatureTypeLimiter(const CCreature & creature_, bool IncludeUpgrades)
 	: creature(&creature_), includeUpgrades(IncludeUpgrades)
 {