1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

SetHeroesInTown: properly update all client interfaces in multiplayer

All interfaces that hero or town visible for must be updated when hero position in town changes. Fix issue 2089
This commit is contained in:
Arseniy Shestakov 2016-09-11 13:56:00 +03:00
parent 6747555339
commit 9ab7650746
2 changed files with 16 additions and 16 deletions

View File

@ -529,17 +529,17 @@ void CPlayerInterface::heroInGarrisonChange(const CGTownInstance *town)
EVENT_HANDLER_CALLED_BY_CLIENT;
updateInfo(town);
if(town->garrisonHero && vstd::contains(wanderingHeroes,town->garrisonHero)) //wandering hero moved to the garrison
if(town->garrisonHero) //wandering hero moved to the garrison
{
CGI->mh->hideObject(town->garrisonHero);
if (town->garrisonHero->tempOwner == playerID) // our hero
if(town->garrisonHero->tempOwner == playerID && vstd::contains(wanderingHeroes,town->garrisonHero)) // our hero
wanderingHeroes -= town->garrisonHero;
}
if(town->visitingHero && !vstd::contains(wanderingHeroes,town->visitingHero)) //hero leaves garrison
if(town->visitingHero) //hero leaves garrison
{
CGI->mh->printObject(town->visitingHero);
if (town->visitingHero->tempOwner == playerID) // our hero
if(town->visitingHero->tempOwner == playerID && !vstd::contains(wanderingHeroes,town->visitingHero)) // our hero
wanderingHeroes.push_back(town->visitingHero);
}
adventureInt->heroList.update();

View File

@ -451,19 +451,19 @@ void SetHeroesInTown::applyCl( CClient *cl )
CGHeroInstance *hGarr = GS(cl)->getHero(this->garrison);
CGHeroInstance *hVisit = GS(cl)->getHero(this->visiting);
std::set<PlayerColor> playersToNotify;
//inform all players that see this object
for(auto i = cl->playerint.cbegin(); i != cl->playerint.cend(); ++i)
{
if(i->first >= PlayerColor::PLAYER_LIMIT)
continue;
if(vstd::contains(cl->playerint,t->tempOwner)) // our town
playersToNotify.insert(t->tempOwner);
if (hGarr && vstd::contains(cl->playerint, hGarr->tempOwner))
playersToNotify.insert(hGarr->tempOwner);
if (hVisit && vstd::contains(cl->playerint, hVisit->tempOwner))
playersToNotify.insert(hVisit->tempOwner);
for(auto playerID : playersToNotify)
cl->playerint[playerID]->heroInGarrisonChange(t);
if(GS(cl)->isVisible(t, i->first) ||
(hGarr && GS(cl)->isVisible(hGarr, i->first)) ||
(hVisit && GS(cl)->isVisible(hVisit, i->first)))
{
cl->playerint[i->first]->heroInGarrisonChange(t);
}
}
}
// void SetHeroArtifacts::applyCl( CClient *cl )