Merge pull request #8189 from Gymnasiast/path-part-2b

Port most path stuff to new standard
This commit is contained in:
Michael Steenbeek 2018-10-31 13:57:04 +01:00 committed by GitHub
commit 7c38ce6cb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 231 additions and 178 deletions

View File

@ -211,15 +211,15 @@ int32_t viewport_interaction_get_item_right(int32_t x, int32_t y, viewport_inter
info->x = mapCoord.x;
info->y = mapCoord.y;
tileElement = info->tileElement;
rct_sprite* sprite = info->sprite;
switch (info->type)
{
case VIEWPORT_INTERACTION_ITEM_SPRITE:
if ((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || tileElement->type != 0)
if ((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || sprite->generic.sprite_identifier != SPRITE_IDENTIFIER_VEHICLE)
return info->type = VIEWPORT_INTERACTION_ITEM_NONE;
tileElement += 6;
ride = get_ride(tileElement->type);
ride = get_ride(sprite->vehicle.ride);
if (ride->status == RIDE_STATUS_CLOSED)
{
set_map_tooltip_format_arg(0, rct_string_id, STR_MAP_TOOLTIP_STRINGID_CLICK_TO_MODIFY);
@ -504,16 +504,16 @@ static void viewport_interaction_remove_footpath(rct_tile_element* tileElement,
*/
static void viewport_interaction_remove_footpath_item(rct_tile_element* tileElement, int32_t x, int32_t y)
{
int32_t type;
type = tileElement->AsPath()->GetEntryIndex();
int32_t type = tileElement->AsPath()->GetEntryIndex();
if (tileElement->AsPath()->IsQueue())
type |= 0x80;
int32_t slopeData = tileElement->AsPath()->GetSlopeDirection();
if (tileElement->AsPath()->IsSloped())
slopeData |= FOOTPATH_PROPERTIES_FLAG_IS_SLOPED;
gGameCommandErrorTitle = STR_CANT_REMOVE_THIS;
game_do_command(
x, ((tileElement->properties.path.type & 7) << 8) | 1, y, (type << 8) | tileElement->base_height,
GAME_COMMAND_PLACE_PATH, 0, 0);
game_do_command(x, (slopeData << 8) | 1, y, (type << 8) | tileElement->base_height, GAME_COMMAND_PLACE_PATH, 0, 0);
}
/**

View File

@ -758,8 +758,9 @@ static void window_footpath_set_provisional_path_at_point(int32_t x, int32_t y)
slope = DefaultPathSlope[tileElement->AsSurface()->GetSlope() & TILE_ELEMENT_SURFACE_RAISED_CORNERS_MASK];
break;
case VIEWPORT_INTERACTION_ITEM_FOOTPATH:
slope = tileElement->properties.path.type
& (FOOTPATH_PROPERTIES_FLAG_IS_SLOPED | FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK);
slope = tileElement->AsPath()->GetSlopeDirection();
if (tileElement->AsPath()->IsSloped())
slope |= FOOTPATH_PROPERTIES_FLAG_IS_SLOPED;
break;
}
int32_t pathType = (gFootpathSelectedType << 7) + (gFootpathSelectedId & 0xFF);
@ -854,7 +855,7 @@ static void window_footpath_place_path_at_point(int32_t x, int32_t y)
currentType = DefaultPathSlope[tileElement->AsSurface()->GetSlope() & TILE_ELEMENT_SURFACE_RAISED_CORNERS_MASK];
break;
case VIEWPORT_INTERACTION_ITEM_FOOTPATH:
currentType = tileElement->properties.path.type & FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK;
currentType = tileElement->AsPath()->GetSlopeDirection();
if (tileElement->AsPath()->IsSloped())
{
currentType |= FOOTPATH_PROPERTIES_FLAG_IS_SLOPED;
@ -918,9 +919,9 @@ static void window_footpath_start_bridge_at_point(int32_t screenX, int32_t scree
z = tileElement->base_height;
if (tileElement->GetType() == TILE_ELEMENT_TYPE_PATH)
{
if (tileElement->properties.path.type & 4)
if (tileElement->AsPath()->IsSloped())
{
if (direction == (tileElement->properties.path.type & 3))
if (direction == (tileElement->AsPath()->GetSlopeDirection()))
{
z += 2;
}
@ -1002,12 +1003,11 @@ static void footpath_remove_tile_element(rct_tile_element* tileElement)
int32_t x, y, z;
z = tileElement->base_height;
int32_t pathType = tileElement->properties.path.type;
if (pathType & 4)
if (tileElement->AsPath()->IsSloped())
{
pathType &= 3;
pathType ^= 2;
if (pathType == gFootpathConstructDirection)
uint8_t slopeDirection = tileElement->AsPath()->GetSlopeDirection();
slopeDirection ^= 2;
if (slopeDirection == gFootpathConstructDirection)
{
z += 2;
}
@ -1073,9 +1073,9 @@ static rct_tile_element* footpath_get_tile_element_to_remove()
{
if (tileElement->base_height == z)
{
if (tileElement->properties.path.type & 4)
if (tileElement->AsPath()->IsSloped())
{
if (((tileElement->properties.path.type & 3) ^ 2) != gFootpathConstructDirection)
if (((tileElement->AsPath()->GetSlopeDirection()) ^ 2) != gFootpathConstructDirection)
{
continue;
}
@ -1085,9 +1085,9 @@ static rct_tile_element* footpath_get_tile_element_to_remove()
}
else if (tileElement->base_height == zLow)
{
if (!(tileElement->properties.path.type & 4))
if (!tileElement->AsPath()->IsSloped())
{
if ((tileElement->properties.path.type & 3) == gFootpathConstructDirection)
if ((tileElement->AsPath()->GetSlopeDirection()) == gFootpathConstructDirection)
{
continue;
}

View File

@ -3601,8 +3601,7 @@ void ride_construction_toolupdate_construct(int32_t screenX, int32_t screenY)
{
pathsByDir[i] = map_get_footpath_element((x >> 5) + DirOffsets[i].x, (y >> 5) + DirOffsets[i].y, z >> 3);
if (pathsByDir[i] && (pathsByDir[i])->AsPath()->IsSloped()
&& footpath_element_get_slope_direction(pathsByDir[i]) != i)
if (pathsByDir[i] && (pathsByDir[i])->AsPath()->IsSloped() && (pathsByDir[i])->AsPath()->GetSlopeDirection() != i)
{
pathsByDir[i] = nullptr;
}
@ -3613,8 +3612,7 @@ void ride_construction_toolupdate_construct(int32_t screenX, int32_t screenY)
pathsByDir[i] = map_get_footpath_element((x >> 5) + DirOffsets[i].x, (y >> 5) + DirOffsets[i].y, (z >> 3) - 2);
if (pathsByDir[i]
&& (!(pathsByDir[i])->AsPath()->IsSloped()
|| footpath_element_get_slope_direction(pathsByDir[i]) != (i ^ 2)))
&& (!(pathsByDir[i])->AsPath()->IsSloped() || (pathsByDir[i])->AsPath()->GetSlopeDirection() != (i ^ 2)))
{
pathsByDir[i] = nullptr;
}

View File

@ -992,9 +992,10 @@ static void repaint_scenery_tool_down(int16_t x, int16_t y, rct_widgetindex widg
scenery_entry, SMALL_SCENERY_FLAG_HAS_PRIMARY_COLOUR | SMALL_SCENERY_FLAG_HAS_GLASS))
return;
uint8_t quadrant = tile_element->AsSmallScenery()->GetSceneryQuadrant();
gGameCommandErrorTitle = STR_CANT_REPAINT_THIS;
game_do_command(
grid_x, 1 | (tile_element->type << 8), grid_y,
grid_x, GAME_COMMAND_FLAG_APPLY | quadrant, grid_y,
tile_element->base_height | (tile_element->AsSmallScenery()->GetEntryIndex() << 8),
GAME_COMMAND_SET_SCENERY_COLOUR, 0, gWindowSceneryPrimaryColour | (gWindowScenerySecondaryColour << 8));
break;
@ -1450,9 +1451,9 @@ static void sub_6E1F34(
return;
}
*parameter_1 = (tile_element->properties.path.type
& (FOOTPATH_PROPERTIES_FLAG_IS_SLOPED | FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK))
<< 8;
*parameter_1 = tile_element->AsPath()->GetSlopeDirection() << 8;
if (tile_element->AsPath()->IsSloped())
*parameter_1 |= FOOTPATH_PROPERTIES_FLAG_IS_SLOPED << 8;
*parameter_2 = tile_element->base_height;
*parameter_2 |= (tile_element->AsPath()->GetEntryIndex() << 8);
if (tile_element->AsPath()->IsQueue())
@ -1606,9 +1607,9 @@ static void sub_6E1F34(
int16_t z = tile_element->base_height;
if (tile_element->properties.path.type & (1 << 2))
if (tile_element->AsPath()->IsSloped())
{
if (rotation != ((tile_element->properties.path.type & 3) ^ 2))
if (rotation != ((tile_element->AsPath()->GetSlopeDirection()) ^ 2))
{
z += 2;
}

View File

@ -143,7 +143,7 @@ static void cheat_remove_litter()
sceneryEntry = it.element->AsPath()->GetAdditionEntry();
if (sceneryEntry->path_bit.flags & PATH_BIT_FLAG_IS_BIN)
it.element->properties.path.addition_status = 0xFF;
it.element->AsPath()->SetAdditionStatus(0xFF);
} while (tile_element_iterator_next(&it));

View File

@ -131,8 +131,7 @@ void setup_in_use_selection_flags()
case TILE_ELEMENT_TYPE_TRACK:
break;
case TILE_ELEMENT_TYPE_PATH:
type = iter.element->properties.path.type;
type >>= 4;
type = iter.element->AsPath()->GetEntryIndex();
assert(type < object_entry_group_counts[OBJECT_TYPE_PATHS]);
Editor::SetSelectedObject(OBJECT_TYPE_PATHS, type, OBJECT_SELECTION_FLAG_SELECTED);

View File

@ -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 "2"
#define NETWORK_STREAM_VERSION "3"
#define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION
static rct_peep* _pickup_peep = nullptr;

View File

@ -166,7 +166,7 @@ static void path_bit_bins_paint(
// Edges have been rotated around the rotation to check addition status
// this will also need to be rotated.
binIsFull = !(tileElement->properties.path.addition_status & ror8(0x3, (2 * session->CurrentRotation)));
binIsFull = !(tileElement->AsPath()->GetAdditionStatus() & ror8(0x3, (2 * session->CurrentRotation)));
if (binIsFull)
imageId += 8;
}
@ -187,7 +187,7 @@ static void path_bit_bins_paint(
// Edges have been rotated around the rotation to check addition status
// this will also need to be rotated.
binIsFull = !(tileElement->properties.path.addition_status & ror8(0xC, (2 * session->CurrentRotation)));
binIsFull = !(tileElement->AsPath()->GetAdditionStatus() & ror8(0xC, (2 * session->CurrentRotation)));
if (binIsFull)
imageId += 8;
}
@ -209,7 +209,7 @@ static void path_bit_bins_paint(
// Edges have been rotated around the rotation to check addition status
// this will also need to be rotated.
binIsFull = !(tileElement->properties.path.addition_status & ror8(0x30, (2 * session->CurrentRotation)));
binIsFull = !(tileElement->AsPath()->GetAdditionStatus() & ror8(0x30, (2 * session->CurrentRotation)));
if (binIsFull)
imageId += 8;
}
@ -231,7 +231,7 @@ static void path_bit_bins_paint(
// Edges have been rotated around the rotation to check addition status
// this will also need to be rotated.
binIsFull = !(tileElement->properties.path.addition_status & ror8(0xC0, (2 * session->CurrentRotation)));
binIsFull = !(tileElement->AsPath()->GetAdditionStatus() & ror8(0xC0, (2 * session->CurrentRotation)));
if (binIsFull)
imageId += 8;
}
@ -325,7 +325,7 @@ static void sub_6A4101(
uint8_t local_ebp = ebp & 0x0F;
if (tile_element->AsPath()->IsSloped())
{
switch ((footpath_element_get_slope_direction(tile_element) + session->CurrentRotation)
switch ((tile_element->AsPath()->GetSlopeDirection() + session->CurrentRotation)
& FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK)
{
case 0:
@ -414,7 +414,7 @@ static void sub_6A4101(
session->InteractionType = VIEWPORT_INTERACTION_ITEM_RIDE;
if (tile_element->AsPath()->IsSloped())
{
if (footpath_element_get_slope_direction(tile_element) == direction)
if (tile_element->AsPath()->GetSlopeDirection() == direction)
height += 16;
}
direction += session->CurrentRotation;
@ -436,7 +436,7 @@ static void sub_6A4101(
direction--;
// If text shown
if (direction < 2 && tile_element->properties.path.ride_index != RIDE_ID_NULL && imageFlags == 0)
if (direction < 2 && tile_element->AsPath()->GetRideIndex() != RIDE_ID_NULL && imageFlags == 0)
{
uint16_t scrollingMode = footpathEntry->scrolling_mode;
scrollingMode += direction;
@ -444,7 +444,7 @@ static void sub_6A4101(
set_format_arg(0, uint32_t, 0);
set_format_arg(4, uint32_t, 0);
Ride* ride = get_ride(tile_element->properties.path.ride_index);
Ride* ride = get_ride(tile_element->AsPath()->GetRideIndex());
rct_string_id string_id = STR_RIDE_ENTRANCE_CLOSED;
if (ride->status == RIDE_STATUS_OPEN && !(ride->lifecycle_flags & RIDE_LIFECYCLE_BROKEN_DOWN))
{
@ -489,7 +489,7 @@ static void sub_6A4101(
if (tile_element->AsPath()->IsSloped())
{
switch ((footpath_element_get_slope_direction(tile_element) + session->CurrentRotation)
switch ((tile_element->AsPath()->GetSlopeDirection() + session->CurrentRotation)
& FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK)
{
case 0:
@ -736,7 +736,7 @@ static void sub_6A3F61(
}
// This is about tunnel drawing
uint8_t direction = (footpath_element_get_slope_direction(tile_element) + session->CurrentRotation)
uint8_t direction = (tile_element->AsPath()->GetSlopeDirection() + session->CurrentRotation)
& FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK;
bool sloped = tile_element->AsPath()->IsSloped();
@ -799,7 +799,7 @@ void path_paint(paint_session* session, uint16_t height, const rct_tile_element*
{
if (tile_element->AsPath()->IsQueue())
{
if (tile_element->properties.path.ride_index != gTrackDesignSaveRideIndex)
if (tile_element->AsPath()->GetRideIndex() != gTrackDesignSaveRideIndex)
{
return;
}
@ -859,7 +859,7 @@ void path_paint(paint_session* session, uint16_t height, const rct_tile_element*
{
// Diagonal path
if (surface->AsSurface()->GetSlope() != byte_98D800[footpath_element_get_slope_direction(tile_element)])
if (surface->AsSurface()->GetSlope() != byte_98D800[tile_element->AsPath()->GetSlopeDirection()])
{
word_F3F038 = true;
}
@ -899,7 +899,7 @@ void path_paint(paint_session* session, uint16_t height, const rct_tile_element*
int32_t height2 = tile_element->base_height * 8;
if (tile_element->AsPath()->IsSloped())
{
imageId = 2619 + ((footpath_element_get_slope_direction(tile_element) + session->CurrentRotation) & 3);
imageId = 2619 + ((tile_element->AsPath()->GetSlopeDirection() + session->CurrentRotation) & 3);
height2 += 16;
}
@ -989,7 +989,7 @@ void path_paint_box_support(
uint32_t imageId;
if (tileElement->AsPath()->IsSloped())
{
imageId = ((footpath_element_get_slope_direction(tileElement) + session->CurrentRotation)
imageId = ((tileElement->AsPath()->GetSlopeDirection() + session->CurrentRotation)
& FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK)
+ 16;
}
@ -1036,7 +1036,7 @@ void path_paint_box_support(
uint32_t image_id;
if (tileElement->AsPath()->IsSloped())
{
image_id = ((footpath_element_get_slope_direction(tileElement) + session->CurrentRotation)
image_id = ((tileElement->AsPath()->GetSlopeDirection() + session->CurrentRotation)
& FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK)
+ footpathEntry->bridge_image + 51;
}
@ -1066,7 +1066,7 @@ void path_paint_box_support(
uint16_t ax = 0;
if (tileElement->AsPath()->IsSloped())
{
ax = ((footpath_element_get_slope_direction(tileElement) + session->CurrentRotation) & 0x3) + 1;
ax = ((tileElement->AsPath()->GetSlopeDirection() + session->CurrentRotation) & 0x3) + 1;
}
if (byte_98D8A4[edges] == 0)
@ -1143,7 +1143,7 @@ void path_paint_pole_support(
uint32_t imageId;
if (tileElement->AsPath()->IsSloped())
{
imageId = ((footpath_element_get_slope_direction(tileElement) + session->CurrentRotation) & 3) + 16;
imageId = ((tileElement->AsPath()->GetSlopeDirection() + session->CurrentRotation) & 3) + 16;
}
else
{
@ -1189,7 +1189,7 @@ void path_paint_pole_support(
uint32_t bridgeImage;
if (tileElement->AsPath()->IsSloped())
{
bridgeImage = ((footpath_element_get_slope_direction(tileElement) + session->CurrentRotation)
bridgeImage = ((tileElement->AsPath()->GetSlopeDirection() + session->CurrentRotation)
& FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK)
+ footpathEntry->bridge_image + 16;
}

View File

@ -4913,7 +4913,8 @@ void rct_peep::UpdateRideLeaveExit()
if (tileElement->GetType() != TILE_ELEMENT_TYPE_PATH)
continue;
int16_t height = map_height_from_slope({ x, y }, tileElement->properties.path.type, tileElement->AsPath()->IsSloped());
int16_t height = map_height_from_slope(
{ x, y }, tileElement->AsPath()->GetSlopeDirection(), tileElement->AsPath()->IsSloped());
height += tileElement->base_height * 8;
int16_t z_diff = z - height;
@ -5781,7 +5782,7 @@ void rct_peep::UpdateUsingBin()
uint8_t selected_bin = var_37 * 2;
// This counts down 2 = No rubbish, 0 = full
uint8_t space_left_in_bin = 0x3 & (tileElement->properties.path.addition_status >> selected_bin);
uint8_t space_left_in_bin = 0x3 & (tileElement->AsPath()->GetAdditionStatus() >> selected_bin);
uint32_t empty_containers = HasEmptyContainerStandardFlag();
for (uint8_t cur_container = 0; cur_container < 32; cur_container++)
@ -5847,10 +5848,12 @@ void rct_peep::UpdateUsingBin()
UpdateSpriteType();
}
uint8_t additionStatus = tileElement->AsPath()->GetAdditionStatus();
// Place new amount in bin by first clearing the value
tileElement->properties.path.addition_status &= ~(3 << selected_bin);
additionStatus &= ~(3 << selected_bin);
// Then placing the new value.
tileElement->properties.path.addition_status |= space_left_in_bin << selected_bin;
additionStatus |= space_left_in_bin << selected_bin;
tileElement->AsPath()->SetAdditionStatus(additionStatus);
map_invalidate_tile_zoom0(next_x, next_y, tileElement->base_height << 3, tileElement->clearance_height << 3);
StateReset();
@ -6038,7 +6041,7 @@ bool rct_peep::UpdateWalkingFindBin()
uint8_t chosen_edge = scenario_rand() & 0x3;
// Note: Bin quantity is inverted 0 = full, 3 = empty
uint8_t bin_quantities = tileElement->properties.path.addition_status;
uint8_t bin_quantities = tileElement->AsPath()->GetAdditionStatus();
// Rotate the bin to the correct edge. Makes it easier for next calc.
bin_quantities = ror8(ror8(bin_quantities, chosen_edge), chosen_edge);

View File

@ -228,7 +228,7 @@ static uint8_t footpath_element_next_in_direction(TileCoordsXYZ loc, rct_tile_el
if (tileElement->AsPath()->IsSloped())
{
if (footpath_element_get_slope_direction(tileElement) == chosenDirection)
if (tileElement->AsPath()->GetSlopeDirection() == chosenDirection)
{
loc.z += 2;
}
@ -247,7 +247,7 @@ static uint8_t footpath_element_next_in_direction(TileCoordsXYZ loc, rct_tile_el
if (nextTileElement->AsPath()->IsWide())
return PATH_SEARCH_WIDE;
// Only queue tiles that are connected to a ride are returned as ride queues.
if (nextTileElement->AsPath()->IsQueue() && nextTileElement->properties.path.ride_index != 0xFF)
if (nextTileElement->AsPath()->IsQueue() && nextTileElement->AsPath()->GetRideIndex() != 0xFF)
return PATH_SEARCH_RIDE_QUEUE;
return PATH_SEARCH_OTHER;
@ -356,7 +356,7 @@ static uint8_t footpath_element_dest_in_dir(
if (tileElement->AsPath()->IsSloped())
{
if (footpath_element_get_slope_direction(tileElement) == direction)
if (tileElement->AsPath()->GetSlopeDirection() == direction)
{
loc.z += 2;
}
@ -398,7 +398,7 @@ static uint8_t footpath_element_destination_in_direction(
{
if (inputTileElement->AsPath()->IsSloped())
{
if (footpath_element_get_slope_direction(inputTileElement) == chosenDirection)
if (inputTileElement->AsPath()->GetSlopeDirection() == chosenDirection)
{
loc.z += 2;
}
@ -751,14 +751,14 @@ static void peep_pathfind_heuristic_search(
else
{ // numEdges == 2
if (tileElement->AsPath()->IsQueue()
&& tileElement->properties.path.ride_index != gPeepPathFindQueueRideIndex)
&& tileElement->AsPath()->GetRideIndex() != gPeepPathFindQueueRideIndex)
{
if (gPeepPathFindIgnoreForeignQueues && (tileElement->properties.path.ride_index != 0xFF))
if (gPeepPathFindIgnoreForeignQueues && (tileElement->AsPath()->GetRideIndex() != 0xFF))
{
// Path is a queue we aren't interested in
/* The rideIndex will be useful for
* adding transport rides later. */
rideIndex = tileElement->properties.path.ride_index;
rideIndex = tileElement->AsPath()->GetRideIndex();
searchResult = PATH_SEARCH_RIDE_QUEUE;
}
}
@ -1087,7 +1087,7 @@ static void peep_pathfind_heuristic_search(
uint8_t savedNumJunctions = _peepPathFindNumJunctions;
uint8_t height = loc.z;
if (tileElement->AsPath()->IsSloped() && footpath_element_get_slope_direction(tileElement) == next_test_edge)
if (tileElement->AsPath()->IsSloped() && tileElement->AsPath()->GetSlopeDirection() == next_test_edge)
{
height += 2;
}
@ -1353,8 +1353,7 @@ int32_t peep_pathfind_choose_direction(TileCoordsXYZ loc, rct_peep* peep)
edges &= ~(1 << test_edge);
uint8_t height = loc.z;
if (first_tile_element->AsPath()->IsSloped()
&& footpath_element_get_slope_direction(first_tile_element) == test_edge)
if (first_tile_element->AsPath()->IsSloped() && first_tile_element->AsPath()->GetSlopeDirection() == test_edge)
{
height += 0x2;
}
@ -1766,7 +1765,7 @@ static void get_ride_queue_end(TileCoordsXYZ& loc)
// queueEnd.direction = direction;
if (tileElement->AsPath()->IsSloped())
{
if (footpath_element_get_slope_direction(tileElement) == direction)
if (tileElement->AsPath()->GetSlopeDirection() == direction)
{
baseZ += 2;
}
@ -1788,7 +1787,7 @@ static void get_ride_queue_end(TileCoordsXYZ& loc)
{
if (tileElement->AsPath()->IsSloped())
{
if (footpath_element_get_slope_direction(tileElement) != direction)
if (tileElement->AsPath()->GetSlopeDirection() != direction)
{
break;
}
@ -1802,7 +1801,7 @@ static void get_ride_queue_end(TileCoordsXYZ& loc)
if (!tileElement->AsPath()->IsSloped())
break;
if (footpath_element_get_slope_direction(tileElement) != (direction ^ 2))
if (tileElement->AsPath()->GetSlopeDirection() != (direction ^ 2))
break;
baseZ -= 2;

View File

@ -1022,7 +1022,7 @@ void rct_peep::UpdateFalling()
if (tile_element->GetType() == TILE_ELEMENT_TYPE_PATH)
{
int32_t height = map_height_from_slope(
{ x, y }, tile_element->properties.path.type, tile_element->AsPath()->IsSloped())
{ x, y }, tile_element->AsPath()->GetSlopeDirection(), tile_element->AsPath()->IsSloped())
+ tile_element->base_height * 8;
if (height < z - 1 || height > z + 4)
@ -1099,7 +1099,7 @@ void rct_peep::UpdateFalling()
}
else
{
SetNextFlags(saved_map->properties.path.type & 0x3, saved_map->properties.path.type & 0x4, false);
SetNextFlags(saved_map->AsPath()->GetSlopeDirection(), saved_map->AsPath()->IsSloped(), false);
}
SetState(PEEP_STATE_1);
}
@ -2634,7 +2634,7 @@ static void peep_interact_with_entrance(
if (nextTileElement->AsPath()->IsSloped())
{
uint8_t slopeDirection = footpath_element_get_slope_direction(nextTileElement);
uint8_t slopeDirection = nextTileElement->AsPath()->GetSlopeDirection();
if (slopeDirection == entranceDirection)
{
if (z != nextTileElement->base_height)
@ -2731,7 +2731,7 @@ static void peep_footpath_move_forward(rct_peep* peep, int16_t x, int16_t y, rct
peep->next_x = (x & 0xFFE0);
peep->next_y = (y & 0xFFE0);
peep->next_z = tile_element->base_height;
peep->SetNextFlags(tile_element->properties.path.type & 3, tile_element->properties.path.type & 4, false);
peep->SetNextFlags(tile_element->AsPath()->GetSlopeDirection(), tile_element->AsPath()->IsSloped(), false);
int16_t z = peep->GetZOnSlope(x, y);
@ -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 && tile_element->AsPath()->IsQueue())
{
uint8_t rideIndex = tile_element->properties.path.ride_index;
uint8_t rideIndex = tile_element->AsPath()->GetRideIndex();
if (peep->state == PEEP_STATE_QUEUING)
{
@ -2926,7 +2926,7 @@ static void peep_interact_with_path(rct_peep* peep, int16_t x, int16_t y, rct_ti
peep->time_lost = 0;
uint8_t stationNum = tile_element->AsPath()->GetStationIndex();
if ((tile_element->properties.path.type & (1 << 3)) // Queue has the ride sign on it
if ((tile_element->AsPath()->HasQueueBanner())
&& (tile_element->AsPath()->GetQueueBannerDirection()
== ((peep->direction) ^ 2)) // Ride sign is facing the direction the peep is walking
)
@ -3093,7 +3093,7 @@ bool is_valid_path_z_and_direction(rct_tile_element* tileElement, int32_t curren
{
if (tileElement->AsPath()->IsSloped())
{
int32_t slopeDirection = footpath_element_get_slope_direction(tileElement);
int32_t slopeDirection = tileElement->AsPath()->GetSlopeDirection();
if (slopeDirection == currentDirection)
{
if (currentZ != tileElement->base_height)

View File

@ -709,7 +709,7 @@ bool staff_can_ignore_wide_flag(rct_peep* staff, int32_t x, int32_t y, uint8_t z
if (path->AsPath()->IsSloped())
{
if (footpath_element_get_slope_direction(path) == adjac_dir)
if (path->AsPath()->GetSlopeDirection() == adjac_dir)
{
adjac_z = z + 2;
}
@ -1824,7 +1824,8 @@ void rct_peep::UpdateEmptyingBin()
return;
}
tile_element->properties.path.addition_status |= ((3 << var_37) << var_37);
uint8_t additionStatus = tile_element->AsPath()->GetAdditionStatus() | ((3 << var_37) << var_37);
tile_element->AsPath()->SetAdditionStatus(additionStatus);
map_invalidate_tile_zoom0(next_x, next_y, tile_element->base_height * 8, tile_element->clearance_height * 8);
@ -2224,7 +2225,7 @@ static int32_t peep_update_patrolling_find_bin(rct_peep* peep)
return 0;
uint8_t bin_positions = tileElement->properties.path.edges & 0xF;
uint8_t bin_quantity = tileElement->properties.path.addition_status;
uint8_t bin_quantity = tileElement->AsPath()->GetAdditionStatus();
uint8_t chosen_position = 0;
for (; chosen_position < 4; ++chosen_position)

View File

@ -3557,7 +3557,7 @@ static void ride_queue_banner_set_map_tooltip(rct_tile_element* tileElement)
int32_t rideIndex;
Ride* ride;
rideIndex = tileElement->properties.path.ride_index;
rideIndex = tileElement->AsPath()->GetRideIndex();
ride = get_ride(rideIndex);
set_map_tooltip_format_arg(0, rct_string_id, STR_RIDE_MAP_TIP);

View File

@ -370,12 +370,12 @@ static void track_design_save_add_wall(int32_t x, int32_t y, rct_tile_element* t
static void track_design_save_add_footpath(int32_t x, int32_t y, rct_tile_element* tileElement)
{
int32_t entryType = tileElement->properties.path.type >> 4;
int32_t entryType = tileElement->AsPath()->GetEntryIndex();
auto entry = object_entry_get_entry(OBJECT_TYPE_PATHS, entryType);
uint8_t flags = 0;
flags |= tileElement->properties.path.edges & FOOTPATH_PROPERTIES_EDGES_EDGES_MASK;
flags |= (tileElement->properties.path.type & FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK) << 5;
flags |= (tileElement->AsPath()->GetSlopeDirection()) << 5;
if (tileElement->AsPath()->IsSloped())
flags |= 0b00010000;
if (tileElement->AsPath()->IsQueue())
@ -557,13 +557,14 @@ static void track_design_save_remove_wall(int32_t x, int32_t y, rct_tile_element
static void track_design_save_remove_footpath(int32_t x, int32_t y, rct_tile_element* tileElement)
{
int32_t entryType = tileElement->properties.path.type >> 4;
int32_t entryType = tileElement->AsPath()->GetEntryIndex();
auto entry = object_entry_get_entry(OBJECT_TYPE_PATHS, entryType);
uint8_t flags = 0;
flags |= tileElement->properties.path.edges & FOOTPATH_PROPERTIES_EDGES_EDGES_MASK;
flags |= (tileElement->properties.path.type & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED) << 2;
flags |= (tileElement->properties.path.type & FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK) << 5;
if (tileElement->AsPath()->IsSloped())
flags |= (1 << 4);
flags |= (tileElement->AsPath()->GetSlopeDirection()) << 5;
if (tileElement->AsPath()->IsQueue())
flags |= (1 << 7);
@ -599,7 +600,7 @@ static bool track_design_save_should_select_scenery_around(int32_t rideIndex, rc
switch (tileElement->GetType())
{
case TILE_ELEMENT_TYPE_PATH:
if (tileElement->AsPath()->IsQueue() && tileElement->properties.path.ride_index == rideIndex)
if (tileElement->AsPath()->IsQueue() && tileElement->AsPath()->GetRideIndex() == rideIndex)
return true;
break;
case TILE_ELEMENT_TYPE_TRACK:
@ -636,7 +637,7 @@ static void track_design_save_select_nearby_scenery_for_tile(int32_t rideIndex,
case TILE_ELEMENT_TYPE_PATH:
if (!tileElement->AsPath()->IsQueue())
interactionType = VIEWPORT_INTERACTION_ITEM_FOOTPATH;
else if (tileElement->properties.path.ride_index == rideIndex)
else if (tileElement->AsPath()->GetRideIndex() == rideIndex)
interactionType = VIEWPORT_INTERACTION_ITEM_FOOTPATH;
break;
case TILE_ELEMENT_TYPE_SMALL_SCENERY:

View File

@ -154,14 +154,14 @@ rct_tile_element* map_get_footpath_element(int32_t x, int32_t y, int32_t z)
static rct_tile_element* map_get_footpath_element_slope(int32_t x, int32_t y, int32_t z, int32_t slope)
{
rct_tile_element* tileElement;
bool isSloped = slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED;
tileElement = map_get_first_element_at(x, y);
do
{
if (tileElement->GetType() == TILE_ELEMENT_TYPE_PATH && tileElement->base_height == z
&& (tileElement->properties.path.type
& (FOOTPATH_PROPERTIES_FLAG_IS_SLOPED | FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK))
== slope)
&& (tileElement->AsPath()->IsSloped() == isSloped)
&& (tileElement->AsPath()->GetSlopeDirection() == (slope & FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK)))
{
return tileElement;
}
@ -174,7 +174,7 @@ static void loc_6A6620(int32_t flags, int32_t x, int32_t y, rct_tile_element* ti
{
if (tileElement->AsPath()->IsSloped() && !(flags & GAME_COMMAND_FLAG_GHOST))
{
int32_t direction = footpath_element_get_slope_direction(tileElement);
int32_t direction = tileElement->AsPath()->GetSlopeDirection();
int32_t z = tileElement->base_height;
wall_remove_intersecting_walls(x, y, z, z + 6, direction ^ 2);
wall_remove_intersecting_walls(x, y, z, z + 6, direction);
@ -265,17 +265,21 @@ static money32 footpath_element_insert(
{
tileElement = tile_element_insert(x / 32, y / 32, z, 0x0F);
assert(tileElement != nullptr);
tileElement->type = TILE_ELEMENT_TYPE_PATH;
tileElement->clearance_height = z + 4 + ((slope & TILE_ELEMENT_SLOPE_NE_SIDE_UP) ? 2 : 0);
tileElement->AsPath()->SetEntryIndex(type);
tileElement->properties.path.type |= (slope & TILE_ELEMENT_SLOPE_W_CORNER_DN);
tileElement->SetType(TILE_ELEMENT_TYPE_PATH);
PathElement* pathElement = tileElement->AsPath();
pathElement->clearance_height = z + 4 + ((slope & FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK) ? 2 : 0);
pathElement->SetEntryIndex(type);
pathElement->SetSlopeDirection(slope & FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK);
if (slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED)
pathElement->SetSloped(true);
if (type & FOOTPATH_ELEMENT_INSERT_QUEUE)
tileElement->AsPath()->SetIsQueue(true);
tileElement->AsPath()->SetAddition(pathItemType);
tileElement->properties.path.addition_status = 255;
tileElement->flags &= ~TILE_ELEMENT_FLAG_BROKEN;
pathElement->SetIsQueue(true);
pathElement->SetAddition(pathItemType);
tileElement->AsPath()->SetRideIndex(RIDE_ID_NULL);
tileElement->AsPath()->SetAdditionStatus(255);
pathElement->flags &= ~TILE_ELEMENT_FLAG_BROKEN;
if (flags & GAME_COMMAND_FLAG_GHOST)
tileElement->flags |= TILE_ELEMENT_FLAG_GHOST;
pathElement->flags |= TILE_ELEMENT_FLAG_GHOST;
footpath_queue_chain_reset();
@ -384,7 +388,7 @@ static money32 footpath_element_update(
rct_scenery_entry* scenery_entry = get_footpath_item_entry(pathItemType - 1);
if (scenery_entry->path_bit.flags & PATH_BIT_FLAG_IS_BIN)
{
tileElement->properties.path.addition_status = 255;
tileElement->AsPath()->SetAdditionStatus(255);
}
}
map_invalidate_tile_full(x, y);
@ -402,8 +406,10 @@ static money32 footpath_element_update(
footpath_remove_edges_at(x, y, tileElement);
tileElement->AsPath()->SetEntryIndex(type);
tileElement->type = (tileElement->type & 0xFE) | (type >> 7);
if (type & (1 << 7))
tileElement->AsPath()->SetIsQueue(true);
else
tileElement->AsPath()->SetIsQueue(false);
tileElement->AsPath()->SetAddition(pathItemType);
tileElement->flags &= ~TILE_ELEMENT_FLAG_BROKEN;
@ -646,16 +652,28 @@ static money32 footpath_place_from_track(
{
tileElement = tile_element_insert(x / 32, y / 32, z, 0x0F);
assert(tileElement != nullptr);
tileElement->type = TILE_ELEMENT_TYPE_PATH;
tileElement->clearance_height = z + 4 + ((slope & TILE_ELEMENT_SLOPE_S_CORNER_UP) ? 2 : 0);
tileElement->properties.path.type = (type << 4) | (slope & TILE_ELEMENT_SLOPE_W_CORNER_DN);
tileElement->type |= type >> 7;
tileElement->AsPath()->SetAddition(0);
tileElement->properties.path.addition_status = 255;
tileElement->SetType(TILE_ELEMENT_TYPE_PATH);
PathElement* pathElement = tileElement->AsPath();
// This can NEVER happen, but GCC does not want to believe that...
if (pathElement == nullptr)
{
assert(false);
return MONEY32_UNDEFINED;
}
pathElement->clearance_height = z + 4 + ((slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED) ? 2 : 0);
pathElement->SetEntryIndex(type & 0xF);
pathElement->SetSlopeDirection(slope & FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK);
if (slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED)
pathElement->SetSloped(true);
if (type & (1 << 7))
tileElement->AsPath()->SetIsQueue(true);
pathElement->SetAddition(0);
tileElement->AsPath()->SetRideIndex(RIDE_ID_NULL);
tileElement->AsPath()->SetAdditionStatus(255);
tileElement->properties.path.edges = edges & FOOTPATH_PROPERTIES_EDGES_EDGES_MASK;
tileElement->flags &= ~TILE_ELEMENT_FLAG_BROKEN;
pathElement->flags &= ~TILE_ELEMENT_FLAG_BROKEN;
if (flags & (1 << 6))
tileElement->flags |= TILE_ELEMENT_FLAG_GHOST;
pathElement->flags |= TILE_ELEMENT_FLAG_GHOST;
map_invalidate_tile_full(x, y);
}
@ -932,7 +950,7 @@ void footpath_bridge_get_info_from_pos(
if (directions & 0x0F)
{
int32_t bx = bitscanforward(directions);
bx += (*tileElement)->type;
bx += (*tileElement)->AsEntrance()->GetDirection();
bx &= 3;
if (direction != nullptr)
*direction = bx;
@ -1231,7 +1249,7 @@ static rct_tile_element* footpath_get_element(int32_t x, int32_t y, int32_t z0,
{
if (tileElement->AsPath()->IsSloped())
{
slope = footpath_element_get_slope_direction(tileElement);
slope = tileElement->AsPath()->GetSlopeDirection();
if (slope != direction)
break;
}
@ -1242,7 +1260,7 @@ static rct_tile_element* footpath_get_element(int32_t x, int32_t y, int32_t z0,
if (!tileElement->AsPath()->IsSloped())
break;
slope = footpath_element_get_slope_direction(tileElement) ^ 2;
slope = tileElement->AsPath()->GetSlopeDirection() ^ 2;
if (slope != direction)
break;
@ -1266,13 +1284,13 @@ static bool sub_footpath_disconnect_queue_from_path(
rct_tile_element* otherTileElement = footpath_get_element(x1, y1, z - 2, z, direction);
if (otherTileElement != nullptr && !otherTileElement->AsPath()->IsQueue())
{
tileElement->properties.path.type &= ~FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK;
tileElement->AsPath()->SetSlopeDirection(0);
if (action > 0)
{
tileElement->properties.path.edges &= ~(1 << direction);
otherTileElement->properties.path.edges &= ~(1 << ((direction + 2) & 3));
if (action >= 2)
tileElement->properties.path.type |= direction;
tileElement->AsPath()->SetSlopeDirection(direction);
}
else if (action < 0)
{
@ -1300,14 +1318,14 @@ static bool footpath_disconnect_queue_from_path(int32_t x, int32_t y, rct_tile_e
if (action < 0)
{
uint8_t direction = footpath_element_get_slope_direction(tileElement);
uint8_t direction = tileElement->AsPath()->GetSlopeDirection();
if (sub_footpath_disconnect_queue_from_path(x, y, tileElement, action, direction))
return true;
}
for (int32_t direction = 0; direction < 4; direction++)
{
if ((action < 0) && (direction == footpath_element_get_slope_direction(tileElement)))
if ((action < 0) && (direction == tileElement->AsPath()->GetSlopeDirection()))
continue;
if (sub_footpath_disconnect_queue_from_path(x, y, tileElement, action, direction))
return true;
@ -1343,7 +1361,7 @@ static void loc_6A6D7E(
case TILE_ELEMENT_TYPE_PATH:
if (z == tileElement->base_height)
{
if (tileElement->AsPath()->IsSloped() && footpath_element_get_slope_direction(tileElement) != direction)
if (tileElement->AsPath()->IsSloped() && tileElement->AsPath()->GetSlopeDirection() != direction)
{
return;
}
@ -1354,8 +1372,7 @@ static void loc_6A6D7E(
}
if (z - 2 == tileElement->base_height)
{
if (!tileElement->AsPath()->IsSloped()
|| footpath_element_get_slope_direction(tileElement) != (direction ^ 2))
if (!tileElement->AsPath()->IsSloped() || tileElement->AsPath()->GetSlopeDirection() != (direction ^ 2))
{
return;
}
@ -1427,8 +1444,8 @@ static void loc_6A6D7E(
if (connected_path_count[tileElement->properties.path.edges & FOOTPATH_PROPERTIES_EDGES_EDGES_MASK] < 2)
{
neighbour_list_push(
neighbourList, 4, direction, tileElement->properties.path.ride_index,
tileElement->properties.path.additions);
neighbourList, 4, direction, tileElement->AsPath()->GetRideIndex(),
tileElement->AsPath()->GetStationIndex());
}
else
{
@ -1437,8 +1454,8 @@ static void loc_6A6D7E(
if (footpath_disconnect_queue_from_path(x, y, tileElement, 0))
{
neighbour_list_push(
neighbourList, 3, direction, tileElement->properties.path.ride_index,
tileElement->properties.path.additions);
neighbourList, 3, direction, tileElement->AsPath()->GetRideIndex(),
tileElement->AsPath()->GetStationIndex());
}
}
}
@ -1454,7 +1471,7 @@ static void loc_6A6D7E(
tileElement->properties.path.edges |= (1 << (direction ^ 2));
if (tileElement->AsPath()->IsQueue())
{
footpath_queue_chain_push(tileElement->properties.path.ride_index);
footpath_queue_chain_push(tileElement->AsPath()->GetRideIndex());
}
}
if (!(flags & (GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED)))
@ -1515,11 +1532,11 @@ static void loc_6A6C85(
{
if (tileElement->AsPath()->IsSloped())
{
if ((footpath_element_get_slope_direction(tileElement) - direction) & 1)
if ((tileElement->AsPath()->GetSlopeDirection() - direction) & 1)
{
return;
}
if (footpath_element_get_slope_direction(tileElement) == direction)
if (tileElement->AsPath()->GetSlopeDirection() == direction)
{
z += 2;
}
@ -1613,7 +1630,7 @@ void footpath_chain_ride_queue(
lastPathDirection = direction;
if (tileElement->AsPath()->IsSloped())
{
if (footpath_element_get_slope_direction(tileElement) == direction)
if (tileElement->AsPath()->GetSlopeDirection() == direction)
{
z += 2;
}
@ -1633,7 +1650,7 @@ void footpath_chain_ride_queue(
{
if (tileElement->AsPath()->IsSloped())
{
if (footpath_element_get_slope_direction(tileElement) != direction)
if (tileElement->AsPath()->GetSlopeDirection() != direction)
break;
}
goto foundNextPath;
@ -1643,7 +1660,7 @@ void footpath_chain_ride_queue(
if (!tileElement->AsPath()->IsSloped())
break;
if ((footpath_element_get_slope_direction(tileElement) ^ 2) != direction)
if ((tileElement->AsPath()->GetSlopeDirection() ^ 2) != direction)
break;
z -= 2;
@ -1668,9 +1685,9 @@ void footpath_chain_ride_queue(
}
}
tileElement->properties.path.type &= ~FOOTPATH_PROPERTIES_FLAG_HAS_QUEUE_BANNER;
tileElement->AsPath()->SetHasQueueBanner(false);
tileElement->properties.path.edges |= (1 << (direction ^ 2));
tileElement->properties.path.ride_index = rideIndex;
tileElement->AsPath()->SetRideIndex(rideIndex);
tileElement->AsPath()->SetStationIndex(entranceIndex);
map_invalidate_element(x, y, tileElement);
@ -1698,7 +1715,7 @@ void footpath_chain_ride_queue(
{
if (lastPathElement->AsPath()->IsQueue())
{
lastPathElement->properties.path.type |= FOOTPATH_PROPERTIES_FLAG_HAS_QUEUE_BANNER;
lastPathElement->AsPath()->SetHasQueueBanner(true);
lastPathElement->AsPath()->SetQueueBannerDirection(lastPathDirection); // set the ride sign direction
map_animation_create(MAP_ANIMATION_TYPE_QUEUE_BANNER, lastPathX, lastPathY, lastPathElement->base_height);
@ -1840,8 +1857,7 @@ static int32_t footpath_is_connected_to_map_edge_recurse(
if (tileElement->GetType() != TILE_ELEMENT_TYPE_PATH)
continue;
if (tileElement->AsPath()->IsSloped()
&& (slopeDirection = footpath_element_get_slope_direction(tileElement)) != direction)
if (tileElement->AsPath()->IsSloped() && (slopeDirection = tileElement->AsPath()->GetSlopeDirection()) != direction)
{
if ((slopeDirection ^ 2) != direction)
continue;
@ -1869,24 +1885,24 @@ static int32_t footpath_is_connected_to_map_edge_recurse(
direction ^= 2;
if (!(flags & (1 << 7)))
{
if (tileElement[1].type == TILE_ELEMENT_TYPE_BANNER)
if (tileElement[1].GetType() == TILE_ELEMENT_TYPE_BANNER)
{
for (int32_t i = 1; i < 4; i++)
{
if ((&tileElement[i - 1])->IsLastForTile())
break;
if (tileElement[i].type != TILE_ELEMENT_TYPE_BANNER)
if (tileElement[i].GetType() != TILE_ELEMENT_TYPE_BANNER)
break;
edges &= tileElement[i].AsBanner()->GetAllowedEdges();
}
}
if (tileElement[2].type == TILE_ELEMENT_TYPE_BANNER && tileElement[1].type != TILE_ELEMENT_TYPE_PATH)
if (tileElement[2].GetType() == TILE_ELEMENT_TYPE_BANNER && tileElement[1].GetType() != TILE_ELEMENT_TYPE_PATH)
{
for (int32_t i = 1; i < 6; i++)
{
if ((&tileElement[i - 1])->IsLastForTile())
break;
if (tileElement[i].type != TILE_ELEMENT_TYPE_BANNER)
if (tileElement[i].GetType() != TILE_ELEMENT_TYPE_BANNER)
break;
edges &= tileElement[i].AsBanner()->GetAllowedEdges();
}
@ -1911,7 +1927,7 @@ searchFromFootpath:
if (edges == 0)
{
// Only possible direction to go
if (tileElement->AsPath()->IsSloped() && footpath_element_get_slope_direction(tileElement) == direction)
if (tileElement->AsPath()->IsSloped() && tileElement->AsPath()->GetSlopeDirection() == direction)
{
z += 2;
}
@ -1934,7 +1950,7 @@ searchFromFootpath:
do
{
edges &= ~(1 << direction);
if (tileElement->AsPath()->IsSloped() && footpath_element_get_slope_direction(tileElement) == direction)
if (tileElement->AsPath()->IsSloped() && tileElement->AsPath()->GetSlopeDirection() == direction)
{
z += 2;
}
@ -1967,9 +1983,15 @@ void PathElement::SetSloped(bool isSloped)
entryIndex |= FOOTPATH_PROPERTIES_FLAG_IS_SLOPED;
}
uint8_t footpath_element_get_slope_direction(const rct_tile_element* tileElement)
uint8_t PathElement::GetSlopeDirection() const
{
return tileElement->properties.path.type & FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK;
return entryIndex & FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK;
}
void PathElement::SetSlopeDirection(uint8_t newSlope)
{
entryIndex &= ~FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK;
entryIndex |= newSlope & FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK;
}
bool PathElement::IsQueue() const
@ -1989,6 +2011,13 @@ bool PathElement::HasQueueBanner() const
return (entryIndex & FOOTPATH_PROPERTIES_FLAG_HAS_QUEUE_BANNER) != 0;
}
void PathElement::SetHasQueueBanner(bool hasQueueBanner)
{
entryIndex &= ~FOOTPATH_PROPERTIES_FLAG_HAS_QUEUE_BANNER;
if (hasQueueBanner)
entryIndex |= FOOTPATH_PROPERTIES_FLAG_HAS_QUEUE_BANNER;
}
uint8_t PathElement::GetStationIndex() const
{
return (additions & FOOTPATH_PROPERTIES_ADDITIONS_STATION_INDEX_MASK) >> 4;
@ -2338,7 +2367,7 @@ void footpath_update_queue_entrance_banner(int32_t x, int32_t y, rct_tile_elemen
case TILE_ELEMENT_TYPE_PATH:
if (tileElement->AsPath()->IsQueue())
{
footpath_queue_chain_push(tileElement->properties.path.ride_index);
footpath_queue_chain_push(tileElement->AsPath()->GetRideIndex());
for (int32_t direction = 0; direction < 4; direction++)
{
if (tileElement->properties.path.edges & (1 << direction))
@ -2346,7 +2375,7 @@ void footpath_update_queue_entrance_banner(int32_t x, int32_t y, rct_tile_elemen
footpath_chain_ride_queue(255, 0, x, y, tileElement, direction);
}
}
tileElement->properties.path.ride_index = 255;
tileElement->AsPath()->SetRideIndex(RIDE_ID_NULL);
}
break;
case TILE_ELEMENT_TYPE_ENTRANCE:
@ -2370,7 +2399,7 @@ static void footpath_remove_edges_towards_here(
if (tileElement->AsPath()->IsQueue())
{
footpath_queue_chain_push(tileElement->properties.path.ride_index);
footpath_queue_chain_push(tileElement->AsPath()->GetRideIndex());
}
d = direction ^ 2;
@ -2427,7 +2456,7 @@ static void footpath_remove_edges_towards(int32_t x, int32_t y, int32_t z0, int3
{
if (tileElement->AsPath()->IsSloped())
{
uint8_t slope = footpath_element_get_slope_direction(tileElement);
uint8_t slope = tileElement->AsPath()->GetSlopeDirection();
if (slope != direction)
break;
}
@ -2440,7 +2469,7 @@ static void footpath_remove_edges_towards(int32_t x, int32_t y, int32_t z0, int3
if (!tileElement->AsPath()->IsSloped())
break;
uint8_t slope = footpath_element_get_slope_direction(tileElement) ^ 2;
uint8_t slope = tileElement->AsPath()->GetSlopeDirection() ^ 2;
if (slope != direction)
break;
@ -2469,14 +2498,13 @@ bool tile_element_wants_path_connection_towards(TileCoordsXYZD coords, const rct
if (!tileElement->AsPath()->IsSloped())
// The footpath is flat, it can be connected to from any direction
return true;
else if (footpath_element_get_slope_direction(tileElement) == (coords.direction ^ 2))
else if (tileElement->AsPath()->GetSlopeDirection() == (coords.direction ^ 2))
// The footpath is sloped and its lowest point matches the edge connection
return true;
}
else if (tileElement->base_height + 2 == coords.z)
{
if (tileElement->AsPath()->IsSloped()
&& footpath_element_get_slope_direction(tileElement) == coords.direction)
if (tileElement->AsPath()->IsSloped() && tileElement->AsPath()->GetSlopeDirection() == coords.direction)
// The footpath is sloped and its higher point matches the edge connection
return true;
}
@ -2585,7 +2613,7 @@ void footpath_remove_edges_at(int32_t x, int32_t y, rct_tile_element* tileElemen
{
if (tileElement->AsPath()->IsSloped())
{
int32_t slope = footpath_element_get_slope_direction(tileElement);
int32_t slope = tileElement->AsPath()->GetSlopeDirection();
// Sloped footpaths don't connect sideways
if ((slope - direction) & 1)
continue;
@ -2638,3 +2666,23 @@ uint8_t footpath_get_edges(const rct_tile_element* element)
{
return element->properties.path.edges & 0xF;
}
uint8_t PathElement::GetRideIndex() const
{
return rideIndex;
}
void PathElement::SetRideIndex(uint8_t newRideIndex)
{
rideIndex = newRideIndex;
}
uint8_t PathElement::GetAdditionStatus() const
{
return additionStatus;
}
void PathElement::SetAdditionStatus(uint8_t newStatus)
{
additionStatus = newStatus;
}

View File

@ -154,7 +154,6 @@ void footpath_update_path_wide_flags(int32_t x, int32_t y);
bool footpath_is_blocked_by_vehicle(const TileCoordsXYZ& position);
int32_t footpath_is_connected_to_map_edge(int32_t x, int32_t y, int32_t z, int32_t direction, int32_t flags);
uint8_t footpath_element_get_slope_direction(const rct_tile_element* tileElement);
void footpath_remove_edges_at(int32_t x, int32_t y, rct_tile_element* tileElement);
int32_t entrance_get_directions(const rct_tile_element* tileElement);

View File

@ -629,17 +629,16 @@ bool map_coord_is_connected(int32_t x, int32_t y, int32_t z, uint8_t faceDirecti
if (tileElement->GetType() != TILE_ELEMENT_TYPE_PATH)
continue;
rct_tile_element_path_properties props = tileElement->properties.path;
uint8_t pathDirection = props.type & 3;
uint8_t slopeDirection = tileElement->AsPath()->GetSlopeDirection();
if (tileElement->AsPath()->IsSloped())
{
if (pathDirection == faceDirection)
if (slopeDirection == faceDirection)
{
if (z == tileElement->base_height + 2)
return true;
}
else if ((pathDirection ^ 2) == faceDirection && z == tileElement->base_height)
else if ((slopeDirection ^ 2) == faceDirection && z == tileElement->base_height)
{
return true;
}
@ -2812,7 +2811,7 @@ void game_command_set_water_height(
if (gCheatsDisableClearanceChecks || map_can_construct_at(x, y, zLow, zHigh, 0xFF))
{
if (tile_element->type & 0x40)
if (tile_element->AsSurface()->HasTrackThatNeedsWater())
{
gGameCommandErrorText = 0;
*ebx = MONEY32_UNDEFINED;
@ -3139,8 +3138,8 @@ void map_remove_all_rides()
case TILE_ELEMENT_TYPE_PATH:
if (it.element->AsPath()->IsQueue())
{
it.element->properties.path.type &= ~8;
it.element->properties.path.addition_status = 255;
it.element->AsPath()->SetHasQueueBanner(false);
it.element->AsPath()->SetRideIndex(RIDE_ID_NULL);
}
break;
case TILE_ELEMENT_TYPE_ENTRANCE:

View File

@ -431,8 +431,8 @@ void game_command_set_scenery_colour(
int32_t* ebp)
{
*ebx = SmallScenerySetColour(
*eax & 0xFFFF, *ecx & 0xFFFF, *edx & 0xFF, ((*ebx >> 8) & 0xFF) >> 6, (*edx >> 8) & 0xFF, *ebp & 0xFF,
(*ebp >> 8) & 0xFF, *ebx & 0xFF);
*eax & 0xFFFF, *ecx & 0xFFFF, *edx & 0xFF, ((*ebx >> 8) & 0xFF), (*edx >> 8) & 0xFF, *ebp & 0xFF, (*ebp >> 8) & 0xFF,
*ebx & 0xFF);
}
/**

View File

@ -134,7 +134,7 @@ uint8_t tile_element_get_ride_index(const rct_tile_element* tileElement)
case TILE_ELEMENT_TYPE_ENTRANCE:
return tileElement->AsEntrance()->GetRideIndex();
case TILE_ELEMENT_TYPE_PATH:
return tileElement->properties.path.ride_index;
return tileElement->AsPath()->GetRideIndex();
default:
return 0xFF;
}

View File

@ -188,8 +188,8 @@ assert_struct_size(SurfaceElement, 8);
struct PathElement : TileElementBase
{
private:
uint8_t entryIndex; // 4 0xF0 Path type, 0x08 Ride sign, 0x04 Set when path is diagonal, 0x03 Rotation
uint8_t additions; // 5
uint8_t entryIndex; // 4, 0xF0 Path type, 0x08 Ride sign, 0x04 Set when path is sloped, 0x03 Rotation
uint8_t additions; // 5, 0bGSSSAAAA: G = Ghost, S = station index, A = addition (0 means no addition)
uint8_t edges; // 6
union
{
@ -208,6 +208,12 @@ public:
bool IsSloped() const;
void SetSloped(bool isSloped);
uint8_t GetSlopeDirection() const;
void SetSlopeDirection(uint8_t newSlope);
uint8_t GetRideIndex() const;
void SetRideIndex(uint8_t newRideIndex);
uint8_t GetStationIndex() const;
void SetStationIndex(uint8_t newStationIndex);
@ -217,6 +223,7 @@ public:
bool IsQueue() const;
void SetIsQueue(bool isQueue);
bool HasQueueBanner() const;
void SetHasQueueBanner(bool hasQueueBanner);
bool HasAddition() const;
uint8_t GetAddition() const;
@ -227,6 +234,9 @@ public:
bool AdditionIsGhost() const;
void SetAdditionIsGhost(bool isGhost);
uint8_t GetAdditionStatus() const;
void SetAdditionStatus(uint8_t newStatus);
uint8_t GetRCT1PathType() const;
};
assert_struct_size(PathElement, 8);

View File

@ -224,9 +224,8 @@ int32_t tile_inspector_rotate_element_at(int32_t x, int32_t y, int32_t elementIn
case TILE_ELEMENT_TYPE_PATH:
if (tileElement->AsPath()->IsSloped())
{
newRotation = (footpath_element_get_slope_direction(tileElement) + 1) & TILE_ELEMENT_DIRECTION_MASK;
tileElement->properties.path.type &= ~TILE_ELEMENT_DIRECTION_MASK;
tileElement->properties.path.type |= newRotation;
newRotation = (tileElement->AsPath()->GetSlopeDirection() + 1) & TILE_ELEMENT_DIRECTION_MASK;
tileElement->AsPath()->SetSlopeDirection(newRotation);
}
pathEdges = tileElement->properties.path.edges & 0x0F;
pathCorners = tileElement->properties.path.edges & 0xF0;
@ -612,11 +611,7 @@ int32_t tile_inspector_path_set_sloped(int32_t x, int32_t y, int32_t elementInde
if (flags & GAME_COMMAND_FLAG_APPLY)
{
pathElement->properties.path.type &= ~(1 << 2);
if (sloped)
{
pathElement->properties.path.type |= (1 << 2);
}
pathElement->AsPath()->SetSloped(sloped);
map_invalidate_tile_full(x << 5, y << 5);