From 995c6debf14b4160ae82d42e474094ab2f8fb882 Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Wed, 26 Sep 2018 13:02:51 +0200 Subject: [PATCH] Port entrance path type lookup --- src/openrct2/EditorObjectSelectionSession.cpp | 2 +- src/openrct2/actions/PlaceParkEntranceAction.hpp | 2 +- src/openrct2/paint/tile_element/Paint.Entrance.cpp | 2 +- src/openrct2/rct1/S4Importer.cpp | 4 ++-- src/openrct2/world/Entrance.cpp | 10 ++++++++++ src/openrct2/world/Footpath.cpp | 8 ++++---- src/openrct2/world/TileElement.h | 13 +++---------- 7 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/openrct2/EditorObjectSelectionSession.cpp b/src/openrct2/EditorObjectSelectionSession.cpp index 41818e822b..e70c572a46 100644 --- a/src/openrct2/EditorObjectSelectionSession.cpp +++ b/src/openrct2/EditorObjectSelectionSession.cpp @@ -156,7 +156,7 @@ void setup_in_use_selection_flags() Editor::SetSelectedObject(OBJECT_TYPE_PARK_ENTRANCE, 0, OBJECT_SELECTION_FLAG_SELECTED); - type = iter.element->properties.entrance.path_type; + type = iter.element->AsEntrance()->GetPathType(); assert(type < object_entry_group_counts[OBJECT_TYPE_PATHS]); Editor::SetSelectedObject(OBJECT_TYPE_PATHS, type, OBJECT_SELECTION_FLAG_SELECTED); break; diff --git a/src/openrct2/actions/PlaceParkEntranceAction.hpp b/src/openrct2/actions/PlaceParkEntranceAction.hpp index 45ed9d0a5a..d6dad9a262 100644 --- a/src/openrct2/actions/PlaceParkEntranceAction.hpp +++ b/src/openrct2/actions/PlaceParkEntranceAction.hpp @@ -194,7 +194,7 @@ public: newElement->SetDirection(_direction); newElement->AsEntrance()->SetSequenceIndex(index); newElement->AsEntrance()->SetEntranceType(ENTRANCE_TYPE_PARK_ENTRANCE); - newElement->properties.entrance.path_type = gFootpathSelectedId; + newElement->AsEntrance()->SetPathType(gFootpathSelectedId); if (!(flags & GAME_COMMAND_FLAG_GHOST)) { diff --git a/src/openrct2/paint/tile_element/Paint.Entrance.cpp b/src/openrct2/paint/tile_element/Paint.Entrance.cpp index 078793ac0f..87733df724 100644 --- a/src/openrct2/paint/tile_element/Paint.Entrance.cpp +++ b/src/openrct2/paint/tile_element/Paint.Entrance.cpp @@ -237,7 +237,7 @@ static void park_entrance_paint(paint_session* session, uint8_t direction, int32 // The left and right of the park entrance often have this set to 127. // So only attempt to get the footpath type if we're dealing with the middle bit of the entrance. if (part_index == 0) - path_entry = get_footpath_entry(tile_element->properties.entrance.path_type); + path_entry = get_footpath_entry(tile_element->AsEntrance()->GetPathType()); rct_entrance_type* entrance; uint8_t di = ((direction / 2 + part_index / 2) & 1) ? 0x1A : 0x20; diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 17d490326e..1d3f6c688b 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -2538,13 +2538,13 @@ private: case TILE_ELEMENT_TYPE_ENTRANCE: if (tileElement->AsEntrance()->GetEntranceType() == ENTRANCE_TYPE_PARK_ENTRANCE) { - uint8_t pathType = tileElement->properties.entrance.path_type; + uint8_t pathType = tileElement->AsEntrance()->GetPathType(); if (pathType == 0) { pathType = RCT1_FOOTPATH_TYPE_TARMAC_GRAY; } uint8_t entryIndex = _pathTypeToEntryMap[pathType]; - tileElement->properties.entrance.path_type = entryIndex & 0x7F; + tileElement->AsEntrance()->SetPathType(entryIndex & 0x7F); } break; } diff --git a/src/openrct2/world/Entrance.cpp b/src/openrct2/world/Entrance.cpp index d7506fb478..90501dfffe 100644 --- a/src/openrct2/world/Entrance.cpp +++ b/src/openrct2/world/Entrance.cpp @@ -671,4 +671,14 @@ void EntranceElement::SetSequenceIndex(uint8_t newSequenceIndex) { index &= ~0xF; index |= (newSequenceIndex & 0xF); +} + +uint8_t EntranceElement::GetPathType() const +{ + return pathType; +} + +void EntranceElement::SetPathType(uint8_t newPathType) +{ + pathType = newPathType; } \ No newline at end of file diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index 85d5472f24..0859a6c290 100644 --- a/src/openrct2/world/Footpath.cpp +++ b/src/openrct2/world/Footpath.cpp @@ -222,7 +222,7 @@ static money32 footpath_element_insert( { entrancePath = true; // Make the price the same as replacing a path - if (entranceElement->properties.entrance.path_type == (type & 0xF)) + if (entranceElement->AsEntrance()->GetPathType() == (type & 0xF)) entranceIsSamePath = true; else gFootpathPrice -= MONEY(6, 00); @@ -256,7 +256,7 @@ static money32 footpath_element_insert( if (!(flags & GAME_COMMAND_FLAG_GHOST) && !entranceIsSamePath) { // Set the path type but make sure it's not a queue as that will not show up - entranceElement->properties.entrance.path_type = type & 0x7F; + entranceElement->AsEntrance()->SetPathType(type & 0x7F); map_invalidate_tile_full(x, y); } } @@ -593,7 +593,7 @@ static money32 footpath_place_from_track( { entrancePath = true; // Make the price the same as replacing a path - if (entranceElement->properties.entrance.path_type == (type & 0xF)) + if (entranceElement->AsEntrance()->GetPathType() == (type & 0xF)) entranceIsSamePath = true; else gFootpathPrice -= MONEY(6, 00); @@ -636,7 +636,7 @@ static money32 footpath_place_from_track( if (!(flags & GAME_COMMAND_FLAG_GHOST) && !entranceIsSamePath) { // Set the path type but make sure it's not a queue as that will not show up - entranceElement->properties.entrance.path_type = type & 0x7F; + entranceElement->AsEntrance()->SetPathType(type & 0x7F); map_invalidate_tile_full(x, y); } } diff --git a/src/openrct2/world/TileElement.h b/src/openrct2/world/TileElement.h index d7e1dd3380..fb7986eb9d 100644 --- a/src/openrct2/world/TileElement.h +++ b/src/openrct2/world/TileElement.h @@ -28,15 +28,6 @@ struct rct_tile_element_path_properties }; assert_struct_size(rct_tile_element_path_properties, 4); -struct rct_tile_element_entrance_properties -{ - uint8_t type; // 4 - uint8_t index; // 5 - uint8_t path_type; // 6 - uint8_t ride_index; // 7 -}; -assert_struct_size(rct_tile_element_entrance_properties, 4); - struct rct_tile_element_banner_properties { BannerIndex index; // 4 @@ -49,7 +40,6 @@ assert_struct_size(rct_tile_element_banner_properties, 4); union rct_tile_element_properties { rct_tile_element_path_properties path; - rct_tile_element_entrance_properties entrance; rct_tile_element_banner_properties banner; }; assert_struct_size(rct_tile_element_properties, 4); @@ -392,6 +382,9 @@ public: uint8_t GetSequenceIndex() const; void SetSequenceIndex(uint8_t newSequenceIndex); + + uint8_t GetPathType() const; + void SetPathType(uint8_t newPathType); }; assert_struct_size(EntranceElement, 8);