浏览代码

Ignore garrison update events of another towns for our castleInt

Ivan Savenko 2 年之前
父节点
当前提交
2af7d7c085
共有 2 个文件被更改,包括 14 次插入18 次删除
  1. 9 18
      client/CPlayerInterface.cpp
  2. 5 0
      client/windows/CCastleInterface.cpp

+ 9 - 18
client/CPlayerInterface.cpp

@@ -479,24 +479,14 @@ void CPlayerInterface::heroInGarrisonChange(const CGTownInstance *town)
 	adventureInt->onHeroChanged(nullptr);
 	adventureInt->onHeroChanged(nullptr);
 	adventureInt->onTownChanged(town);
 	adventureInt->onTownChanged(town);
 
 
-	if(castleInt)
-	{
-		castleInt->garr->selectSlot(nullptr);
-		castleInt->garr->setArmy(town->getUpperArmy(), EGarrisonType::UPPER);
-		castleInt->garr->setArmy(town->visitingHero, EGarrisonType::LOWER);
-		castleInt->garr->recreateSlots();
-		castleInt->heroes->update();
-
-		// Perform totalRedraw to update hero list on adventure map
-		GH.windows().totalRedraw();
-	}
+	for (auto gh : GH.windows().findWindows<IGarrisonHolder>())
+		gh->updateGarrisons();
 
 
 	for (auto ki : GH.windows().findWindows<CKingdomInterface>())
 	for (auto ki : GH.windows().findWindows<CKingdomInterface>())
-	{
 		ki->townChanged(town);
 		ki->townChanged(town);
-		ki->updateGarrisons();
-		ki->redraw();
-	}
+
+	// Perform totalRedraw to update hero list on adventure map, if any dialogs are open
+	GH.windows().totalRedraw();
 }
 }
 
 
 void CPlayerInterface::heroVisitsTown(const CGHeroInstance* hero, const CGTownInstance * town)
 void CPlayerInterface::heroVisitsTown(const CGHeroInstance* hero, const CGTownInstance * town)
@@ -1126,7 +1116,8 @@ void CPlayerInterface::availableCreaturesChanged( const CGDwelling *town )
 			fortScreen->creaturesChangedEventHandler();
 			fortScreen->creaturesChangedEventHandler();
 
 
 		for (auto castleInterface : GH.windows().findWindows<CCastleInterface>())
 		for (auto castleInterface : GH.windows().findWindows<CCastleInterface>())
-			castleInterface->creaturesChangedEventHandler();
+			if(castleInterface->town == town)
+				castleInterface->creaturesChangedEventHandler();
 
 
 		if (townObj)
 		if (townObj)
 			for (auto ki : GH.windows().findWindows<CKingdomInterface>())
 			for (auto ki : GH.windows().findWindows<CKingdomInterface>())
@@ -1414,9 +1405,9 @@ void CPlayerInterface::objectRemovedAfter()
 	EVENT_HANDLER_CALLED_BY_CLIENT;
 	EVENT_HANDLER_CALLED_BY_CLIENT;
 	adventureInt->onMapTilesChanged(boost::none);
 	adventureInt->onMapTilesChanged(boost::none);
 
 
-	// visiting or garrisoned hero removed - recreate castle window
+	// visiting or garrisoned hero removed - update window
 	if (castleInt)
 	if (castleInt)
-		openTownWindow(castleInt->town);
+		castleInt->updateGarrisons();
 
 
 	for (auto ki : GH.windows().findWindows<CKingdomInterface>())
 	for (auto ki : GH.windows().findWindows<CKingdomInterface>())
 		ki->heroRemoved();
 		ki->heroRemoved();

+ 5 - 0
client/windows/CCastleInterface.cpp

@@ -1213,7 +1213,12 @@ CCastleInterface::~CCastleInterface()
 
 
 void CCastleInterface::updateGarrisons()
 void CCastleInterface::updateGarrisons()
 {
 {
+	garr->setArmy(town->getUpperArmy(), EGarrisonType::UPPER);
+	garr->setArmy(town->visitingHero, EGarrisonType::LOWER);
 	garr->recreateSlots();
 	garr->recreateSlots();
+	heroes->update();
+
+	redraw();
 }
 }
 
 
 void CCastleInterface::close()
 void CCastleInterface::close()