diff --git a/src/openrct2-ui/windows/Footpath.cpp b/src/openrct2-ui/windows/Footpath.cpp index 591746e731..df28e81003 100644 --- a/src/openrct2-ui/windows/Footpath.cpp +++ b/src/openrct2-ui/windows/Footpath.cpp @@ -1015,16 +1015,16 @@ static void footpath_remove_tile_element(rct_tile_element* tileElement) // Find a connected edge int32_t edge = gFootpathConstructDirection ^ 2; - if (!(tileElement->properties.path.edges & (1 << edge))) + if (!(tileElement->AsPath()->GetEdges() & (1 << edge))) { edge = (edge + 1) & 3; - if (!(tileElement->properties.path.edges & (1 << edge))) + if (!(tileElement->AsPath()->GetEdges() & (1 << edge))) { edge = (edge + 2) & 3; - if (!(tileElement->properties.path.edges & (1 << edge))) + if (!(tileElement->AsPath()->GetEdges() & (1 << edge))) { edge = (edge - 1) & 3; - if (!(tileElement->properties.path.edges & (1 << edge))) + if (!(tileElement->AsPath()->GetEdges() & (1 << edge))) { edge ^= 2; } diff --git a/src/openrct2-ui/windows/TileInspector.cpp b/src/openrct2-ui/windows/TileInspector.cpp index a0f3a2d27b..491ce5f591 100644 --- a/src/openrct2-ui/windows/TileInspector.cpp +++ b/src/openrct2-ui/windows/TileInspector.cpp @@ -1515,25 +1515,21 @@ static void window_tile_inspector_invalidate(rct_window* w) w->widgets[WIDX_PATH_CHECK_EDGE_NW].bottom = w->widgets[WIDX_PATH_CHECK_EDGE_NW].top + 13; widget_set_checkbox_value(w, WIDX_PATH_CHECK_SLOPED, tileElement->AsPath()->IsSloped()); widget_set_checkbox_value( - w, WIDX_PATH_CHECK_EDGE_NE, tileElement->properties.path.edges & (1 << ((0 - get_current_rotation()) & 3))); + w, WIDX_PATH_CHECK_EDGE_NE, tileElement->AsPath()->GetEdges() & (1 << ((0 - get_current_rotation()) & 3))); widget_set_checkbox_value( - w, WIDX_PATH_CHECK_EDGE_SE, tileElement->properties.path.edges & (1 << ((1 - get_current_rotation()) & 3))); + w, WIDX_PATH_CHECK_EDGE_SE, tileElement->AsPath()->GetEdges() & (1 << ((1 - get_current_rotation()) & 3))); widget_set_checkbox_value( - w, WIDX_PATH_CHECK_EDGE_SW, tileElement->properties.path.edges & (1 << ((2 - get_current_rotation()) & 3))); + w, WIDX_PATH_CHECK_EDGE_SW, tileElement->AsPath()->GetEdges() & (1 << ((2 - get_current_rotation()) & 3))); widget_set_checkbox_value( - w, WIDX_PATH_CHECK_EDGE_NW, tileElement->properties.path.edges & (1 << ((3 - get_current_rotation()) & 3))); + w, WIDX_PATH_CHECK_EDGE_NW, tileElement->AsPath()->GetEdges() & (1 << ((3 - get_current_rotation()) & 3))); widget_set_checkbox_value( - w, WIDX_PATH_CHECK_EDGE_E, - tileElement->properties.path.edges & (1 << (4 + ((0 - get_current_rotation()) & 3)))); + w, WIDX_PATH_CHECK_EDGE_E, tileElement->AsPath()->GetCorners() & (1 << ((0 - get_current_rotation()) & 3))); widget_set_checkbox_value( - w, WIDX_PATH_CHECK_EDGE_S, - tileElement->properties.path.edges & (1 << (4 + ((1 - get_current_rotation()) & 3)))); + w, WIDX_PATH_CHECK_EDGE_S, tileElement->AsPath()->GetCorners() & (1 << ((1 - get_current_rotation()) & 3))); widget_set_checkbox_value( - w, WIDX_PATH_CHECK_EDGE_W, - tileElement->properties.path.edges & (1 << (4 + ((2 - get_current_rotation()) & 3)))); + w, WIDX_PATH_CHECK_EDGE_W, tileElement->AsPath()->GetCorners() & (1 << ((2 - get_current_rotation()) & 3))); widget_set_checkbox_value( - w, WIDX_PATH_CHECK_EDGE_N, - tileElement->properties.path.edges & (1 << (4 + ((3 - get_current_rotation()) & 3)))); + w, WIDX_PATH_CHECK_EDGE_N, tileElement->AsPath()->GetCorners() & (1 << ((3 - get_current_rotation()) & 3))); break; case TILE_INSPECTOR_PAGE_TRACK: w->widgets[WIDX_TRACK_CHECK_APPLY_TO_ALL].top = GBBT(propertiesAnchor, 0); diff --git a/src/openrct2/paint/tile_element/Paint.Path.cpp b/src/openrct2/paint/tile_element/Paint.Path.cpp index ce3fa9f5b8..7589496c00 100644 --- a/src/openrct2/paint/tile_element/Paint.Path.cpp +++ b/src/openrct2/paint/tile_element/Paint.Path.cpp @@ -942,22 +942,22 @@ void path_paint(paint_session* session, uint16_t height, const rct_tile_element* rct_scenery_entry* sceneryEntry = tile_element->AsPath()->GetAdditionEntry(); if (sceneryEntry->path_bit.flags & PATH_BIT_FLAG_LAMP) { - if (!(tile_element->properties.path.edges & EDGE_NE)) + if (!(tile_element->AsPath()->GetEdges() & EDGE_NE)) { lightfx_add_3d_light_magic_from_drawing_tile( session->MapPosition, -16, 0, height + 23, LIGHTFX_LIGHT_TYPE_LANTERN_3); } - if (!(tile_element->properties.path.edges & EDGE_SE)) + if (!(tile_element->AsPath()->GetEdges() & EDGE_SE)) { lightfx_add_3d_light_magic_from_drawing_tile( session->MapPosition, 0, 16, height + 23, LIGHTFX_LIGHT_TYPE_LANTERN_3); } - if (!(tile_element->properties.path.edges & EDGE_SW)) + if (!(tile_element->AsPath()->GetEdges() & EDGE_SW)) { lightfx_add_3d_light_magic_from_drawing_tile( session->MapPosition, 16, 0, height + 23, LIGHTFX_LIGHT_TYPE_LANTERN_3); } - if (!(tile_element->properties.path.edges & EDGE_NW)) + if (!(tile_element->AsPath()->GetEdges() & EDGE_NW)) { lightfx_add_3d_light_magic_from_drawing_tile( session->MapPosition, 0, -16, height + 23, LIGHTFX_LIGHT_TYPE_LANTERN_3); @@ -975,11 +975,11 @@ void path_paint_box_support( PathElement* pathElement = tileElement->AsPath(); // Rol edges around rotation - uint8_t edges = ((tileElement->properties.path.edges << session->CurrentRotation) & 0xF) - | (((tileElement->properties.path.edges & 0xF) << session->CurrentRotation) >> 4); + uint8_t edges = ((tileElement->AsPath()->GetEdges() << session->CurrentRotation) & 0xF) + | (((tileElement->AsPath()->GetEdges()) << session->CurrentRotation) >> 4); - uint8_t corners = (((tileElement->properties.path.edges >> 4) << session->CurrentRotation) & 0xF) - | (((tileElement->properties.path.edges >> 4) << session->CurrentRotation) >> 4); + uint8_t corners = (((tileElement->AsPath()->GetCorners()) << session->CurrentRotation) & 0xF) + | (((tileElement->AsPath()->GetCorners()) << session->CurrentRotation) >> 4); LocationXY16 boundBoxOffset = { stru_98D804[edges][0], stru_98D804[edges][1] }; LocationXY16 boundBoxSize = { stru_98D804[edges][2], stru_98D804[edges][3] }; @@ -1086,13 +1086,13 @@ void path_paint_box_support( paint_util_set_general_support_height(session, height, 0x20); - if (pathElement->IsQueue() || (tileElement->properties.path.edges != 0xFF && hasFences)) + if (pathElement->IsQueue() || (tileElement->AsPath()->GetEdgesAndCorners() != 0xFF && hasFences)) { paint_util_set_segment_support_height(session, SEGMENTS_ALL, 0xFFFF, 0); return; } - if (tileElement->properties.path.edges == 0xFF) + if (tileElement->AsPath()->GetEdgesAndCorners() == 0xFF) { paint_util_set_segment_support_height(session, SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, 0xFFFF, 0); return; @@ -1128,15 +1128,15 @@ void path_paint_pole_support( PathElement* pathElement = tileElement->AsPath(); // Rol edges around rotation - uint8_t edges = ((tileElement->properties.path.edges << session->CurrentRotation) & 0xF) - | (((tileElement->properties.path.edges & 0xF) << session->CurrentRotation) >> 4); + uint8_t edges = ((tileElement->AsPath()->GetEdges() << session->CurrentRotation) & 0xF) + | (((tileElement->AsPath()->GetEdges()) << session->CurrentRotation) >> 4); LocationXY16 boundBoxOffset = { stru_98D804[edges][0], stru_98D804[edges][1] }; LocationXY16 boundBoxSize = { stru_98D804[edges][2], stru_98D804[edges][3] }; - uint8_t corners = (((tileElement->properties.path.edges >> 4) << session->CurrentRotation) & 0xF) - | (((tileElement->properties.path.edges >> 4) << session->CurrentRotation) >> 4); + uint8_t corners = (((tileElement->AsPath()->GetCorners()) << session->CurrentRotation) & 0xF) + | (((tileElement->AsPath()->GetCorners()) << session->CurrentRotation) >> 4); uint16_t edi = edges | (corners << 4); @@ -1242,13 +1242,13 @@ void path_paint_pole_support( paint_util_set_general_support_height(session, height, 0x20); - if (pathElement->IsQueue() || (tileElement->properties.path.edges != 0xFF && hasFences)) + if (pathElement->IsQueue() || (tileElement->AsPath()->GetEdgesAndCorners() != 0xFF && hasFences)) { paint_util_set_segment_support_height(session, SEGMENTS_ALL, 0xFFFF, 0); return; } - if (tileElement->properties.path.edges == 0xFF) + if (tileElement->AsPath()->GetEdgesAndCorners() == 0xFF) { paint_util_set_segment_support_height(session, SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, 0xFFFF, 0); return; diff --git a/src/openrct2/peep/Guest.cpp b/src/openrct2/peep/Guest.cpp index a25bbbdffa..45e584e5d2 100644 --- a/src/openrct2/peep/Guest.cpp +++ b/src/openrct2/peep/Guest.cpp @@ -5333,7 +5333,7 @@ void rct_peep::UpdateWalking() } } - int32_t edges = (tileElement->properties.path.edges & 0xF) ^ 0xF; + int32_t edges = (tileElement->AsPath()->GetEdges()) ^ 0xF; if (edges == 0) return; @@ -5935,7 +5935,7 @@ bool rct_peep::UpdateWalkingFindBench() if (tileElement->AsPath()->AdditionIsGhost()) return false; - int32_t edges = (tileElement->properties.path.edges & 0xF) ^ 0xF; + int32_t edges = (tileElement->AsPath()->GetEdges()) ^ 0xF; if (edges == 0) return false; @@ -6034,7 +6034,7 @@ bool rct_peep::UpdateWalkingFindBin() if (tileElement->AsPath()->AdditionIsGhost()) return false; - int32_t edges = (tileElement->properties.path.edges & 0xF) ^ 0xF; + int32_t edges = (tileElement->AsPath()->GetEdges()) ^ 0xF; if (edges == 0) return false; @@ -6131,7 +6131,7 @@ static void peep_update_walking_break_scenery(rct_peep* peep) if (tileElement->AsPath()->AdditionIsGhost()) return; - int32_t edges = tileElement->properties.path.edges & 0xF; + int32_t edges = tileElement->AsPath()->GetEdges(); if (edges == 0xF) return; diff --git a/src/openrct2/peep/GuestPathfinding.cpp b/src/openrct2/peep/GuestPathfinding.cpp index 3a2d109ddd..9df537e48a 100644 --- a/src/openrct2/peep/GuestPathfinding.cpp +++ b/src/openrct2/peep/GuestPathfinding.cpp @@ -97,7 +97,7 @@ static int32_t banner_clear_path_edges(rct_tile_element* tileElement, int32_t ed */ static int32_t path_get_permitted_edges(rct_tile_element* tileElement) { - return banner_clear_path_edges(tileElement, tileElement->properties.path.edges) & 0x0F; + return banner_clear_path_edges(tileElement, tileElement->AsPath()->GetEdgesAndCorners()) & 0x0F; } /** @@ -475,7 +475,7 @@ static uint8_t peep_pathfind_get_max_number_junctions(rct_peep* peep) */ static bool path_is_thin_junction(rct_tile_element* path, TileCoordsXYZ loc) { - uint8_t edges = footpath_get_edges(path); + uint8_t edges = path->AsPath()->GetEdges(); int32_t test_edge = bitscanforward(edges); if (test_edge == -1) @@ -738,7 +738,7 @@ static void peep_pathfind_heuristic_search( searchResult = PATH_SEARCH_THIN; - uint8_t numEdges = bitcount(footpath_get_edges(tileElement)); + uint8_t numEdges = bitcount(tileElement->AsPath()->GetEdges()); if (numEdges < 2) { @@ -1816,25 +1816,25 @@ static void get_ride_queue_end(TileCoordsXYZ& loc) if (!tileElement->AsPath()->IsQueue()) break; - if (!(tileElement->properties.path.edges & (1 << (direction ^ (1 << 1))))) + if (!(tileElement->AsPath()->GetEdges() & (1 << (direction ^ (1 << 1))))) break; if (firstPathElement == nullptr) firstPathElement = tileElement; // More queue to go. - if (tileElement->properties.path.edges & (1 << (direction))) + if (tileElement->AsPath()->GetEdges() & (1 << (direction))) continue; direction++; direction &= 3; // More queue to go. - if (tileElement->properties.path.edges & (1 << (direction))) + if (tileElement->AsPath()->GetEdges() & (1 << (direction))) continue; direction ^= (1 << 1); // More queue to go. - if (tileElement->properties.path.edges & (1 << (direction))) + if (tileElement->AsPath()->GetEdges() & (1 << (direction))) continue; break; diff --git a/src/openrct2/peep/Peep.cpp b/src/openrct2/peep/Peep.cpp index 33d41c2922..bcc6c10841 100644 --- a/src/openrct2/peep/Peep.cpp +++ b/src/openrct2/peep/Peep.cpp @@ -2877,7 +2877,7 @@ static void peep_interact_with_path(rct_peep* peep, int16_t x, int16_t y, rct_ti // 0x00F1AEE2 bool vandalism_present = false; if (tile_element->AsPath()->HasAddition() && (tile_element->flags & TILE_ELEMENT_FLAG_BROKEN) - && (tile_element->properties.path.edges & 0xF) != 0xF) + && (tile_element->AsPath()->GetEdges()) != 0xF) { vandalism_present = true; } diff --git a/src/openrct2/peep/Staff.cpp b/src/openrct2/peep/Staff.cpp index fa2ad59cc6..90ecd93842 100644 --- a/src/openrct2/peep/Staff.cpp +++ b/src/openrct2/peep/Staff.cpp @@ -702,7 +702,7 @@ bool staff_can_ignore_wide_flag(rct_peep* staff, int32_t x, int32_t y, uint8_t z total++; /* Check if path has an edge in adjac_dir */ - if (!(path->properties.path.edges & (1u << adjac_dir))) + if (!(path->AsPath()->GetEdges() & (1u << adjac_dir))) { continue; } @@ -1069,7 +1069,7 @@ static bool staff_path_finding_handyman(rct_peep* peep) if (tileElement == nullptr) return true; - uint8_t pathDirections = (tileElement->properties.path.edges & validDirections) & 0xF; + uint8_t pathDirections = (tileElement->AsPath()->GetEdges() & validDirections) & 0xF; if (pathDirections == 0) { direction = staff_handyman_direction_rand_surface(peep, validDirections); @@ -1233,7 +1233,7 @@ static uint8_t staff_mechanic_direction_path_rand(rct_peep* peep, uint8_t pathDi static uint8_t staff_mechanic_direction_path(rct_peep* peep, uint8_t validDirections, rct_tile_element* pathElement) { uint8_t direction = 0xFF; - uint8_t pathDirections = pathElement->properties.path.edges & 0xF; + uint8_t pathDirections = pathElement->AsPath()->GetEdges(); pathDirections &= validDirections; if (pathDirections == 0) @@ -1367,7 +1367,7 @@ static bool staff_path_finding_mechanic(rct_peep* peep) static uint8_t staff_direction_path(rct_peep* peep, uint8_t validDirections, rct_tile_element* pathElement) { uint8_t direction = 0xFF; - uint8_t pathDirections = pathElement->properties.path.edges & 0xF; + uint8_t pathDirections = pathElement->AsPath()->GetEdges(); if (peep->state != PEEP_STATE_ANSWERING && peep->state != PEEP_STATE_HEADING_TO_INSPECTION) { pathDirections &= validDirections; @@ -2224,7 +2224,7 @@ static int32_t peep_update_patrolling_find_bin(rct_peep* peep) if (tileElement->AsPath()->AdditionIsGhost()) return 0; - uint8_t bin_positions = tileElement->properties.path.edges & 0xF; + uint8_t bin_positions = tileElement->AsPath()->GetEdges(); uint8_t bin_quantity = tileElement->AsPath()->GetAdditionStatus(); uint8_t chosen_position = 0; diff --git a/src/openrct2/ride/TrackDesignSave.cpp b/src/openrct2/ride/TrackDesignSave.cpp index b09ca9dcce..4a26d46031 100644 --- a/src/openrct2/ride/TrackDesignSave.cpp +++ b/src/openrct2/ride/TrackDesignSave.cpp @@ -374,7 +374,7 @@ static void track_design_save_add_footpath(int32_t x, int32_t y, rct_tile_elemen auto entry = object_entry_get_entry(OBJECT_TYPE_PATHS, entryType); uint8_t flags = 0; - flags |= tileElement->properties.path.edges & FOOTPATH_PROPERTIES_EDGES_EDGES_MASK; + flags |= tileElement->AsPath()->GetEdges(); flags |= (tileElement->AsPath()->GetSlopeDirection()) << 5; if (tileElement->AsPath()->IsSloped()) flags |= 0b00010000; @@ -561,7 +561,7 @@ static void track_design_save_remove_footpath(int32_t x, int32_t y, rct_tile_ele auto entry = object_entry_get_entry(OBJECT_TYPE_PATHS, entryType); uint8_t flags = 0; - flags |= tileElement->properties.path.edges & FOOTPATH_PROPERTIES_EDGES_EDGES_MASK; + flags |= tileElement->AsPath()->GetEdges(); if (tileElement->AsPath()->IsSloped()) flags |= (1 << 4); flags |= (tileElement->AsPath()->GetSlopeDirection()) << 5; diff --git a/src/openrct2/ride/transport/MiniatureRailway.cpp b/src/openrct2/ride/transport/MiniatureRailway.cpp index e4708a29c5..e63f28773c 100644 --- a/src/openrct2/ride/transport/MiniatureRailway.cpp +++ b/src/openrct2/ride/transport/MiniatureRailway.cpp @@ -565,7 +565,7 @@ static uint32_t miniature_railway_track_to_grooved_indent( uint32_t imageIdAlt = SPR_G2_MINIATURE_RAILWAY_GROOVED_SW_NE; - uint8_t correctedEdges = path->properties.path.edges; + uint8_t correctedEdges = path->AsPath()->GetEdges(); correctedEdges |= correctedEdges << 4; correctedEdges >>= 4 - rotation; correctedEdges &= 0x0F; diff --git a/src/openrct2/world/Banner.cpp b/src/openrct2/world/Banner.cpp index 71d88e49c8..4948652f28 100644 --- a/src/openrct2/world/Banner.cpp +++ b/src/openrct2/world/Banner.cpp @@ -198,7 +198,7 @@ static money32 BannerPlace( if (tileElement->base_height != pathBaseHeight * 2 && tileElement->base_height != (pathBaseHeight - 1) * 2) continue; - if (!(tileElement->properties.path.edges & (1 << direction))) + if (!(tileElement->AsPath()->GetEdges() & (1 << direction))) continue; pathFound = true; diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index 86be783417..8ba4632ab2 100644 --- a/src/openrct2/world/Footpath.cpp +++ b/src/openrct2/world/Footpath.cpp @@ -339,7 +339,7 @@ static money32 footpath_element_update( } if (!(unk6 & (PATH_BIT_FLAG_JUMPING_FOUNTAIN_WATER | PATH_BIT_FLAG_JUMPING_FOUNTAIN_SNOW)) - && (tileElement->properties.path.edges & FOOTPATH_PROPERTIES_EDGES_EDGES_MASK) == 0x0F) + && (tileElement->AsPath()->GetEdges()) == 0x0F) { gGameCommandErrorText = STR_NONE; return MONEY32_UNDEFINED; @@ -670,7 +670,7 @@ static money32 footpath_place_from_track( pathElement->SetAddition(0); tileElement->AsPath()->SetRideIndex(RIDE_ID_NULL); tileElement->AsPath()->SetAdditionStatus(255); - tileElement->properties.path.edges = edges & FOOTPATH_PROPERTIES_EDGES_EDGES_MASK; + tileElement->AsPath()->SetCorners(0); pathElement->flags &= ~TILE_ELEMENT_FLAG_BROKEN; if (flags & (1 << 6)) pathElement->flags |= TILE_ELEMENT_FLAG_GHOST; @@ -1078,7 +1078,7 @@ static rct_tile_element* footpath_connect_corners_get_neighbour(int32_t x, int32 continue; if (tileElement->base_height != z) continue; - if (!(tileElement->properties.path.edges & requireEdges)) + if (!(tileElement->AsPath()->GetEdgesAndCorners() & requireEdges)) continue; return tileElement; @@ -1138,19 +1138,21 @@ static void footpath_connect_corners(int32_t initialX, int32_t initialY, rct_til continue; direction = (direction + 1) & 3; - tileElement[3]->properties.path.edges |= (1 << (direction + 4)); + tileElement[3]->AsPath()->SetCorners(tileElement[3]->AsPath()->GetCorners() | (1 << (direction))); map_invalidate_element(x, y, tileElement[3]); direction = (direction - 1) & 3; - tileElement[2]->properties.path.edges |= (1 << (direction + 4)); + tileElement[2]->AsPath()->SetCorners(tileElement[2]->AsPath()->GetCorners() | (1 << (direction))); + map_invalidate_element(x, y, tileElement[2]); direction = (direction - 1) & 3; - tileElement[1]->properties.path.edges |= (1 << (direction + 4)); + tileElement[1]->AsPath()->SetCorners(tileElement[1]->AsPath()->GetCorners() | (1 << (direction))); + map_invalidate_element(x, y, tileElement[1]); direction = initialDirection; - tileElement[0]->properties.path.edges |= (1 << (direction + 4)); + tileElement[0]->AsPath()->SetCorners(tileElement[0]->AsPath()->GetCorners() | (1 << (direction))); map_invalidate_element(x, y, tileElement[0]); } } @@ -1273,7 +1275,7 @@ static rct_tile_element* footpath_get_element(int32_t x, int32_t y, int32_t z0, static bool sub_footpath_disconnect_queue_from_path( int32_t x, int32_t y, rct_tile_element* tileElement, int32_t action, int32_t direction) { - if (((tileElement->properties.path.edges & (1 << direction)) == 0) ^ (action < 0)) + if (((tileElement->AsPath()->GetEdges() & (1 << direction)) == 0) ^ (action < 0)) return false; if ((action < 0) && fence_in_the_way(x, y, tileElement->base_height, tileElement->clearance_height, direction)) return false; @@ -1287,15 +1289,15 @@ static bool sub_footpath_disconnect_queue_from_path( tileElement->AsPath()->SetSlopeDirection(0); if (action > 0) { - tileElement->properties.path.edges &= ~(1 << direction); - otherTileElement->properties.path.edges &= ~(1 << ((direction + 2) & 3)); + tileElement->AsPath()->SetEdges(tileElement->AsPath()->GetEdges() & ~(1 << direction)); + otherTileElement->AsPath()->SetEdges(otherTileElement->AsPath()->GetEdges() & ~(1 << ((direction + 2) & 3))); if (action >= 2) tileElement->AsPath()->SetSlopeDirection(direction); } else if (action < 0) { - tileElement->properties.path.edges |= (1 << direction); - otherTileElement->properties.path.edges |= (1 << ((direction + 2) & 3)); + tileElement->AsPath()->SetEdges(tileElement->AsPath()->GetEdges() | (1 << direction)); + otherTileElement->AsPath()->SetEdges(otherTileElement->AsPath()->GetEdges() | (1 << ((direction + 2) & 3))); } if (action != 0) map_invalidate_tile_full(x1, y1); @@ -1312,7 +1314,7 @@ static bool footpath_disconnect_queue_from_path(int32_t x, int32_t y, rct_tile_e if (tileElement->AsPath()->IsSloped()) return false; - uint8_t c = connected_path_count[tileElement->properties.path.edges & FOOTPATH_PROPERTIES_EDGES_EDGES_MASK]; + uint8_t c = connected_path_count[tileElement->AsPath()->GetEdges()]; if ((action < 0) ? (c >= 2) : (c < 2)) return false; @@ -1441,7 +1443,7 @@ static void loc_6A6D7E( } if (tileElement->AsPath()->IsQueue()) { - if (connected_path_count[tileElement->properties.path.edges & FOOTPATH_PROPERTIES_EDGES_EDGES_MASK] < 2) + if (connected_path_count[tileElement->AsPath()->GetEdges()] < 2) { neighbour_list_push( neighbourList, 4, direction, tileElement->AsPath()->GetRideIndex(), @@ -1468,7 +1470,7 @@ static void loc_6A6D7E( else { footpath_disconnect_queue_from_path(x, y, tileElement, 1 + ((flags >> 6) & 1)); - tileElement->properties.path.edges |= (1 << (direction ^ 2)); + tileElement->AsPath()->SetEdges(tileElement->AsPath()->GetEdges() | (1 << (direction ^ 2))); if (tileElement->AsPath()->IsQueue()) { footpath_queue_chain_push(tileElement->AsPath()->GetRideIndex()); @@ -1486,7 +1488,7 @@ loc_6A6FD2: { if (!query) { - initialTileElement->properties.path.edges |= (1 << direction); + initialTileElement->AsPath()->SetEdges(initialTileElement->AsPath()->GetEdges() | (1 << direction)); map_invalidate_element(initialX, initialY, initialTileElement); } } @@ -1674,7 +1676,7 @@ void footpath_chain_ride_queue( { // Fix #2051: Stop queue paths that are already connected to two other tiles // from connecting to the tile we are coming from. - int32_t edges = tileElement->properties.path.edges; + int32_t edges = tileElement->AsPath()->GetEdges(); int32_t numEdges = bitcount(edges); if (numEdges >= 2) { @@ -1686,7 +1688,7 @@ void footpath_chain_ride_queue( } tileElement->AsPath()->SetHasQueueBanner(false); - tileElement->properties.path.edges |= (1 << (direction ^ 2)); + tileElement->AsPath()->SetEdges(tileElement->AsPath()->GetEdges() | (1 << (direction ^ 2))); tileElement->AsPath()->SetRideIndex(rideIndex); tileElement->AsPath()->SetStationIndex(entranceIndex); @@ -1697,15 +1699,15 @@ void footpath_chain_ride_queue( lastQueuePathElement = tileElement; } - if (tileElement->properties.path.edges & (1 << direction)) + if (tileElement->AsPath()->GetEdges() & (1 << direction)) continue; direction = (direction + 1) & 3; - if (tileElement->properties.path.edges & (1 << direction)) + if (tileElement->AsPath()->GetEdges() & (1 << direction)) continue; direction ^= 2; - if (tileElement->properties.path.edges & (1 << direction)) + if (tileElement->AsPath()->GetEdges() & (1 << direction)) continue; } break; @@ -1881,7 +1883,7 @@ static int32_t footpath_is_connected_to_map_edge_recurse( { footpath_fix_ownership(x, y); } - edges = tileElement->properties.path.edges & FOOTPATH_PROPERTIES_EDGES_EDGES_MASK; + edges = tileElement->AsPath()->GetEdges(); direction ^= 2; if (!(flags & (1 << 7))) { @@ -2194,7 +2196,7 @@ void footpath_update_path_wide_flags(int32_t x, int32_t y) if (tileElement->AsPath()->IsSloped()) continue; - if ((tileElement->properties.path.edges & FOOTPATH_PROPERTIES_EDGES_EDGES_MASK) == 0) + if (tileElement->AsPath()->GetEdges() == 0) continue; uint8_t height = tileElement->base_height; @@ -2223,7 +2225,7 @@ void footpath_update_path_wide_flags(int32_t x, int32_t y) y += 0x20; uint8_t F3EFA5 = 0; - if (tileElement->properties.path.edges & EDGE_NW) + if (tileElement->AsPath()->GetEdges() & EDGE_NW) { F3EFA5 |= 0x80; if (pathList[7] != nullptr) @@ -2235,7 +2237,7 @@ void footpath_update_path_wide_flags(int32_t x, int32_t y) } } - if (tileElement->properties.path.edges & EDGE_NE) + if (tileElement->AsPath()->GetEdges() & EDGE_NE) { F3EFA5 |= 0x2; if (pathList[1] != nullptr) @@ -2247,7 +2249,7 @@ void footpath_update_path_wide_flags(int32_t x, int32_t y) } } - if (tileElement->properties.path.edges & EDGE_SE) + if (tileElement->AsPath()->GetEdges() & EDGE_SE) { F3EFA5 |= 0x8; /* In the following: @@ -2262,7 +2264,7 @@ void footpath_update_path_wide_flags(int32_t x, int32_t y) //} } - if (tileElement->properties.path.edges & EDGE_SW) + if (tileElement->AsPath()->GetEdges() & EDGE_SW) { F3EFA5 |= 0x20; /* In the following: @@ -2280,7 +2282,7 @@ void footpath_update_path_wide_flags(int32_t x, int32_t y) if ((F3EFA5 & 0x80) && (pathList[7] != nullptr) && !(pathList[7])->AsPath()->IsWide()) { if ((F3EFA5 & 2) && (pathList[0] != nullptr) && !(pathList[0])->AsPath()->IsWide() - && ((pathList[0]->properties.path.edges & 6) == 6) && // N E + && ((pathList[0]->AsPath()->GetEdges() & 6) == 6) && // N E (pathList[1] != nullptr) && !(pathList[1])->AsPath()->IsWide()) { F3EFA5 |= 0x1; @@ -2292,7 +2294,7 @@ void footpath_update_path_wide_flags(int32_t x, int32_t y) * in combination with reset tiles. * Short circuit the logic appropriately. */ if ((F3EFA5 & 0x20) && (pathList[6] != nullptr) && !(pathList[6])->AsPath()->IsWide() - && ((pathList[6]->properties.path.edges & 3) == 3) && // N W + && ((pathList[6]->AsPath()->GetEdges() & 3) == 3) && // N W (pathList[5] != nullptr) && (true || !(pathList[5])->AsPath()->IsWide())) { F3EFA5 |= 0x40; @@ -2308,7 +2310,7 @@ void footpath_update_path_wide_flags(int32_t x, int32_t y) if ((F3EFA5 & 0x8) && (pathList[3] != nullptr) && (true || !(pathList[3])->AsPath()->IsWide())) { if ((F3EFA5 & 2) && (pathList[2] != nullptr) && (true || !(pathList[2])->AsPath()->IsWide()) - && ((pathList[2]->properties.path.edges & 0xC) == 0xC) && (pathList[1] != nullptr) + && ((pathList[2]->AsPath()->GetEdges() & 0xC) == 0xC) && (pathList[1] != nullptr) && (!(pathList[1])->AsPath()->IsWide())) { F3EFA5 |= 0x4; @@ -2321,7 +2323,7 @@ void footpath_update_path_wide_flags(int32_t x, int32_t y) * in combination with reset tiles. * Short circuit the logic appropriately. */ if ((F3EFA5 & 0x20) && (pathList[4] != nullptr) && (true || !(pathList[4])->AsPath()->IsWide()) - && ((pathList[4]->properties.path.edges & 9) == 9) && (pathList[5] != nullptr) + && ((pathList[4]->AsPath()->GetEdges() & 9) == 9) && (pathList[5] != nullptr) && (true || !(pathList[5])->AsPath()->IsWide())) { F3EFA5 |= 0x10; @@ -2342,7 +2344,7 @@ void footpath_update_path_wide_flags(int32_t x, int32_t y) if (!(F3EFA5 & (0x2 | 0x8 | 0x20 | 0x80))) { - uint8_t e = tileElement->properties.path.edges; + uint8_t e = tileElement->AsPath()->GetEdgesAndCorners(); if ((e != 0b10101111) && (e != 0b01011111) && (e != 0b11101111)) tileElement->AsPath()->SetWide(true); } @@ -2370,7 +2372,7 @@ void footpath_update_queue_entrance_banner(int32_t x, int32_t y, rct_tile_elemen footpath_queue_chain_push(tileElement->AsPath()->GetRideIndex()); for (int32_t direction = 0; direction < 4; direction++) { - if (tileElement->properties.path.edges & (1 << direction)) + if (tileElement->AsPath()->GetEdges() & (1 << direction)) { footpath_chain_ride_queue(255, 0, x, y, tileElement, direction); } @@ -2395,19 +2397,17 @@ void footpath_update_queue_entrance_banner(int32_t x, int32_t y, rct_tile_elemen static void footpath_remove_edges_towards_here( int32_t x, int32_t y, int32_t z, int32_t direction, rct_tile_element* tileElement, bool isQueue) { - int32_t d; - if (tileElement->AsPath()->IsQueue()) { footpath_queue_chain_push(tileElement->AsPath()->GetRideIndex()); } - d = direction ^ 2; - tileElement->properties.path.edges &= ~(1 << d); - d = ((d - 1) & 3) + 4; - tileElement->properties.path.edges &= ~(1 << d); - d = (((d - 4) + 1) & 3) + 4; - tileElement->properties.path.edges &= ~(1 << d); + int32_t d = direction ^ 2; + tileElement->AsPath()->SetEdges(tileElement->AsPath()->GetEdges() & ~(1 << d)); + int32_t cd = ((d - 1) & 3); + tileElement->AsPath()->SetCorners(tileElement->AsPath()->GetCorners() & ~(1 << cd)); + cd = ((cd + 1) & 3); + tileElement->AsPath()->SetCorners(tileElement->AsPath()->GetCorners() & ~(1 << cd)); map_invalidate_tile(x, y, tileElement->base_height * 8, tileElement->clearance_height * 8); if (isQueue) @@ -2428,8 +2428,8 @@ static void footpath_remove_edges_towards_here( if (tileElement->AsPath()->IsSloped()) break; - d = ((direction + 1) & 3) + 4; - tileElement->properties.path.edges &= ~(1 << d); + cd = ((direction + 1) & 3); + tileElement->AsPath()->SetCorners(tileElement->AsPath()->GetCorners() & ~(1 << cd)); map_invalidate_tile(x, y, tileElement->base_height * 8, tileElement->clearance_height * 8); break; } while (!(tileElement++)->IsLastForTile()); @@ -2581,7 +2581,7 @@ static void footpath_fix_corners_around(int32_t x, int32_t y, rct_tile_element* const int32_t ix = xOffset + 1; const int32_t iy = yOffset + 1; - tileElement->properties.path.edges &= ~(cornersTouchingTile[iy][ix] << 4); + tileElement->AsPath()->SetCorners(tileElement->AsPath()->GetCorners() & ~(cornersTouchingTile[iy][ix])); } while (!(tileElement++)->IsLastForTile()); } } @@ -2647,7 +2647,7 @@ void footpath_remove_edges_at(int32_t x, int32_t y, rct_tile_element* tileElemen } if (tileElement->GetType() == TILE_ELEMENT_TYPE_PATH) - tileElement->properties.path.edges = 0; + tileElement->AsPath()->SetEdgesAndCorners(0); } rct_footpath_entry* get_footpath_entry(int32_t entryIndex) @@ -2662,11 +2662,6 @@ rct_footpath_entry* get_footpath_entry(int32_t entryIndex) return result; } -uint8_t footpath_get_edges(const rct_tile_element* element) -{ - return element->properties.path.edges & 0xF; -} - uint8_t PathElement::GetRideIndex() const { return rideIndex; @@ -2685,4 +2680,36 @@ uint8_t PathElement::GetAdditionStatus() const void PathElement::SetAdditionStatus(uint8_t newStatus) { additionStatus = newStatus; +} + +uint8_t PathElement::GetEdges() const +{ + return edges & FOOTPATH_PROPERTIES_EDGES_EDGES_MASK; +} + +void PathElement::SetEdges(uint8_t newEdges) +{ + edges &= ~FOOTPATH_PROPERTIES_EDGES_EDGES_MASK; + edges |= (newEdges & FOOTPATH_PROPERTIES_EDGES_EDGES_MASK); +} + +uint8_t PathElement::GetCorners() const +{ + return edges >> 4; +} + +void PathElement::SetCorners(uint8_t newCorners) +{ + edges &= ~FOOTPATH_PROPERTIES_EDGES_CORNERS_MASK; + edges |= (newCorners << 4); +} + +uint8_t PathElement::GetEdgesAndCorners() const +{ + return edges; +} + +void PathElement::SetEdgesAndCorners(uint8_t newEdgesAndCorners) +{ + edges = newEdgesAndCorners; } \ No newline at end of file diff --git a/src/openrct2/world/Footpath.h b/src/openrct2/world/Footpath.h index a3712605ce..dd4c9ca09b 100644 --- a/src/openrct2/world/Footpath.h +++ b/src/openrct2/world/Footpath.h @@ -162,6 +162,4 @@ rct_footpath_entry* get_footpath_entry(int32_t entryIndex); void footpath_queue_chain_reset(); void footpath_queue_chain_push(uint8_t rideIndex); -uint8_t footpath_get_edges(const rct_tile_element* element); - #endif diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index d363d893e8..6179d11753 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -3372,7 +3372,7 @@ rct_tile_element* tile_element_insert(int32_t x, int32_t y, int32_t z, int32_t f newTileElement->base_height = z; newTileElement->flags = flags; newTileElement->clearance_height = z; - memset(&newTileElement->properties, 0, sizeof(newTileElement->properties)); + memset(&newTileElement->pad_04, 0, sizeof(newTileElement->pad_04)); newTileElement++; // Insert rest of map elements above insert height diff --git a/src/openrct2/world/TileElement.h b/src/openrct2/world/TileElement.h index b7da37e8a6..4d91053cb9 100644 --- a/src/openrct2/world/TileElement.h +++ b/src/openrct2/world/TileElement.h @@ -16,24 +16,6 @@ struct rct_scenery_entry; struct rct_footpath_entry; #pragma pack(push, 1) -struct rct_tile_element_path_properties -{ - uint8_t type; // 4 0xF0 Path type, 0x08 Ride sign, 0x04 Set when path is diagonal, 0x03 Rotation - uint8_t additions; // 5 - uint8_t edges; // 6 - union - { - uint8_t addition_status; // 7 - uint8_t ride_index; - }; -}; -assert_struct_size(rct_tile_element_path_properties, 4); - -union rct_tile_element_properties -{ - rct_tile_element_path_properties path; -}; -assert_struct_size(rct_tile_element_properties, 4); enum { @@ -96,12 +78,7 @@ struct TileElementBase */ struct rct_tile_element : public TileElementBase { - union - { - uint8_t pad_04[4]; - // TODO: Remove this field. - rct_tile_element_properties properties; - }; + uint8_t pad_04[4]; template TType* as() const { @@ -225,6 +202,13 @@ public: bool HasQueueBanner() const; void SetHasQueueBanner(bool hasQueueBanner); + uint8_t GetEdges() const; + void SetEdges(uint8_t newEdges); + uint8_t GetCorners() const; + void SetCorners(uint8_t newCorners); + uint8_t GetEdgesAndCorners() const; + void SetEdgesAndCorners(uint8_t newEdgesAndCorners); + bool HasAddition() const; uint8_t GetAddition() const; uint8_t GetAdditionEntryIndex() const; diff --git a/src/openrct2/world/TileInspector.cpp b/src/openrct2/world/TileInspector.cpp index 322ca37d89..e630252f3a 100644 --- a/src/openrct2/world/TileInspector.cpp +++ b/src/openrct2/world/TileInspector.cpp @@ -227,11 +227,10 @@ int32_t tile_inspector_rotate_element_at(int32_t x, int32_t y, int32_t elementIn newRotation = (tileElement->AsPath()->GetSlopeDirection() + 1) & TILE_ELEMENT_DIRECTION_MASK; tileElement->AsPath()->SetSlopeDirection(newRotation); } - pathEdges = tileElement->properties.path.edges & 0x0F; - pathCorners = tileElement->properties.path.edges & 0xF0; - tileElement->properties.path.edges = 0; - tileElement->properties.path.edges |= ((pathEdges << 1) | (pathEdges >> 3)) & 0x0F; - tileElement->properties.path.edges |= ((pathCorners << 1) | (pathCorners >> 3)) & 0xF0; + pathEdges = tileElement->AsPath()->GetEdges(); + pathCorners = tileElement->AsPath()->GetCorners(); + tileElement->AsPath()->SetEdges((pathEdges << 1) | (pathEdges >> 3)); + tileElement->AsPath()->SetCorners((pathCorners << 1) | (pathCorners >> 3)); break; case TILE_ELEMENT_TYPE_ENTRANCE: { @@ -635,7 +634,8 @@ int32_t tile_inspector_path_toggle_edge(int32_t x, int32_t y, int32_t elementInd if (flags & GAME_COMMAND_FLAG_APPLY) { - pathElement->properties.path.edges ^= 1 << edgeIndex; + uint8_t newEdges = pathElement->AsPath()->GetEdgesAndCorners() ^ (1 << edgeIndex); + pathElement->AsPath()->SetEdgesAndCorners(newEdges); map_invalidate_tile_full(x << 5, y << 5); diff --git a/src/openrct2/world/Wall.cpp b/src/openrct2/world/Wall.cpp index 04a27dbc45..bab1de7cb2 100644 --- a/src/openrct2/world/Wall.cpp +++ b/src/openrct2/world/Wall.cpp @@ -200,7 +200,7 @@ static bool WallCheckObstruction( map_obstruction_set_error_text(tileElement); return false; case TILE_ELEMENT_TYPE_PATH: - if (tileElement->properties.path.edges & (1 << edge)) + if (tileElement->AsPath()->GetEdges() & (1 << edge)) { map_obstruction_set_error_text(tileElement); return false; diff --git a/test/testpaint/Compat.cpp b/test/testpaint/Compat.cpp index 31ba90e7e9..d505755f74 100644 --- a/test/testpaint/Compat.cpp +++ b/test/testpaint/Compat.cpp @@ -414,3 +414,8 @@ bool TrackElement::IsHighlighted() const { return (type & TILE_ELEMENT_TYPE_FLAG_HIGHLIGHT); } + +uint8_t PathElement::GetEdges() const +{ + return edges & 0xF; +}