Refactor access to some footpath stuff

This commit is contained in:
Michael Steenbeek 2017-12-08 16:47:54 +01:00
parent 02128131e2
commit 9ea5302a2a
7 changed files with 126 additions and 58 deletions

View File

@ -316,7 +316,7 @@ sint32 viewport_interaction_get_item_right(sint32 x, sint32 y, viewport_interact
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 (tileElement->type & 1)
if (footpath_element_is_queue(tileElement))
set_map_tooltip_format_arg(2, rct_string_id, STR_QUEUE_LINE_MAP_TIP);
return info->type;
@ -467,7 +467,7 @@ static void viewport_interaction_remove_footpath_item(rct_tile_element *tileElem
sint32 type;
type = tileElement->properties.path.type >> 4;
if (tileElement->type & 1)
if (footpath_element_is_queue(tileElement))
type |= 0x80;
gGameCommandErrorTitle = STR_CANT_REMOVE_THIS;

View File

@ -80,6 +80,8 @@ static const uint8 byte_98D8A4[] = {
void path_paint_box_support(paint_session * session, rct_tile_element * tileElement, sint32 height, rct_footpath_entry * footpathEntry, bool hasFences, uint32 imageFlags, uint32 sceneryImageFlags);
void path_paint_pole_support(paint_session * session, rct_tile_element* tileElement, sint16 height, rct_footpath_entry* footpathEntry, bool hasFences, uint32 imageFlags, uint32 sceneryImageFlags);
/* rct2: 0x006A5AE5 */
static void path_bit_lights_paint(paint_session * session, rct_scenery_entry* pathBitEntry, rct_tile_element* tileElement, sint32 height, uint8 edges, uint32 pathBitImageFlags) {
if (footpath_element_is_sloped(tileElement))
@ -358,7 +360,7 @@ static void sub_6A4101(paint_session * session, rct_tile_element * tile_element,
return;
}
uint8 direction = ((tile_element->type & 0xC0) >> 6);
uint8 direction = footpath_element_get_direction(tile_element);
// Draw ride sign
session->InteractionType = VIEWPORT_INTERACTION_ITEM_RIDE;
if (footpath_element_is_sloped(tile_element)) {
@ -1045,3 +1047,5 @@ void path_paint_pole_support(paint_session * session, rct_tile_element* tileElem
paint_util_set_segment_support_height(session, SEGMENT_C8, 0xFFFF, 0);
}
}

View File

@ -8958,7 +8958,7 @@ static sint32 peep_interact_with_entrance(rct_peep * peep, sint16 x, sint16 y, r
if (tile_element_get_type(nextTileElement) != TILE_ELEMENT_TYPE_PATH)
continue;
if (nextTileElement->type & 1)
if (footpath_element_is_queue(nextTileElement))
continue;
if (footpath_element_is_sloped(nextTileElement))
@ -9252,7 +9252,7 @@ static sint32 peep_interact_with_path(rct_peep * peep, sint16 x, sint16 y, rct_t
uint8 stationNum = (tile_element->properties.path.additions & 0x70) >> 4;
if ((tile_element->properties.path.type & (1 << 3)) // Queue has the ride sign on it
&& (((tile_element->type & (3 << 6)) >> 6) ==
&& (footpath_element_get_direction(tile_element) ==
((peep->direction) ^ 2)) // Ride sign is facing the direction the peep is walking
)
{

View File

@ -24,6 +24,7 @@
#include "../ride/Track.h"
#include "../ride/TrackData.h"
#include "../util/util.h"
#include "map.h"
void footpath_interrupt_peeps(sint32 x, sint32 y, sint32 z);
void footpath_update_queue_entrance_banner(sint32 x, sint32 y, rct_tile_element *tileElement);
@ -80,7 +81,7 @@ static const uint8 connected_path_count[] = {
4, // 0b1111
};
sint32 entrance_get_directions(rct_tile_element *tileElement)
sint32 entrance_get_directions(const rct_tile_element * tileElement)
{
uint8 entranceType = tileElement->properties.entrance.type;
uint8 sequence = tileElement->properties.entrance.index & 0x0F;
@ -151,8 +152,9 @@ static rct_tile_element *map_get_footpath_element_slope(sint32 x, sint32 y, sint
static void loc_6A6620(sint32 flags, sint32 x, sint32 y, rct_tile_element *tileElement)
{
if ((tileElement->properties.path.type & 4) && !(flags & GAME_COMMAND_FLAG_GHOST)) {
sint32 direction = tileElement->properties.path.type & 3;
if (footpath_element_is_sloped(tileElement) && !(flags & GAME_COMMAND_FLAG_GHOST))
{
sint32 direction = footpath_element_get_slope_direction(tileElement);
sint32 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);
@ -235,7 +237,8 @@ static money32 footpath_element_insert(sint32 type, sint32 x, sint32 y, sint32 z
assert(tileElement != NULL);
tileElement->type = TILE_ELEMENT_TYPE_PATH;
tileElement->clearance_height = z + 4 + ((slope & TILE_ELEMENT_SLOPE_NE_SIDE_UP) ? 2 : 0);
tileElement->properties.path.type = (type << 4) | (slope & TILE_ELEMENT_SLOPE_W_CORNER_DN);
footpath_element_set_type(tileElement, type);
tileElement->properties.path.type |= (slope & TILE_ELEMENT_SLOPE_W_CORNER_DN);
tileElement->type |= type >> 7;
tileElement->properties.path.additions = pathItemType;
tileElement->properties.path.addition_status = 255;
@ -264,7 +267,7 @@ static money32 footpath_element_insert(sint32 type, sint32 x, sint32 y, sint32 z
static money32 footpath_element_update(sint32 x, sint32 y, rct_tile_element *tileElement, sint32 type, sint32 flags, uint8 pathItemType)
{
if ((tileElement->properties.path.type >> 4) != (type & 0x0F) || (tileElement->type & 1) != (type >> 7)) {
if (footpath_element_get_type(tileElement) != (type & 0x0F) || (tileElement->type & 1) != (type >> 7)) {
gFootpathPrice += MONEY(6, 00);
} else if (pathItemType != 0) {
if (
@ -352,7 +355,8 @@ static money32 footpath_element_update(sint32 x, sint32 y, rct_tile_element *til
if (!(flags & GAME_COMMAND_FLAG_PATH_SCENERY))
footpath_remove_edges_at(x, y, tileElement);
tileElement->properties.path.type = (tileElement->properties.path.type & 0x0F) | (type << 4);
tileElement->properties.path.type = (tileElement->properties.path.type & 0x0F);
footpath_element_set_type(tileElement, type);
tileElement->type = (tileElement->type & 0xFE) | (type >> 7);
footpath_element_set_path_scenery(tileElement, pathItemType);
tileElement->flags &= ~TILE_ELEMENT_FLAG_BROKEN;
@ -1533,7 +1537,7 @@ void footpath_chain_ride_queue(sint32 rideIndex, sint32 entranceIndex, sint32 x,
if (footpath_element_is_queue(lastPathElement)) {
lastPathElement->properties.path.type |= (1 << 3); // Set the ride sign flag
lastPathElement->type &= 0x3F; // Clear the ride sign direction
lastPathElement->type |= lastPathDirection << 6; // set the ride sign direction
footpath_element_set_direction(lastPathElement, lastPathDirection); // set the ride sign direction
map_animation_create(
MAP_ANIMATION_TYPE_QUEUE_BANNER,
@ -1767,63 +1771,96 @@ sint32 footpath_is_connected_to_map_edge(sint32 x, sint32 y, sint32 z, sint32 di
return footpath_is_connected_to_map_edge_recurse(x, y, z, direction, flags, 0, 0, 16);
}
bool footpath_element_is_sloped(rct_tile_element *tileElement)
bool footpath_element_is_sloped(const rct_tile_element * tileElement)
{
return tileElement->properties.path.type & 4;
return tileElement->properties.path.type & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED;
}
uint8 footpath_element_get_slope_direction(rct_tile_element *tileElement)
void footpath_element_set_sloped(rct_tile_element * tileElement, bool isSloped)
{
return tileElement->properties.path.type & 3;
if (isSloped)
tileElement->properties.path.type |= FOOTPATH_PROPERTIES_FLAG_IS_SLOPED;
else
tileElement->properties.path.type &= ~FOOTPATH_PROPERTIES_FLAG_IS_SLOPED;
}
bool footpath_element_is_queue(rct_tile_element *tileElement)
uint8 footpath_element_get_slope_direction(const rct_tile_element * tileElement)
{
return tileElement->type & 1;
return tileElement->properties.path.type & FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK;
}
bool footpath_element_is_wide(rct_tile_element *tileElement)
bool footpath_element_is_queue(const rct_tile_element * tileElement)
{
return tileElement->type & 2;
return tileElement->type & FOOTPATH_ELEMENT_TYPE_FLAG_IS_QUEUE;
}
bool footpath_element_has_path_scenery(rct_tile_element *tileElement)
bool footpath_element_is_wide(const rct_tile_element * tileElement)
{
return tileElement->type & FOOTPATH_ELEMENT_TYPE_FLAG_IS_WIDE;
}
void footpath_element_set_wide(rct_tile_element * tileElement, bool isWide)
{
if (isWide)
tileElement->type |= FOOTPATH_ELEMENT_TYPE_FLAG_IS_WIDE;
else
tileElement->type &= ~FOOTPATH_ELEMENT_TYPE_FLAG_IS_WIDE;
}
bool footpath_element_has_path_scenery(const rct_tile_element * tileElement)
{
return (tileElement->properties.path.additions & 0xF) > 0;
}
uint8 footpath_element_get_path_scenery(rct_tile_element *tileElement)
uint8 footpath_element_get_path_scenery(const rct_tile_element * tileElement)
{
return tileElement->properties.path.additions & 0xF;
}
void footpath_element_set_path_scenery(rct_tile_element *tileElement, uint8 pathSceneryType)
void footpath_element_set_path_scenery(rct_tile_element * tileElement, uint8 pathSceneryType)
{
tileElement->properties.path.additions = (tileElement->properties.path.additions & 0xF0) | pathSceneryType;
}
uint8 footpath_element_get_path_scenery_index(rct_tile_element *tileElement)
uint8 footpath_element_get_path_scenery_index(const rct_tile_element * tileElement)
{
return footpath_element_get_path_scenery(tileElement) - 1;
}
bool footpath_element_path_scenery_is_ghost(rct_tile_element *tileElement)
bool footpath_element_path_scenery_is_ghost(const rct_tile_element * tileElement)
{
return (tileElement->properties.path.additions & 0x80) == 0x80;
return (tileElement->properties.path.additions & FOOTPATH_ADDITION_FLAG_IS_GHOST) == FOOTPATH_ADDITION_FLAG_IS_GHOST;
}
void footpath_scenery_set_is_ghost(rct_tile_element *tileElement, bool isGhost)
{
// Remove ghost flag
tileElement->properties.path.additions &= ~0x80;
tileElement->properties.path.additions &= ~FOOTPATH_ADDITION_FLAG_IS_GHOST;
// Set flag if it should be a ghost
if (isGhost)
tileElement->properties.path.additions |= 0x80;
tileElement->properties.path.additions |= FOOTPATH_ADDITION_FLAG_IS_GHOST;
}
uint8 footpath_element_get_type(rct_tile_element *tileElement)
uint8 footpath_element_get_type(const rct_tile_element * tileElement)
{
return tileElement->properties.path.type >> 4;
return (tileElement->properties.path.type & FOOTPATH_PROPERTIES_TYPE_MASK) >> 4;
}
void footpath_element_set_type(rct_tile_element * tileElement, uint8 type)
{
tileElement->properties.path.type &= ~FOOTPATH_PROPERTIES_TYPE_MASK;
tileElement->properties.path.type |= (type << 4);
}
uint8 footpath_element_get_direction(const rct_tile_element * tileElement)
{
return ((tileElement->type & FOOTPATH_ELEMENT_TYPE_DIRECTION_MASK) >> 6);
}
void footpath_element_set_direction(rct_tile_element * tileElement, uint8 direction)
{
tileElement->type &= ~FOOTPATH_ELEMENT_TYPE_DIRECTION_MASK;
tileElement->type |= (direction << 6);
}
/**
@ -1835,11 +1872,13 @@ uint8 footpath_element_get_type(rct_tile_element *tileElement)
static void footpath_clear_wide(sint32 x, sint32 y)
{
rct_tile_element *tileElement = map_get_first_element_at(x / 32, y / 32);
do {
do
{
if (tile_element_get_type(tileElement) != TILE_ELEMENT_TYPE_PATH)
continue;
tileElement->type &= ~0x2;
} while (!tile_element_is_last_for_tile(tileElement++));
footpath_element_set_wide(tileElement, false);
}
while (!tile_element_is_last_for_tile(tileElement++));
}
/**
@ -2051,8 +2090,8 @@ void footpath_update_path_wide_flags(sint32 x, sint32 y)
if (!(F3EFA5 & (0x2 | 0x8 | 0x20 | 0x80))) {
uint8 e = tileElement->properties.path.edges;
if ((e != 0xAF) && (e != 0x5F) && (e != 0xEF))
tileElement->type |= 2;
if ((e != 0b10101111) && (e != 0b01011111) && (e != 0b11101111))
footpath_element_set_wide(tileElement, true);
}
} while (!tile_element_is_last_for_tile(tileElement++));
}

View File

@ -39,6 +39,21 @@ typedef struct rct_footpath_entry {
assert_struct_size(rct_footpath_entry, 13);
#pragma pack(pop)
enum
{
FOOTPATH_ELEMENT_TYPE_FLAG_IS_QUEUE = (1 << 0),
FOOTPATH_ELEMENT_TYPE_FLAG_IS_WIDE = (1 << 1),
FOOTPATH_ELEMENT_TYPE_DIRECTION_MASK = (1 << 6) | (1 << 7),
};
enum
{
FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK = (1 << 0) | (1 << 1),
FOOTPATH_PROPERTIES_FLAG_IS_SLOPED = (1 << 2),
FOOTPATH_PROPERTIES_TYPE_MASK = (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7),
};
enum {
FOOTPATH_ENTRY_SUPPORT_TYPE_BOX = 0,
FOOTPATH_ENTRY_SUPPORT_TYPE_POLE = 1,
@ -58,6 +73,11 @@ enum {
FOOTPATH_SEARCH_TOO_COMPLEX
};
enum
{
FOOTPATH_ADDITION_FLAG_IS_GHOST = (1 << 7),
};
enum
{
FOOTPATH_CLEAR_DIRECTIONAL = (1 << 8), // Flag set when direction is used.
@ -84,40 +104,43 @@ extern uint8 gFootpathGroundFlags;
extern const LocationXY16 word_981D6C[4];
money32 footpath_remove_real(sint32 x, sint32 y, sint32 z, sint32 flags);
void game_command_place_footpath(sint32 *eax, sint32 *ebx, sint32 *ecx, sint32 *edx, sint32 *esi, sint32 *edi, sint32 *ebp);
void game_command_place_footpath_from_track(sint32 *eax, sint32 *ebx, sint32 *ecx, sint32 *edx, sint32 *esi, sint32 *edi, sint32 *ebp);
void game_command_remove_footpath(sint32 *eax, sint32 *ebx, sint32 *ecx, sint32 *edx, sint32 *esi, sint32 *edi, sint32 *ebp);
void game_command_place_footpath(sint32 * eax, sint32 * ebx, sint32 * ecx, sint32 * edx, sint32 * esi, sint32 * edi, sint32 * ebp);
void game_command_place_footpath_from_track(sint32 * eax, sint32 * ebx, sint32 * ecx, sint32 * edx, sint32 * esi, sint32 * edi, sint32 * ebp);
void game_command_remove_footpath(sint32 * eax, sint32 * ebx, sint32 * ecx, sint32 * edx, sint32 * esi, sint32 * edi, sint32 * ebp);
money32 footpath_place(sint32 type, sint32 x, sint32 y, sint32 z, sint32 slope, sint32 flags);
money32 footpath_place_remove_intersecting(sint32 type, sint32 x, sint32 y, sint32 z, sint32 slope, sint32 flags, sint32 direction);
void footpath_remove(sint32 x, sint32 y, sint32 z, sint32 flags);
money32 footpath_provisional_set(sint32 type, sint32 x, sint32 y, sint32 z, sint32 slope);
void footpath_provisional_remove();
void footpath_provisional_update();
void footpath_get_coordinates_from_pos(sint32 screenX, sint32 screenY, sint32 *x, sint32 *y, sint32 *direction, rct_tile_element **tileElement);
void footpath_bridge_get_info_from_pos(sint32 screenX, sint32 screenY, sint32 *x, sint32 *y, sint32 *direction, rct_tile_element **tileElement);
void footpath_get_coordinates_from_pos(sint32 screenX, sint32 screenY, sint32 * x, sint32 * y, sint32 * direction, rct_tile_element ** tileElement);
void footpath_bridge_get_info_from_pos(sint32 screenX, sint32 screenY, sint32 * x, sint32 * y, sint32 * direction, rct_tile_element ** tileElement);
void footpath_remove_litter(sint32 x, sint32 y, sint32 z);
void footpath_connect_edges(sint32 x, sint32 y, rct_tile_element *tileElement, sint32 flags);
void footpath_connect_edges(sint32 x, sint32 y, rct_tile_element * tileElement, sint32 flags);
void footpath_update_queue_chains();
bool fence_in_the_way(sint32 x, sint32 y, sint32 z0, sint32 z1, sint32 direction);
void footpath_chain_ride_queue(sint32 rideIndex, sint32 entranceIndex, sint32 x, sint32 y, rct_tile_element *tileElement, sint32 direction);
void footpath_chain_ride_queue(sint32 rideIndex, sint32 entranceIndex, sint32 x, sint32 y, rct_tile_element * tileElement, sint32 direction);
void footpath_update_path_wide_flags(sint32 x, sint32 y);
sint32 footpath_is_connected_to_map_edge(sint32 x, sint32 y, sint32 z, sint32 direction, sint32 flags);
bool footpath_element_is_sloped(rct_tile_element *tileElement);
uint8 footpath_element_get_slope_direction(rct_tile_element *tileElement);
bool footpath_element_is_queue(rct_tile_element *tileElement);
bool footpath_element_is_wide(rct_tile_element *tileElement);
uint8 footpath_element_get_type(rct_tile_element *tileElement);
bool footpath_element_has_path_scenery(rct_tile_element *tileElement);
uint8 footpath_element_get_path_scenery(rct_tile_element *tileElement);
void footpath_element_set_path_scenery(rct_tile_element *tileElement, uint8 pathSceneryType);
uint8 footpath_element_get_path_scenery_index(rct_tile_element *tileElement);
bool footpath_element_path_scenery_is_ghost(rct_tile_element *tileElement);
void footpath_scenery_set_is_ghost(rct_tile_element *tileElement, bool isGhost);
void footpath_remove_edges_at(sint32 x, sint32 y, rct_tile_element *tileElement);
sint32 entrance_get_directions(rct_tile_element *tileElement);
bool footpath_element_is_sloped(const rct_tile_element * tileElement);
uint8 footpath_element_get_slope_direction(const rct_tile_element * tileElement);
bool footpath_element_is_queue(const rct_tile_element * tileElement);
bool footpath_element_is_wide(const rct_tile_element * tileElement);
uint8 footpath_element_get_type(const rct_tile_element * tileElement);
void footpath_element_set_type(rct_tile_element * tileElement, uint8 type);
uint8 footpath_element_get_direction(const rct_tile_element * tileElement);
void footpath_element_set_direction(rct_tile_element * tileElement, uint8 direction);
bool footpath_element_has_path_scenery(const rct_tile_element * tileElement);
uint8 footpath_element_get_path_scenery(const rct_tile_element * tileElement);
void footpath_element_set_path_scenery(rct_tile_element * tileElement, uint8 pathSceneryType);
uint8 footpath_element_get_path_scenery_index(const rct_tile_element * tileElement);
bool footpath_element_path_scenery_is_ghost(const rct_tile_element * tileElement);
void footpath_scenery_set_is_ghost(rct_tile_element * tileElement, bool isGhost);
void footpath_remove_edges_at(sint32 x, sint32 y, rct_tile_element * tileElement);
sint32 entrance_get_directions(const rct_tile_element * tileElement);
rct_footpath_entry *get_footpath_entry(sint32 entryIndex);
rct_footpath_entry * get_footpath_entry(sint32 entryIndex);
void footpath_queue_chain_reset();
void footpath_queue_chain_push(uint8 rideIndex);

View File

@ -2912,7 +2912,8 @@ void map_remove_all_rides()
do {
switch (tile_element_get_type(it.element)) {
case TILE_ELEMENT_TYPE_PATH:
if (it.element->type & 1) {
if (footpath_element_is_queue(it.element))
{
it.element->properties.path.type &= ~8;
it.element->properties.path.addition_status = 255;
}

View File

@ -24,6 +24,7 @@
#include "scenery.h"
#include "SmallScenery.h"
#include "sprite.h"
#include "footpath.h"
typedef bool (*map_animation_invalidate_event_handler)(sint32 x, sint32 y, sint32 baseZ);
@ -153,7 +154,7 @@ static bool map_animation_invalidate_queue_banner(sint32 x, sint32 y, sint32 bas
if (!(tileElement->properties.path.type & PATH_FLAG_QUEUE_BANNER))
continue;
sint32 direction = ((tileElement->type >> 6) + get_current_rotation()) & 3;
sint32 direction = (footpath_element_get_direction(tileElement) + get_current_rotation()) & 3;
if (direction == TILE_ELEMENT_DIRECTION_NORTH || direction == TILE_ELEMENT_DIRECTION_EAST) {
baseZ = tileElement->base_height * 8;
map_invalidate_tile_zoom1(x, y, baseZ + 16, baseZ + 30);