From 8af76947cb4bb569c06d56d99578663b96b8e3e2 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Wed, 22 Mar 2023 19:49:57 +0200 Subject: [PATCH] Do not cache hovered tile and always update state --- client/CPlayerInterface.cpp | 19 ++++++++++--------- client/mapView/MapViewActions.cpp | 18 +----------------- client/mapView/MapViewActions.h | 4 ---- 3 files changed, 11 insertions(+), 30 deletions(-) diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index 01aa76b06..6927611f0 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -1511,6 +1511,7 @@ void CPlayerInterface::objectRemoved(const CGObjectInstance * obj) const CGHeroInstance * h = static_cast(obj); heroKilled(h); } + GH.fakeMouseMove(); } void CPlayerInterface::objectRemovedAfter() @@ -2029,15 +2030,15 @@ bool CPlayerInterface::capturedAllEvents() if (duringMovement) { //just inform that we are capturing events. they will be processed by heroMoved() in client thread. - return true; - } - - bool needToLockAdventureMap = adventureInt->active && CGI->mh->hasOngoingAnimations(); - - if (ignoreEvents || needToLockAdventureMap) - { - boost::unique_lock un(eventsM); - while(!SDLEventsQueue.empty()) + return true; + } + + bool needToLockAdventureMap = adventureInt->active && CGI->mh->hasOngoingAnimations(); + + if (ignoreEvents || needToLockAdventureMap) + { + boost::unique_lock un(eventsM); + while(!SDLEventsQueue.empty()) { SDLEventsQueue.pop(); } diff --git a/client/mapView/MapViewActions.cpp b/client/mapView/MapViewActions.cpp index 854edd036..40402cb8f 100644 --- a/client/mapView/MapViewActions.cpp +++ b/client/mapView/MapViewActions.cpp @@ -24,7 +24,6 @@ MapViewActions::MapViewActions(MapView & owner, const std::shared_ptr & model) : model(model) , owner(owner) - , curHoveredTile(-1, -1, -1) , isSwiping(false) { pos.w = model->getPixelsVisibleDimensions().x; @@ -47,17 +46,6 @@ void MapViewActions::setContext(const std::shared_ptr & con this->context = context; } -void MapViewActions::activate() -{ - CIntObject::activate(); -} - -void MapViewActions::deactivate() -{ - CIntObject::deactivate(); - curHoveredTile = int3(-1, -1, -1); //we lost info about hovered tile when disabling -} - void MapViewActions::clickLeft(tribool down, bool previousState) { if(indeterminate(down)) @@ -159,11 +147,7 @@ void MapViewActions::handleHover(const Point & cursorPosition) return; } - if(tile != curHoveredTile) - { - curHoveredTile = tile; - adventureInt->onTileHovered(tile); - } + adventureInt->onTileHovered(tile); } void MapViewActions::hover(bool on) diff --git a/client/mapView/MapViewActions.h b/client/mapView/MapViewActions.h index c2655f7b0..dc6d84e16 100644 --- a/client/mapView/MapViewActions.h +++ b/client/mapView/MapViewActions.h @@ -23,8 +23,6 @@ class MapViewActions : public CIntObject Point swipeInitialViewPos; Point swipeInitialRealPos; - int3 curHoveredTile; - MapView & owner; std::shared_ptr model; std::shared_ptr context; @@ -39,8 +37,6 @@ public: void setContext(const std::shared_ptr & context); - void activate() override; - void deactivate() override; void clickLeft(tribool down, bool previousState) override; void clickRight(tribool down, bool previousState) override; void clickMiddle(tribool down, bool previousState) override;