Skip to content

Commit

Permalink
scrollrt: Add IsFloor function
Browse files Browse the repository at this point in the history
Makes the connection between `foliage` and floor more obvious,
see
#7327 (comment).
  • Loading branch information
glebm committed Aug 18, 2024
1 parent d41c7e4 commit a2961ea
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions Source/engine/render/scrollrt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "hwcursor.hpp"
#include "init.h"
#include "inv.h"
#include "levels/gendung.h"
#include "lighting.h"
#include "lua/lua.hpp"
#include "minitext.h"
Expand All @@ -48,9 +49,7 @@
#include "stores.h"
#include "towners.h"
#include "utils/attributes.h"
#include "utils/bitset2d.hpp"
#include "utils/display.h"
#include "utils/endian.hpp"
#include "utils/log.hpp"
#include "utils/str_cat.hpp"

Expand All @@ -77,6 +76,16 @@ bool frameflag;

namespace {

[[nodiscard]] DVL_ALWAYS_INLINE bool IsFloor(Point tilePosition)
{
return !TileHasAny(tilePosition, TileProperties::Solid);
}

[[nodiscard]] DVL_ALWAYS_INLINE bool IsWall(Point tilePosition)
{
return !IsFloor(tilePosition) || dSpecial[tilePosition.x][tilePosition.y] != 0;
}

/**
* @brief Contains all Missile at rendering position
*/
Expand Down Expand Up @@ -472,7 +481,7 @@ void DrawCell(const Surface &out, Point tilePosition, Point targetBufferPosition
if ((SDL_GetModState() & KMOD_ALT) != 0)
transparency = false;
#endif
const bool foliage = !TileHasAny(tilePosition, TileProperties::Solid);
const bool foliage = IsFloor(tilePosition);

const auto getFirstTileMaskLeft = [=](TileType tile) -> MaskType {
if (transparency) {
Expand Down Expand Up @@ -639,8 +648,9 @@ void DrawMonsterHelper(const Surface &out, Point tilePosition, Point targetBuffe
return;
}

if (!IsTileLit(tilePosition) && (!MyPlayer->_pInfraFlag || TileHasAny(tilePosition, TileProperties::Solid)))
if (!IsTileLit(tilePosition) && !(MyPlayer->_pInfraFlag && IsFloor(tilePosition))) {
return;
}

if (static_cast<size_t>(mi) >= MaxMonsters) {
Log("Draw Monster: tried to draw illegal monster {}", mi);
Expand Down Expand Up @@ -836,8 +846,9 @@ void DrawFloor(const Surface &out, Point tilePosition, Point targetBufferPositio
for (int i = 0; i < rows; i++) {
for (int j = 0; j < columns; j++) {
if (InDungeonBounds(tilePosition)) {
if (!TileHasAny(tilePosition, TileProperties::Solid))
if (IsFloor(tilePosition)) {
DrawFloorTile(out, tilePosition, targetBufferPosition);
}
} else {
world_draw_black_tile(out, targetBufferPosition.x, targetBufferPosition.y);
}
Expand All @@ -862,11 +873,6 @@ void DrawFloor(const Surface &out, Point tilePosition, Point targetBufferPositio
}
}

[[nodiscard]] DVL_ALWAYS_INLINE bool IsWall(Point position)
{
return TileHasAny(position, TileProperties::Solid) || dSpecial[position.x][position.y] != 0;
}

/**
* @brief Render a row of tile
* @param out Output buffer
Expand Down

0 comments on commit a2961ea

Please sign in to comment.