1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-15 01:24:45 +02:00

Fixed #1820, better detection of object below cursor that uses same logic as renderer

This commit is contained in:
Ivan Savenko
2014-07-01 17:19:08 +03:00
parent bae9f2083f
commit c956b3f02a
5 changed files with 21 additions and 10 deletions

View File

@ -1127,17 +1127,19 @@ void CAdvMapInt::endingTurn()
LOCPLINT->cb->endTurn();
}
const CGObjectInstance* CAdvMapInt::getBlockingObject(const int3 &mapPos)
const CGObjectInstance* CAdvMapInt::getActiveObject(const int3 &mapPos)
{
std::vector < const CGObjectInstance * > bobjs = LOCPLINT->cb->getBlockingObjs(mapPos); //blocking objects at tile
if (bobjs.empty())
return nullptr;
return *boost::range::max_element(bobjs, &CMapHandler::compareObjectBlitOrder);
/*
if (bobjs.back()->ID == Obj::HERO)
return bobjs.back();
else
return bobjs.front();
return bobjs.front();*/
}
void CAdvMapInt::tileLClicked(const int3 &mapPos)
@ -1147,7 +1149,7 @@ void CAdvMapInt::tileLClicked(const int3 &mapPos)
const TerrainTile *tile = LOCPLINT->cb->getTile(mapPos);
const CGObjectInstance *topBlocking = getBlockingObject(mapPos);
const CGObjectInstance *topBlocking = getActiveObject(mapPos);
int3 selPos = selection->getSightCenter();
if(spellBeingCasted && isInScreenRange(selPos, mapPos))
@ -1232,7 +1234,7 @@ void CAdvMapInt::tileHovered(const int3 &mapPos)
statusbar.clear();
return;
}
const CGObjectInstance *objAtTile = getBlockingObject(mapPos);
const CGObjectInstance *objAtTile = getActiveObject(mapPos);
if (objAtTile)
{
@ -1432,7 +1434,7 @@ void CAdvMapInt::tileRClicked(const int3 &mapPos)
return;
}
const CGObjectInstance * obj = getBlockingObject(mapPos);
const CGObjectInstance * obj = getActiveObject(mapPos);
if(!obj)
{
// Bare or undiscovered terrain