Skip to content

Commit

Permalink
fix: limitsFloorView incorrect thing check when calculating visible f…
Browse files Browse the repository at this point in the history
…loor (mehah#920)
  • Loading branch information
nekiro authored Oct 12, 2024
1 parent 98bf9d2 commit 22db98e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/client/mapview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -710,16 +710,16 @@ uint8_t MapView::calcFirstVisibleFloor(bool checkLimitsFloorsView) const
firstFloor = std::max<uint8_t >(m_posInfo.camera.z - g_gameConfig.getMapAwareUndergroundFloorRange(), g_gameConfig.getMapUndergroundFloorRange());

// loop in 3x3 tiles around the camera
for (int_fast32_t ix = -1; checkLimitsFloorsView && ix <= 1 && firstFloor < m_posInfo.camera.z; ++ix) {
for (int_fast32_t iy = -1; iy <= 1 && firstFloor < m_posInfo.camera.z; ++iy) {
for (int ix = -1; checkLimitsFloorsView && ix <= 1 && firstFloor < m_posInfo.camera.z; ++ix) {
for (int iy = -1; iy <= 1 && firstFloor < m_posInfo.camera.z; ++iy) {
const auto& pos = m_posInfo.camera.translated(ix, iy);
const bool isLookPossible = g_map.isLookPossible(pos);

// process tiles that we can look through, e.g. windows, doors
if ((ix == 0 && iy == 0) || ((std::abs(ix) != std::abs(iy)) && g_map.isLookPossible(pos))) {
if ((ix == 0 && iy == 0) || ((std::abs(ix) != std::abs(iy)) && isLookPossible)) {
Position upperPos = pos;
Position coveredPos = pos;

const bool isLookPossible = g_map.isLookPossible(pos);
while (coveredPos.coveredUp() && upperPos.up() && upperPos.z >= firstFloor) {
// check tiles physically above
if (const TilePtr& tile = g_map.getTile(upperPos)) {
Expand Down Expand Up @@ -754,7 +754,7 @@ uint8_t MapView::calcLastVisibleFloor() const
{
uint8_t z = g_gameConfig.getMapSeaFloor();

// this could happens if the player is not known yet
// this could happen if the player is not known yet
if (m_posInfo.camera.isValid()) {
// view only underground floors when below sea level
if (m_posInfo.camera.z > g_gameConfig.getMapSeaFloor())
Expand Down
14 changes: 12 additions & 2 deletions src/client/tile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -695,8 +695,18 @@ bool Tile::hasBlockingCreature() const
bool Tile::limitsFloorsView(bool isFreeView)
{
// ground and walls limits the view
const auto& firstThing = getThing(0);
return firstThing && !firstThing->isDontHide() && (firstThing->isGround() || (isFreeView ? firstThing->isOnBottom() : firstThing->isOnBottom() && firstThing->blockProjectile()));
for (const auto& thing : m_things) {
// iterate until common item is encountered
if (thing->isCommon()) {
break;
}

if (!thing->isDontHide() && (thing->isGround() || (isFreeView ? thing->isOnBottom() : thing->isOnBottom() && thing->blockProjectile()))) {
return true;
}
}

return false;
}

bool Tile::checkForDetachableThing(const TileSelectType selectType)
Expand Down

0 comments on commit 22db98e

Please sign in to comment.