Port queue functions

This commit is contained in:
Michael Steenbeek 2018-10-03 10:57:29 +02:00
parent deeb34f4aa
commit 882a65e4c0
13 changed files with 63 additions and 62 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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:

View File

@ -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
{

View File

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

View File

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

View File

@ -193,6 +193,9 @@ struct PathElement : TileElementBase
};
public:
bool IsQueue() const;
void SetIsQueue(bool isQueue);
uint8_t GetRCT1PathType() const;
};
assert_struct_size(PathElement, 8);