Fix supports changing when trees were invisible

This commit is contained in:
Kane 2021-08-10 04:38:14 +10:00 committed by Ted John
parent e134be9538
commit 1c306e0a1a
1 changed files with 47 additions and 42 deletions

View File

@ -103,54 +103,15 @@ static void SetSupportHeights(
}
}
/**
*
* rct2: 0x006DFF47
*/
void PaintSmallScenery(paint_session& session, uint8_t direction, int32_t height, const SmallSceneryElement& sceneryElement)
static void PaintSmallSceneryBody(
paint_session& session, uint8_t direction, int32_t height, const SmallSceneryElement& sceneryElement,
const SmallSceneryEntry* sceneryEntry, ImageId imageTemplate)
{
PROFILED_FUNCTION();
if (session.ViewFlags & VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES)
{
return;
}
auto* sceneryEntry = sceneryElement.GetEntry();
if (sceneryEntry == nullptr)
{
return;
}
if (sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_IS_TREE) && (session.ViewFlags & VIEWPORT_FLAG_INVISIBLE_TREES))
{
return;
}
session.InteractionType = ViewportInteractionItem::Scenery;
CoordsXYZ boxLength;
CoordsXYZ boxOffset{ 0, 0, height };
ImageId imageTemplate;
if (gTrackDesignSaveMode)
{
if (!track_design_save_contains_tile_element(reinterpret_cast<const TileElement*>(&sceneryElement)))
{
imageTemplate = ImageId().WithRemap(FilterPaletteID::Palette46);
}
}
if (sceneryElement.IsGhost())
{
session.InteractionType = ViewportInteractionItem::None;
imageTemplate = ImageId().WithRemap(FilterPaletteID::Palette44);
}
else if (OpenRCT2::TileInspector::IsElementSelected(reinterpret_cast<const TileElement*>(&sceneryElement)))
{
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);
}
boxLength.x = 2;
boxLength.y = 2;
@ -344,6 +305,50 @@ void PaintSmallScenery(paint_session& session, uint8_t direction, int32_t height
}
}
}
}
void PaintSmallScenery(paint_session& session, uint8_t direction, int32_t height, const SmallSceneryElement& sceneryElement)
{
PROFILED_FUNCTION();
if (session.ViewFlags & VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES)
{
return;
}
auto* sceneryEntry = sceneryElement.GetEntry();
if (sceneryEntry == nullptr)
{
return;
}
session.InteractionType = ViewportInteractionItem::Scenery;
ImageId imageTemplate;
if (gTrackDesignSaveMode)
{
if (!track_design_save_contains_tile_element(reinterpret_cast<const TileElement*>(&sceneryElement)))
{
imageTemplate = ImageId().WithRemap(FilterPaletteID::Palette46);
}
}
if (sceneryElement.IsGhost())
{
session.InteractionType = ViewportInteractionItem::None;
imageTemplate = ImageId().WithRemap(FilterPaletteID::Palette44);
}
else if (OpenRCT2::TileInspector::IsElementSelected(reinterpret_cast<const TileElement*>(&sceneryElement)))
{
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_INVISIBLE_TREES))
{
PaintSmallSceneryBody(session, direction, height, sceneryElement, sceneryEntry, imageTemplate);
}
PaintSmallScenerySupports(session, *sceneryEntry, sceneryElement, direction, height, imageTemplate);
SetSupportHeights(session, *sceneryEntry, sceneryElement, height);