1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-02-13 13:18:43 +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;
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);

View File

@ -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

View File

@ -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;