diff --git a/src/openrct2-ui/windows/Footpath.cpp b/src/openrct2-ui/windows/Footpath.cpp index 83acdd9356..7c8fce9fa7 100644 --- a/src/openrct2-ui/windows/Footpath.cpp +++ b/src/openrct2-ui/windows/Footpath.cpp @@ -1099,8 +1099,8 @@ static void footpath_remove_tile_element(rct_tile_element * tileElement) // Move selection edge ^= 2; - x = gFootpathConstructFromPosition.x - TileDirectionDelta[edge].x; - y = gFootpathConstructFromPosition.y - TileDirectionDelta[edge].y; + x = gFootpathConstructFromPosition.x - CoordsDirectionDelta[edge].x; + y = gFootpathConstructFromPosition.y - CoordsDirectionDelta[edge].y; gFootpathConstructFromPosition.x = x; gFootpathConstructFromPosition.y = y; gFootpathConstructFromPosition.z = z << 3; @@ -1202,8 +1202,8 @@ static void window_footpath_set_enabled_and_pressed_widgets() gMapSelectFlags |= MAP_SELECT_FLAG_GREEN; sint32 direction = gFootpathConstructDirection; - gMapSelectionTiles[0].x = gFootpathConstructFromPosition.x + TileDirectionDelta[direction].x; - gMapSelectionTiles[0].y = gFootpathConstructFromPosition.y + TileDirectionDelta[direction].y; + gMapSelectionTiles[0].x = gFootpathConstructFromPosition.x + CoordsDirectionDelta[direction].x; + gMapSelectionTiles[0].y = gFootpathConstructFromPosition.y + CoordsDirectionDelta[direction].y; gMapSelectionTiles[1].x = -1; map_invalidate_map_selection_tiles(); } @@ -1285,8 +1285,8 @@ static void footpath_get_next_path_info(sint32 * type, sint32 * x, sint32 * y, s sint32 direction; direction = gFootpathConstructDirection; - *x = gFootpathConstructFromPosition.x + TileDirectionDelta[direction].x; - *y = gFootpathConstructFromPosition.y + TileDirectionDelta[direction].y; + *x = gFootpathConstructFromPosition.x + CoordsDirectionDelta[direction].x; + *y = gFootpathConstructFromPosition.y + CoordsDirectionDelta[direction].y; *z = gFootpathConstructFromPosition.z / 8; *type = (gFootpathSelectedType << 7) + (gFootpathSelectedId & 0xFF); *slope = TILE_ELEMENT_SLOPE_FLAT; diff --git a/src/openrct2-ui/windows/Map.cpp b/src/openrct2-ui/windows/Map.cpp index ed01e94642..8874c4d24e 100644 --- a/src/openrct2-ui/windows/Map.cpp +++ b/src/openrct2-ui/windows/Map.cpp @@ -1247,10 +1247,10 @@ static void window_map_place_park_entrance_tool_update(sint32 x, sint32 y) sideDirection = (direction + 1) & 3; gMapSelectionTiles[0].x = mapX; gMapSelectionTiles[0].y = mapY; - gMapSelectionTiles[1].x = mapX + TileDirectionDelta[sideDirection].x; - gMapSelectionTiles[1].y = mapY + TileDirectionDelta[sideDirection].y; - gMapSelectionTiles[2].x = mapX - TileDirectionDelta[sideDirection].x; - gMapSelectionTiles[2].y = mapY - TileDirectionDelta[sideDirection].y; + gMapSelectionTiles[1].x = mapX + CoordsDirectionDelta[sideDirection].x; + gMapSelectionTiles[1].y = mapY + CoordsDirectionDelta[sideDirection].y; + gMapSelectionTiles[2].x = mapX - CoordsDirectionDelta[sideDirection].x; + gMapSelectionTiles[2].y = mapY - CoordsDirectionDelta[sideDirection].y; gMapSelectionTiles[3].x = -1; gMapSelectionTiles[3].y = -1; diff --git a/src/openrct2-ui/windows/MazeConstruction.cpp b/src/openrct2-ui/windows/MazeConstruction.cpp index e3d02f6483..5c8f184ad6 100644 --- a/src/openrct2-ui/windows/MazeConstruction.cpp +++ b/src/openrct2-ui/windows/MazeConstruction.cpp @@ -490,8 +490,8 @@ static void window_maze_construction_construct(sint32 direction) ride_construction_invalidate_current_track(); - x = _currentTrackBeginX + (TileDirectionDelta[direction].x / 2); - y = _currentTrackBeginY + (TileDirectionDelta[direction].y / 2); + x = _currentTrackBeginX + (CoordsDirectionDelta[direction].x / 2); + y = _currentTrackBeginY + (CoordsDirectionDelta[direction].y / 2); z = _currentTrackBeginZ; switch (_rideConstructionState) { case RIDE_CONSTRUCTION_STATE_MAZE_BUILD: diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index 69370158d9..4aff38e5f6 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -1707,8 +1707,8 @@ static void window_ride_construction_construct(rct_window *w) y = _currentTrackBeginY; z = _currentTrackBeginZ; if (!(trackDirection & 4)) { - x += TileDirectionDelta[trackDirection].x; - y += TileDirectionDelta[trackDirection].y; + x += CoordsDirectionDelta[trackDirection].x; + y += CoordsDirectionDelta[trackDirection].y; } if (track_block_get_previous_from_zero(x, y, z, _currentRideIndex, trackDirection, &trackBeginEnd)) { @@ -1730,8 +1730,8 @@ static void window_ride_construction_construct(rct_window *w) y = _currentTrackBeginY; z = _currentTrackBeginZ; if (!(trackDirection & 4)) { - x -= TileDirectionDelta[trackDirection].x; - y -= TileDirectionDelta[trackDirection].y; + x -= CoordsDirectionDelta[trackDirection].x; + y -= CoordsDirectionDelta[trackDirection].y; } CoordsXYE next_track; diff --git a/src/openrct2-ui/windows/TrackDesignPlace.cpp b/src/openrct2-ui/windows/TrackDesignPlace.cpp index 7e07693af7..6e8714c861 100644 --- a/src/openrct2-ui/windows/TrackDesignPlace.cpp +++ b/src/openrct2-ui/windows/TrackDesignPlace.cpp @@ -567,8 +567,8 @@ static void window_track_place_draw_mini_preview_track(rct_track_td6 *td6, sint3 rotation |= 4; } if (!(rotation & 4)) { - origin.x += TileDirectionDelta[rotation].x; - origin.y += TileDirectionDelta[rotation].y; + origin.x += CoordsDirectionDelta[rotation].x; + origin.y += CoordsDirectionDelta[rotation].y; } trackElement++; } diff --git a/src/openrct2/actions/MazeSetTrackAction.hpp b/src/openrct2/actions/MazeSetTrackAction.hpp index 4701730ffd..913d1fdc3b 100644 --- a/src/openrct2/actions/MazeSetTrackAction.hpp +++ b/src/openrct2/actions/MazeSetTrackAction.hpp @@ -274,8 +274,8 @@ public: uint8 temp_edx = byte_993CFC[segmentOffset]; if (temp_edx != 0xFF) { - uint16 previousElementX = floor2(_x, 32) - TileDirectionDelta[_direction].x; - uint16 previousElementY = floor2(_y, 32) - TileDirectionDelta[_direction].y; + uint16 previousElementX = floor2(_x, 32) - CoordsDirectionDelta[_direction].x; + uint16 previousElementY = floor2(_y, 32) - CoordsDirectionDelta[_direction].y; rct_tile_element * previousTileElement = map_get_track_element_at_of_type_from_ride( previousElementX, @@ -304,8 +304,8 @@ public: case GC_SET_MAZE_TRACK_FILL: if (!_initialPlacement) { - uint16 previousSegmentX = _x - TileDirectionDelta[_direction].x / 2; - uint16 previousSegmentY = _y - TileDirectionDelta[_direction].y / 2; + uint16 previousSegmentX = _x - CoordsDirectionDelta[_direction].x / 2; + uint16 previousSegmentY = _y - CoordsDirectionDelta[_direction].y / 2; tileElement = map_get_track_element_at_of_type_from_ride( previousSegmentX, @@ -337,8 +337,8 @@ public: tileElement->properties.track.maze_entry |= (1 << segmentBit); uint32 direction1 = byte_993D0C[segmentBit]; - uint16 nextElementX = floor2(previousSegmentX, 32) + TileDirectionDelta[direction1].x; - uint16 nextElementY = floor2(previousSegmentY, 32) + TileDirectionDelta[direction1].y; + uint16 nextElementX = floor2(previousSegmentX, 32) + CoordsDirectionDelta[direction1].x; + uint16 nextElementY = floor2(previousSegmentY, 32) + CoordsDirectionDelta[direction1].y; rct_tile_element * tmp_tileElement = map_get_track_element_at_of_type_from_ride( nextElementX, diff --git a/src/openrct2/actions/PlaceParkEntranceAction.hpp b/src/openrct2/actions/PlaceParkEntranceAction.hpp index 3baa3b345d..4e3acd2035 100644 --- a/src/openrct2/actions/PlaceParkEntranceAction.hpp +++ b/src/openrct2/actions/PlaceParkEntranceAction.hpp @@ -104,13 +104,13 @@ public: { if (index == 1) { - entranceLoc.x += TileDirectionDelta[(_direction - 1) & 0x3].x; - entranceLoc.y += TileDirectionDelta[(_direction - 1) & 0x3].y; + entranceLoc.x += CoordsDirectionDelta[(_direction - 1) & 0x3].x; + entranceLoc.y += CoordsDirectionDelta[(_direction - 1) & 0x3].y; } else if (index == 2) { - entranceLoc.x += TileDirectionDelta[(_direction + 1) & 0x3].x * 2; - entranceLoc.y += TileDirectionDelta[(_direction + 1) & 0x3].y * 2; + entranceLoc.x += CoordsDirectionDelta[(_direction + 1) & 0x3].x * 2; + entranceLoc.y += CoordsDirectionDelta[(_direction + 1) & 0x3].y * 2; } if (!gCheatsDisableClearanceChecks) @@ -166,13 +166,13 @@ public: { if (index == 1) { - entranceLoc.x += TileDirectionDelta[(_direction - 1) & 0x3].x; - entranceLoc.y += TileDirectionDelta[(_direction - 1) & 0x3].y; + entranceLoc.x += CoordsDirectionDelta[(_direction - 1) & 0x3].x; + entranceLoc.y += CoordsDirectionDelta[(_direction - 1) & 0x3].y; } else if (index == 2) { - entranceLoc.x += TileDirectionDelta[(_direction + 1) & 0x3].x * 2; - entranceLoc.y += TileDirectionDelta[(_direction + 1) & 0x3].y * 2; + entranceLoc.x += CoordsDirectionDelta[(_direction + 1) & 0x3].x * 2; + entranceLoc.y += CoordsDirectionDelta[(_direction + 1) & 0x3].y * 2; } if (!(flags & GAME_COMMAND_FLAG_GHOST)) diff --git a/src/openrct2/interface/ViewportInteraction.cpp b/src/openrct2/interface/ViewportInteraction.cpp index 5538d1bd35..2e7408b92d 100644 --- a/src/openrct2/interface/ViewportInteraction.cpp +++ b/src/openrct2/interface/ViewportInteraction.cpp @@ -491,12 +491,12 @@ void viewport_interaction_remove_park_entrance(rct_tile_element *tileElement, si sint32 rotation = tile_element_get_direction_with_offset(tileElement, 1); switch (tileElement->properties.entrance.index & 0x0F) { case 1: - x += TileDirectionDelta[rotation].x; - y += TileDirectionDelta[rotation].y; + x += CoordsDirectionDelta[rotation].x; + y += CoordsDirectionDelta[rotation].y; break; case 2: - x -= TileDirectionDelta[rotation].x; - y -= TileDirectionDelta[rotation].y; + x -= CoordsDirectionDelta[rotation].x; + y -= CoordsDirectionDelta[rotation].y; break; } gGameCommandErrorTitle = STR_CANT_REMOVE_THIS; diff --git a/src/openrct2/peep/Guest.cpp b/src/openrct2/peep/Guest.cpp index f5fbff8b0f..a3aa189dbd 100644 --- a/src/openrct2/peep/Guest.cpp +++ b/src/openrct2/peep/Guest.cpp @@ -3442,8 +3442,8 @@ static void peep_update_ride_leave_entrance_maze(rct_peep * peep, Ride * ride, T entrance_loc.x *= 32; entrance_loc.y *= 32; - entrance_loc.x += TileDirectionDelta[entrance_loc.direction].x; - entrance_loc.y += TileDirectionDelta[entrance_loc.direction].y; + entrance_loc.x += CoordsDirectionDelta[entrance_loc.direction].x; + entrance_loc.y += CoordsDirectionDelta[entrance_loc.direction].y; uint8 direction = entrance_loc.direction * 4 + 11; if (scenario_rand() & 0x40) @@ -4807,8 +4807,8 @@ void rct_peep::UpdateRideMazePathfinding() chosenEdge = (chosenEdge + 1) & 3; } - actionX = TileDirectionDelta[chosenEdge].x / 2; - actionY = TileDirectionDelta[chosenEdge].y / 2; + actionX = CoordsDirectionDelta[chosenEdge].x / 2; + actionY = CoordsDirectionDelta[chosenEdge].y / 2; actionX += destination_x; actionY += destination_y; @@ -6311,8 +6311,8 @@ static bool peep_find_ride_to_look_at(rct_peep * peep, uint8 edge, uint8 * rideT return false; } while (!tile_element_is_last_for_tile(tileElement++)); - uint16 x = peep->next_x + TileDirectionDelta[edge].x; - uint16 y = peep->next_y + TileDirectionDelta[edge].y; + uint16 x = peep->next_x + CoordsDirectionDelta[edge].x; + uint16 y = peep->next_y + CoordsDirectionDelta[edge].y; if (x > 255 * 32 || y > 255 * 32) { return false; @@ -6423,8 +6423,8 @@ static bool peep_find_ride_to_look_at(rct_peep * peep, uint8 edge, uint8 * rideT return false; } while (!tile_element_is_last_for_tile(tileElement++)); - x += TileDirectionDelta[edge].x; - y += TileDirectionDelta[edge].y; + x += CoordsDirectionDelta[edge].x; + y += CoordsDirectionDelta[edge].y; if (x > 255 * 32 || y > 255 * 32) { return false; @@ -6535,8 +6535,8 @@ static bool peep_find_ride_to_look_at(rct_peep * peep, uint8 edge, uint8 * rideT return false; } while (!tile_element_is_last_for_tile(tileElement++)); - x += TileDirectionDelta[edge].x; - y += TileDirectionDelta[edge].y; + x += CoordsDirectionDelta[edge].x; + y += CoordsDirectionDelta[edge].y; if (x > 255 * 32 || y > 255 * 32) { return false; diff --git a/src/openrct2/peep/GuestPathfinding.cpp b/src/openrct2/peep/GuestPathfinding.cpp index e5431d5eab..e0cafdcb9f 100644 --- a/src/openrct2/peep/GuestPathfinding.cpp +++ b/src/openrct2/peep/GuestPathfinding.cpp @@ -115,8 +115,8 @@ static sint32 peep_move_one_tile(uint8 direction, rct_peep * peep) assert(direction <= 3); sint16 x = peep->next_x; sint16 y = peep->next_y; - x += TileDirectionDelta[direction].x; - y += TileDirectionDelta[direction].y; + x += CoordsDirectionDelta[direction].x; + y += CoordsDirectionDelta[direction].y; if (x >= 8192 || y >= 8192) { @@ -148,8 +148,8 @@ static sint32 guest_surface_path_finding(rct_peep * peep) if (!fence_in_the_way(x, y, z, z + 4, randDirection)) { - x += TileDirectionDelta[randDirection].x; - y += TileDirectionDelta[randDirection].y; + x += CoordsDirectionDelta[randDirection].x; + y += CoordsDirectionDelta[randDirection].y; uint8 backwardsDirection = randDirection ^ (1 << 1); if (!fence_in_the_way(x, y, z, z + 4, backwardsDirection)) @@ -173,8 +173,8 @@ static sint32 guest_surface_path_finding(rct_peep * peep) y = peep->next_y; if (!fence_in_the_way(x, y, z, z + 4, randDirection)) { - x += TileDirectionDelta[randDirection].x; - y += TileDirectionDelta[randDirection].y; + x += CoordsDirectionDelta[randDirection].x; + y += CoordsDirectionDelta[randDirection].y; uint8 backwardsDirection = randDirection ^ (1 << 1); if (!fence_in_the_way(x, y, z, z + 4, backwardsDirection)) @@ -193,8 +193,8 @@ static sint32 guest_surface_path_finding(rct_peep * peep) y = peep->next_y; if (!fence_in_the_way(x, y, z, z + 4, randDirection)) { - x += TileDirectionDelta[randDirection].x; - y += TileDirectionDelta[randDirection].y; + x += CoordsDirectionDelta[randDirection].x; + y += CoordsDirectionDelta[randDirection].y; uint8 backwardsDirection = randDirection ^ (1 << 1); if (!fence_in_the_way(x, y, z, z + 4, backwardsDirection)) @@ -241,8 +241,8 @@ static uint8 footpath_element_next_in_direction(sint16 x, sint16 y, sint16 z, rc } } - x += TileDirectionDelta[chosenDirection].x; - y += TileDirectionDelta[chosenDirection].y; + x += CoordsDirectionDelta[chosenDirection].x; + y += CoordsDirectionDelta[chosenDirection].y; nextTileElement = map_get_first_element_at(x / 32, y / 32); do { @@ -291,8 +291,8 @@ static uint8 footpath_element_dest_in_dir(sint16 x, sint16 y, sint16 z, rct_tile if (level > 25) return PATH_SEARCH_LIMIT_REACHED; - x += TileDirectionDelta[chosenDirection].x; - y += TileDirectionDelta[chosenDirection].y; + x += CoordsDirectionDelta[chosenDirection].x; + y += CoordsDirectionDelta[chosenDirection].y; tileElement = map_get_first_element_at(x / 32, y / 32); if (tileElement == nullptr) { @@ -478,7 +478,7 @@ static uint8 peep_pathfind_get_max_number_junctions(rct_peep * peep) * A junction is considered 'thin' if it has more than 2 edges * leading to/from non-wide path elements; edges leading to/from non-path * elements (e.g. ride/shop entrances) or ride queues are not counted, - * since entrances and ride queues coming off a path should not result in + * since entrances and ride queues coming off a path should not queueEnd in * the path being considered a junction. */ static bool path_is_thin_junction(rct_tile_element * path, sint16 x, sint16 y, uint8 z) @@ -526,7 +526,7 @@ static bool path_is_thin_junction(rct_tile_element * path, sint16 x, sint16 y, u * steps as possible. * * Each tile is checked to determine if the goal is reached. - * When the goal is not reached the search result is only updated at the END + * When the goal is not reached the search queueEnd is only updated at the END * of each search path (some map element that is not a path or a path at which * a search limit is reached), NOT at each step along the way. * This means that the search ignores thin paths that are "no through paths" @@ -537,13 +537,13 @@ static bool path_is_thin_junction(rct_tile_element * path, sint16 x, sint16 y, u * according to the search limits. * Unlike an A* search, which tracks for each tile a heuristic score (a * function of the xyz distances to the goal) and cost of reaching that tile - * (steps to the tile), a single best result "so far" (best heuristic score + * (steps to the tile), a single best queueEnd "so far" (best heuristic score * with least cost) is tracked via the score parameter. * With this approach, explicit loop detection is necessary to limit the * search space, and each alternate route through the same tile can be - * returned as the best result, rather than only the shortest route with A*. + * returned as the best queueEnd, rather than only the shortest route with A*. * - * The parameters that hold the best search result so far are: + * The parameters that hold the best search queueEnd so far are: * - score - the least heuristic distance from the goal * - endSteps - the least number of steps that achieve the score. * @@ -578,13 +578,13 @@ static bool path_is_thin_junction(rct_tile_element * path, sint16 x, sint16 y, u * * The score is only updated when: * - the goal is reached; - * - a wide tile is encountered with a better search result - the goal may + * - a wide tile is encountered with a better search queueEnd - the goal may * still be reachable from here (only if the current tile is also wide); - * - a junction is encountered with a better search result and + * - a junction is encountered with a better search queueEnd and * maxNumJunctions is exceeded - the goal may still be reachable from here; * - returning from a recursive call if a search limit (i.e. either * maxNumStep or maxTilesChecked) was reached and the current tile has a - * better search result and the goal may still be reachable from here + * better search queueEnd and the goal may still be reachable from here * (i.e. not a dead end path tile). * * rct2: 0x0069A997 @@ -599,15 +599,15 @@ static void peep_pathfind_heuristic_search(sint16 x, sint16 y, uint8 z, rct_peep bool currentElementIsWide = (footpath_element_is_wide(currentTileElement) && !staff_can_ignore_wide_flag(peep, x, y, z, currentTileElement)); - x += TileDirectionDelta[test_edge].x; - y += TileDirectionDelta[test_edge].y; + x += CoordsDirectionDelta[test_edge].x; + y += CoordsDirectionDelta[test_edge].y; ++counter; _peepPathFindTilesChecked--; /* If this is where the search started this is a search loop and the * current search path ends here. - * Return without updating the parameters (best result so far). */ + * Return without updating the parameters (best queueEnd so far). */ if ((_peepPathFindHistory[0].location.x == (uint8)(x >> 5)) && (_peepPathFindHistory[0].location.y == (uint8)(y >> 5)) && (_peepPathFindHistory[0].location.z == z)) { @@ -628,7 +628,7 @@ static void peep_pathfind_heuristic_search(sint16 x, sint16 y, uint8 z, rct_peep { /* The mechanic will leave his patrol area by taking * the test_edge so the current search path ends here. - * Return without updating the parameters (best result so far). */ + * Return without updating the parameters (best queueEnd so far). */ #if defined(DEBUG_LEVEL_2) && DEBUG_LEVEL_2 if (gPathFindDebug) { @@ -809,7 +809,7 @@ static void peep_pathfind_heuristic_search(sint16 x, sint16 y, uint8 z, rct_peep /* If this map element is the search goal the current search path ends here. */ if (new_score == 0) { - /* If the search result is better than the best so far (in the parameters), + /* If the search queueEnd is better than the best so far (in the parameters), * then update the parameters with this search before continuing to the next map element. */ if (new_score < *endScore || (new_score == *endScore && counter < *endSteps)) { @@ -843,7 +843,7 @@ static void peep_pathfind_heuristic_search(sint16 x, sint16 y, uint8 z, rct_peep /* At this point the map element tile is not the goal. */ /* If this map element is not a path, the search cannot be continued. - * Continue to the next map element without updating the parameters (best result so far). */ + * Continue to the next map element without updating the parameters (best queueEnd so far). */ if (searchResult != PATH_SEARCH_DEAD_END && searchResult != PATH_SEARCH_THIN && searchResult != PATH_SEARCH_JUNCTION && searchResult != PATH_SEARCH_WIDE) { @@ -868,7 +868,7 @@ static void peep_pathfind_heuristic_search(sint16 x, sint16 y, uint8 z, rct_peep * * So, if the current path is also wide the goal could * still be reachable from here. - * If the search result is better than the best so far + * If the search queueEnd is better than the best so far * (in the parameters), then update the parameters with * this search before continuing to the next map element. */ if (currentElementIsWide && (new_score < *endScore || (new_score == *endScore && counter < *endSteps))) @@ -919,7 +919,7 @@ static void peep_pathfind_heuristic_search(sint16 x, sint16 y, uint8 z, rct_peep sint32 next_test_edge = bitscanforward(edges); /* If there are no other edges the current search ends here. - * Continue to the next map element without updating the parameters (best result so far). */ + * Continue to the next map element without updating the parameters (best queueEnd so far). */ if (next_test_edge == -1) { #if defined(DEBUG_LEVEL_2) && DEBUG_LEVEL_2 @@ -937,7 +937,7 @@ static void peep_pathfind_heuristic_search(sint16 x, sint16 y, uint8 z, rct_peep { /* The current search ends here. * The path continues, so the goal could still be reachable from here. - * If the search result is better than the best so far (in the parameters), + * If the search queueEnd is better than the best so far (in the parameters), * then update the parameters with this search before continuing to the next map element. */ if (new_score < *endScore || (new_score == *endScore && counter < *endSteps)) { @@ -1034,7 +1034,7 @@ static void peep_pathfind_heuristic_search(sint16 x, sint16 y, uint8 z, rct_peep if (pathLoop) { /* Loop detected. The current search path ends here. - * Continue to the next map element without updating the parameters (best result so far). */ + * Continue to the next map element without updating the parameters (best queueEnd so far). */ #if defined(DEBUG_LEVEL_2) && DEBUG_LEVEL_2 if (gPathFindDebug) { @@ -1047,7 +1047,7 @@ static void peep_pathfind_heuristic_search(sint16 x, sint16 y, uint8 z, rct_peep /* If the junction search limit is reached, the * current search path ends here. The goal may still * be reachable from here. - * If the search result is better than the best so far (in the parameters), + * If the search queueEnd is better than the best so far (in the parameters), * then update the parameters with this search before continuing to the next map element. */ if (_peepPathFindNumJunctions <= 0) { @@ -1147,7 +1147,7 @@ static void peep_pathfind_heuristic_search(sint16 x, sint16 y, uint8 z, rct_peep if (!found) { /* No map element could be found. - * Return without updating the parameters (best result so far). */ + * Return without updating the parameters (best queueEnd so far). */ #if defined(DEBUG_LEVEL_2) && DEBUG_LEVEL_2 if (gPathFindDebug) { @@ -1732,10 +1732,10 @@ static sint32 guest_path_find_park_entrance(rct_peep * peep, rct_tile_element * * In case where the map element at (x, y) is invalid or there is no entrance * or queue leading to it the function will not update its arguments. */ -static void get_ride_queue_end(sint16 * x, sint16 * y, sint16 * z) +static void get_ride_queue_end(TileCoordsXYZ &loc) { - LocationXY16 result = { 0, 0 }; - rct_tile_element * tileElement = map_get_first_element_at(*x / 32, *y / 32); + TileCoordsXY queueEnd = { 0, 0 }; + rct_tile_element * tileElement = map_get_first_element_at(loc.x, loc.y); if (tileElement == nullptr) { @@ -1748,7 +1748,7 @@ static void get_ride_queue_end(sint16 * x, sint16 * y, sint16 * z) if (tileElement->GetType() != TILE_ELEMENT_TYPE_ENTRANCE) continue; - if (*z != tileElement->base_height) + if (loc.z != tileElement->base_height) continue; found = true; @@ -1763,16 +1763,16 @@ static void get_ride_queue_end(sint16 * x, sint16 * y, sint16 * z) rct_tile_element * firstPathElement = nullptr; sint16 baseZ = tileElement->base_height; - sint16 nextX = *x; - sint16 nextY = *y; + TileCoordsXY nextTile = { loc.x, loc.y }; + while (true) { if (tileElement->GetType() == TILE_ELEMENT_TYPE_PATH) { lastPathElement = tileElement; - result.x = nextX; - result.y = nextY; - // result.direction = direction; + // Update the current queue end + queueEnd = nextTile; + // queueEnd.direction = direction; if (footpath_element_is_sloped(tileElement)) { if (footpath_element_get_slope_direction(tileElement) == direction) @@ -1781,10 +1781,9 @@ static void get_ride_queue_end(sint16 * x, sint16 * y, sint16 * z) } } } - nextX += TileDirectionDelta[direction].x; - nextY += TileDirectionDelta[direction].y; + nextTile += TileDirectionDelta[direction]; - tileElement = map_get_first_element_at(nextX / 32, nextY / 32); + tileElement = map_get_first_element_at(nextTile.x, nextTile.y); found = false; do { @@ -1851,7 +1850,7 @@ static void get_ride_queue_end(sint16 * x, sint16 * y, sint16 * z) break; } - if ((uint8)*z == 0xFF) + if (loc.z == 0xFF) return; tileElement = lastPathElement; @@ -1861,9 +1860,9 @@ static void get_ride_queue_end(sint16 * x, sint16 * y, sint16 * z) if (!footpath_element_is_queue(tileElement)) return; - *x = result.x; - *y = result.y; - *z = tileElement->base_height; + loc.x = queueEnd.x; + loc.y = queueEnd.y; + loc.z = tileElement->base_height; } /** @@ -1872,7 +1871,7 @@ static void get_ride_queue_end(sint16 * x, sint16 * y, sint16 * z) */ sint32 guest_path_finding(rct_peep * peep) { - sint16 x, y, z; + //sint16 x, y, z; #if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 pathfind_logging_enable(peep); @@ -1887,11 +1886,9 @@ sint32 guest_path_finding(rct_peep * peep) return guest_surface_path_finding(peep); } - x = peep->next_x; - y = peep->next_y; - z = peep->next_z; + TileCoordsXYZ loc = { peep->next_x / 32, peep->next_y / 32, peep->next_z / 8}; - rct_tile_element * tileElement = map_get_path_element_at(x / 32, y / 32, z); + rct_tile_element * tileElement = map_get_path_element_at(loc.x, loc.y, loc.z); if (tileElement == nullptr) { return 1; @@ -2140,21 +2137,21 @@ sint32 guest_path_finding(rct_peep * peep) { // closestStationNum is always 0 here. LocationXY8 entranceXY = ride->station_starts[closestStationNum]; - x = entranceXY.x * 32; - y = entranceXY.y * 32; - z = ride->station_heights[closestStationNum]; + loc.x = entranceXY.x; + loc.y = entranceXY.y; + loc.z = ride->station_heights[closestStationNum]; } else { TileCoordsXYZD entranceXYZD = ride_get_entrance_location(rideIndex, closestStationNum); - x = entranceXYZD.x * 32; - y = entranceXYZD.y * 32; - z = entranceXYZD.z; + loc.x = entranceXYZD.x; + loc.y = entranceXYZD.y; + loc.z = entranceXYZD.z; } - get_ride_queue_end(&x, &y, &z); + get_ride_queue_end(loc); - gPeepPathFindGoalPosition = { x, y, z }; + gPeepPathFindGoalPosition = { loc.x * 32, loc.y * 32, loc.z }; gPeepPathFindIgnoreForeignQueues = true; direction = peep_pathfind_choose_direction(peep->next_x, peep->next_y, peep->next_z, peep); diff --git a/src/openrct2/peep/Peep.cpp b/src/openrct2/peep/Peep.cpp index ce2b435728..d29fda3581 100644 --- a/src/openrct2/peep/Peep.cpp +++ b/src/openrct2/peep/Peep.cpp @@ -2585,8 +2585,8 @@ static void peep_interact_with_entrance(rct_peep * peep, sint16 x, sint16 y, rct } } - peep->destination_x += TileDirectionDelta[peep->direction].x; - peep->destination_y += TileDirectionDelta[peep->direction].y; + peep->destination_x += CoordsDirectionDelta[peep->direction].x; + peep->destination_y += CoordsDirectionDelta[peep->direction].y; peep->destination_tolerance = 9; peep->Invalidate(); sprite_move(x, y, peep->z, (rct_sprite *)peep); @@ -2635,8 +2635,8 @@ static void peep_interact_with_entrance(rct_peep * peep, sint16 x, sint16 y, rct sint16 z = gParkEntrances[entranceIndex].z / 8; entranceDirection = gParkEntrances[entranceIndex].direction; - sint16 next_x = (x & 0xFFE0) + TileDirectionDelta[entranceDirection].x; - sint16 next_y = (y & 0xFFE0) + TileDirectionDelta[entranceDirection].y; + sint16 next_x = (x & 0xFFE0) + CoordsDirectionDelta[entranceDirection].x; + sint16 next_y = (y & 0xFFE0) + CoordsDirectionDelta[entranceDirection].y; // Make sure there is a path right behind the entrance, otherwise turn around bool found = false; @@ -2729,8 +2729,8 @@ static void peep_interact_with_entrance(rct_peep * peep, sint16 x, sint16 y, rct window_invalidate_by_number(WC_PARK_INFORMATION, 0); peep->var_37 = 1; - peep->destination_x += TileDirectionDelta[peep->direction].x; - peep->destination_y += TileDirectionDelta[peep->direction].y; + peep->destination_x += CoordsDirectionDelta[peep->direction].x; + peep->destination_y += CoordsDirectionDelta[peep->direction].y; peep->destination_tolerance = 7; peep->Invalidate(); diff --git a/src/openrct2/peep/Staff.cpp b/src/openrct2/peep/Staff.cpp index 9681b1e831..080f9bf3c0 100644 --- a/src/openrct2/peep/Staff.cpp +++ b/src/openrct2/peep/Staff.cpp @@ -628,8 +628,8 @@ bool staff_is_location_on_patrol_edge(rct_peep * mechanic, sint32 x, sint32 y) sint32 neighbourDir = 0; while (!onZoneEdge && neighbourDir <= 7) { - sint32 neighbourX = x + TileDirectionDelta[neighbourDir].x; - sint32 neighbourY = y + TileDirectionDelta[neighbourDir].y; + sint32 neighbourX = x + CoordsDirectionDelta[neighbourDir].x; + sint32 neighbourY = y + CoordsDirectionDelta[neighbourDir].y; onZoneEdge = !staff_is_location_in_patrol(mechanic, neighbourX, neighbourY); neighbourDir++; } @@ -674,8 +674,8 @@ bool staff_can_ignore_wide_flag(rct_peep * staff, sint32 x, sint32 y, uint8 z, r uint8 widecount = 0; for (sint32 adjac_dir = 0; adjac_dir <= 3; adjac_dir++) { - sint32 adjac_x = x + TileDirectionDelta[adjac_dir].x; - sint32 adjac_y = y + TileDirectionDelta[adjac_dir].y; + sint32 adjac_x = x + CoordsDirectionDelta[adjac_dir].x; + sint32 adjac_y = y + CoordsDirectionDelta[adjac_dir].y; uint8 adjac_z = z; /* Ignore adjacent tiles outside the patrol zone. */ @@ -905,8 +905,8 @@ static uint8 staff_handyman_direction_to_nearest_litter(rct_peep * peep) nextDirection = x_diff < 0 ? 0 : 2; } - CoordsXY nextTile = { static_cast((nearestLitter->x & 0xFFE0) - TileDirectionDelta[nextDirection].x), - static_cast((nearestLitter->y & 0xFFE0) - TileDirectionDelta[nextDirection].y) }; + CoordsXY nextTile = { static_cast((nearestLitter->x & 0xFFE0) - CoordsDirectionDelta[nextDirection].x), + static_cast((nearestLitter->y & 0xFFE0) - CoordsDirectionDelta[nextDirection].y) }; sint16 nextZ = ((peep->z + 8) & 0xFFF0) / 8; @@ -923,8 +923,8 @@ static uint8 staff_handyman_direction_to_nearest_litter(rct_peep * peep) } } while (!tile_element_is_last_for_tile(tileElement++)); - nextTile.x = (peep->x & 0xFFE0) + TileDirectionDelta[nextDirection].x; - nextTile.y = (peep->y & 0xFFE0) + TileDirectionDelta[nextDirection].y; + nextTile.x = (peep->x & 0xFFE0) + CoordsDirectionDelta[nextDirection].x; + nextTile.y = (peep->y & 0xFFE0) + CoordsDirectionDelta[nextDirection].y; tileElement = map_get_first_element_at(nextTile.x / 32, nextTile.y / 32); @@ -976,8 +976,8 @@ static uint8 staff_handyman_direction_to_uncut_grass(rct_peep * peep, uint8 vali continue; } - CoordsXY chosenTile = { static_cast(peep->next_x + TileDirectionDelta[chosenDirection].x), - static_cast(peep->next_y + TileDirectionDelta[chosenDirection].y) }; + CoordsXY chosenTile = { static_cast(peep->next_x + CoordsDirectionDelta[chosenDirection].x), + static_cast(peep->next_y + CoordsDirectionDelta[chosenDirection].y) }; if (chosenTile.x > 0x1FFF || chosenTile.y > 0x1FFF) continue; @@ -1011,8 +1011,8 @@ static sint32 staff_handyman_direction_rand_surface(rct_peep * peep, uint8 valid if (!(validDirections & (1 << direction))) continue; - LocationXY16 chosenTile = { static_cast(peep->next_x + TileDirectionDelta[direction].x), - static_cast(peep->next_y + TileDirectionDelta[direction].y) }; + LocationXY16 chosenTile = { static_cast(peep->next_x + CoordsDirectionDelta[direction].x), + static_cast(peep->next_y + CoordsDirectionDelta[direction].y) }; if (map_surface_is_blocked(chosenTile.x, chosenTile.y)) continue; @@ -1097,17 +1097,17 @@ static bool staff_path_finding_handyman(rct_peep * peep) } } - // countof(TileDirectionDelta) + // countof(CoordsDirectionDelta) assert(direction < 8); - LocationXY16 chosenTile = { static_cast(peep->next_x + TileDirectionDelta[direction].x), - static_cast(peep->next_y + TileDirectionDelta[direction].y) }; + LocationXY16 chosenTile = { static_cast(peep->next_x + CoordsDirectionDelta[direction].x), + static_cast(peep->next_y + CoordsDirectionDelta[direction].y) }; while (chosenTile.x > 0x1FFF || chosenTile.y > 0x1FFF) { direction = staff_handyman_direction_rand_surface(peep, validDirections); - chosenTile.x = peep->next_x + TileDirectionDelta[direction].x; - chosenTile.y = peep->next_y + TileDirectionDelta[direction].y; + chosenTile.x = peep->next_x + CoordsDirectionDelta[direction].x; + chosenTile.y = peep->next_y + CoordsDirectionDelta[direction].y; } peep->direction = direction; @@ -1149,8 +1149,8 @@ static uint8 staff_direction_surface(rct_peep * peep, uint8 initialDirection) if (fence_in_the_way(peep->next_x, peep->next_y, peep->next_z, peep->next_z + 4, direction ^ (1 << 1)) == true) continue; - LocationXY16 chosenTile = { static_cast(peep->next_x + TileDirectionDelta[direction].x), - static_cast(peep->next_y + TileDirectionDelta[direction].y) }; + LocationXY16 chosenTile = { static_cast(peep->next_x + CoordsDirectionDelta[direction].x), + static_cast(peep->next_y + CoordsDirectionDelta[direction].y) }; if (map_surface_is_blocked(chosenTile.x, chosenTile.y) == false) { @@ -1331,17 +1331,17 @@ static bool staff_path_finding_mechanic(rct_peep * peep) direction = staff_mechanic_direction_path(peep, validDirections, pathElement); } - // countof(TileDirectionDelta) + // countof(CoordsDirectionDelta) assert(direction < 8); - LocationXY16 chosenTile = { static_cast(peep->next_x + TileDirectionDelta[direction].x), - static_cast(peep->next_y + TileDirectionDelta[direction].y) }; + LocationXY16 chosenTile = { static_cast(peep->next_x + CoordsDirectionDelta[direction].x), + static_cast(peep->next_y + CoordsDirectionDelta[direction].y) }; while (chosenTile.x > 0x1FFF || chosenTile.y > 0x1FFF) { direction = staff_mechanic_direction_surface(peep); - chosenTile.x = peep->next_x + TileDirectionDelta[direction].x; - chosenTile.y = peep->next_y + TileDirectionDelta[direction].y; + chosenTile.x = peep->next_x + CoordsDirectionDelta[direction].x; + chosenTile.y = peep->next_y + CoordsDirectionDelta[direction].y; } peep->direction = direction; @@ -1419,14 +1419,14 @@ static bool staff_path_finding_misc(rct_peep * peep) direction = staff_direction_path(peep, validDirections, pathElement); } - LocationXY16 chosenTile = { static_cast(peep->next_x + TileDirectionDelta[direction].x), - static_cast(peep->next_y + TileDirectionDelta[direction].y) }; + LocationXY16 chosenTile = { static_cast(peep->next_x + CoordsDirectionDelta[direction].x), + static_cast(peep->next_y + CoordsDirectionDelta[direction].y) }; while (chosenTile.x > 0x1FFF || chosenTile.y > 0x1FFF) { direction = staff_direction_surface(peep, scenario_rand() & 3); - chosenTile.x = peep->next_x + TileDirectionDelta[direction].x; - chosenTile.y = peep->next_y + TileDirectionDelta[direction].y; + chosenTile.x = peep->next_x + CoordsDirectionDelta[direction].x; + chosenTile.y = peep->next_y + CoordsDirectionDelta[direction].y; } peep->direction = direction; @@ -1717,8 +1717,8 @@ void rct_peep::UpdateWatering() return; } - sint32 actionX = next_x + TileDirectionDelta[var_37].x; - sint32 actionY = next_y + TileDirectionDelta[var_37].y; + sint32 actionX = next_x + CoordsDirectionDelta[var_37].x; + sint32 actionY = next_y + CoordsDirectionDelta[var_37].y; rct_tile_element * tile_element = map_get_first_element_at(actionX / 32, actionY / 32); @@ -2121,8 +2121,8 @@ static sint32 peep_update_patrolling_find_watering(rct_peep * peep) { chosen_position &= 7; - sint32 x = peep->next_x + TileDirectionDelta[chosen_position].x; - sint32 y = peep->next_y + TileDirectionDelta[chosen_position].y; + sint32 x = peep->next_x + CoordsDirectionDelta[chosen_position].x; + sint32 y = peep->next_y + CoordsDirectionDelta[chosen_position].y; rct_tile_element * tile_element = map_get_first_element_at(x / 32, y / 32); diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index 87dc386be6..4df438d8fe 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -543,8 +543,8 @@ bool track_block_get_next_from_zero(sint16 x, sint16 y, sint16 z_start, uint8 ri Ride* ride = get_ride(rideIndex); if (!(direction_start & (1 << 2))){ - x += TileDirectionDelta[direction_start].x; - y += TileDirectionDelta[direction_start].y; + x += CoordsDirectionDelta[direction_start].x; + y += CoordsDirectionDelta[direction_start].y; } rct_tile_element* tileElement = map_get_first_element_at(x / 32, y / 32); @@ -665,8 +665,8 @@ bool track_block_get_previous_from_zero(sint16 x, sint16 y, sint16 z, uint8 ride direction ^= (1 << 1); if (!(direction & (1 << 2))){ - x += TileDirectionDelta[direction].x; - y += TileDirectionDelta[direction].y; + x += CoordsDirectionDelta[direction].x; + y += CoordsDirectionDelta[direction].y; } rct_tile_element* tileElement = map_get_first_element_at(x / 32, y / 32); @@ -1391,8 +1391,8 @@ void ride_remove_provisional_track_piece() { direction = _unkF440C5.direction; if (!(direction & 4)) { - x -= TileDirectionDelta[direction].x; - y -= TileDirectionDelta[direction].y; + x -= CoordsDirectionDelta[direction].x; + y -= CoordsDirectionDelta[direction].y; } CoordsXYE next_track; if (track_block_get_next_from_zero(x, y, z, rideIndex, direction, &next_track, &z, &direction)) { @@ -3215,8 +3215,8 @@ static sint32 ride_entrance_exit_is_reachable(TileCoordsXYZD coordinates) x *= 32; y *= 32; - x -= TileDirectionDelta[face_direction].x; - y -= TileDirectionDelta[face_direction].y; + x -= CoordsDirectionDelta[face_direction].x; + y -= CoordsDirectionDelta[face_direction].y; x /= 32; y /= 32; @@ -3311,8 +3311,8 @@ static void ride_shop_connected(Ride* ride, sint32 ride_idx) // Flip direction north<->south, east<->west uint8 face_direction = count ^ 2; - sint32 y2 = y - TileDirectionDelta[face_direction].y; - sint32 x2 = x - TileDirectionDelta[face_direction].x; + sint32 y2 = y - CoordsDirectionDelta[face_direction].y; + sint32 x2 = x - CoordsDirectionDelta[face_direction].x; if (map_coord_is_connected(x2 / 32, y2 / 32, tileElement->base_height, face_direction)) return; @@ -4869,8 +4869,8 @@ static bool ride_create_vehicles(Ride *ride, sint32 rideIndex, CoordsXYE *elemen // if (ride->mode == RIDE_MODE_STATION_TO_STATION) { - x = element->x - TileDirectionDelta[direction].x; - y = element->y - TileDirectionDelta[direction].y; + x = element->x - CoordsDirectionDelta[direction].x; + y = element->y - CoordsDirectionDelta[direction].y; tileElement = map_get_first_element_at(x >> 5, y >> 5); do { @@ -5896,8 +5896,8 @@ void game_command_callback_ride_construct_placed_back( y = _currentTrackBeginY; z = _currentTrackBeginZ; if (!(trackDirection & 4)) { - x += TileDirectionDelta[trackDirection].x; - y += TileDirectionDelta[trackDirection].y; + x += CoordsDirectionDelta[trackDirection].x; + y += CoordsDirectionDelta[trackDirection].y; } if (track_block_get_previous_from_zero(x, y, z, _currentRideIndex, trackDirection, &trackBeginEnd)) { @@ -5935,8 +5935,8 @@ void game_command_callback_ride_construct_placed_front( y = _currentTrackBeginY; z = _currentTrackBeginZ; if (!(trackDirection & 4)) { - x -= TileDirectionDelta[trackDirection].x; - y -= TileDirectionDelta[trackDirection].y; + x -= CoordsDirectionDelta[trackDirection].x; + y -= CoordsDirectionDelta[trackDirection].y; } CoordsXYE next_track; @@ -6706,8 +6706,8 @@ void ride_get_entrance_or_exit_position_from_screen_position(sint32 screenX, sin for (sint32 i = 0; i < MAX_STATIONS; i++) { - mapX = _unkF44188.x + TileDirectionDelta[direction].x; - mapY = _unkF44188.y + TileDirectionDelta[direction].y; + mapX = _unkF44188.x + CoordsDirectionDelta[direction].x; + mapY = _unkF44188.y + CoordsDirectionDelta[direction].y; if (mapX >= 0 && mapY >= 0 && mapX < (256 * 32) && mapY < (256 * 32)) { tileElement = map_get_first_element_at(mapX >> 5, mapY >> 5); @@ -6762,8 +6762,8 @@ void ride_get_entrance_or_exit_position_from_screen_position(sint32 screenX, sin { entranceMaxX = mapX; entranceMaxY = mapY; - mapX -= TileDirectionDelta[direction].x; - mapY -= TileDirectionDelta[direction].y; + mapX -= CoordsDirectionDelta[direction].x; + mapY -= CoordsDirectionDelta[direction].y; tileElement = map_get_first_element_at(mapX >> 5, mapY >> 5); bool goToNextTile = false; @@ -7516,8 +7516,8 @@ void sub_6CB945(sint32 rideIndex) while (true) { if (direction != 0xFF) { - location.x -= TileDirectionDelta[direction].x; - location.y -= TileDirectionDelta[direction].y; + location.x -= CoordsDirectionDelta[direction].x; + location.y -= CoordsDirectionDelta[direction].y; } tileElement = map_get_first_element_at(location.x >> 5, location.y >> 5); @@ -7625,8 +7625,8 @@ void sub_6CB945(sint32 rideIndex) if (tileElement->properties.entrance.type > ENTRANCE_TYPE_RIDE_EXIT) continue; CoordsXY nextLocation = location; - nextLocation.x += TileDirectionDelta[tile_element_get_direction(tileElement)].x; - nextLocation.y += TileDirectionDelta[tile_element_get_direction(tileElement)].y; + nextLocation.x += CoordsDirectionDelta[tile_element_get_direction(tileElement)].x; + nextLocation.y += CoordsDirectionDelta[tile_element_get_direction(tileElement)].y; bool shouldRemove = true; rct_tile_element *trackElement = map_get_first_element_at(nextLocation.x >> 5, nextLocation.y >> 5); @@ -7994,8 +7994,8 @@ static bool check_for_adjacent_station(sint32 x, sint32 y, sint32 z, uint8 direc sint32 adjY = y; for (uint32 i = 0; i <= RIDE_ADJACENCY_CHECK_DISTANCE; i++) { - adjX += TileDirectionDelta[direction].x; - adjY += TileDirectionDelta[direction].y; + adjX += CoordsDirectionDelta[direction].x; + adjY += CoordsDirectionDelta[direction].y; rct_tile_element * stationElement = get_station_platform(adjX, adjY, z, 2); if (stationElement != nullptr) { diff --git a/src/openrct2/ride/RideRatings.cpp b/src/openrct2/ride/RideRatings.cpp index c61173b4bf..deec2afc63 100644 --- a/src/openrct2/ride/RideRatings.cpp +++ b/src/openrct2/ride/RideRatings.cpp @@ -388,8 +388,8 @@ static void proximity_score_increment(sint32 type) */ static void ride_ratings_score_close_proximity_in_direction(rct_tile_element *inputTileElement, sint32 direction) { - sint32 x = gRideRatingsCalcData.proximity_x + TileDirectionDelta[direction].x; - sint32 y = gRideRatingsCalcData.proximity_y + TileDirectionDelta[direction].y; + sint32 x = gRideRatingsCalcData.proximity_x + CoordsDirectionDelta[direction].x; + sint32 y = gRideRatingsCalcData.proximity_y + CoordsDirectionDelta[direction].y; if (x < 0 || y < 0 || x >= (32 * 256) || y >= (32 * 256)) return; @@ -478,8 +478,8 @@ static void ride_ratings_score_close_proximity_loops(rct_tile_element *inputTile ride_ratings_score_close_proximity_loops_helper(inputTileElement, x, y); sint32 direction = tile_element_get_direction(inputTileElement); - x = gRideRatingsCalcData.proximity_x + TileDirectionDelta[direction].x; - y = gRideRatingsCalcData.proximity_y + TileDirectionDelta[direction].y; + x = gRideRatingsCalcData.proximity_x + CoordsDirectionDelta[direction].x; + y = gRideRatingsCalcData.proximity_y + CoordsDirectionDelta[direction].y; ride_ratings_score_close_proximity_loops_helper(inputTileElement, x, y); } } diff --git a/src/openrct2/ride/Track.cpp b/src/openrct2/ride/Track.cpp index af84b71c68..9ee6ff1caa 100644 --- a/src/openrct2/ride/Track.cpp +++ b/src/openrct2/ride/Track.cpp @@ -686,8 +686,8 @@ static bool track_add_station_element(sint32 x, sint32 y, sint32 z, sint32 direc y = stationY0; do { - x -= TileDirectionDelta[direction].x; - y -= TileDirectionDelta[direction].y; + x -= CoordsDirectionDelta[direction].x; + y -= CoordsDirectionDelta[direction].y; stationElement = find_station_element(x, y, z, direction, rideIndex); if (stationElement != nullptr) @@ -712,8 +712,8 @@ static bool track_add_station_element(sint32 x, sint32 y, sint32 z, sint32 direc y = stationY1; do { - x += TileDirectionDelta[direction].x; - y += TileDirectionDelta[direction].y; + x += CoordsDirectionDelta[direction].x; + y += CoordsDirectionDelta[direction].y; stationElement = find_station_element(x, y, z, direction, rideIndex); if (stationElement != nullptr) @@ -787,8 +787,8 @@ static bool track_add_station_element(sint32 x, sint32 y, sint32 z, sint32 direc if (x != stationX0 || y != stationY0) { - x -= TileDirectionDelta[direction].x; - y -= TileDirectionDelta[direction].y; + x -= CoordsDirectionDelta[direction].x; + y -= CoordsDirectionDelta[direction].y; finaliseStationDone = false; } } @@ -846,8 +846,8 @@ static bool track_remove_station_element(sint32 x, sint32 y, sint32 z, sint32 di stationY0 = y; byte_F441D1++; - x -= TileDirectionDelta[direction].x; - y -= TileDirectionDelta[direction].y; + x -= CoordsDirectionDelta[direction].x; + y -= CoordsDirectionDelta[direction].y; } // Search forwards for more station @@ -855,8 +855,8 @@ static bool track_remove_station_element(sint32 x, sint32 y, sint32 z, sint32 di y = stationY1; do { - x += TileDirectionDelta[direction].x; - y += TileDirectionDelta[direction].y; + x += CoordsDirectionDelta[direction].x; + y += CoordsDirectionDelta[direction].y; stationElement = find_station_element(x, y, z, direction, rideIndex); if (stationElement != nullptr) @@ -923,15 +923,15 @@ static bool track_remove_station_element(sint32 x, sint32 y, sint32 z, sint32 di } else { - if (x + TileDirectionDelta[direction].x == removeX && - y + TileDirectionDelta[direction].y == removeY) + if (x + CoordsDirectionDelta[direction].x == removeX && + y + CoordsDirectionDelta[direction].y == removeY) { goto loc_6C4BF5; } else { - if (x - TileDirectionDelta[direction].x == removeX && - y - TileDirectionDelta[direction].y == removeY) + if (x - CoordsDirectionDelta[direction].x == removeX && + y - CoordsDirectionDelta[direction].y == removeY) { targetTrackType = TRACK_ELEM_BEGIN_STATION; } @@ -956,8 +956,8 @@ static bool track_remove_station_element(sint32 x, sint32 y, sint32 z, sint32 di if (x != stationX0 || y != stationY0) { - x -= TileDirectionDelta[direction].x; - y -= TileDirectionDelta[direction].y; + x -= CoordsDirectionDelta[direction].x; + y -= CoordsDirectionDelta[direction].y; finaliseStationDone = false; } } @@ -1362,8 +1362,8 @@ static money32 track_place(sint32 rideIndex, _bl &= ~(1 << dl); sint32 temp_x = x, temp_y = y; sint32 temp_direction = (direction + dl) & 3; - temp_x += TileDirectionDelta[temp_direction].x; - temp_y += TileDirectionDelta[temp_direction].y; + temp_x += CoordsDirectionDelta[temp_direction].x; + temp_y += CoordsDirectionDelta[temp_direction].y; temp_direction ^= (1 << 1); wall_remove_intersecting_walls(temp_x, temp_y, baseZ, clearanceZ, temp_direction & 3); } diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index 53dd31be44..94c78b145e 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -1547,8 +1547,8 @@ static bool track_design_place_ride(rct_track_td6 * td6, sint16 x, sint16 y, sin } else { - x += TileDirectionDelta[rotation].x; - y += TileDirectionDelta[rotation].y; + x += CoordsDirectionDelta[rotation].x; + y += CoordsDirectionDelta[rotation].y; } } @@ -1585,8 +1585,8 @@ static bool track_design_place_ride(rct_track_td6 * td6, sint16 x, sint16 y, sin if (_trackDesignPlaceOperation != PTD_OPERATION_1) { LocationXY16 tile = { - (sint16) (x + TileDirectionDelta[rotation].x), - (sint16) (y + TileDirectionDelta[rotation].y) + (sint16) (x + CoordsDirectionDelta[rotation].x), + (sint16) (y + CoordsDirectionDelta[rotation].y) }; rct_tile_element * tile_element = map_get_first_element_at(tile.x >> 5, tile.y >> 5); z = gTrackPreviewOrigin.z / 8; diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index 3a14cce6af..5e8e873dee 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -2864,8 +2864,8 @@ static bool vehicle_can_depart_synchronised(rct_vehicle * vehicle) spaceBetween = maxCheckDistance; while (_lastSynchronisedVehicle < &_synchronisedVehicles[SYNCHRONISED_VEHICLE_COUNT - 1]) { - x += TileDirectionDelta[direction].x; - y += TileDirectionDelta[direction].y; + x += CoordsDirectionDelta[direction].x; + y += CoordsDirectionDelta[direction].y; if (try_add_synchronised_station(x, y, z)) { spaceBetween = maxCheckDistance; @@ -2886,8 +2886,8 @@ static bool vehicle_can_depart_synchronised(rct_vehicle * vehicle) spaceBetween = maxCheckDistance; while (_lastSynchronisedVehicle < &_synchronisedVehicles[SYNCHRONISED_VEHICLE_COUNT - 1]) { - x += TileDirectionDelta[direction].x; - y += TileDirectionDelta[direction].y; + x += CoordsDirectionDelta[direction].x; + y += CoordsDirectionDelta[direction].y; if (try_add_synchronised_station(x, y, z)) { spaceBetween = maxCheckDistance; @@ -3170,8 +3170,8 @@ static void vehicle_update_travelling_boat_hire_setup(rct_vehicle * vehicle) vehicle->track_x = vehicle->x & 0xFFE0; vehicle->track_y = vehicle->y & 0xFFE0; - LocationXY8 location = { static_cast((vehicle->track_x + TileDirectionDelta[vehicle->sprite_direction >> 3].x) / 32), - static_cast((vehicle->track_y + TileDirectionDelta[vehicle->sprite_direction >> 3].y) / + LocationXY8 location = { static_cast((vehicle->track_x + CoordsDirectionDelta[vehicle->sprite_direction >> 3].x) / 32), + static_cast((vehicle->track_y + CoordsDirectionDelta[vehicle->sprite_direction >> 3].y) / 32) }; vehicle->boat_location = location; @@ -4605,8 +4605,8 @@ static void vehicle_update_boat_location(rct_vehicle * vehicle) LocationXY8 returnPosition = ride->boat_hire_return_position; uint8 returnDirection = ride->boat_hire_return_direction & 3; - LocationXY8 location = { static_cast((vehicle->x + TileDirectionDelta[returnDirection].x) / 32), - static_cast((vehicle->y + TileDirectionDelta[returnDirection].y) / 32) }; + LocationXY8 location = { static_cast((vehicle->x + CoordsDirectionDelta[returnDirection].x) / 32), + static_cast((vehicle->y + CoordsDirectionDelta[returnDirection].y) / 32) }; if (location.xy == returnPosition.xy) { @@ -4625,8 +4625,8 @@ static void vehicle_update_boat_location(rct_vehicle * vehicle) if (scenario_rand() & 1) { LocationXY16 destLocation = { - static_cast(returnPosition.x * 32 - TileDirectionDelta[returnDirection].x + 16), - static_cast(returnPosition.y * 32 - TileDirectionDelta[returnDirection].y + 16) + static_cast(returnPosition.x * 32 - CoordsDirectionDelta[returnDirection].x + 16), + static_cast(returnPosition.y * 32 - CoordsDirectionDelta[returnDirection].y + 16) }; destLocation.x -= vehicle->x; @@ -4651,8 +4651,8 @@ static void vehicle_update_boat_location(rct_vehicle * vehicle) continue; } - sint16 x = vehicle->track_x + TileDirectionDelta[(randDirection + rotation) & 3].x; - sint16 y = vehicle->track_y + TileDirectionDelta[(randDirection + rotation) & 3].y; + sint16 x = vehicle->track_x + CoordsDirectionDelta[(randDirection + rotation) & 3].x; + sint16 y = vehicle->track_y + CoordsDirectionDelta[(randDirection + rotation) & 3].y; if (!vehicle_boat_is_location_accessible(TileCoordsXYZ(CoordsXYZ{x, y, vehicle->track_z}))) { @@ -4663,8 +4663,8 @@ static void vehicle_update_boat_location(rct_vehicle * vehicle) return; } - sint16 x = vehicle->track_x + TileDirectionDelta[curDirection & 3].x; - sint16 y = vehicle->track_y + TileDirectionDelta[curDirection & 3].y; + sint16 x = vehicle->track_x + CoordsDirectionDelta[curDirection & 3].x; + sint16 y = vehicle->track_y + CoordsDirectionDelta[curDirection & 3].y; vehicle->boat_location.x = x / 32; vehicle->boat_location.y = y / 32; } diff --git a/src/openrct2/ride/transport/Chairlift.cpp b/src/openrct2/ride/transport/Chairlift.cpp index 3fa15f9639..29d8d13ce9 100644 --- a/src/openrct2/ride/transport/Chairlift.cpp +++ b/src/openrct2/ride/transport/Chairlift.cpp @@ -146,7 +146,7 @@ static bool chairlift_paint_util_is_first_track(uint8 rideIndex, const rct_tile_ return false; } - CoordsXY delta = TileDirectionDelta[tile_element_get_direction(tileElement)]; + CoordsXY delta = CoordsDirectionDelta[tile_element_get_direction(tileElement)]; CoordsXY newPos = { static_cast(pos.x - delta.x), static_cast(pos.y - delta.y), @@ -166,7 +166,7 @@ static bool chairlift_paint_util_is_last_track(uint8 rideIndex, const rct_tile_e return false; } - CoordsXY delta = TileDirectionDelta[tile_element_get_direction(tileElement)]; + CoordsXY delta = CoordsDirectionDelta[tile_element_get_direction(tileElement)]; CoordsXY newPos = { static_cast(pos.x + delta.x), static_cast(pos.y + delta.y), diff --git a/src/openrct2/world/Entrance.cpp b/src/openrct2/world/Entrance.cpp index 826911122c..1b5c4c1b01 100644 --- a/src/openrct2/world/Entrance.cpp +++ b/src/openrct2/world/Entrance.cpp @@ -86,15 +86,15 @@ static money32 ParkEntranceRemove(sint16 x, sint16 y, uint8 z, uint8 flags) // Left post ParkEntranceRemoveSegment( - x + TileDirectionDelta[direction].x, - y + TileDirectionDelta[direction].y, + x + CoordsDirectionDelta[direction].x, + y + CoordsDirectionDelta[direction].y, z * 2 ); // Right post ParkEntranceRemoveSegment( - x - TileDirectionDelta[direction].x, - y - TileDirectionDelta[direction].y, + x - CoordsDirectionDelta[direction].x, + y - CoordsDirectionDelta[direction].y, z * 2 ); @@ -633,8 +633,8 @@ void game_command_remove_ride_entrance_or_exit( void maze_entrance_hedge_replacement(sint32 x, sint32 y, rct_tile_element *tileElement) { sint32 direction = tile_element_get_direction(tileElement); - x += TileDirectionDelta[direction].x; - y += TileDirectionDelta[direction].y; + x += CoordsDirectionDelta[direction].x; + y += CoordsDirectionDelta[direction].y; sint32 z = tileElement->base_height; sint32 rideIndex = track_element_get_ride_index(tileElement); @@ -664,8 +664,8 @@ void maze_entrance_hedge_replacement(sint32 x, sint32 y, rct_tile_element *tileE void maze_entrance_hedge_removal(sint32 x, sint32 y, rct_tile_element *tileElement) { sint32 direction = tile_element_get_direction(tileElement); - x += TileDirectionDelta[direction].x; - y += TileDirectionDelta[direction].y; + x += CoordsDirectionDelta[direction].x; + y += CoordsDirectionDelta[direction].y; sint32 z = tileElement->base_height; sint32 rideIndex = track_element_get_ride_index(tileElement); diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index a20836fcc4..805ff31389 100644 --- a/src/openrct2/world/Footpath.cpp +++ b/src/openrct2/world/Footpath.cpp @@ -468,8 +468,8 @@ static money32 footpath_place_real(sint32 type, sint32 x, sint32 y, sint32 z, si // It is possible, let's remove walls between the old and new piece of path wall_remove_intersecting_walls(x, y, z, z + 4 + ((slope & TILE_ELEMENT_SURFACE_RAISED_CORNERS_MASK) ? 2 : 0), direction ^ 2); wall_remove_intersecting_walls( - x - TileDirectionDelta[direction].x, - y - TileDirectionDelta[direction].y, + x - CoordsDirectionDelta[direction].x, + y - CoordsDirectionDelta[direction].y, z, z + 4, direction ); } @@ -1109,22 +1109,22 @@ static void footpath_connect_corners(sint32 initialX, sint32 initialY, rct_tile_ sint32 y = initialY; sint32 direction = initialDirection; - x += TileDirectionDelta[direction].x; - y += TileDirectionDelta[direction].y; + x += CoordsDirectionDelta[direction].x; + y += CoordsDirectionDelta[direction].y; tileElement[1] = footpath_connect_corners_get_neighbour(x, y, z, (1 << (direction ^ 2))); if (tileElement[1] == nullptr) continue; direction = (direction + 1) & 3; - x += TileDirectionDelta[direction].x; - y += TileDirectionDelta[direction].y; + x += CoordsDirectionDelta[direction].x; + y += CoordsDirectionDelta[direction].y; tileElement[2] = footpath_connect_corners_get_neighbour(x, y, z, (1 << (direction ^ 2))); if (tileElement[2] == nullptr) continue; direction = (direction + 1) & 3; - x += TileDirectionDelta[direction].x; - y += TileDirectionDelta[direction].y; + x += CoordsDirectionDelta[direction].x; + y += CoordsDirectionDelta[direction].y; // First check link to previous tile tileElement[3] = footpath_connect_corners_get_neighbour(x, y, z, (1 << (direction ^ 2))); if (tileElement[3] == nullptr) @@ -1259,8 +1259,8 @@ static bool sub_footpath_disconnect_queue_from_path(sint32 x, sint32 y, rct_tile if ((action < 0) && fence_in_the_way(x, y, tileElement->base_height, tileElement->clearance_height, direction)) return false; - sint32 x1 = x + TileDirectionDelta[direction].x; - sint32 y1 = y + TileDirectionDelta[direction].y; + sint32 x1 = x + CoordsDirectionDelta[direction].x; + sint32 y1 = y + CoordsDirectionDelta[direction].y; sint32 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)) { @@ -1312,8 +1312,8 @@ static void loc_6A6D7E( sint32 initialX, sint32 initialY, sint32 z, sint32 direction, rct_tile_element *initialTileElement, sint32 flags, bool query, rct_neighbour_list *neighbourList ) { - sint32 x = initialX + TileDirectionDelta[direction].x; - sint32 y = initialY + TileDirectionDelta[direction].y; + sint32 x = initialX + CoordsDirectionDelta[direction].x; + sint32 y = initialY + CoordsDirectionDelta[direction].y; if (((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gCheatsSandboxMode) && map_is_edge(x, y)) { if (query) { neighbour_list_push(neighbourList, 7, direction, 255, 255); @@ -1537,8 +1537,8 @@ void footpath_chain_ride_queue(sint32 rideIndex, sint32 entranceIndex, sint32 x, } } - x += TileDirectionDelta[direction].x; - y += TileDirectionDelta[direction].y; + x += CoordsDirectionDelta[direction].x; + y += CoordsDirectionDelta[direction].y; tileElement = map_get_first_element_at(x >> 5, y >> 5); do { if (lastQueuePathElement == tileElement) @@ -1735,8 +1735,8 @@ static sint32 footpath_is_connected_to_map_edge_recurse( rct_tile_element *tileElement; sint32 edges, slopeDirection; - x += TileDirectionDelta[direction].x; - y += TileDirectionDelta[direction].y; + x += CoordsDirectionDelta[direction].x; + y += CoordsDirectionDelta[direction].y; if (++level > 250) return FOOTPATH_SEARCH_TOO_COMPLEX; @@ -2233,8 +2233,8 @@ static void footpath_remove_edges_towards_here(sint32 x, sint32 y, sint32 z, sin if (isQueue) footpath_disconnect_queue_from_path(x, y, tileElement, -1); direction = (direction + 1) & 3; - x += TileDirectionDelta[direction].x; - y += TileDirectionDelta[direction].y; + x += CoordsDirectionDelta[direction].x; + y += CoordsDirectionDelta[direction].y; tileElement = map_get_first_element_at(x >> 5, y >> 5); do { @@ -2438,7 +2438,7 @@ void footpath_remove_edges_at(sint32 x, sint32 y, rct_tile_element *tileElement) { sint32 z0 = z1 - 2; footpath_remove_edges_towards( - x + TileDirectionDelta[direction].x, y + TileDirectionDelta[direction].y, z0, z1, direction, + x + CoordsDirectionDelta[direction].x, y + CoordsDirectionDelta[direction].y, z0, z1, direction, footpath_element_is_queue(tileElement)); } else diff --git a/src/openrct2/world/Fountain.cpp b/src/openrct2/world/Fountain.cpp index 657eaffdd9..7dfa32c54b 100644 --- a/src/openrct2/world/Fountain.cpp +++ b/src/openrct2/world/Fountain.cpp @@ -249,8 +249,8 @@ static void jumping_fountain_continue(rct_jumping_fountain * jumpingFountain) { sint32 type = jumping_fountain_get_type(jumpingFountain); sint32 direction = (jumpingFountain->sprite_direction >> 3) & 7; - sint32 x = jumpingFountain->x + TileDirectionDelta[direction].x; - sint32 y = jumpingFountain->y + TileDirectionDelta[direction].y; + sint32 x = jumpingFountain->x + CoordsDirectionDelta[direction].x; + sint32 y = jumpingFountain->y + CoordsDirectionDelta[direction].y; sint32 z = jumpingFountain->z; sint32 availableDirections = 0; diff --git a/src/openrct2/world/Location.hpp b/src/openrct2/world/Location.hpp index 9fc94aab73..cd166cc6db 100644 --- a/src/openrct2/world/Location.hpp +++ b/src/openrct2/world/Location.hpp @@ -67,6 +67,11 @@ struct TileCoordsXY TileCoordsXY() = default; TileCoordsXY(sint32 x_, sint32 y_) : x(x_), y(y_) {} explicit TileCoordsXY(CoordsXY c) : x(c.x / 32), y(c.y / 32) {} + TileCoordsXY& operator+=(const TileCoordsXY rhs) + { + x += rhs.x; + y += rhs.y; + } sint32 x = 0, y = 0; }; diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index df236b14ff..8a9edf1104 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -53,7 +53,7 @@ /** * Replaces 0x00993CCC, 0x00993CCE */ -const CoordsXY TileDirectionDelta[] = { +const CoordsXY CoordsDirectionDelta[] = { { -32, 0 }, { 0, +32 }, { +32, 0 }, @@ -64,6 +64,17 @@ const CoordsXY TileDirectionDelta[] = { { -32, -32 } }; +const TileCoordsXY TileDirectionDelta[] = { + { -1, 0 }, + { 0, +1 }, + { +1, 0 }, + { 0, -1 }, + { -1, +1 }, + { +1, +1 }, + { +1, -1 }, + { -1, -1 } +}; + /** rct2: 0x0097B8B8 */ const money32 TerrainPricing[] = { 300, // TERRAIN_GRASS diff --git a/src/openrct2/world/Map.h b/src/openrct2/world/Map.h index 73b82643fa..853fd4b3d2 100644 --- a/src/openrct2/world/Map.h +++ b/src/openrct2/world/Map.h @@ -83,7 +83,8 @@ enum CREATE_CROSSING_MODE_PATH_OVER_TRACK, }; -extern const CoordsXY TileDirectionDelta[]; +extern const CoordsXY CoordsDirectionDelta[]; +extern const TileCoordsXY TileDirectionDelta[]; extern const money32 TerrainPricing[]; extern uint16 gWidePathTileLoopX; diff --git a/src/openrct2/world/MapAnimation.cpp b/src/openrct2/world/MapAnimation.cpp index 78ab8b7f18..27fc06a5bc 100644 --- a/src/openrct2/world/MapAnimation.cpp +++ b/src/openrct2/world/MapAnimation.cpp @@ -188,8 +188,8 @@ static bool map_animation_invalidate_small_scenery(sint32 x, sint32 y, sint32 ba // Peep, looking at scenery if (!(gCurrentTicks & 0x3FF) && game_is_not_paused()) { sint32 direction = tile_element_get_direction(tileElement); - sint32 x2 = x - TileDirectionDelta[direction].x; - sint32 y2 = y - TileDirectionDelta[direction].y; + sint32 x2 = x - CoordsDirectionDelta[direction].x; + sint32 y2 = y - CoordsDirectionDelta[direction].y; uint16 spriteIdx = sprite_get_first_in_quadrant(x2, y2); for (; spriteIdx != SPRITE_INDEX_NULL; spriteIdx = sprite->unknown.next_in_quadrant) { diff --git a/src/openrct2/world/Sprite.cpp b/src/openrct2/world/Sprite.cpp index 8657649d3f..5f5c925504 100644 --- a/src/openrct2/world/Sprite.cpp +++ b/src/openrct2/world/Sprite.cpp @@ -673,8 +673,8 @@ void litter_create(sint32 x, sint32 y, sint32 z, sint32 direction, sint32 type) if (gCheatsDisableLittering) return; - x += TileDirectionDelta[direction >> 3].x / 8; - y += TileDirectionDelta[direction >> 3].y / 8; + x += CoordsDirectionDelta[direction >> 3].x / 8; + y += CoordsDirectionDelta[direction >> 3].y / 8; if (!litter_can_be_at(x, y, z)) return;