From 79989a5e84dd4cec9bb6c92f63c40ffc9304efb6 Mon Sep 17 00:00:00 2001 From: Ted John Date: Fri, 4 Mar 2022 00:39:22 +0000 Subject: [PATCH] Fix transparency issues --- src/openrct2/paint/Paint.Entity.cpp | 2 +- src/openrct2/paint/Paint.cpp | 38 ++++--------------- .../paint/tile_element/Paint.SmallScenery.cpp | 2 +- 3 files changed, 10 insertions(+), 32 deletions(-) diff --git a/src/openrct2/paint/Paint.Entity.cpp b/src/openrct2/paint/Paint.Entity.cpp index f5a9fea625..e1296bd394 100644 --- a/src/openrct2/paint/Paint.Entity.cpp +++ b/src/openrct2/paint/Paint.Entity.cpp @@ -73,7 +73,7 @@ void EntityPaintSetup(paint_session& session, const CoordsXY& pos) } } - if ((session.ViewFlags & VIEWPORT_FLAG_INVISIBLE_RIDES) && spr->Type == EntityType::Vehicle) + if ((session.ViewFlags & VIEWPORT_FLAG_INVISIBLE_VEHICLES) && spr->Type == EntityType::Vehicle) { const auto veh = spr->As(); if (veh != nullptr) diff --git a/src/openrct2/paint/Paint.cpp b/src/openrct2/paint/Paint.cpp index 6cc496d9ed..2b3067c0e5 100644 --- a/src/openrct2/paint/Paint.cpp +++ b/src/openrct2/paint/Paint.cpp @@ -56,7 +56,8 @@ bool gPaintBlockedTiles; static void PaintAttachedPS(rct_drawpixelinfo* dpi, paint_struct* ps, uint32_t viewFlags); static void PaintPSImageWithBoundingBoxes(rct_drawpixelinfo* dpi, paint_struct* ps, ImageId imageId, int32_t x, int32_t y); static void PaintPSImage(rct_drawpixelinfo* dpi, paint_struct* ps, ImageId imageId, int32_t x, int32_t y); -static ImageId PaintPSColourifyImage(ImageId imageId, ViewportInteractionItem spriteType, EntityType entityType, uint32_t viewFlags); +static ImageId PaintPSColourifyImage( + ImageId imageId, ViewportInteractionItem spriteType, EntityType entityType, uint32_t viewFlags); static int32_t RemapPositionToQuadrant(const paint_struct& ps, uint8_t rotation) { @@ -674,7 +675,8 @@ static void PaintPSImage(rct_drawpixelinfo* dpi, paint_struct* ps, ImageId image gfx_draw_sprite(dpi, imageId, { x, y }); } -static ImageId PaintPSColourifyImage(ImageId imageId, ViewportInteractionItem spriteType, EntityType entityType, uint32_t viewFlags) +static ImageId PaintPSColourifyImage( + ImageId imageId, ViewportInteractionItem spriteType, EntityType entityType, uint32_t viewFlags) { auto seeThrough = imageId.WithTransparancy(FilterPaletteID::PaletteDarken1); if (viewFlags & VIEWPORT_FLAG_SEETHROUGH_RIDES) @@ -684,11 +686,11 @@ static ImageId PaintPSColourifyImage(ImageId imageId, ViewportInteractionItem sp return seeThrough; } } - if ((viewFlags & VIEWPORT_FLAG_SEETHROUGH_VEHICLES) && !(viewFlags & VIEWPORT_FLAG_INVISIBLE_VEHICLES)) + if (viewFlags & VIEWPORT_FLAG_SEETHROUGH_VEHICLES) { if (spriteType == ViewportInteractionItem::Entity && entityType == EntityType::Vehicle) { - return seeThrough; + return (viewFlags & VIEWPORT_FLAG_INVISIBLE_VEHICLES) ? ImageId() : seeThrough; } } if (viewFlags & VIEWPORT_FLAG_UNDERGROUND_INSIDE) @@ -705,7 +707,7 @@ static ImageId PaintPSColourifyImage(ImageId imageId, ViewportInteractionItem sp case ViewportInteractionItem::Footpath: case ViewportInteractionItem::FootpathItem: case ViewportInteractionItem::Banner: - return seeThrough; + return (viewFlags & VIEWPORT_FLAG_INVISIBLE_PATHS) ? ImageId() : seeThrough; default: break; } @@ -717,31 +719,7 @@ static ImageId PaintPSColourifyImage(ImageId imageId, ViewportInteractionItem sp case ViewportInteractionItem::Scenery: case ViewportInteractionItem::LargeScenery: case ViewportInteractionItem::Wall: - return seeThrough; - default: - break; - } - } - if ((viewFlags & VIEWPORT_FLAG_SEETHROUGH_PATHS) && (viewFlags & VIEWPORT_FLAG_INVISIBLE_PATHS)) - { - switch (spriteType) - { - case ViewportInteractionItem::Footpath: - case ViewportInteractionItem::FootpathItem: - case ViewportInteractionItem::Banner: - return ImageId(); - default: - break; - } - } - if ((viewFlags & VIEWPORT_FLAG_SEETHROUGH_SCENERY) && (viewFlags & VIEWPORT_FLAG_INVISIBLE_SCENERY)) - { - switch (spriteType) - { - case ViewportInteractionItem::Scenery: - case ViewportInteractionItem::LargeScenery: - case ViewportInteractionItem::Wall: - return ImageId(); + return (viewFlags & VIEWPORT_FLAG_INVISIBLE_SCENERY) ? ImageId() : seeThrough; default: break; } diff --git a/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp b/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp index 43eeb74ca3..94d36403d1 100644 --- a/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp +++ b/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp @@ -345,7 +345,7 @@ void PaintSmallScenery(paint_session& session, uint8_t direction, int32_t height imageTemplate = ImageId().WithTransparancy(FilterPaletteID::PaletteDarken1); } - if (!sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_IS_TREE) || !(session.ViewFlags & VIEWPORT_FLAG_INVISIBLE_TREES)) + 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); }