From b82504c5e450b01d45c09e60fb95068042182c7d Mon Sep 17 00:00:00 2001 From: Hielke Morsink Date: Thu, 3 Dec 2015 23:49:26 +0100 Subject: [PATCH] Better consistensy with already existing helper functions --- src/windows/tile_inspector.c | 16 ++++++++-------- src/world/footpath.c | 19 ++++++++++++------- src/world/footpath.h | 10 +++++----- 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/src/windows/tile_inspector.c b/src/windows/tile_inspector.c index 86018bedd4..ecd29809e8 100644 --- a/src/windows/tile_inspector.c +++ b/src/windows/tile_inspector.c @@ -332,23 +332,23 @@ static void window_tile_inspector_scrollpaint(rct_window *w, rct_drawpixelinfo * break; case MAP_ELEMENT_TYPE_PATH: { - rct_map_element_path_properties *pathProperties = &element->properties.path; - uint8 pathType = footpath_element_get_type(pathProperties); - uint8 pathAdditionType = footpath_element_get_addition_type(pathProperties); + const uint8 pathType = footpath_element_get_type(element); + const uint8 pathHasScenery = footpath_element_has_path_scenery(element); + const uint8 pathAdditionType = footpath_element_get_path_scenery_index(element); if (footpath_element_is_queue(element)) { sprintf( buffer, "Queue (%s)%s%s for (%d)", language_get_string(g_pathSceneryEntries[pathType]->name), // Path name - pathAdditionType ? " with " : "", // Adds " with " when there is something on the path - pathAdditionType ? language_get_string(g_pathBitSceneryEntries[pathAdditionType - 1]->name) : "", // Path addition name - pathProperties->ride_index // Ride index for queue + pathHasScenery ? " with " : "", // Adds " with " when there is something on the path + pathHasScenery ? language_get_string(g_pathBitSceneryEntries[pathAdditionType]->name) : "", // Path addition name + element->properties.path.ride_index // Ride index for queue ); } else { sprintf( buffer, "Path (%s)%s%s", language_get_string(g_pathSceneryEntries[pathType]->name), // Path name - pathAdditionType ? " with " : "", // Adds " with " when there is something on the path - pathAdditionType ? language_get_string(g_pathBitSceneryEntries[pathAdditionType - 1]->name) : "" // Path addition name + pathHasScenery ? " with " : "", // Adds " with " when there is something on the path + pathHasScenery ? language_get_string(g_pathBitSceneryEntries[pathAdditionType]->name) : "" // Path addition name ); } } diff --git a/src/world/footpath.c b/src/world/footpath.c index a6cdeb9346..8eb39db1cc 100644 --- a/src/world/footpath.c +++ b/src/world/footpath.c @@ -1582,7 +1582,7 @@ bool footpath_element_is_sloped(rct_map_element *mapElement) return mapElement->properties.path.type & 4; } -int footpath_element_get_slope_direction(rct_map_element *mapElement) +uint8 footpath_element_get_slope_direction(rct_map_element *mapElement) { return mapElement->properties.path.type & 3; } @@ -1597,19 +1597,24 @@ bool footpath_element_is_wide(rct_map_element *mapElement) return mapElement->type & 2; } -uint8 footpath_element_get_type(rct_map_element_path_properties *pathProperties) +bool footpath_element_has_path_scenery(rct_map_element *mapElement) { - return pathProperties->type >> 4; + return (mapElement->properties.path.additions & 0xF) > 0; } -uint8 footpath_element_get_direction(rct_map_element_path_properties *pathProperties) +uint8 footpath_element_get_path_scenery(rct_map_element *mapElement) { - return pathProperties->type & 3; + return mapElement->properties.path.additions & 0xF; } -uint8 footpath_element_get_addition_type(rct_map_element_path_properties *pathProperties) +uint8 footpath_element_get_path_scenery_index(rct_map_element *mapElement) { - return pathProperties->additions & 0xF; + return footpath_element_get_path_scenery(mapElement) - 1; +} + +uint8 footpath_element_get_type(rct_map_element *mapElement) +{ + return mapElement->properties.path.type >> 4; } /** diff --git a/src/world/footpath.h b/src/world/footpath.h index f77630fe63..f0db78154d 100644 --- a/src/world/footpath.h +++ b/src/world/footpath.h @@ -70,13 +70,13 @@ void footpath_bridge_get_info_from_pos(int screenX, int screenY, int *x, int *y, int footpath_is_connected_to_map_edge(int x, int y, int z, int direction, int flags); bool footpath_element_is_sloped(rct_map_element *mapElement); -int footpath_element_get_slope_direction(rct_map_element *mapElement); +uint8 footpath_element_get_slope_direction(rct_map_element *mapElement); bool footpath_element_is_queue(rct_map_element *mapElement); bool footpath_element_is_wide(rct_map_element *mapElement); -uint8 footpath_element_get_type(rct_map_element_path_properties *pathProperties); -uint8 footpath_element_get_direction(rct_map_element_path_properties *pathProperties); -uint8 footpath_element_get_addition_type(rct_map_element_path_properties *pathProperties); -uint8 footpath_element_get_addition_type(rct_map_element_path_properties *pathProperties); +uint8 footpath_element_get_type(rct_map_element *mapElement); +bool footpath_element_has_path_scenery(rct_map_element *mapElement); +uint8 footpath_element_get_path_scenery(rct_map_element *mapElement); +uint8 footpath_element_get_path_scenery_index(rct_map_element *mapElement); void footpath_remove_edges_at(int x, int y, rct_map_element *mapElement); #endif