From 58a6185b43605ac21292dba5bf62f888658814aa Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Fri, 14 Feb 2025 14:29:58 +0000 Subject: [PATCH] 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 --- config/factions/castle.json | 5 +++++ lib/mapObjects/CGTownInstance.cpp | 9 ++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/config/factions/castle.json b/config/factions/castle.json index 801ddc923..595843663 100644 --- a/config/factions/castle.json +++ b/config/factions/castle.json @@ -202,6 +202,11 @@ { "type": "MORALE", "val": 2 + }, + { + "propagator": "PLAYER_PROPAGATOR", + "type": "THIEVES_GUILD_ACCESS", + "val": 1 } ], "upgrades" : "tavern" diff --git a/lib/mapObjects/CGTownInstance.cpp b/lib/mapObjects/CGTownInstance.cpp index 192457163..803cd201b 100644 --- a/lib/mapObjects/CGTownInstance.cpp +++ b/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); + addNewBonus(bonusCopy); + } } }