mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-15 01:24:45 +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:
@ -529,17 +529,17 @@ void CPlayerInterface::heroInGarrisonChange(const CGTownInstance *town)
|
|||||||
EVENT_HANDLER_CALLED_BY_CLIENT;
|
EVENT_HANDLER_CALLED_BY_CLIENT;
|
||||||
updateInfo(town);
|
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);
|
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;
|
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);
|
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);
|
wanderingHeroes.push_back(town->visitingHero);
|
||||||
}
|
}
|
||||||
adventureInt->heroList.update();
|
adventureInt->heroList.update();
|
||||||
|
@ -451,19 +451,19 @@ void SetHeroesInTown::applyCl( CClient *cl )
|
|||||||
CGHeroInstance *hGarr = GS(cl)->getHero(this->garrison);
|
CGHeroInstance *hGarr = GS(cl)->getHero(this->garrison);
|
||||||
CGHeroInstance *hVisit = GS(cl)->getHero(this->visiting);
|
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
|
if(GS(cl)->isVisible(t, i->first) ||
|
||||||
playersToNotify.insert(t->tempOwner);
|
(hGarr && GS(cl)->isVisible(hGarr, i->first)) ||
|
||||||
|
(hVisit && GS(cl)->isVisible(hVisit, i->first)))
|
||||||
if (hGarr && vstd::contains(cl->playerint, hGarr->tempOwner))
|
{
|
||||||
playersToNotify.insert(hGarr->tempOwner);
|
cl->playerint[i->first]->heroInGarrisonChange(t);
|
||||||
|
}
|
||||||
if (hVisit && vstd::contains(cl->playerint, hVisit->tempOwner))
|
}
|
||||||
playersToNotify.insert(hVisit->tempOwner);
|
|
||||||
|
|
||||||
for(auto playerID : playersToNotify)
|
|
||||||
cl->playerint[playerID]->heroInGarrisonChange(t);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// void SetHeroArtifacts::applyCl( CClient *cl )
|
// void SetHeroArtifacts::applyCl( CClient *cl )
|
||||||
|
Reference in New Issue
Block a user