1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-21 22:13:07 +01:00

Turn railing support type into enum class

This commit is contained in:
Michael Steenbeek
2019-03-16 14:21:44 +01:00
committed by GitHub
parent 1c0877fc6c
commit 6884eac24c
3 changed files with 16 additions and 16 deletions

View File

@@ -18,7 +18,7 @@
void FootpathObject::ReadLegacy(IReadObjectContext* context, IStream* stream)
{
stream->Seek(10, STREAM_SEEK_CURRENT);
_legacyType.support_type = stream->ReadValue<uint8_t>();
_legacyType.support_type = static_cast<RailingEntrySupportType>(stream->ReadValue<uint8_t>());
_legacyType.flags = stream->ReadValue<uint8_t>();
_legacyType.scrolling_mode = stream->ReadValue<uint8_t>();
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)

View File

@@ -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);

View File

@@ -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),