mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-04 13:42:55 +01:00
@@ -192,7 +192,7 @@ static money32 footpath_element_insert(int type, int x, int y, int z, int slope,
|
||||
mapElement->properties.path.addition_status = 255;
|
||||
mapElement->flags &= ~MAP_ELEMENT_FLAG_BROKEN;
|
||||
if (flags & (1 << 6))
|
||||
mapElement->flags |= 1 << 4;
|
||||
mapElement->flags |= MAP_ELEMENT_FLAG_GHOST;
|
||||
|
||||
RCT2_GLOBAL(0x00F3EFF4, uint32) = 0x00F3EFF8;
|
||||
|
||||
@@ -825,8 +825,14 @@ static int rct_neighbour_compare(const void *a, const void *b)
|
||||
uint8 va = ((rct_neighbour*)a)->order;
|
||||
uint8 vb = ((rct_neighbour*)b)->order;
|
||||
if (va < vb) return 1;
|
||||
else if (va == vb) return 0;
|
||||
else return -1;
|
||||
else if (va > vb) return -1;
|
||||
else {
|
||||
uint8 da = ((rct_neighbour*)a)->direction;
|
||||
uint8 db = ((rct_neighbour*)b)->direction;
|
||||
if (va < vb) return -1;
|
||||
else if (va > vb) return 1;
|
||||
else return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void neighbour_list_init(rct_neighbour_list *neighbourList)
|
||||
@@ -858,6 +864,87 @@ static void neighbour_list_sort(rct_neighbour_list *neighbourList)
|
||||
qsort(neighbourList->items, neighbourList->count, sizeof(rct_neighbour), rct_neighbour_compare);
|
||||
}
|
||||
|
||||
static rct_map_element *footpath_get_element(int x, int y, int z0, int z1, int direction)
|
||||
{
|
||||
rct_map_element *mapElement;
|
||||
int slope;
|
||||
|
||||
mapElement = map_get_first_element_at(x >> 5, y >> 5);
|
||||
do {
|
||||
if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_PATH)
|
||||
continue;
|
||||
|
||||
if (z1 == mapElement->base_height) {
|
||||
if (footpath_element_is_sloped(mapElement)) {
|
||||
slope = footpath_element_get_slope_direction(mapElement);
|
||||
if (slope != direction)
|
||||
break;
|
||||
}
|
||||
return mapElement;
|
||||
}
|
||||
if (z0 == mapElement->base_height) {
|
||||
if (!footpath_element_is_sloped(mapElement))
|
||||
break;
|
||||
|
||||
slope = footpath_element_get_slope_direction(mapElement) ^ 2;
|
||||
if (slope != direction)
|
||||
break;
|
||||
|
||||
return mapElement;
|
||||
}
|
||||
} while (!map_element_is_last_for_tile(mapElement++));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static bool sub_footpath_disconnect_queue_from_path(int x, int y, rct_map_element *mapElement, int action, int direction) {
|
||||
if (((mapElement->properties.path.edges & (1 << direction)) == 0) ^ (action < 0))
|
||||
return false;
|
||||
if ((action < 0) && sub_6E59DC(x, y, mapElement->base_height, mapElement->clearance_height, direction))
|
||||
return false;
|
||||
|
||||
int x1 = x + TileDirectionDelta[direction].x;
|
||||
int y1 = y + TileDirectionDelta[direction].y;
|
||||
int z = mapElement->base_height;
|
||||
rct_map_element *otherMapElement = footpath_get_element(x1, y1, z - 2, z, direction);
|
||||
if (otherMapElement != NULL && !footpath_element_is_queue(otherMapElement)) {
|
||||
mapElement->properties.path.type &= 0xFC;
|
||||
if (action > 0) {
|
||||
mapElement->properties.path.edges &= ~(1 << direction);
|
||||
otherMapElement->properties.path.edges &= ~(1 << ((direction + 2) & 3));
|
||||
if (action >= 2) mapElement->properties.path.type |= direction;
|
||||
}
|
||||
else if (action < 0) {
|
||||
mapElement->properties.path.edges |= (1 << direction);
|
||||
otherMapElement->properties.path.edges |= (1 << ((direction + 2) & 3));
|
||||
}
|
||||
if (action != 0) map_invalidate_tile_full(x1, y1);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool footpath_disconnect_queue_from_path(int x, int y, rct_map_element *mapElement, int action) {
|
||||
if (!footpath_element_is_queue(mapElement)) return false;
|
||||
|
||||
if (mapElement->properties.path.type & 4) return false;
|
||||
|
||||
uint8 c = RCT2_ADDRESS(0x0098D7F0, uint8)[mapElement->properties.path.edges & 0x0F];
|
||||
if ((action < 0) ? (c >= 2) : (c < 2)) return false;
|
||||
|
||||
if (action < 0) {
|
||||
if (sub_footpath_disconnect_queue_from_path(x, y, mapElement, action, mapElement->properties.path.type & 3))
|
||||
return true;
|
||||
}
|
||||
|
||||
for (int direction = 0; direction < 4; direction++) {
|
||||
if ((action < 0) && (direction == (mapElement->properties.path.type & 3))) continue;
|
||||
if (sub_footpath_disconnect_queue_from_path(x, y, mapElement, action, direction))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006A6D7E
|
||||
@@ -937,11 +1024,19 @@ static void loc_6A6D7E(
|
||||
if (footpath_element_is_queue(mapElement)) {
|
||||
if (RCT2_ADDRESS(0x0098D7F0, uint8)[mapElement->properties.path.edges & 0x0F] < 2) {
|
||||
neighbour_list_push(neighbourList, 3, direction);
|
||||
} else {
|
||||
if (map_element_get_type(initialMapElement) == MAP_ELEMENT_TYPE_PATH &&
|
||||
footpath_element_is_queue(initialMapElement)) {
|
||||
if (footpath_disconnect_queue_from_path(x, y, mapElement, 0)) {
|
||||
neighbour_list_push(neighbourList, 3, direction);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
neighbour_list_push(neighbourList, 2, direction);
|
||||
}
|
||||
} else {
|
||||
footpath_disconnect_queue_from_path(x, y, mapElement, 1 + ((flags >> 6) & 1));
|
||||
mapElement->properties.path.edges |= (1 << (direction ^ 2));
|
||||
if (footpath_element_is_queue(mapElement)) {
|
||||
sub_6A76E9(mapElement->properties.path.ride_index);
|
||||
@@ -1023,10 +1118,9 @@ void footpath_connect_edges(int x, int y, rct_map_element *mapElement, int flags
|
||||
|
||||
neighbour_list_sort(&neighbourList);
|
||||
|
||||
if (map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_PATH) {
|
||||
if (footpath_element_is_queue(mapElement)) {
|
||||
neighbourList.count = min(neighbourList.count, 2);
|
||||
}
|
||||
if (map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_PATH
|
||||
&& footpath_element_is_queue(mapElement)) {
|
||||
neighbourList.count = min(neighbourList.count, 2);
|
||||
}
|
||||
|
||||
while (neighbour_list_pop(&neighbourList, &neighbour)) {
|
||||
@@ -1377,7 +1471,7 @@ void sub_6A7642(int x, int y, rct_map_element *mapElement)
|
||||
*
|
||||
* rct2: 0x006A6B7F
|
||||
*/
|
||||
static void footpath_remove_edges_towards_here(int x, int y, int z, int direction, rct_map_element *mapElement)
|
||||
static void footpath_remove_edges_towards_here(int x, int y, int z, int direction, rct_map_element *mapElement, bool isQueue)
|
||||
{
|
||||
int d;
|
||||
|
||||
@@ -1393,6 +1487,8 @@ static void footpath_remove_edges_towards_here(int x, int y, int z, int directio
|
||||
mapElement->properties.path.edges &= ~(1 << d);
|
||||
map_invalidate_tile(x, y, mapElement->base_height, mapElement->clearance_height);
|
||||
|
||||
if (isQueue) footpath_disconnect_queue_from_path(x, y, mapElement, -1);
|
||||
|
||||
direction = (direction + 1) & 3;
|
||||
x += TileDirectionDelta[direction].x;
|
||||
y += TileDirectionDelta[direction].y;
|
||||
@@ -1418,7 +1514,7 @@ static void footpath_remove_edges_towards_here(int x, int y, int z, int directio
|
||||
*
|
||||
* rct2: 0x006A6B14
|
||||
*/
|
||||
void footpath_remove_edges_towards(int x, int y, int z0, int z1, int direction)
|
||||
static void footpath_remove_edges_towards(int x, int y, int z0, int z1, int direction, bool isQueue)
|
||||
{
|
||||
rct_map_element *mapElement;
|
||||
int slope;
|
||||
@@ -1434,7 +1530,7 @@ void footpath_remove_edges_towards(int x, int y, int z0, int z1, int direction)
|
||||
if (slope != direction)
|
||||
break;
|
||||
}
|
||||
footpath_remove_edges_towards_here(x, y, z1, direction, mapElement);
|
||||
footpath_remove_edges_towards_here(x, y, z1, direction, mapElement, isQueue);
|
||||
break;
|
||||
}
|
||||
if (z0 == mapElement->base_height) {
|
||||
@@ -1445,7 +1541,7 @@ void footpath_remove_edges_towards(int x, int y, int z0, int z1, int direction)
|
||||
if (slope != direction)
|
||||
break;
|
||||
|
||||
footpath_remove_edges_towards_here(x, y, z1, direction, mapElement);
|
||||
footpath_remove_edges_towards_here(x, y, z1, direction, mapElement, isQueue);
|
||||
break;
|
||||
}
|
||||
} while (!map_element_is_last_for_tile(mapElement++));
|
||||
@@ -1483,7 +1579,8 @@ void footpath_remove_edges_at(int x, int y, rct_map_element *mapElement)
|
||||
}
|
||||
}
|
||||
z0 = z1 - 2;
|
||||
footpath_remove_edges_towards(x + TileDirectionDelta[direction].x, y + TileDirectionDelta[direction].y, z0, z1, direction);
|
||||
footpath_remove_edges_towards(x + TileDirectionDelta[direction].x, y + TileDirectionDelta[direction].y,
|
||||
z0, z1, direction, footpath_element_is_queue(mapElement));
|
||||
}
|
||||
|
||||
if (map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_PATH)
|
||||
|
||||
Reference in New Issue
Block a user