From deeb34f4aa09a592344d3abc35a084d2c67df984 Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Wed, 3 Oct 2018 10:38:46 +0200 Subject: [PATCH 1/9] Add fields to PathElement, port GetRCT1Path() --- src/openrct2/rct1/S4Importer.cpp | 16 +++++++--------- src/openrct2/world/TileElement.h | 12 +++++++++++- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 4d02b92907..c088884575 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -60,8 +60,6 @@ using namespace OpenRCT2; -static uint8_t GetPathType(rct_tile_element* tileElement); - class EntryList { private: @@ -480,7 +478,7 @@ private: { case TILE_ELEMENT_TYPE_PATH: { - uint8_t pathType = GetPathType(tileElement); + uint8_t pathType = tileElement->AsPath()->GetRCT1PathType(); uint8_t pathAdditionsType = tileElement->properties.path.additions & 0x0F; AddEntryForPath(pathType); @@ -2507,7 +2505,7 @@ private: case TILE_ELEMENT_TYPE_PATH: { // Type - uint8_t pathType = GetPathType(tileElement); + uint8_t pathType = tileElement->AsPath()->GetRCT1PathType(); uint8_t entryIndex = _pathTypeToEntryMap[pathType]; tileElement->type &= ~TILE_ELEMENT_DIRECTION_MASK; @@ -2886,13 +2884,13 @@ void load_from_sc4(const utf8* path) s4Importer->Import(); } -static uint8_t GetPathType(rct_tile_element* tileElement) +uint8_t PathElement::GetRCT1PathType() const { - uint8_t pathColour = tileElement->type & 3; - uint8_t pathType = (tileElement->properties.path.type & FOOTPATH_PROPERTIES_TYPE_MASK) >> 2; + uint8_t pathColour = type & 3; + uint8_t pathType2 = (pathType & FOOTPATH_PROPERTIES_TYPE_MASK) >> 2; - pathType = pathType | pathColour; - return pathType; + pathType2 = pathType2 | pathColour; + return pathType2; } int32_t WallElement::GetRCT1WallType(int32_t edge) const diff --git a/src/openrct2/world/TileElement.h b/src/openrct2/world/TileElement.h index d9dd7196bf..cd7012dccc 100644 --- a/src/openrct2/world/TileElement.h +++ b/src/openrct2/world/TileElement.h @@ -183,7 +183,17 @@ assert_struct_size(SurfaceElement, 8); struct PathElement : TileElementBase { - rct_tile_element_path_properties temp; + uint8_t pathType; // 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 additionStatus; // 7 + uint8_t rideIndex; + }; + +public: + uint8_t GetRCT1PathType() const; }; assert_struct_size(PathElement, 8); From 882a65e4c0107c5f2565fcc46da1e441d0b9f819 Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Wed, 3 Oct 2018 10:57:29 +0200 Subject: [PATCH 2/9] Port queue functions --- .../interface/ViewportInteraction.cpp | 4 +- src/openrct2-ui/windows/RideConstruction.cpp | 2 +- src/openrct2-ui/windows/TileInspector.cpp | 4 +- src/openrct2-ui/windows/TopToolbar.cpp | 2 +- .../paint/tile_element/Paint.Path.cpp | 20 ++++--- src/openrct2/peep/GuestPathfinding.cpp | 8 +-- src/openrct2/peep/Peep.cpp | 4 +- src/openrct2/rct1/S4Importer.cpp | 2 +- src/openrct2/ride/TrackDesignSave.cpp | 13 +++-- src/openrct2/world/Footpath.cpp | 56 +++++++++---------- src/openrct2/world/Footpath.h | 3 - src/openrct2/world/Map.cpp | 4 +- src/openrct2/world/TileElement.h | 3 + 13 files changed, 63 insertions(+), 62 deletions(-) diff --git a/src/openrct2-ui/interface/ViewportInteraction.cpp b/src/openrct2-ui/interface/ViewportInteraction.cpp index f652f1854f..b8ae99cb01 100644 --- a/src/openrct2-ui/interface/ViewportInteraction.cpp +++ b/src/openrct2-ui/interface/ViewportInteraction.cpp @@ -357,7 +357,7 @@ int32_t viewport_interaction_get_item_right(int32_t x, int32_t y, viewport_inter case VIEWPORT_INTERACTION_ITEM_FOOTPATH: set_map_tooltip_format_arg(0, rct_string_id, STR_MAP_TOOLTIP_STRINGID_CLICK_TO_REMOVE); set_map_tooltip_format_arg(2, rct_string_id, STR_FOOTPATH_MAP_TIP); - if (footpath_element_is_queue(tileElement)) + if (tileElement->AsPath()->IsQueue()) set_map_tooltip_format_arg(2, rct_string_id, STR_QUEUE_LINE_MAP_TIP); return info->type; @@ -507,7 +507,7 @@ static void viewport_interaction_remove_footpath_item(rct_tile_element* tileElem int32_t type; type = footpath_element_get_type(tileElement); - if (footpath_element_is_queue(tileElement)) + if (tileElement->AsPath()->IsQueue()) type |= 0x80; gGameCommandErrorTitle = STR_CANT_REMOVE_THIS; diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index 0b3e01a64e..85b34e7930 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -3620,7 +3620,7 @@ void ride_construction_toolupdate_construct(int32_t screenX, int32_t screenY) } } - if (pathsByDir[i] && footpath_element_is_queue(pathsByDir[i])) + if (pathsByDir[i] && (pathsByDir[i])->AsPath()->IsQueue()) { pathsByDir[i] = nullptr; } diff --git a/src/openrct2-ui/windows/TileInspector.cpp b/src/openrct2-ui/windows/TileInspector.cpp index 29d4c36cf3..9bacba3479 100644 --- a/src/openrct2-ui/windows/TileInspector.cpp +++ b/src/openrct2-ui/windows/TileInspector.cpp @@ -2140,8 +2140,8 @@ static void window_tile_inspector_scrollpaint(rct_window* w, rct_drawpixelinfo* typeName = language_get_string(STR_TILE_INSPECTOR_SURFACE); break; case TILE_ELEMENT_TYPE_PATH: - typeName = footpath_element_is_queue(tileElement) ? language_get_string(STR_QUEUE_LINE_MAP_TIP) - : language_get_string(STR_FOOTPATH_MAP_TIP); + typeName = tileElement->AsPath()->IsQueue() ? language_get_string(STR_QUEUE_LINE_MAP_TIP) + : language_get_string(STR_FOOTPATH_MAP_TIP); break; case TILE_ELEMENT_TYPE_TRACK: typeName = language_get_string(STR_RIDE_COMPONENT_TRACK_CAPITALISED); diff --git a/src/openrct2-ui/windows/TopToolbar.cpp b/src/openrct2-ui/windows/TopToolbar.cpp index c309f52361..9454d5a624 100644 --- a/src/openrct2-ui/windows/TopToolbar.cpp +++ b/src/openrct2-ui/windows/TopToolbar.cpp @@ -1455,7 +1455,7 @@ static void sub_6E1F34( << 8; *parameter_2 = tile_element->base_height; *parameter_2 |= ((footpath_element_get_type(tile_element)) << 8); - if (footpath_element_is_queue(tile_element)) + if (tile_element->AsPath()->IsQueue()) { *parameter_2 |= LOCATION_NULL; } diff --git a/src/openrct2/paint/tile_element/Paint.Path.cpp b/src/openrct2/paint/tile_element/Paint.Path.cpp index 63bbcea56b..463ab79a16 100644 --- a/src/openrct2/paint/tile_element/Paint.Path.cpp +++ b/src/openrct2/paint/tile_element/Paint.Path.cpp @@ -320,7 +320,7 @@ static void sub_6A4101( paint_session* session, const rct_tile_element* tile_element, uint16_t height, uint32_t ebp, bool word_F3F038, rct_footpath_entry* footpathEntry, uint32_t base_image_id, uint32_t imageFlags) { - if (footpath_element_is_queue(tile_element)) + if (tile_element->AsPath()->IsQueue()) { uint8_t local_ebp = ebp & 0x0F; if (footpath_element_is_sloped(tile_element)) @@ -798,7 +798,7 @@ void path_paint(paint_session* session, uint16_t height, const rct_tile_element* if (gTrackDesignSaveMode) { - if (footpath_element_is_queue(tile_element)) + if (tile_element->AsPath()->IsQueue()) { if (tile_element->properties.path.ride_index != gTrackDesignSaveRideIndex) { @@ -974,6 +974,8 @@ void path_paint_box_support( paint_session* session, const rct_tile_element* tileElement, int32_t height, rct_footpath_entry* footpathEntry, bool hasFences, uint32_t imageFlags, uint32_t sceneryImageFlags) { + 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); @@ -999,7 +1001,7 @@ void path_paint_box_support( } imageId += footpathEntry->image; - if (footpath_element_is_queue(tileElement)) + if (pathElement->IsQueue()) { imageId += 51; } @@ -1049,7 +1051,7 @@ void path_paint_box_support( session, image_id | imageFlags, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, boundBoxOffset.y, height + boundingBoxZOffset); - if (!footpath_element_is_queue(tileElement) && !(footpathEntry->flags & FOOTPATH_ENTRY_FLAG_HAS_PATH_BASE_SPRITE)) + if (!pathElement->IsQueue() && !(footpathEntry->flags & FOOTPATH_ENTRY_FLAG_HAS_PATH_BASE_SPRITE)) { // don't draw } @@ -1086,7 +1088,7 @@ void path_paint_box_support( paint_util_set_general_support_height(session, height, 0x20); - if (footpath_element_is_queue(tileElement) || (tileElement->properties.path.edges != 0xFF && hasFences)) + if (pathElement->IsQueue() || (tileElement->properties.path.edges != 0xFF && hasFences)) { paint_util_set_segment_support_height(session, SEGMENTS_ALL, 0xFFFF, 0); return; @@ -1125,6 +1127,8 @@ void path_paint_pole_support( paint_session* session, const rct_tile_element* tileElement, int16_t height, rct_footpath_entry* footpathEntry, bool hasFences, uint32_t imageFlags, uint32_t sceneryImageFlags) { + 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); @@ -1149,7 +1153,7 @@ void path_paint_pole_support( } imageId += footpathEntry->image; - if (footpath_element_is_queue(tileElement)) + if (pathElement->IsQueue()) { imageId += 51; } @@ -1201,7 +1205,7 @@ void path_paint_pole_support( session, bridgeImage | imageFlags, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, boundBoxOffset.y, height + boundingBoxZOffset); - if (footpath_element_is_queue(tileElement) || (footpathEntry->flags & FOOTPATH_ENTRY_FLAG_HAS_PATH_BASE_SPRITE)) + if (pathElement->IsQueue() || (footpathEntry->flags & FOOTPATH_ENTRY_FLAG_HAS_PATH_BASE_SPRITE)) { sub_98199C( session, imageId | imageFlags, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, @@ -1240,7 +1244,7 @@ void path_paint_pole_support( paint_util_set_general_support_height(session, height, 0x20); - if (footpath_element_is_queue(tileElement) || (tileElement->properties.path.edges != 0xFF && hasFences)) + if (pathElement->IsQueue() || (tileElement->properties.path.edges != 0xFF && hasFences)) { paint_util_set_segment_support_height(session, SEGMENTS_ALL, 0xFFFF, 0); return; diff --git a/src/openrct2/peep/GuestPathfinding.cpp b/src/openrct2/peep/GuestPathfinding.cpp index bac872c6be..323bf710e3 100644 --- a/src/openrct2/peep/GuestPathfinding.cpp +++ b/src/openrct2/peep/GuestPathfinding.cpp @@ -247,7 +247,7 @@ static uint8_t footpath_element_next_in_direction(TileCoordsXYZ loc, rct_tile_el if (footpath_element_is_wide(nextTileElement)) return PATH_SEARCH_WIDE; // Only queue tiles that are connected to a ride are returned as ride queues. - if (footpath_element_is_queue(nextTileElement) && nextTileElement->properties.path.ride_index != 0xFF) + if (nextTileElement->AsPath()->IsQueue() && nextTileElement->properties.path.ride_index != 0xFF) return PATH_SEARCH_RIDE_QUEUE; return PATH_SEARCH_OTHER; @@ -750,7 +750,7 @@ static void peep_pathfind_heuristic_search( } else { // numEdges == 2 - if (footpath_element_is_queue(tileElement) + if (tileElement->AsPath()->IsQueue() && tileElement->properties.path.ride_index != gPeepPathFindQueueRideIndex) { if (gPeepPathFindIgnoreForeignQueues && (tileElement->properties.path.ride_index != 0xFF)) @@ -1814,7 +1814,7 @@ static void get_ride_queue_end(TileCoordsXYZ& loc) if (found == false) break; - if (!footpath_element_is_queue(tileElement)) + if (!tileElement->AsPath()->IsQueue()) break; if (!(tileElement->properties.path.edges & (1 << (direction ^ (1 << 1))))) @@ -1848,7 +1848,7 @@ static void get_ride_queue_end(TileCoordsXYZ& loc) if (tileElement == nullptr) return; - if (!footpath_element_is_queue(tileElement)) + if (!tileElement->AsPath()->IsQueue()) return; loc.x = queueEnd.x; diff --git a/src/openrct2/peep/Peep.cpp b/src/openrct2/peep/Peep.cpp index 345df07a81..0919e594d0 100644 --- a/src/openrct2/peep/Peep.cpp +++ b/src/openrct2/peep/Peep.cpp @@ -2631,7 +2631,7 @@ static void peep_interact_with_entrance( if (nextTileElement->GetType() != TILE_ELEMENT_TYPE_PATH) continue; - if (footpath_element_is_queue(nextTileElement)) + if (nextTileElement->AsPath()->IsQueue()) continue; if (footpath_element_is_sloped(nextTileElement)) @@ -2902,7 +2902,7 @@ static void peep_interact_with_path(rct_peep* peep, int16_t x, int16_t y, rct_ti } } - if (peep->type == PEEP_TYPE_GUEST && footpath_element_is_queue(tile_element)) + if (peep->type == PEEP_TYPE_GUEST && tile_element->AsPath()->IsQueue()) { uint8_t rideIndex = tile_element->properties.path.ride_index; diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index c088884575..0d92be3d69 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -2514,7 +2514,7 @@ private: footpath_element_set_type(tileElement, entryIndex); if (RCT1::PathIsQueue(pathType)) { - footpath_element_set_queue(tileElement); + tileElement->AsPath()->SetIsQueue(true); } footpath_scenery_set_is_ghost(tileElement, false); diff --git a/src/openrct2/ride/TrackDesignSave.cpp b/src/openrct2/ride/TrackDesignSave.cpp index 62f23245fa..d73702d605 100644 --- a/src/openrct2/ride/TrackDesignSave.cpp +++ b/src/openrct2/ride/TrackDesignSave.cpp @@ -377,7 +377,8 @@ static void track_design_save_add_footpath(int32_t x, int32_t y, rct_tile_elemen flags |= tileElement->properties.path.edges & FOOTPATH_PROPERTIES_EDGES_EDGES_MASK; flags |= (tileElement->properties.path.type & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED) << 2; flags |= (tileElement->properties.path.type & FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK) << 5; - flags |= (tileElement->type & FOOTPATH_ELEMENT_TYPE_FLAG_IS_QUEUE) << 7; + if (tileElement->AsPath()->IsQueue()) + flags |= 1 << 7; track_design_save_push_tile_element(x, y, tileElement); track_design_save_push_tile_element_desc(entry, x, y, tileElement->base_height, flags, 0, 0); @@ -562,7 +563,8 @@ static void track_design_save_remove_footpath(int32_t x, int32_t y, rct_tile_ele flags |= tileElement->properties.path.edges & FOOTPATH_PROPERTIES_EDGES_EDGES_MASK; flags |= (tileElement->properties.path.type & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED) << 2; flags |= (tileElement->properties.path.type & FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK) << 5; - flags |= (tileElement->type & FOOTPATH_ELEMENT_TYPE_FLAG_IS_QUEUE) << 7; + if (tileElement->AsPath()->IsQueue()) + flags |= (1 << 7); track_design_save_pop_tile_element(x, y, tileElement); track_design_save_pop_tile_element_desc(entry, x, y, tileElement->base_height, flags); @@ -596,8 +598,7 @@ static bool track_design_save_should_select_scenery_around(int32_t rideIndex, rc switch (tileElement->GetType()) { case TILE_ELEMENT_TYPE_PATH: - if ((tileElement->type & FOOTPATH_ELEMENT_TYPE_FLAG_IS_QUEUE) - && tileElement->properties.path.addition_status == rideIndex) + if (tileElement->AsPath()->IsQueue() && tileElement->properties.path.ride_index == rideIndex) return true; break; case TILE_ELEMENT_TYPE_TRACK: @@ -632,9 +633,9 @@ static void track_design_save_select_nearby_scenery_for_tile(int32_t rideIndex, switch (tileElement->GetType()) { case TILE_ELEMENT_TYPE_PATH: - if (!(tileElement->type & FOOTPATH_ELEMENT_TYPE_FLAG_IS_QUEUE)) + if (!tileElement->AsPath()->IsQueue()) interactionType = VIEWPORT_INTERACTION_ITEM_FOOTPATH; - else if (tileElement->properties.path.addition_status == rideIndex) + else if (tileElement->properties.path.ride_index == rideIndex) interactionType = VIEWPORT_INTERACTION_ITEM_FOOTPATH; break; case TILE_ELEMENT_TYPE_SMALL_SCENERY: diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index b666d7b24b..2b33709429 100644 --- a/src/openrct2/world/Footpath.cpp +++ b/src/openrct2/world/Footpath.cpp @@ -270,7 +270,7 @@ static money32 footpath_element_insert( footpath_element_set_type(tileElement, type); tileElement->properties.path.type |= (slope & TILE_ELEMENT_SLOPE_W_CORNER_DN); if (type & FOOTPATH_ELEMENT_INSERT_QUEUE) - footpath_element_set_queue(tileElement); + tileElement->AsPath()->SetIsQueue(true); tileElement->properties.path.additions = pathItemType; tileElement->properties.path.addition_status = 255; tileElement->flags &= ~TILE_ELEMENT_FLAG_BROKEN; @@ -302,7 +302,7 @@ static money32 footpath_element_update( const int32_t newFootpathType = (type & (FOOTPATH_PROPERTIES_TYPE_MASK >> 4)); const bool newPathIsQueue = ((type >> 7) == 1); - if (footpath_element_get_type(tileElement) != newFootpathType || footpath_element_is_queue(tileElement) != newPathIsQueue) + if (footpath_element_get_type(tileElement) != newFootpathType || tileElement->AsPath()->IsQueue() != newPathIsQueue) { gFootpathPrice += MONEY(6, 00); } @@ -328,7 +328,7 @@ static money32 footpath_element_update( return MONEY32_UNDEFINED; } - if ((unk6 & PATH_BIT_FLAG_DONT_ALLOW_ON_QUEUE) && footpath_element_is_queue(tileElement)) + if ((unk6 & PATH_BIT_FLAG_DONT_ALLOW_ON_QUEUE) && tileElement->AsPath()->IsQueue()) { gGameCommandErrorText = STR_CANNOT_PLACE_THESE_ON_QUEUE_LINE_AREA; return MONEY32_UNDEFINED; @@ -341,7 +341,7 @@ static money32 footpath_element_update( return MONEY32_UNDEFINED; } - if ((unk6 & PATH_BIT_FLAG_IS_QUEUE_SCREEN) && !footpath_element_is_queue(tileElement)) + if ((unk6 & PATH_BIT_FLAG_IS_QUEUE_SCREEN) && !tileElement->AsPath()->IsQueue()) { gGameCommandErrorText = STR_CAN_ONLY_PLACE_THESE_ON_QUEUE_AREA; return MONEY32_UNDEFINED; @@ -1056,7 +1056,7 @@ static rct_tile_element* footpath_connect_corners_get_neighbour(int32_t x, int32 { if (tileElement->GetType() != TILE_ELEMENT_TYPE_PATH) continue; - if (footpath_element_is_queue(tileElement)) + if (tileElement->AsPath()->IsQueue()) continue; if (tileElement->base_height != z) continue; @@ -1081,7 +1081,7 @@ static void footpath_connect_corners(int32_t initialX, int32_t initialY, rct_til { rct_tile_element* tileElement[4]; - if (footpath_element_is_queue(initialTileElement)) + if (initialTileElement->AsPath()->IsQueue()) return; if (footpath_element_is_sloped(initialTileElement)) return; @@ -1264,7 +1264,7 @@ static bool sub_footpath_disconnect_queue_from_path( int32_t y1 = y + CoordsDirectionDelta[direction].y; int32_t z = tileElement->base_height; rct_tile_element* otherTileElement = footpath_get_element(x1, y1, z - 2, z, direction); - if (otherTileElement != nullptr && !footpath_element_is_queue(otherTileElement)) + if (otherTileElement != nullptr && !otherTileElement->AsPath()->IsQueue()) { tileElement->properties.path.type &= ~FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK; if (action > 0) @@ -1288,7 +1288,7 @@ static bool sub_footpath_disconnect_queue_from_path( static bool footpath_disconnect_queue_from_path(int32_t x, int32_t y, rct_tile_element* tileElement, int32_t action) { - if (!footpath_element_is_queue(tileElement)) + if (!tileElement->AsPath()->IsQueue()) return false; if (footpath_element_is_sloped(tileElement)) @@ -1423,7 +1423,7 @@ static void loc_6A6D7E( { return; } - if (footpath_element_is_queue(tileElement)) + if (tileElement->AsPath()->IsQueue()) { if (connected_path_count[tileElement->properties.path.edges & FOOTPATH_PROPERTIES_EDGES_EDGES_MASK] < 2) { @@ -1433,8 +1433,7 @@ static void loc_6A6D7E( } else { - if ((initialTileElement)->GetType() == TILE_ELEMENT_TYPE_PATH - && footpath_element_is_queue(initialTileElement)) + if ((initialTileElement)->GetType() == TILE_ELEMENT_TYPE_PATH && initialTileElement->AsPath()->IsQueue()) { if (footpath_disconnect_queue_from_path(x, y, tileElement, 0)) { @@ -1454,7 +1453,7 @@ static void loc_6A6D7E( { footpath_disconnect_queue_from_path(x, y, tileElement, 1 + ((flags >> 6) & 1)); tileElement->properties.path.edges |= (1 << (direction ^ 2)); - if (footpath_element_is_queue(tileElement)) + if (tileElement->AsPath()->IsQueue()) { footpath_queue_chain_push(tileElement->properties.path.ride_index); } @@ -1552,7 +1551,7 @@ void footpath_connect_edges(int32_t x, int32_t y, rct_tile_element* tileElement, neighbour_list_sort(&neighbourList); - if (tileElement->GetType() == TILE_ELEMENT_TYPE_PATH && footpath_element_is_queue(tileElement)) + if (tileElement->GetType() == TILE_ELEMENT_TYPE_PATH && tileElement->AsPath()->IsQueue()) { int32_t rideIndex = -1; uint8_t entranceIndex = 255; @@ -1655,7 +1654,7 @@ void footpath_chain_ride_queue( break; foundNextPath: - if (footpath_element_is_queue(tileElement)) + if (tileElement->AsPath()->IsQueue()) { // Fix #2051: Stop queue paths that are already connected to two other tiles // from connecting to the tile we are coming from. @@ -1699,7 +1698,7 @@ void footpath_chain_ride_queue( if (rideIndex != 255 && lastPathElement != nullptr) { - if (footpath_element_is_queue(lastPathElement)) + if (lastPathElement->AsPath()->IsQueue()) { lastPathElement->properties.path.type |= FOOTPATH_PROPERTIES_FLAG_HAS_QUEUE_BANNER; lastPathElement->type &= 0x3F; // Clear the ride sign direction @@ -1859,7 +1858,7 @@ static int32_t footpath_is_connected_to_map_edge_recurse( if (!(flags & (1 << 0))) { - if (footpath_element_is_queue(tileElement)) + if (tileElement->AsPath()->IsQueue()) { continue; } @@ -1976,19 +1975,16 @@ uint8_t footpath_element_get_slope_direction(const rct_tile_element* tileElement return tileElement->properties.path.type & FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK; } -bool footpath_element_is_queue(const rct_tile_element* tileElement) +bool PathElement::IsQueue() const { - return (tileElement->type & FOOTPATH_ELEMENT_TYPE_FLAG_IS_QUEUE) != 0; + return (type & FOOTPATH_ELEMENT_TYPE_FLAG_IS_QUEUE) != 0; } -void footpath_element_set_queue(rct_tile_element* tileElement) +void PathElement::SetIsQueue(bool isQueue) { - tileElement->type |= FOOTPATH_ELEMENT_TYPE_FLAG_IS_QUEUE; -} - -void footpath_element_clear_queue(rct_tile_element* tileElement) -{ - tileElement->type &= ~FOOTPATH_ELEMENT_TYPE_FLAG_IS_QUEUE; + type &= ~FOOTPATH_ELEMENT_TYPE_FLAG_IS_QUEUE; + if (isQueue) + type |= FOOTPATH_ELEMENT_TYPE_FLAG_IS_QUEUE; } bool footpath_element_has_queue_banner(const rct_tile_element* tileElement) @@ -2097,7 +2093,7 @@ static rct_tile_element* footpath_can_be_wide(int32_t x, int32_t y, uint8_t heig continue; if (height != tileElement->base_height) continue; - if (footpath_element_is_queue(tileElement)) + if (tileElement->AsPath()->IsQueue()) continue; if (footpath_element_is_sloped(tileElement)) continue; @@ -2147,7 +2143,7 @@ void footpath_update_path_wide_flags(int32_t x, int32_t y) if (tileElement->GetType() != TILE_ELEMENT_TYPE_PATH) continue; - if (footpath_element_is_queue(tileElement)) + if (tileElement->AsPath()->IsQueue()) continue; if (footpath_element_is_sloped(tileElement)) @@ -2324,7 +2320,7 @@ void footpath_update_queue_entrance_banner(int32_t x, int32_t y, rct_tile_elemen switch (elementType) { case TILE_ELEMENT_TYPE_PATH: - if (footpath_element_is_queue(tileElement)) + if (tileElement->AsPath()->IsQueue()) { footpath_queue_chain_push(tileElement->properties.path.ride_index); for (int32_t direction = 0; direction < 4; direction++) @@ -2356,7 +2352,7 @@ static void footpath_remove_edges_towards_here( { int32_t d; - if (footpath_element_is_queue(tileElement)) + if (tileElement->AsPath()->IsQueue()) { footpath_queue_chain_push(tileElement->properties.path.ride_index); } @@ -2591,7 +2587,7 @@ void footpath_remove_edges_at(int32_t x, int32_t y, rct_tile_element* tileElemen int32_t z0 = z1 - 2; footpath_remove_edges_towards( x + CoordsDirectionDelta[direction].x, y + CoordsDirectionDelta[direction].y, z0, z1, direction, - footpath_element_is_queue(tileElement)); + tileElement->AsPath()->IsQueue()); } else { diff --git a/src/openrct2/world/Footpath.h b/src/openrct2/world/Footpath.h index 5fbbb040dd..24afdede33 100644 --- a/src/openrct2/world/Footpath.h +++ b/src/openrct2/world/Footpath.h @@ -157,9 +157,6 @@ int32_t footpath_is_connected_to_map_edge(int32_t x, int32_t y, int32_t z, int32 bool footpath_element_is_sloped(const rct_tile_element* tileElement); void footpath_element_set_sloped(rct_tile_element* tileElement, bool isSloped); uint8_t footpath_element_get_slope_direction(const rct_tile_element* tileElement); -bool footpath_element_is_queue(const rct_tile_element* tileElement); -void footpath_element_set_queue(rct_tile_element* tileElement); -void footpath_element_clear_queue(rct_tile_element* tileElement); bool footpath_element_has_queue_banner(const rct_tile_element* tileElement); bool footpath_element_is_wide(const rct_tile_element* tileElement); uint8_t footpath_element_get_type(const rct_tile_element* tileElement); diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 68d2e564ce..a5eb5388cc 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -3137,7 +3137,7 @@ void map_remove_all_rides() switch (it.element->GetType()) { case TILE_ELEMENT_TYPE_PATH: - if (footpath_element_is_queue(it.element)) + if (it.element->AsPath()->IsQueue()) { it.element->properties.path.type &= ~8; it.element->properties.path.addition_status = 255; @@ -3586,7 +3586,7 @@ bool map_can_construct_with_clear_at( // Crossing mode 1: building track over path if (crossingMode == 1 && canBuildCrossing && tileElement->GetType() == TILE_ELEMENT_TYPE_PATH - && tileElement->base_height == zLow && !footpath_element_is_queue(tileElement) + && tileElement->base_height == zLow && !tileElement->AsPath()->IsQueue() && !footpath_element_is_sloped(tileElement)) { continue; diff --git a/src/openrct2/world/TileElement.h b/src/openrct2/world/TileElement.h index cd7012dccc..c77cfc1814 100644 --- a/src/openrct2/world/TileElement.h +++ b/src/openrct2/world/TileElement.h @@ -193,6 +193,9 @@ struct PathElement : TileElementBase }; public: + bool IsQueue() const; + void SetIsQueue(bool isQueue); + uint8_t GetRCT1PathType() const; }; assert_struct_size(PathElement, 8); From 02cfffcb1e4b4142769cdea0d00ca648975d8d8e Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Wed, 3 Oct 2018 11:07:50 +0200 Subject: [PATCH 3/9] Remove some direct usage of TileElement->type --- src/openrct2/world/MapGen.cpp | 4 ++-- src/openrct2/world/TileInspector.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/openrct2/world/MapGen.cpp b/src/openrct2/world/MapGen.cpp index 5260cdfbc1..0aec0eb7a2 100644 --- a/src/openrct2/world/MapGen.cpp +++ b/src/openrct2/world/MapGen.cpp @@ -245,8 +245,8 @@ static void mapgen_place_tree(int32_t type, int32_t x, int32_t y) tileElement = tile_element_insert(x, y, surfaceZ, (1 | 2 | 4 | 8)); assert(tileElement != nullptr); tileElement->clearance_height = surfaceZ + (sceneryEntry->small_scenery.height >> 3); - - tileElement->type = TILE_ELEMENT_TYPE_SMALL_SCENERY | (util_rand() & 3); + tileElement->SetType(TILE_ELEMENT_TYPE_SMALL_SCENERY); + tileElement->SetDirection(util_rand() & 3); SmallSceneryElement* sceneryElement = tileElement->AsSmallScenery(); sceneryElement->SetEntryIndex(type); sceneryElement->SetAge(0); diff --git a/src/openrct2/world/TileInspector.cpp b/src/openrct2/world/TileInspector.cpp index 891d3c2142..c078f027cb 100644 --- a/src/openrct2/world/TileInspector.cpp +++ b/src/openrct2/world/TileInspector.cpp @@ -967,7 +967,7 @@ int32_t tile_inspector_track_set_chain( if (tileElement->AsTrack()->HasChain() != setChain) { - tileElement->type ^= TRACK_ELEMENT_TYPE_FLAG_CHAIN_LIFT; + tileElement->AsTrack()->SetHasChain(setChain); } } } From 28d302d6530d9860d873206f75d03d6ba8d6247a Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Wed, 3 Oct 2018 11:39:33 +0200 Subject: [PATCH 4/9] Remove more direct access to TileElement->type --- src/openrct2/rct1/S4Importer.cpp | 2 +- src/openrct2/ride/Ride.cpp | 4 ++-- src/openrct2/ride/Track.cpp | 24 +++++++++++++++------- src/openrct2/ride/TrackDesign.cpp | 2 +- src/openrct2/ride/TrackDesignSave.cpp | 29 ++++++++++++++------------- src/openrct2/ride/TrackPaint.cpp | 2 +- src/openrct2/world/Map.cpp | 10 ++++----- src/openrct2/world/Surface.cpp | 12 +++++++++++ src/openrct2/world/TileElement.h | 9 ++++++++- test/testpaint/Compat.cpp | 5 +++++ 10 files changed, 67 insertions(+), 32 deletions(-) diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 0d92be3d69..c6a98b4fa3 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -2508,7 +2508,7 @@ private: uint8_t pathType = tileElement->AsPath()->GetRCT1PathType(); uint8_t entryIndex = _pathTypeToEntryMap[pathType]; - tileElement->type &= ~TILE_ELEMENT_DIRECTION_MASK; + tileElement->SetDirection(0); tileElement->flags &= ~(TILE_ELEMENT_FLAG_BROKEN | TILE_ELEMENT_FLAG_INDESTRUCTIBLE_TRACK_PIECE); footpath_element_set_type(tileElement, entryIndex); diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index 3ec1404e5b..70f73e3ff2 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -1389,11 +1389,11 @@ int32_t sub_6C683D( } if (flags & (1 << 0)) { - tileElement->type &= ~TILE_ELEMENT_TYPE_FLAG_HIGHLIGHT; + tileElement->AsTrack()->SetHighlight(false); } if (flags & (1 << 1)) { - tileElement->type |= TILE_ELEMENT_TYPE_FLAG_HIGHLIGHT; + tileElement->AsTrack()->SetHighlight(true); } if (flags & (1 << 2)) { diff --git a/src/openrct2/ride/Track.cpp b/src/openrct2/ride/Track.cpp index f36718af34..b7d4dbabc1 100644 --- a/src/openrct2/ride/Track.cpp +++ b/src/openrct2/ride/Track.cpp @@ -1448,14 +1448,12 @@ static money32 track_place( tileElement = tile_element_insert(x / 32, y / 32, baseZ, bl & 0xF); assert(tileElement != nullptr); tileElement->clearance_height = clearanceZ; - - uint8_t map_type = direction; - map_type |= TILE_ELEMENT_TYPE_TRACK; + tileElement->SetType(TILE_ELEMENT_TYPE_TRACK); + tileElement->SetDirection(direction); if (liftHillAndAlternativeState & CONSTRUCTION_LIFT_HILL_SELECTED) { - map_type |= (1 << 7); + tileElement->AsTrack()->SetHasChain(true); } - tileElement->type = map_type; tileElement->AsTrack()->SetSequenceIndex(trackBlock->index); tileElement->AsTrack()->SetRideIndex(rideIndex); @@ -1518,7 +1516,7 @@ static money32 track_place( if (rideTypeFlags & RIDE_TYPE_FLAG_TRACK_MUST_BE_ON_WATER) { rct_tile_element* surfaceElement = map_get_surface_element_at({ x, y }); - surfaceElement->type |= (1 << 6); + surfaceElement->AsSurface()->SetHasTrackThatNeedsWater(true); tileElement = surfaceElement; } @@ -1786,7 +1784,7 @@ static money32 track_remove( if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_TRACK_MUST_BE_ON_WATER)) { - surfaceElement->type &= ~(1 << 6); + surfaceElement->AsSurface()->SetHasTrackThatNeedsWater(false); } invalidate_test_results(rideIndex); @@ -2357,3 +2355,15 @@ void TrackElement::SetHasGreenLight(uint8_t greenLight) sequence |= MAP_ELEM_TRACK_SEQUENCE_GREEN_LIGHT; } } + +bool TrackElement::IsHighlighted() const +{ + return (type & TILE_ELEMENT_TYPE_FLAG_HIGHLIGHT); +} + +void TrackElement::SetHighlight(bool on) +{ + type &= ~TILE_ELEMENT_TYPE_FLAG_HIGHLIGHT; + if (on) + type |= TILE_ELEMENT_TYPE_FLAG_HIGHLIGHT; +} \ No newline at end of file diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index dd148cdd2f..7877d57ac6 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -2105,7 +2105,7 @@ static money32 place_maze_design(uint8_t flags, uint8_t rideIndex, uint16_t maze int32_t fz = z >> 3; rct_tile_element* tileElement = tile_element_insert(fx >> 5, fy >> 5, fz, 15); tileElement->clearance_height = fz + 4; - tileElement->type = TILE_ELEMENT_TYPE_TRACK; + tileElement->SetType(TILE_ELEMENT_TYPE_TRACK); tileElement->AsTrack()->SetTrackType(TRACK_ELEM_MAZE); tileElement->AsTrack()->SetRideIndex(rideIndex); tileElement->AsTrack()->SetMazeEntry(mazeEntry); diff --git a/src/openrct2/ride/TrackDesignSave.cpp b/src/openrct2/ride/TrackDesignSave.cpp index d73702d605..05f4bf46ff 100644 --- a/src/openrct2/ride/TrackDesignSave.cpp +++ b/src/openrct2/ride/TrackDesignSave.cpp @@ -296,8 +296,8 @@ static void track_design_save_add_scenery(int32_t x, int32_t y, rct_tile_element auto entry = object_entry_get_entry(OBJECT_TYPE_SMALL_SCENERY, entryType); uint8_t flags = 0; - flags |= tileElement->type & 3; - flags |= (tileElement->type & 0xC0) >> 4; + flags |= tileElement->GetDirection(); + flags |= tileElement->AsSmallScenery()->GetSceneryQuadrant() << 2; uint8_t primaryColour = sceneryElement->GetPrimaryColour(); uint8_t secondaryColour = sceneryElement->GetSecondaryColour(); @@ -317,7 +317,7 @@ static void track_design_save_add_large_scenery(int32_t x, int32_t y, rct_tile_e sceneryTiles = get_large_scenery_entry(entryType)->large_scenery.tiles; z = tileElement->base_height; - direction = tileElement->type & 3; + direction = tileElement->GetDirection(); sequence = tileElement->AsLargeScenery()->GetSequenceIndex(); if (!map_large_scenery_get_origin(x, y, z, direction, sequence, &x0, &y0, &z0, nullptr)) @@ -341,7 +341,7 @@ static void track_design_save_add_large_scenery(int32_t x, int32_t y, rct_tile_e { if (sequence == 0) { - uint8_t flags = tileElement->type & 3; + uint8_t flags = tileElement->GetDirection(); uint8_t primaryColour = tileElement->AsLargeScenery()->GetPrimaryColour(); uint8_t secondaryColour = tileElement->AsLargeScenery()->GetSecondaryColour(); @@ -358,7 +358,7 @@ static void track_design_save_add_wall(int32_t x, int32_t y, rct_tile_element* t auto entry = object_entry_get_entry(OBJECT_TYPE_WALLS, entryType); uint8_t flags = 0; - flags |= tileElement->type & 3; + flags |= tileElement->GetDirection(); flags |= tileElement->AsWall()->GetTertiaryColour() << 2; uint8_t secondaryColour = tileElement->AsWall()->GetSecondaryColour(); @@ -491,8 +491,8 @@ static void track_design_save_remove_scenery(int32_t x, int32_t y, rct_tile_elem auto entry = object_entry_get_entry(OBJECT_TYPE_SMALL_SCENERY, entryType); uint8_t flags = 0; - flags |= tileElement->type & 3; - flags |= (tileElement->type & 0xC0) >> 4; + flags |= tileElement->GetDirection(); + flags |= tileElement->AsSmallScenery()->GetSceneryQuadrant() << 2; track_design_save_pop_tile_element(x, y, tileElement); track_design_save_pop_tile_element_desc(entry, x, y, tileElement->base_height, flags); @@ -509,7 +509,7 @@ static void track_design_save_remove_large_scenery(int32_t x, int32_t y, rct_til sceneryTiles = get_large_scenery_entry(entryType)->large_scenery.tiles; z = tileElement->base_height; - direction = tileElement->type & 3; + direction = tileElement->GetDirection(); sequence = tileElement->AsLargeScenery()->GetSequenceIndex(); if (!map_large_scenery_get_origin(x, y, z, direction, sequence, &x0, &y0, &z0, nullptr)) @@ -533,7 +533,7 @@ static void track_design_save_remove_large_scenery(int32_t x, int32_t y, rct_til { if (sequence == 0) { - uint8_t flags = tileElement->type & 3; + uint8_t flags = tileElement->GetDirection(); track_design_save_pop_tile_element_desc(entry, x, y, z, flags); } track_design_save_pop_tile_element(x, y, tileElement); @@ -547,7 +547,7 @@ static void track_design_save_remove_wall(int32_t x, int32_t y, rct_tile_element auto entry = object_entry_get_entry(OBJECT_TYPE_WALLS, entryType); uint8_t flags = 0; - flags |= tileElement->type & 3; + flags |= tileElement->GetDirection(); flags |= tileElement->AsWall()->GetTertiaryColour() << 2; track_design_save_pop_tile_element(x, y, tileElement); @@ -1047,17 +1047,18 @@ static bool track_design_save_to_td6_for_tracked_ride(uint8_t rideIndex, rct_tra track->type = TRACK_ELEM_255_ALIAS; } - uint8_t bh; + uint8_t flags; if (track_element_has_speed_setting(track->type)) { - bh = trackElement.element->AsTrack()->GetBrakeBoosterSpeed() >> 1; + flags = trackElement.element->AsTrack()->GetBrakeBoosterSpeed() >> 1; } else { - bh = trackElement.element->AsTrack()->GetSeatRotation(); + flags = trackElement.element->AsTrack()->GetSeatRotation(); } - uint8_t flags = (trackElement.element->type & (1 << 7)) | bh; + if (trackElement.element->AsTrack()->HasChain()) + flags |= (1 << 7); flags |= trackElement.element->AsTrack()->GetColourScheme() << 4; if (RideData4[ride->type].flags & RIDE_TYPE_FLAG4_HAS_ALTERNATIVE_TRACK_TYPE && trackElement.element->AsTrack()->IsInverted()) diff --git a/src/openrct2/ride/TrackPaint.cpp b/src/openrct2/ride/TrackPaint.cpp index f4e2c83b55..27ffaf36ef 100644 --- a/src/openrct2/ride/TrackPaint.cpp +++ b/src/openrct2/ride/TrackPaint.cpp @@ -2185,7 +2185,7 @@ void track_paint(paint_session* session, uint8_t direction, int32_t height, cons session->TrackColours[SCHEME_SUPPORTS] = SPRITE_ID_PALETTE_COLOUR_1(ride->track_colour_supports[trackColourScheme]); session->TrackColours[SCHEME_MISC] = IMAGE_TYPE_REMAP; session->TrackColours[SCHEME_3] = 0x20C00000; - if (tileElement->type & TILE_ELEMENT_TYPE_FLAG_HIGHLIGHT) + if (tileElement->AsTrack()->IsHighlighted()) { session->TrackColours[SCHEME_TRACK] = 0x21600000; session->TrackColours[SCHEME_SUPPORTS] = 0x21600000; diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index a5eb5388cc..386ffcf157 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -342,8 +342,7 @@ void map_init(int32_t size) for (int32_t i = 0; i < MAX_TILE_TILE_ELEMENT_POINTERS; i++) { rct_tile_element* tile_element = &gTileElements[i]; - memset(tile_element, 0, sizeof(rct_tile_element)); - tile_element->type = (TILE_ELEMENT_TYPE_SURFACE << 2); + tile_element->ClearAs(TILE_ELEMENT_TYPE_SURFACE); tile_element->flags = TILE_ELEMENT_FLAG_LAST_TILE; tile_element->base_height = 14; tile_element->clearance_height = 14; @@ -1628,7 +1627,7 @@ static money32 map_set_land_height(int32_t flags, int32_t x, int32_t y, int32_t uint8_t zCorner = height; // z position of highest corner of tile rct_tile_element* surfaceElement = map_get_surface_element_at({ x, y }); - if (surfaceElement->type & TILE_ELEMENT_TYPE_FLAG_HIGHLIGHT) + if (surfaceElement->AsSurface()->HasTrackThatNeedsWater()) { uint32_t waterHeight = surfaceElement->AsSurface()->GetWaterHeight(); if (waterHeight != 0) @@ -3059,7 +3058,8 @@ void game_command_place_large_scenery( map_animation_create(MAP_ANIMATION_TYPE_LARGE_SCENERY, curTile.x, curTile.y, zLow); new_tile_element->clearance_height = zHigh; - new_tile_element->type = TILE_ELEMENT_TYPE_LARGE_SCENERY | rotation; + new_tile_element->SetType(TILE_ELEMENT_TYPE_LARGE_SCENERY); + new_tile_element->SetDirection(rotation); auto newSceneryElement = new_tile_element->AsLargeScenery(); newSceneryElement->SetEntryIndex(entry_index); @@ -4043,7 +4043,7 @@ rct_tile_element* map_get_small_scenery_element_at(int32_t x, int32_t y, int32_t { if (tileElement->GetType() != TILE_ELEMENT_TYPE_SMALL_SCENERY) continue; - if (tileElement->type >> 6 != quadrant) + if (tileElement->AsSmallScenery()->GetSceneryQuadrant() != quadrant) continue; if (tileElement->base_height != z) continue; diff --git a/src/openrct2/world/Surface.cpp b/src/openrct2/world/Surface.cpp index 4bfaf83a14..a2afe87f29 100644 --- a/src/openrct2/world/Surface.cpp +++ b/src/openrct2/world/Surface.cpp @@ -215,3 +215,15 @@ void SurfaceElement::SetSlope(uint8_t newSlope) slope &= ~TILE_ELEMENT_SURFACE_SLOPE_MASK; slope |= (newSlope & TILE_ELEMENT_SURFACE_SLOPE_MASK); } + +bool SurfaceElement::HasTrackThatNeedsWater() const +{ + return (type & SURFACE_ELEMENT_HAS_TRACK_THAT_NEEDS_WATER) != 0; +} + +void SurfaceElement::SetHasTrackThatNeedsWater(bool on) +{ + type &= ~SURFACE_ELEMENT_HAS_TRACK_THAT_NEEDS_WATER; + if (on) + type |= SURFACE_ELEMENT_HAS_TRACK_THAT_NEEDS_WATER; +} \ No newline at end of file diff --git a/src/openrct2/world/TileElement.h b/src/openrct2/world/TileElement.h index c77cfc1814..6787d37d36 100644 --- a/src/openrct2/world/TileElement.h +++ b/src/openrct2/world/TileElement.h @@ -178,6 +178,9 @@ public: uint8_t GetParkFences() const; void SetParkFences(uint8_t newParkFences); + + bool HasTrackThatNeedsWater() const; + void SetHasTrackThatNeedsWater(bool on); }; assert_struct_size(SurfaceElement, 8); @@ -268,6 +271,9 @@ public: void SetPhotoTimeout(); void DecrementPhotoTimeout(); + bool IsHighlighted() const; + void SetHighlight(bool on); + // Used in RCT1, will be reintroduced at some point. // (See https://github.com/OpenRCT2/OpenRCT2/issues/7059) uint8_t GetDoorAState() const; @@ -432,7 +438,8 @@ enum enum { - TILE_ELEMENT_TYPE_FLAG_HIGHLIGHT = (1 << 6) + TILE_ELEMENT_TYPE_FLAG_HIGHLIGHT = (1 << 6), + SURFACE_ELEMENT_HAS_TRACK_THAT_NEEDS_WATER = (1 << 6), }; enum diff --git a/test/testpaint/Compat.cpp b/test/testpaint/Compat.cpp index a413308750..31ba90e7e9 100644 --- a/test/testpaint/Compat.cpp +++ b/test/testpaint/Compat.cpp @@ -409,3 +409,8 @@ uint32_t SurfaceElement::GetWaterHeight() const { return terrain & TILE_ELEMENT_SURFACE_WATER_HEIGHT_MASK; } + +bool TrackElement::IsHighlighted() const +{ + return (type & TILE_ELEMENT_TYPE_FLAG_HIGHLIGHT); +} From 90d7e146f7edf16c7923117da741769f3ec164c8 Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Wed, 3 Oct 2018 11:57:19 +0200 Subject: [PATCH 5/9] Clean up small scenery GC calls a bit --- src/openrct2-ui/interface/ViewportInteraction.cpp | 4 ++-- src/openrct2/ride/TrackDesign.cpp | 8 +++++--- src/openrct2/world/Scenery.cpp | 4 +++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/openrct2-ui/interface/ViewportInteraction.cpp b/src/openrct2-ui/interface/ViewportInteraction.cpp index b8ae99cb01..c8cb601990 100644 --- a/src/openrct2-ui/interface/ViewportInteraction.cpp +++ b/src/openrct2-ui/interface/ViewportInteraction.cpp @@ -467,8 +467,8 @@ static void viewport_interaction_remove_scenery(rct_tile_element* tileElement, i { gGameCommandErrorTitle = STR_CANT_REMOVE_THIS; game_do_command( - x, (tileElement->type << 8) | 1, y, (tileElement->AsSmallScenery()->GetEntryIndex() << 8) | tileElement->base_height, - GAME_COMMAND_REMOVE_SCENERY, 0, 0); + x, (tileElement->type << 8) | GAME_COMMAND_FLAG_APPLY, y, + (tileElement->AsSmallScenery()->GetEntryIndex() << 8) | tileElement->base_height, GAME_COMMAND_REMOVE_SCENERY, 0, 0); } /** diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index 7877d57ac6..f76fce801d 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -816,7 +816,8 @@ static int32_t track_design_place_scenery( uint8_t quadrant = (scenery->flags >> 2) + _currentTrackPieceDirection; quadrant &= 3; - uint8_t bh = rotation | (quadrant << 6) | TILE_ELEMENT_TYPE_SMALL_SCENERY; + // So called because it mirrors the SmallSceneryElement->type byte. + uint8_t typeByte = rotation | (quadrant << 6) | TILE_ELEMENT_TYPE_SMALL_SCENERY; rct_scenery_entry* small_scenery = get_small_scenery_entry(entry_index); if (!(!scenery_small_entry_has_flag(small_scenery, SMALL_SCENERY_FLAG_FULL_TILE) @@ -826,12 +827,13 @@ static int32_t track_design_place_scenery( SMALL_SCENERY_FLAG_DIAGONAL | SMALL_SCENERY_FLAG_HALF_SPACE | SMALL_SCENERY_FLAG_THREE_QUARTERS)) { - bh &= 0x3F; + typeByte &= ~TILE_ELEMENT_QUADRANT_MASK; } z = (scenery->z * 8 + originZ) / 8; game_do_command( - mapCoord.x, flags | bh << 8, mapCoord.y, (entry_index << 8) | z, GAME_COMMAND_REMOVE_SCENERY, 0, 0); + mapCoord.x, flags | typeByte << 8, mapCoord.y, (entry_index << 8) | z, GAME_COMMAND_REMOVE_SCENERY, + 0, 0); break; } case OBJECT_TYPE_LARGE_SCENERY: diff --git a/src/openrct2/world/Scenery.cpp b/src/openrct2/world/Scenery.cpp index 9453e945e9..d990e12a72 100644 --- a/src/openrct2/world/Scenery.cpp +++ b/src/openrct2/world/Scenery.cpp @@ -184,8 +184,10 @@ void scenery_remove_ghost_tool_placement() if (gSceneryGhostType & SCENERY_ENTRY_FLAG_0) { gSceneryGhostType &= ~SCENERY_ENTRY_FLAG_0; + uint8_t flags = GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_5 + | GAME_COMMAND_FLAG_GHOST; game_do_command( - x, 105 | (gSceneryTileElementType << 8), y, z | (gSceneryPlaceObject << 8), GAME_COMMAND_REMOVE_SCENERY, 0, 0); + x, flags | (gSceneryTileElementType << 8), y, z | (gSceneryPlaceObject << 8), GAME_COMMAND_REMOVE_SCENERY, 0, 0); } if (gSceneryGhostType & SCENERY_ENTRY_FLAG_1) From 28e8b4e12b9bae306ff54b8307e99c230c3b2b19 Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Wed, 3 Oct 2018 12:03:18 +0200 Subject: [PATCH 6/9] Modify game_command_remove_scenery to take unshifted scenery quadrant --- src/openrct2-ui/interface/ViewportInteraction.cpp | 2 +- src/openrct2-ui/windows/TopToolbar.cpp | 2 +- src/openrct2/network/Network.cpp | 2 +- src/openrct2/ride/TrackDesign.cpp | 7 ++----- src/openrct2/world/Map.cpp | 2 +- src/openrct2/world/Scenery.cpp | 4 ++-- src/openrct2/world/Scenery.h | 2 +- src/openrct2/world/SmallScenery.cpp | 2 +- 8 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/openrct2-ui/interface/ViewportInteraction.cpp b/src/openrct2-ui/interface/ViewportInteraction.cpp index c8cb601990..437938f21b 100644 --- a/src/openrct2-ui/interface/ViewportInteraction.cpp +++ b/src/openrct2-ui/interface/ViewportInteraction.cpp @@ -467,7 +467,7 @@ static void viewport_interaction_remove_scenery(rct_tile_element* tileElement, i { gGameCommandErrorTitle = STR_CANT_REMOVE_THIS; game_do_command( - x, (tileElement->type << 8) | GAME_COMMAND_FLAG_APPLY, y, + x, (tileElement->AsSmallScenery()->GetSceneryQuadrant() << 8) | GAME_COMMAND_FLAG_APPLY, y, (tileElement->AsSmallScenery()->GetEntryIndex() << 8) | tileElement->base_height, GAME_COMMAND_REMOVE_SCENERY, 0, 0); } diff --git a/src/openrct2-ui/windows/TopToolbar.cpp b/src/openrct2-ui/windows/TopToolbar.cpp index 9454d5a624..9184caa03a 100644 --- a/src/openrct2-ui/windows/TopToolbar.cpp +++ b/src/openrct2-ui/windows/TopToolbar.cpp @@ -2416,7 +2416,7 @@ static money32 try_place_ghost_scenery( tileElement = gSceneryTileElement; gSceneryGhostPosition.z = tileElement->base_height; - gSceneryTileElementType = tileElement->type; + gSceneryQuadrant = tileElement->AsSmallScenery()->GetSceneryQuadrant(); if (gSceneryGroundFlags & ELEMENT_IS_UNDERGROUND) { // Set underground on diff --git a/src/openrct2/network/Network.cpp b/src/openrct2/network/Network.cpp index ac1315e281..ab3f006e00 100644 --- a/src/openrct2/network/Network.cpp +++ b/src/openrct2/network/Network.cpp @@ -28,7 +28,7 @@ // This string specifies which version of network stream current build uses. // It is used for making sure only compatible builds get connected, even within // single OpenRCT2 version. -#define NETWORK_STREAM_VERSION "1" +#define NETWORK_STREAM_VERSION "2" #define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION static rct_peep* _pickup_peep = nullptr; diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index f76fce801d..54406e5e23 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -816,9 +816,6 @@ static int32_t track_design_place_scenery( uint8_t quadrant = (scenery->flags >> 2) + _currentTrackPieceDirection; quadrant &= 3; - // So called because it mirrors the SmallSceneryElement->type byte. - uint8_t typeByte = rotation | (quadrant << 6) | TILE_ELEMENT_TYPE_SMALL_SCENERY; - rct_scenery_entry* small_scenery = get_small_scenery_entry(entry_index); if (!(!scenery_small_entry_has_flag(small_scenery, SMALL_SCENERY_FLAG_FULL_TILE) && scenery_small_entry_has_flag(small_scenery, SMALL_SCENERY_FLAG_DIAGONAL)) @@ -827,12 +824,12 @@ static int32_t track_design_place_scenery( SMALL_SCENERY_FLAG_DIAGONAL | SMALL_SCENERY_FLAG_HALF_SPACE | SMALL_SCENERY_FLAG_THREE_QUARTERS)) { - typeByte &= ~TILE_ELEMENT_QUADRANT_MASK; + quadrant = 0; } z = (scenery->z * 8 + originZ) / 8; game_do_command( - mapCoord.x, flags | typeByte << 8, mapCoord.y, (entry_index << 8) | z, GAME_COMMAND_REMOVE_SCENERY, + mapCoord.x, flags | quadrant << 8, mapCoord.y, (entry_index << 8) | z, GAME_COMMAND_REMOVE_SCENERY, 0, 0); break; } diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 386ffcf157..f8a3f5e4dc 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -1094,7 +1094,7 @@ restart_from_beginning: if (clear & (1 << 0)) { int32_t eax = x * 32; - int32_t ebx = (tileElement->type << 8) | flags; + int32_t ebx = (tileElement->AsSmallScenery()->GetSceneryQuadrant() << 8) | flags; int32_t ecx = y * 32; int32_t edx = (tileElement->AsSmallScenery()->GetEntryIndex() << 8) | (tileElement->base_height); int32_t edi = 0, ebp = 0; diff --git a/src/openrct2/world/Scenery.cpp b/src/openrct2/world/Scenery.cpp index d990e12a72..697c8f201b 100644 --- a/src/openrct2/world/Scenery.cpp +++ b/src/openrct2/world/Scenery.cpp @@ -38,7 +38,7 @@ colour_t gWindowSceneryTertiaryColour; bool gWindowSceneryEyedropperEnabled; rct_tile_element* gSceneryTileElement; -uint8_t gSceneryTileElementType; +uint8_t gSceneryQuadrant; money32 gSceneryPlaceCost; int16_t gSceneryPlaceObject; @@ -187,7 +187,7 @@ void scenery_remove_ghost_tool_placement() uint8_t flags = GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_5 | GAME_COMMAND_FLAG_GHOST; game_do_command( - x, flags | (gSceneryTileElementType << 8), y, z | (gSceneryPlaceObject << 8), GAME_COMMAND_REMOVE_SCENERY, 0, 0); + x, flags | (gSceneryQuadrant << 8), y, z | (gSceneryPlaceObject << 8), GAME_COMMAND_REMOVE_SCENERY, 0, 0); } if (gSceneryGhostType & SCENERY_ENTRY_FLAG_1) diff --git a/src/openrct2/world/Scenery.h b/src/openrct2/world/Scenery.h index 6404d64158..e8157ded05 100644 --- a/src/openrct2/world/Scenery.h +++ b/src/openrct2/world/Scenery.h @@ -266,7 +266,7 @@ extern colour_t gWindowSceneryTertiaryColour; extern bool gWindowSceneryEyedropperEnabled; extern rct_tile_element* gSceneryTileElement; -extern uint8_t gSceneryTileElementType; +extern uint8_t gSceneryQuadrant; extern money32 gSceneryPlaceCost; extern int16_t gSceneryPlaceObject; diff --git a/src/openrct2/world/SmallScenery.cpp b/src/openrct2/world/SmallScenery.cpp index 0ebfd08a11..579a5920c0 100644 --- a/src/openrct2/world/SmallScenery.cpp +++ b/src/openrct2/world/SmallScenery.cpp @@ -420,7 +420,7 @@ void game_command_remove_scenery( [[maybe_unused]] int32_t* ebp) { *ebx = SmallSceneryRemove( - *eax & 0xFFFF, *ecx & 0xFFFF, *edx & 0xFF, ((*ebx >> 8) & 0xFF) >> 6, (*edx >> 8) & 0xFF, *ebx & 0xFF); + *eax & 0xFFFF, *ecx & 0xFFFF, *edx & 0xFF, ((*ebx >> 8) & 0xFF), (*edx >> 8) & 0xFF, *ebx & 0xFF); } /** From 0af198aa4556b7a6a42107da129283332c0f159e Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Wed, 3 Oct 2018 12:16:57 +0200 Subject: [PATCH 7/9] Use constants for flags --- src/openrct2-ui/windows/TopToolbar.cpp | 6 +- src/openrct2/ride/TrackDesign.cpp | 78 ++++++++++++++------------ src/openrct2/world/SmallScenery.cpp | 3 +- 3 files changed, 48 insertions(+), 39 deletions(-) diff --git a/src/openrct2-ui/windows/TopToolbar.cpp b/src/openrct2-ui/windows/TopToolbar.cpp index 9184caa03a..4bd76304e8 100644 --- a/src/openrct2-ui/windows/TopToolbar.cpp +++ b/src/openrct2-ui/windows/TopToolbar.cpp @@ -2403,8 +2403,10 @@ static money32 try_place_ghost_scenery( // Small Scenery // 6e252b cost = game_do_command( - map_tile.x, parameter_1 | 0x69, map_tile.y, parameter_2, GAME_COMMAND_PLACE_SCENERY, parameter_3, - gSceneryPlaceZ); + map_tile.x, + parameter_1 | GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_5 + | GAME_COMMAND_FLAG_GHOST, + map_tile.y, parameter_2, GAME_COMMAND_PLACE_SCENERY, parameter_3, gSceneryPlaceZ); if (cost == MONEY32_UNDEFINED) return cost; diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index 54406e5e23..8a9972bffa 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -912,7 +912,7 @@ static int32_t track_design_place_scenery( money32 cost; int16_t z; - uint8_t bl; + uint8_t flags; uint8_t quadrant; switch (entry_type) @@ -932,24 +932,26 @@ static int32_t track_design_place_scenery( z = scenery->z * 8 + originZ; quadrant = ((scenery->flags >> 2) + _currentTrackPieceDirection) & 3; - bl = 0x81; + flags = GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_PATH_SCENERY; if (_trackDesignPlaceOperation == PTD_OPERATION_GET_COST) { - bl = 0xA9; + flags = GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_PATH_SCENERY + | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_5; } - if (_trackDesignPlaceOperation == PTD_OPERATION_4) + else if (_trackDesignPlaceOperation == PTD_OPERATION_4) { - bl = 0xE9; + flags = GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_PATH_SCENERY + | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_5; } - if (_trackDesignPlaceOperation == PTD_OPERATION_1) + else if (_trackDesignPlaceOperation == PTD_OPERATION_1) { - bl = 0x80; + flags = GAME_COMMAND_FLAG_PATH_SCENERY; } gGameCommandErrorTitle = STR_CANT_POSITION_THIS_HERE; cost = game_do_command( - mapCoord.x, bl | (entry_index << 8), mapCoord.y, quadrant | (scenery->primary_colour << 8), + mapCoord.x, flags | (entry_index << 8), mapCoord.y, quadrant | (scenery->primary_colour << 8), GAME_COMMAND_PLACE_SCENERY, rotation | (scenery->secondary_colour << 16), z); if (cost == MONEY32_UNDEFINED) @@ -972,22 +974,24 @@ static int32_t track_design_place_scenery( z = scenery->z * 8 + originZ; - bl = 0x81; + flags = GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_PATH_SCENERY; if (_trackDesignPlaceOperation == PTD_OPERATION_GET_COST) { - bl = 0xA9; + flags = GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_PATH_SCENERY + | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_5; } - if (_trackDesignPlaceOperation == PTD_OPERATION_4) + else if (_trackDesignPlaceOperation == PTD_OPERATION_4) { - bl = 0xE9; + flags = GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_PATH_SCENERY + | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_5; } - if (_trackDesignPlaceOperation == PTD_OPERATION_1) + else if (_trackDesignPlaceOperation == PTD_OPERATION_1) { - bl = 0x80; + flags = GAME_COMMAND_FLAG_PATH_SCENERY; } cost = game_do_command( - mapCoord.x, bl | (rotation << 8), mapCoord.y, + mapCoord.x, flags | (rotation << 8), mapCoord.y, scenery->primary_colour | (scenery->secondary_colour << 8), GAME_COMMAND_PLACE_LARGE_SCENERY, entry_index, z); @@ -1010,24 +1014,26 @@ static int32_t track_design_place_scenery( rotation += scenery->flags; rotation &= 3; - bl = 1; + flags = GAME_COMMAND_FLAG_APPLY; if (_trackDesignPlaceOperation == PTD_OPERATION_GET_COST) { - bl = 0xA9; + flags = GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_PATH_SCENERY + | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_5; } - if (_trackDesignPlaceOperation == PTD_OPERATION_4) + else if (_trackDesignPlaceOperation == PTD_OPERATION_4) { - bl = 105; + flags = GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_5 + | GAME_COMMAND_FLAG_GHOST; } - if (_trackDesignPlaceOperation == PTD_OPERATION_1) + else if (_trackDesignPlaceOperation == PTD_OPERATION_1) { - bl = 0; + flags = 0; } gGameCommandErrorTitle = STR_CANT_BUILD_PARK_ENTRANCE_HERE; cost = game_do_command( - mapCoord.x, bl | (entry_index << 8), mapCoord.y, rotation | (scenery->primary_colour << 8), + mapCoord.x, flags | (entry_index << 8), mapCoord.y, rotation | (scenery->primary_colour << 8), GAME_COMMAND_PLACE_WALL, z, scenery->secondary_colour | ((scenery->flags & 0xFC) << 6)); if (cost == MONEY32_UNDEFINED) @@ -1051,30 +1057,31 @@ static int32_t track_design_place_scenery( } uint8_t bh = ((scenery->flags & 0xF) << rotation); - bl = bh >> 4; - bh = (bh | bl) & 0xF; - bl = (((scenery->flags >> 5) + rotation) & 3) << 5; - bh |= bl; + flags = bh >> 4; + bh = (bh | flags) & 0xF; + flags = (((scenery->flags >> 5) + rotation) & 3) << 5; + bh |= flags; bh |= scenery->flags & 0x90; - bl = 1; + flags = GAME_COMMAND_FLAG_APPLY; if (_trackDesignPlaceOperation == PTD_OPERATION_GET_COST) { - bl = 41; + flags = GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_5; } if (_trackDesignPlaceOperation == PTD_OPERATION_4) { - bl = 105; + flags = GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_5 + | GAME_COMMAND_FLAG_GHOST; } if (_trackDesignPlaceOperation == PTD_OPERATION_1) { - bl = 0; + flags = 0; } gGameCommandErrorTitle = STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE; cost = game_do_command( - mapCoord.x, bl | (bh << 8), mapCoord.y, z | (entry_index << 8), + mapCoord.x, flags | (bh << 8), mapCoord.y, z | (entry_index << 8), GAME_COMMAND_PLACE_PATH_FROM_TRACK, 0, 0); } else @@ -1094,17 +1101,18 @@ static int32_t track_design_place_scenery( footpath_queue_chain_reset(); footpath_remove_edges_at(mapCoord.x, mapCoord.y, tile_element); - bl = 1; + flags = GAME_COMMAND_FLAG_APPLY; if (_trackDesignPlaceOperation == PTD_OPERATION_GET_COST) { - bl = 41; + flags = GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_5; } if (_trackDesignPlaceOperation == PTD_OPERATION_4) { - bl = 105; + flags = GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_5 + | GAME_COMMAND_FLAG_GHOST; } - footpath_connect_edges(mapCoord.x, mapCoord.y, tile_element, bl); + footpath_connect_edges(mapCoord.x, mapCoord.y, tile_element, flags); footpath_update_queue_chains(); continue; } diff --git a/src/openrct2/world/SmallScenery.cpp b/src/openrct2/world/SmallScenery.cpp index 579a5920c0..0d98150219 100644 --- a/src/openrct2/world/SmallScenery.cpp +++ b/src/openrct2/world/SmallScenery.cpp @@ -419,8 +419,7 @@ void game_command_remove_scenery( int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, [[maybe_unused]] int32_t* esi, [[maybe_unused]] int32_t* edi, [[maybe_unused]] int32_t* ebp) { - *ebx = SmallSceneryRemove( - *eax & 0xFFFF, *ecx & 0xFFFF, *edx & 0xFF, ((*ebx >> 8) & 0xFF), (*edx >> 8) & 0xFF, *ebx & 0xFF); + *ebx = SmallSceneryRemove(*eax & 0xFFFF, *ecx & 0xFFFF, *edx & 0xFF, ((*ebx >> 8) & 0xFF), (*edx >> 8) & 0xFF, *ebx & 0xFF); } /** From d3da8634d806a01043dd48137f7d9b37c89eaccc Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Wed, 3 Oct 2018 14:11:30 +0200 Subject: [PATCH 8/9] Use ClearAs in two places --- src/openrct2/rct1/S4Importer.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index c6a98b4fa3..69b12232d6 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -2402,11 +2402,8 @@ private: // Fill the rest of the row with blank tiles for (int32_t y = 0; y < RCT1_MAX_MAP_SIZE; y++) { - memset(nextFreeTileElement, 0, sizeof(rct_tile_element)); - nextFreeTileElement->SetType(TILE_ELEMENT_TYPE_SURFACE); + nextFreeTileElement->ClearAs(TILE_ELEMENT_TYPE_SURFACE); nextFreeTileElement->flags = TILE_ELEMENT_FLAG_LAST_TILE; - nextFreeTileElement->base_height = 2; - nextFreeTileElement->clearance_height = 2; nextFreeTileElement->AsSurface()->SetSlope(TILE_ELEMENT_SLOPE_FLAT); nextFreeTileElement->AsSurface()->SetSurfaceStyle(TERRAIN_GRASS); nextFreeTileElement->AsSurface()->SetEdgeStyle(TERRAIN_EDGE_ROCK); @@ -2419,11 +2416,8 @@ private: // 128 extra rows left to fill with blank tiles for (int32_t y = 0; y < 128 * 256; y++) { - memset(nextFreeTileElement, 0, sizeof(rct_tile_element)); - nextFreeTileElement->SetType(TILE_ELEMENT_TYPE_SURFACE); + nextFreeTileElement->ClearAs(TILE_ELEMENT_TYPE_SURFACE); nextFreeTileElement->flags = TILE_ELEMENT_FLAG_LAST_TILE; - nextFreeTileElement->base_height = 2; - nextFreeTileElement->clearance_height = 2; nextFreeTileElement->AsSurface()->SetSlope(TILE_ELEMENT_SLOPE_FLAT); nextFreeTileElement->AsSurface()->SetSurfaceStyle(TERRAIN_GRASS); nextFreeTileElement->AsSurface()->SetEdgeStyle(TERRAIN_EDGE_ROCK); From 88f3e9be75772cc91e60f1f8f0f4a43cc9f7b747 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Wed, 3 Oct 2018 19:38:18 +0200 Subject: [PATCH 9/9] Fix crash --- src/openrct2/world/Footpath.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index 2b33709429..1b6a04eab9 100644 --- a/src/openrct2/world/Footpath.cpp +++ b/src/openrct2/world/Footpath.cpp @@ -2584,10 +2584,10 @@ void footpath_remove_edges_at(int32_t x, int32_t y, rct_tile_element* tileElemen // to. if (!tile_element_wants_path_connection_towards({ x / 32, y / 32, z1, direction }, tileElement)) { + bool isQueue = tileElement->GetType() == TILE_ELEMENT_TYPE_PATH ? tileElement->AsPath()->IsQueue() : false; int32_t z0 = z1 - 2; footpath_remove_edges_towards( - x + CoordsDirectionDelta[direction].x, y + CoordsDirectionDelta[direction].y, z0, z1, direction, - tileElement->AsPath()->IsQueue()); + x + CoordsDirectionDelta[direction].x, y + CoordsDirectionDelta[direction].y, z0, z1, direction, isQueue); } else {