This commit is contained in:
Henrique Santiago 2012-01-04 11:39:08 -02:00
parent 478e55e658
commit f16318e80a
2 changed files with 5 additions and 17 deletions

View File

@ -199,28 +199,16 @@ ItemPtr Tile::getGround()
ThingPtr Tile::getTopLookThing() ThingPtr Tile::getTopLookThing()
{ {
ThingPtr retThing; if(isEmpty())
// check if there is any lookable object in this tile return nullptr;
for(int i = m_things.size() - 1; i >= 0; --i) { for(int i = m_things.size() - 1; i >= 0; --i) {
ThingPtr thing = m_things[i]; ThingPtr thing = m_things[i];
if(!thing->ignoreLook() && (!thing->isGround() && !thing->isGroundBorder() && !thing->isOnBottom() && !thing->isOnTop())) if(!thing->ignoreLook() && (!thing->isGround() && !thing->isGroundBorder() && !thing->isOnBottom() && !thing->isOnTop()))
return thing; return thing;
else if(!thing->ignoreLook())
retThing = thing;
} }
// return this, it it is lookable. return m_things[0];
if(retThing)
return retThing;
// if not, check on under tile
Position tilePos = m_position;
tilePos.coveredDown();
TilePtr tile = g_map.getTile(tilePos);
if(tile)
return tile->getTopLookThing();
return nullptr;
} }
ThingPtr Tile::getTopUseThing() ThingPtr Tile::getTopUseThing()

View File

@ -79,7 +79,7 @@ bool UIMap::onMousePress(const Point& mousePos, Fw::MouseButton button)
tilePos.perspectiveUp(tilePos.z - firstFloor); tilePos.perspectiveUp(tilePos.z - firstFloor);
for(int i = firstFloor; i <= Map::MAX_Z; i++) { for(int i = firstFloor; i <= Map::MAX_Z; i++) {
tile = g_map.getTile(tilePos); tile = g_map.getTile(tilePos);
if(!tile || !tile->isEmpty()) if(tile && !tile->isEmpty() && tile->getGround())
break; break;
tilePos.coveredDown(); tilePos.coveredDown();
} }