Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scrollrt: Add IsFloor function #7348

Merged
merged 1 commit into from
Aug 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading