From 39f2bef1abad98dedd74fe78f4d7633a7c904086 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Wed, 15 Mar 2023 00:30:58 +0200 Subject: [PATCH] Update town visual on capturing --- client/CPlayerInterface.cpp | 58 ++++++++++++++++++------------------- client/NetPacksClient.cpp | 7 +++++ 2 files changed, 36 insertions(+), 29 deletions(-) diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index 6cd5d0718..8d7ea219a 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -324,13 +324,13 @@ void CPlayerInterface::heroMoved(const TryMoveHero & details, bool verbose) if (!hero) return; - adventureInt->infoBar->requestPopAll(); - if (details.result == TryMoveHero::EMBARK || details.result == TryMoveHero::DISEMBARK) - { - if(hero->getRemovalSound() && hero->tempOwner == playerID) - CCS->soundh->playSound(hero->getRemovalSound().get()); - } - + adventureInt->infoBar->requestPopAll(); + if (details.result == TryMoveHero::EMBARK || details.result == TryMoveHero::DISEMBARK) + { + if(hero->getRemovalSound() && hero->tempOwner == playerID) + CCS->soundh->playSound(hero->getRemovalSound().get()); + } + adventureInt->minimap->updateTile(hero->convertToVisitablePos(details.start)); adventureInt->minimap->updateTile(hero->convertToVisitablePos(details.end)); @@ -372,12 +372,12 @@ void CPlayerInterface::heroMoved(const TryMoveHero & details, bool verbose) } } - if(details.stopMovement()) //hero failed to move - { - stillMoveHero.setn(STOP_MOVE); - adventureInt->heroList->update(hero); - return; - } + if(details.stopMovement()) //hero failed to move + { + stillMoveHero.setn(STOP_MOVE); + adventureInt->heroList->update(hero); + return; + } adventureInt->heroList->redraw(); @@ -1201,22 +1201,22 @@ void CPlayerInterface::showMapObjectSelectDialog(QueryID askID, const Component GH.pushInt(wnd); } -void CPlayerInterface::tileRevealed(const std::unordered_set &pos) -{ - EVENT_HANDLER_CALLED_BY_CLIENT; - //FIXME: wait for dialog? Magi hut/eye would benefit from this but may break other areas - for (auto & po : pos) - adventureInt->minimap->updateTile(po); -} - -void CPlayerInterface::tileHidden(const std::unordered_set &pos) -{ - EVENT_HANDLER_CALLED_BY_CLIENT; - for (auto & po : pos) - adventureInt->minimap->updateTile(po); -} - -void CPlayerInterface::openHeroWindow(const CGHeroInstance *hero) +void CPlayerInterface::tileRevealed(const std::unordered_set &pos) +{ + EVENT_HANDLER_CALLED_BY_CLIENT; + //FIXME: wait for dialog? Magi hut/eye would benefit from this but may break other areas + for (auto & po : pos) + adventureInt->minimap->updateTile(po); +} + +void CPlayerInterface::tileHidden(const std::unordered_set &pos) +{ + EVENT_HANDLER_CALLED_BY_CLIENT; + for (auto & po : pos) + adventureInt->minimap->updateTile(po); +} + +void CPlayerInterface::openHeroWindow(const CGHeroInstance *hero) { boost::unique_lock un(*pim); GH.pushIntT(hero); diff --git a/client/NetPacksClient.cpp b/client/NetPacksClient.cpp index e9e859018..118e50017 100644 --- a/client/NetPacksClient.cpp +++ b/client/NetPacksClient.cpp @@ -604,6 +604,13 @@ void ApplyClientNetPackVisitor::visitSetObjectProperty(SetObjectProperty & pack) if(gs.isVisible(gs.getObjInstance(pack.id), it->first)) callInterfaceIfPresent(cl, it->first, &IGameEventsReceiver::objectPropertyChanged, &pack); } + + if (pack.what == ObjProperty::OWNER) + { + // invalidate section of map view with our objec and force an update with new flag color + CGI->mh->onObjectInstantRemove(gs.getObjInstance(pack.id)); + CGI->mh->onObjectInstantAdd(gs.getObjInstance(pack.id)); + } } void ApplyClientNetPackVisitor::visitHeroLevelUp(HeroLevelUp & pack)