diff --git a/Source/engine/render/dun_render.cpp b/Source/engine/render/dun_render.cpp index 2fba3e3f0..8186075df 100644 --- a/Source/engine/render/dun_render.cpp +++ b/Source/engine/render/dun_render.cpp @@ -1017,7 +1017,7 @@ DVL_ATTRIBUTE_HOT void RenderTileType(TileType tile, std::uint8_t *dst, int dstP } /** Returns the mask that defines what parts of the tile are opaque. */ -const std::uint32_t *GetMask(TileType tile) +const std::uint32_t *GetMask(TileType tile, ArchType archType) { #ifdef _DEBUG if ((SDL_GetModState() & KMOD_ALT) != 0) { @@ -1026,25 +1026,25 @@ const std::uint32_t *GetMask(TileType tile) #endif if (cel_transparency_active) { - if (arch_draw_type == 0) { + if (archType == ArchType::None) { return &WallMaskFullyTrasparent[TILE_HEIGHT - 1]; } - if (arch_draw_type == 1 && tile != TileType::LeftTriangle) { + if (archType == ArchType::Left && tile != TileType::LeftTriangle) { if (TileHasAny(level_piece_id, TileProperties::TransparentLeft)) { return &LeftMaskTransparent[TILE_HEIGHT - 1]; } } - if (arch_draw_type == 2 && tile != TileType::RightTriangle) { + if (archType == ArchType::Right && tile != TileType::RightTriangle) { if (TileHasAny(level_piece_id, TileProperties::TransparentRight)) { return &RightMaskTransparent[TILE_HEIGHT - 1]; } } - } else if (arch_draw_type != 0 && cel_foliage_active) { + } else if (archType != ArchType::None && cel_foliage_active) { if (tile != TileType::TransparentSquare) return nullptr; - if (arch_draw_type == 1) + if (archType == ArchType::Left) return &LeftFoliageMask[TILE_HEIGHT - 1]; - if (arch_draw_type == 2) + if (archType == ArchType::Right) return &RightFoliageMask[TILE_HEIGHT - 1]; } return &SolidMask[TILE_HEIGHT - 1]; @@ -1142,10 +1142,10 @@ void RenderBlackTileFull(std::uint8_t *dst, int dstPitch) } // namespace -void RenderTile(const Surface &out, Point position, LevelCelBlock levelCelBlock) +void RenderTile(const Surface &out, Point position, LevelCelBlock levelCelBlock, ArchType archType) { const TileType tile = levelCelBlock.type(); - const auto *mask = GetMask(tile); + const uint32_t *mask = GetMask(tile, archType); if (mask == nullptr) return; diff --git a/Source/engine/render/dun_render.hpp b/Source/engine/render/dun_render.hpp index 38b848482..bde1ddc97 100644 --- a/Source/engine/render/dun_render.hpp +++ b/Source/engine/render/dun_render.hpp @@ -79,6 +79,15 @@ enum class TileType : uint8_t { RightTrapezoid, }; +/** + * Specifies the type of arches to render. + */ +enum class ArchType { + None, + Left, + Right +}; + /** * Specifies the current MIN block of the level CEL file, as used during rendering of the level tiles. */ @@ -113,8 +122,9 @@ private: * @param out Target buffer * @param position Target buffer coordinates * @param levelCelBlock The MIN block of the level CEL file. + * @param archType The type of arch to render. */ -void RenderTile(const Surface &out, Point position, LevelCelBlock levelCelBlock); +void RenderTile(const Surface &out, Point position, LevelCelBlock levelCelBlock, ArchType archType); /** * @brief Render a black 64x31 tile ◆ diff --git a/Source/engine/render/scrollrt.cpp b/Source/engine/render/scrollrt.cpp index 8a5306627..378fd8e1e 100644 --- a/Source/engine/render/scrollrt.cpp +++ b/Source/engine/render/scrollrt.cpp @@ -62,10 +62,6 @@ namespace devilution { int LightTableIndex; bool AutoMapShowItems; -/** - * Specifies the type of arches to render. - */ -char arch_draw_type; /** * Specifies whether transparency is active for the current CEL file being decoded. */ @@ -516,15 +512,15 @@ void DrawCell(const Surface &out, Point tilePosition, Point targetBufferPosition { const LevelCelBlock levelCelBlock { pMap->mt[2 * i] }; if (levelCelBlock.hasValue()) { - arch_draw_type = i == 0 ? 1 : 0; - RenderTile(out, targetBufferPosition, levelCelBlock); + RenderTile(out, targetBufferPosition, levelCelBlock, + i == 0 ? ArchType::Left : ArchType::None); } } { const LevelCelBlock levelCelBlock { pMap->mt[2 * i + 1] }; if (levelCelBlock.hasValue()) { - arch_draw_type = i == 0 ? 2 : 0; - RenderTile(out, targetBufferPosition + Displacement { TILE_WIDTH / 2, 0 }, levelCelBlock); + RenderTile(out, targetBufferPosition + Displacement { TILE_WIDTH / 2, 0 }, levelCelBlock, + i == 0 ? ArchType::Right : ArchType::None); } } targetBufferPosition.y -= TILE_HEIGHT; @@ -543,19 +539,17 @@ void DrawFloor(const Surface &out, Point tilePosition, Point targetBufferPositio cel_transparency_active = false; LightTableIndex = dLight[tilePosition.x][tilePosition.y]; - arch_draw_type = 1; // Left - int pn = dPiece[tilePosition.x][tilePosition.y]; + const uint16_t pn = dPiece[tilePosition.x][tilePosition.y]; { const LevelCelBlock levelCelBlock { DPieceMicros[pn].mt[0] }; if (levelCelBlock.hasValue()) { - RenderTile(out, targetBufferPosition, levelCelBlock); + RenderTile(out, targetBufferPosition, levelCelBlock, ArchType::Left); } } - arch_draw_type = 2; // Right { const LevelCelBlock levelCelBlock { DPieceMicros[pn].mt[1] }; if (levelCelBlock.hasValue()) { - RenderTile(out, targetBufferPosition + Displacement { TILE_WIDTH / 2, 0 }, levelCelBlock); + RenderTile(out, targetBufferPosition + Displacement { TILE_WIDTH / 2, 0 }, levelCelBlock, ArchType::Right); } } } diff --git a/Source/engine/render/scrollrt.h b/Source/engine/render/scrollrt.h index bd2f1be3c..7c549ae3d 100644 --- a/Source/engine/render/scrollrt.h +++ b/Source/engine/render/scrollrt.h @@ -14,7 +14,6 @@ namespace devilution { extern int LightTableIndex; -extern char arch_draw_type; extern bool cel_transparency_active; extern bool cel_foliage_active; extern int level_piece_id;