diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index efde3aae0..135bd1f81 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -479,24 +479,14 @@ void CPlayerInterface::heroInGarrisonChange(const CGTownInstance *town) adventureInt->onHeroChanged(nullptr); 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()) + gh->updateGarrisons(); for (auto ki : GH.windows().findWindows()) - { 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) @@ -1126,7 +1116,8 @@ void CPlayerInterface::availableCreaturesChanged( const CGDwelling *town ) fortScreen->creaturesChangedEventHandler(); for (auto castleInterface : GH.windows().findWindows()) - castleInterface->creaturesChangedEventHandler(); + if(castleInterface->town == town) + castleInterface->creaturesChangedEventHandler(); if (townObj) for (auto ki : GH.windows().findWindows()) @@ -1414,9 +1405,9 @@ void CPlayerInterface::objectRemovedAfter() EVENT_HANDLER_CALLED_BY_CLIENT; adventureInt->onMapTilesChanged(boost::none); - // visiting or garrisoned hero removed - recreate castle window + // visiting or garrisoned hero removed - update window if (castleInt) - openTownWindow(castleInt->town); + castleInt->updateGarrisons(); for (auto ki : GH.windows().findWindows()) ki->heroRemoved(); diff --git a/client/windows/CCastleInterface.cpp b/client/windows/CCastleInterface.cpp index 31ebd1559..3b56eba39 100644 --- a/client/windows/CCastleInterface.cpp +++ b/client/windows/CCastleInterface.cpp @@ -1213,7 +1213,12 @@ CCastleInterface::~CCastleInterface() void CCastleInterface::updateGarrisons() { + garr->setArmy(town->getUpperArmy(), EGarrisonType::UPPER); + garr->setArmy(town->visitingHero, EGarrisonType::LOWER); garr->recreateSlots(); + heroes->update(); + + redraw(); } void CCastleInterface::close()