瀏覽代碼

Fix stacking of bonuses from buildings like Tavern

- Same buildings in different towns of the same faction that provide
bonuses with propagators will now correctly stack their bonuses. This
fixes Tavern and possibly other such buildings
- Brotherhood of Sword now correctly adds bonus to thieves guild access
Ivan Savenko 8 月之前
父節點
當前提交
58a6185b43
共有 2 個文件被更改,包括 11 次插入3 次删除
  1. 5 0
      config/factions/castle.json
  2. 6 3
      lib/mapObjects/CGTownInstance.cpp

+ 5 - 0
config/factions/castle.json

@@ -202,6 +202,11 @@
 						{
 							"type": "MORALE",
 							"val": 2
+						},
+						{
+							"propagator": "PLAYER_PROPAGATOR",
+							"type": "THIEVES_GUILD_ACCESS",
+							"val": 1
 						}
 					],
 					"upgrades" : "tavern"

+ 6 - 3
lib/mapObjects/CGTownInstance.cpp

@@ -754,8 +754,6 @@ void CGTownInstance::recreateBuildingsBonuses()
 	for(const auto & b : bl)
 		removeBonus(b);
 
-
-
 	for(const auto & bid : builtBuildings)
 	{
 		bool bonusesReplacedByUpgrade = false;
@@ -777,7 +775,12 @@ void CGTownInstance::recreateBuildingsBonuses()
 			continue;
 
 		for(auto & bonus : building->buildingBonuses)
-			addNewBonus(bonus);
+		{
+			// Add copy of bonus to bonus system
+			// Othervice, bonuses with player or global propagator will not stack if player has multiple towns of same faction
+			auto bonusCopy = std::make_shared<Bonus>(*bonus);
+			addNewBonus(bonusCopy);
+		}
 	}
 }