From 6884eac24c50b307f346002c665c510cdc41c0fe Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Sat, 16 Mar 2019 14:21:44 +0100 Subject: [PATCH] Turn railing support type into enum class --- src/openrct2/object/FootpathObject.cpp | 12 ++++++------ src/openrct2/paint/tile_element/Paint.Path.cpp | 2 +- src/openrct2/world/Footpath.h | 18 +++++++++--------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/openrct2/object/FootpathObject.cpp b/src/openrct2/object/FootpathObject.cpp index 83403af7fc..15b0bb1699 100644 --- a/src/openrct2/object/FootpathObject.cpp +++ b/src/openrct2/object/FootpathObject.cpp @@ -18,7 +18,7 @@ void FootpathObject::ReadLegacy(IReadObjectContext* context, IStream* stream) { stream->Seek(10, STREAM_SEEK_CURRENT); - _legacyType.support_type = stream->ReadValue(); + _legacyType.support_type = static_cast(stream->ReadValue()); _legacyType.flags = stream->ReadValue(); _legacyType.scrolling_mode = stream->ReadValue(); stream->Seek(1, STREAM_SEEK_CURRENT); @@ -27,9 +27,9 @@ void FootpathObject::ReadLegacy(IReadObjectContext* context, IStream* stream) GetImageTable().Read(context, stream); // Validate properties - if (_legacyType.support_type >= RAILING_ENTRY_SUPPORT_TYPE_COUNT) + if (_legacyType.support_type >= RailingEntrySupportType::Count) { - context->LogError(OBJECT_ERROR_INVALID_PROPERTY, "SUPPORT_TYPE not supported."); + context->LogError(OBJECT_ERROR_INVALID_PROPERTY, "RailingEntrySupportType not supported."); } } @@ -76,12 +76,12 @@ void FootpathObject::DrawPreview(rct_drawpixelinfo* dpi, int32_t width, int32_t gfx_draw_sprite(dpi, _queueEntry.preview, x + 4, y - 17, 0); } -static uint8_t ParseSupportType(const std::string& s) +static RailingEntrySupportType ParseSupportType(const std::string& s) { if (s == "pole") - return RAILING_ENTRY_SUPPORT_TYPE_POLE; + return RailingEntrySupportType::Pole; else /* if (s == "box") */ - return RAILING_ENTRY_SUPPORT_TYPE_BOX; + return RailingEntrySupportType::Box; } void FootpathObject::ReadJson(IReadObjectContext* context, const json_t* root) diff --git a/src/openrct2/paint/tile_element/Paint.Path.cpp b/src/openrct2/paint/tile_element/Paint.Path.cpp index 8172801679..6bebe317a0 100644 --- a/src/openrct2/paint/tile_element/Paint.Path.cpp +++ b/src/openrct2/paint/tile_element/Paint.Path.cpp @@ -932,7 +932,7 @@ void path_paint(paint_session* session, uint16_t height, const TileElement* tile if (footpathEntry != nullptr && railingEntry != nullptr) { - if (railingEntry->support_type == RAILING_ENTRY_SUPPORT_TYPE_POLE) + if (railingEntry->support_type == RailingEntrySupportType::Pole) { path_paint_pole_support( session, tile_element, height, footpathEntry, railingEntry, hasSupports, imageFlags, sceneryImageFlags); diff --git a/src/openrct2/world/Footpath.h b/src/openrct2/world/Footpath.h index 33cba7114c..4b08589347 100644 --- a/src/openrct2/world/Footpath.h +++ b/src/openrct2/world/Footpath.h @@ -26,13 +26,20 @@ constexpr auto FootpathMinHeight = 2; #define FOOTPATH_ELEMENT_INSERT_QUEUE 0x80 +enum class RailingEntrySupportType : uint8_t +{ + Box = 0, + Pole = 1, + Count +}; + #pragma pack(push, 1) struct rct_footpath_entry { rct_string_id string_idx; // 0x00 uint32_t image; // 0x02 uint32_t bridge_image; // 0x06 - uint8_t support_type; // 0x0A + RailingEntrySupportType support_type; // 0x0A uint8_t flags; // 0x0B uint8_t scrolling_mode; // 0x0C }; @@ -53,7 +60,7 @@ struct PathRailingsEntry uint32_t preview; uint32_t bridge_image; uint32_t railings_image; - uint8_t support_type; + RailingEntrySupportType support_type; uint8_t flags; uint8_t scrolling_mode; }; @@ -91,13 +98,6 @@ enum FOOTPATH_PROPERTIES_ADDITIONS_FLAG_GHOST = (1 << 7), }; -enum -{ - RAILING_ENTRY_SUPPORT_TYPE_BOX = 0, - RAILING_ENTRY_SUPPORT_TYPE_POLE = 1, - RAILING_ENTRY_SUPPORT_TYPE_COUNT -}; - enum { FOOTPATH_ENTRY_FLAG_SHOW_ONLY_IN_SCENARIO_EDITOR = (1 << 2),