From b9e55db2230a49ec1bc968d4d23fef9efa16f063 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Tue, 28 Feb 2023 22:43:19 +0200 Subject: [PATCH] Minor fixes --- client/adventureMap/CAdvMapInt.cpp | 46 ++++++++++++------------ client/mapRenderer/MapViewCache.h | 5 ++- client/mapRenderer/MapViewController.cpp | 6 ++++ 3 files changed, 33 insertions(+), 24 deletions(-) diff --git a/client/adventureMap/CAdvMapInt.cpp b/client/adventureMap/CAdvMapInt.cpp index b0bd75bba..2acfcd30a 100644 --- a/client/adventureMap/CAdvMapInt.cpp +++ b/client/adventureMap/CAdvMapInt.cpp @@ -725,11 +725,6 @@ void CAdvMapInt::keyPressed(const SDL_Keycode & key) return; if(h) { - auto unlockPim = vstd::makeUnlockGuard(*CPlayerInterface::pim); - //TODO!!!!!!! possible freeze, when GS mutex is locked and network thread can't apply package - //this thread leaves scope and tries to lock pim while holding gs, - //network thread tries to lock gs (appluy cl) while holding pim - //this thread should first lock pim, however gs locking/unlocking is done inside cb LOCPLINT->cb->moveHero(h,h->pos); } } @@ -746,7 +741,8 @@ void CAdvMapInt::keyPressed(const SDL_Keycode & key) } case SDLK_ESCAPE: { - if(isActive() || GH.topInt().get() != this || !spellBeingCasted) + //FIXME: this case is never executed since AdvMapInt is disabled while in spellcasting mode + if(!isActive() || GH.topInt().get() != this || !spellBeingCasted) return; leaveCastingMode(); @@ -1049,7 +1045,11 @@ void CAdvMapInt::onTileLeftClicked(const int3 &mapPos) { if(mode != EAdvMapMode::NORMAL) return; - if(!LOCPLINT->cb->isVisible(mapPos) || !LOCPLINT->makingTurn) + + //FIXME: this line breaks H3 behavior for Dimension Door + if(!LOCPLINT->cb->isVisible(mapPos)) + return; + if(!LOCPLINT->makingTurn) return; const TerrainTile *tile = LOCPLINT->cb->getTile(mapPos); @@ -1148,13 +1148,13 @@ void CAdvMapInt::onTileHovered(const int3 &mapPos) std::string text = curHero() ? objAtTile->getHoverText(curHero()) : objAtTile->getHoverText(LOCPLINT->playerID); boost::replace_all(text,"\n"," "); statusbar->write(text); - } - else - { - std::string hlp = CGI->mh->getTerrainDescr(mapPos, false); - statusbar->write(hlp); - } - + } + else + { + std::string hlp = CGI->mh->getTerrainDescr(mapPos, false); + statusbar->write(hlp); + } + if(spellBeingCasted) { switch(spellBeingCasted->id) @@ -1305,15 +1305,15 @@ void CAdvMapInt::onTileRightClicked(const int3 &mapPos) const CGObjectInstance * obj = getActiveObject(mapPos); if(!obj) - { - // Bare or undiscovered terrain - const TerrainTile * tile = LOCPLINT->cb->getTile(mapPos); - if(tile) - { - std::string hlp = CGI->mh->getTerrainDescr(mapPos, true); - CRClickPopup::createAndPush(hlp); - } - return; + { + // Bare or undiscovered terrain + const TerrainTile * tile = LOCPLINT->cb->getTile(mapPos); + if(tile) + { + std::string hlp = CGI->mh->getTerrainDescr(mapPos, true); + CRClickPopup::createAndPush(hlp); + } + return; } CRClickPopup::createAndPush(obj, GH.getCursorPosition(), ETextAlignment::CENTER); diff --git a/client/mapRenderer/MapViewCache.h b/client/mapRenderer/MapViewCache.h index 8528bde89..d503e45fe 100644 --- a/client/mapRenderer/MapViewCache.h +++ b/client/mapRenderer/MapViewCache.h @@ -11,13 +11,16 @@ #include "../../lib/Point.h" +VCMI_LIB_NAMESPACE_BEGIN +class ObjectInstanceID; +VCMI_LIB_NAMESPACE_END + class IImage; class CAnimation; class Canvas; class MapRenderer; class IMapRendererContext; class MapViewModel; -class ObjectInstanceID; /// Class responsible for rendering of entire map view /// uses rendering parameters provided by owner class diff --git a/client/mapRenderer/MapViewController.cpp b/client/mapRenderer/MapViewController.cpp index 9823838bf..4c952f333 100644 --- a/client/mapRenderer/MapViewController.cpp +++ b/client/mapRenderer/MapViewController.cpp @@ -322,6 +322,7 @@ void MapViewController::onBeforeHeroTeleported(const CGHeroInstance * obj, const { // TODO: generate view with old state setViewCenter(obj->getSightCenter()); + removeObject(obj); } } @@ -333,6 +334,7 @@ void MapViewController::onAfterHeroTeleported(const CGHeroInstance * obj, const { // TODO: animation setViewCenter(obj->getSightCenter()); + addObject(obj); } else { @@ -345,6 +347,10 @@ void MapViewController::onHeroMoved(const CGHeroInstance * obj, const int3 & fro { assert(!hasOngoingAnimations()); + // revisiting via spacebar, no need to animate + if (from == dest) + return; + const CGObjectInstance * movingObject = obj; if(obj->boat) movingObject = obj->boat;