From 9794be6a09993b62377d995318e314522d403f28 Mon Sep 17 00:00:00 2001 From: Ted John Date: Fri, 4 Mar 2022 01:48:01 +0000 Subject: [PATCH] Hide trees using colourify function --- src/openrct2/paint/Paint.cpp | 27 +++++++++++++++++++ .../paint/tile_element/Paint.SmallScenery.cpp | 10 +------ 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/openrct2/paint/Paint.cpp b/src/openrct2/paint/Paint.cpp index f9f4739bd6..a979a7208a 100644 --- a/src/openrct2/paint/Paint.cpp +++ b/src/openrct2/paint/Paint.cpp @@ -19,6 +19,7 @@ #include "../paint/Painter.h" #include "../profiling/Profiling.h" #include "../util/Math.hpp" +#include "../world/SmallScenery.h" #include "Paint.Entity.h" #include "tile_element/Paint.TileElement.h" @@ -664,6 +665,20 @@ static void PaintPSImage(rct_drawpixelinfo* dpi, paint_struct* ps, ImageId image gfx_draw_sprite(dpi, imageId, { x, y }); } +static bool IsTileElementTree(const TileElement* tileElement) +{ + auto sceneryItem = tileElement->AsSmallScenery(); + if (sceneryItem != nullptr) + { + auto sceneryEntry = sceneryItem->GetEntry(); + if (sceneryEntry != nullptr && sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_IS_TREE)) + { + return true; + } + } + return false; +} + static ImageId PaintPSColourifyImage( ImageId imageId, ViewportInteractionItem spriteType, uint32_t viewFlags, const TileElement* tileElement, const EntityBase* entity) @@ -707,6 +722,11 @@ static ImageId PaintPSColourifyImage( switch (spriteType) { case ViewportInteractionItem::Scenery: + if (!IsTileElementTree(tileElement)) + { + return (viewFlags & VIEWPORT_FLAG_INVISIBLE_SCENERY) ? ImageId() : seeThrough; + } + break; case ViewportInteractionItem::LargeScenery: case ViewportInteractionItem::Wall: return (viewFlags & VIEWPORT_FLAG_INVISIBLE_SCENERY) ? ImageId() : seeThrough; @@ -714,6 +734,13 @@ static ImageId PaintPSColourifyImage( break; } } + if (viewFlags & VIEWPORT_FLAG_SEETHROUGH_TREES) + { + if (spriteType == ViewportInteractionItem::Scenery && IsTileElementTree(tileElement)) + { + return (viewFlags & VIEWPORT_FLAG_INVISIBLE_TREES) ? ImageId() : seeThrough; + } + } return imageId; } diff --git a/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp b/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp index 94d36403d1..f0f7ca1b30 100644 --- a/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp +++ b/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp @@ -340,16 +340,8 @@ void PaintSmallScenery(paint_session& session, uint8_t direction, int32_t height { imageTemplate = ImageId().WithRemap(FilterPaletteID::Palette44); } - else if (sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_IS_TREE) && (session.ViewFlags & VIEWPORT_FLAG_SEETHROUGH_TREES)) - { - imageTemplate = ImageId().WithTransparancy(FilterPaletteID::PaletteDarken1); - } - - if (!sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_IS_TREE) || !((session.ViewFlags & VIEWPORT_FLAG_SEETHROUGH_TREES) && (session.ViewFlags & VIEWPORT_FLAG_INVISIBLE_TREES))) - { - PaintSmallSceneryBody(session, direction, height, sceneryElement, sceneryEntry, imageTemplate); - } + PaintSmallSceneryBody(session, direction, height, sceneryElement, sceneryEntry, imageTemplate); PaintSmallScenerySupports(session, *sceneryEntry, sceneryElement, direction, height, imageTemplate); SetSupportHeights(session, *sceneryEntry, sceneryElement, height); }