From 28b2995cebe74adee00649f06c424830bee9998d Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Tue, 27 Apr 2021 12:25:34 +0200 Subject: [PATCH] Fix queue preview for legacy paths; clean up legacy path image offsets --- src/openrct2-ui/windows/Footpath.cpp | 11 +++++++---- src/openrct2/paint/tile_element/Paint.Path.cpp | 4 ++-- src/openrct2/world/Footpath.h | 17 +++++++++++++++++ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/openrct2-ui/windows/Footpath.cpp b/src/openrct2-ui/windows/Footpath.cpp index c08835337b..d72c857dd7 100644 --- a/src/openrct2-ui/windows/Footpath.cpp +++ b/src/openrct2-ui/windows/Footpath.cpp @@ -617,8 +617,8 @@ static void window_footpath_invalidate(rct_window* w) if (pathObj != nullptr) { auto pathEntry = reinterpret_cast(pathObj->GetLegacyData()); - pathImage = pathEntry->image + 71; - queueImage = pathEntry->image + 72; + pathImage = pathEntry->GetPreviewImage(); + queueImage = pathEntry->GetQueuePreviewImage(); } window_footpath_widgets[WIDX_FOOTPATH_TYPE].image = pathImage; @@ -670,7 +670,10 @@ static void window_footpath_paint(rct_window* w, rct_drawpixelinfo* dpi) if (pathObj != nullptr) { auto pathEntry = reinterpret_cast(pathObj->GetLegacyData()); - baseImage = pathEntry->image; + if (gFootpathSelection.IsQueueSelected) + baseImage = pathEntry->GetQueueImage(); + else + baseImage = pathEntry->image; } } @@ -766,7 +769,7 @@ static void window_footpath_show_footpath_types_dialog(rct_window* w, rct_widget } gDropdownItemsFormat[numPathTypes] = STR_NONE; - gDropdownItemsArgs[numPathTypes] = pathEntry->image + (showQueues ? 72 : 71); + gDropdownItemsArgs[numPathTypes] = showQueues ? pathEntry->GetQueuePreviewImage() : pathEntry->GetPreviewImage(); _dropdownEntries.push_back({ ObjectType::Paths, i }); numPathTypes++; } diff --git a/src/openrct2/paint/tile_element/Paint.Path.cpp b/src/openrct2/paint/tile_element/Paint.Path.cpp index 6eda35efe3..5c915a4164 100644 --- a/src/openrct2/paint/tile_element/Paint.Path.cpp +++ b/src/openrct2/paint/tile_element/Paint.Path.cpp @@ -815,7 +815,7 @@ static FootpathPaintInfo GetFootpathPaintInfo(const PathElement* pathEl) auto footpathEntry = reinterpret_cast(footpathObj->GetLegacyData()); if (pathEl->IsQueue()) { - pathPaintInfo.SurfaceImageId = footpathEntry->image + 51; + pathPaintInfo.SurfaceImageId = footpathEntry->GetQueueImage(); pathPaintInfo.SurfaceFlags = footpathEntry->flags | FOOTPATH_ENTRY_FLAG_IS_QUEUE; } else @@ -827,7 +827,7 @@ static FootpathPaintInfo GetFootpathPaintInfo(const PathElement* pathEl) pathPaintInfo.SupportType = footpathEntry->support_type; pathPaintInfo.BridgeImageId = footpathEntry->bridge_image; pathPaintInfo.RailingFlags = footpathEntry->flags; - pathPaintInfo.RailingsImageId = footpathEntry->image + 73; + pathPaintInfo.RailingsImageId = footpathEntry->GetRailingsImage(); } else { diff --git a/src/openrct2/world/Footpath.h b/src/openrct2/world/Footpath.h index d544d7b684..e177ac86a0 100644 --- a/src/openrct2/world/Footpath.h +++ b/src/openrct2/world/Footpath.h @@ -44,6 +44,23 @@ struct rct_footpath_entry RailingEntrySupportType support_type; // 0x0A uint8_t flags; // 0x0B uint8_t scrolling_mode; // 0x0C + + constexpr uint32_t GetQueueImage() const + { + return image + 51; + } + constexpr uint32_t GetPreviewImage() const + { + return image + 71; + } + constexpr uint32_t GetQueuePreviewImage() const + { + return image + 72; + } + constexpr uint32_t GetRailingsImage() const + { + return image + 73; + } }; assert_struct_size(rct_footpath_entry, 13); #pragma pack(pop)