1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-26 03:52:01 +02:00

Fix updating of heroes when moving to/from garrison

This commit is contained in:
Ivan Savenko 2023-07-13 16:20:45 +03:00
parent cc6e8e8c7e
commit 3836217da5
2 changed files with 6 additions and 16 deletions

View File

@ -500,7 +500,7 @@ void CPlayerInterface::heroInGarrisonChange(const CGTownInstance *town)
if(town->garrisonHero) //wandering hero moved to the garrison
{
// This method also gets called on hero recruitment -> garrisoned hero is already in garrison
if(town->garrisonHero->tempOwner == playerID && !vstd::contains(localState->getWanderingHeroes(), town->visitingHero))
if(town->garrisonHero->tempOwner == playerID && vstd::contains(localState->getWanderingHeroes(), town->garrisonHero))
localState->removeWanderingHero(town->garrisonHero);
}
@ -520,7 +520,9 @@ void CPlayerInterface::heroInGarrisonChange(const CGTownInstance *town)
castleInt->garr->setArmy(town->visitingHero, 1);
castleInt->garr->recreateSlots();
castleInt->heroes->update();
castleInt->redraw();
// Perform totalRedraw to update hero list on adventure map
GH.windows().totalRedraw();
}
for (auto ki : GH.windows().findWindows<CKingdomInterface>())

View File

@ -287,14 +287,8 @@ void CHeroList::updateElement(const CGHeroInstance * hero)
void CHeroList::updateWidget()
{
for(auto & elem : listBox->getItems())
{
auto item = std::dynamic_pointer_cast<CHeroItem>(elem);
if (item)
item->update();
}
listBox->resize(LOCPLINT->localState->getWanderingHeroes().size());
listBox->reset();
if (LOCPLINT->localState->getCurrentHero())
select(LOCPLINT->localState->getCurrentHero());
@ -370,14 +364,8 @@ void CTownList::updateElement(const CGTownInstance * town)
void CTownList::updateWidget()
{
for(auto & elem : listBox->getItems())
{
auto item = std::dynamic_pointer_cast<CTownItem>(elem);
if (item)
item->update();
}
listBox->resize(LOCPLINT->localState->getOwnedTowns().size());
listBox->reset();
if (LOCPLINT->localState->getCurrentTown())
select(LOCPLINT->localState->getCurrentTown());