1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

Minor fixes

This commit is contained in:
Ivan Savenko
2023-02-28 22:43:19 +02:00
parent 6196d538e7
commit b9e55db223
3 changed files with 33 additions and 24 deletions

View File

@@ -725,11 +725,6 @@ void CAdvMapInt::keyPressed(const SDL_Keycode & key)
return; return;
if(h) 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); LOCPLINT->cb->moveHero(h,h->pos);
} }
} }
@@ -746,7 +741,8 @@ void CAdvMapInt::keyPressed(const SDL_Keycode & key)
} }
case SDLK_ESCAPE: 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; return;
leaveCastingMode(); leaveCastingMode();
@@ -1049,7 +1045,11 @@ void CAdvMapInt::onTileLeftClicked(const int3 &mapPos)
{ {
if(mode != EAdvMapMode::NORMAL) if(mode != EAdvMapMode::NORMAL)
return; 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; return;
const TerrainTile *tile = LOCPLINT->cb->getTile(mapPos); 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); std::string text = curHero() ? objAtTile->getHoverText(curHero()) : objAtTile->getHoverText(LOCPLINT->playerID);
boost::replace_all(text,"\n"," "); boost::replace_all(text,"\n"," ");
statusbar->write(text); statusbar->write(text);
} }
else else
{ {
std::string hlp = CGI->mh->getTerrainDescr(mapPos, false); std::string hlp = CGI->mh->getTerrainDescr(mapPos, false);
statusbar->write(hlp); statusbar->write(hlp);
} }
if(spellBeingCasted) if(spellBeingCasted)
{ {
switch(spellBeingCasted->id) switch(spellBeingCasted->id)
@@ -1305,15 +1305,15 @@ void CAdvMapInt::onTileRightClicked(const int3 &mapPos)
const CGObjectInstance * obj = getActiveObject(mapPos); const CGObjectInstance * obj = getActiveObject(mapPos);
if(!obj) if(!obj)
{ {
// Bare or undiscovered terrain // Bare or undiscovered terrain
const TerrainTile * tile = LOCPLINT->cb->getTile(mapPos); const TerrainTile * tile = LOCPLINT->cb->getTile(mapPos);
if(tile) if(tile)
{ {
std::string hlp = CGI->mh->getTerrainDescr(mapPos, true); std::string hlp = CGI->mh->getTerrainDescr(mapPos, true);
CRClickPopup::createAndPush(hlp); CRClickPopup::createAndPush(hlp);
} }
return; return;
} }
CRClickPopup::createAndPush(obj, GH.getCursorPosition(), ETextAlignment::CENTER); CRClickPopup::createAndPush(obj, GH.getCursorPosition(), ETextAlignment::CENTER);

View File

@@ -11,13 +11,16 @@
#include "../../lib/Point.h" #include "../../lib/Point.h"
VCMI_LIB_NAMESPACE_BEGIN
class ObjectInstanceID;
VCMI_LIB_NAMESPACE_END
class IImage; class IImage;
class CAnimation; class CAnimation;
class Canvas; class Canvas;
class MapRenderer; class MapRenderer;
class IMapRendererContext; class IMapRendererContext;
class MapViewModel; class MapViewModel;
class ObjectInstanceID;
/// Class responsible for rendering of entire map view /// Class responsible for rendering of entire map view
/// uses rendering parameters provided by owner class /// uses rendering parameters provided by owner class

View File

@@ -322,6 +322,7 @@ void MapViewController::onBeforeHeroTeleported(const CGHeroInstance * obj, const
{ {
// TODO: generate view with old state // TODO: generate view with old state
setViewCenter(obj->getSightCenter()); setViewCenter(obj->getSightCenter());
removeObject(obj);
} }
} }
@@ -333,6 +334,7 @@ void MapViewController::onAfterHeroTeleported(const CGHeroInstance * obj, const
{ {
// TODO: animation // TODO: animation
setViewCenter(obj->getSightCenter()); setViewCenter(obj->getSightCenter());
addObject(obj);
} }
else else
{ {
@@ -345,6 +347,10 @@ void MapViewController::onHeroMoved(const CGHeroInstance * obj, const int3 & fro
{ {
assert(!hasOngoingAnimations()); assert(!hasOngoingAnimations());
// revisiting via spacebar, no need to animate
if (from == dest)
return;
const CGObjectInstance * movingObject = obj; const CGObjectInstance * movingObject = obj;
if(obj->boat) if(obj->boat)
movingObject = obj->boat; movingObject = obj->boat;