From c7417e11a4482ba4605ba5ecb63aad8acdf23795 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Thu, 4 Jan 2018 13:36:08 +0100 Subject: [PATCH] Use `bool` type for boolean logic --- src/openrct2/world/Map.cpp | 14 +++++++------- src/openrct2/world/Map.h | 4 ++-- test/testpaint/compat.c | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 9a5f10ef2e..44a28699fa 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -253,9 +253,9 @@ void map_set_tile_elements(sint32 x, sint32 y, rct_tile_element *elements) gTileElementTilePointers[x + y * MAXIMUM_MAP_SIZE_TECHNICAL] = elements; } -sint32 tile_element_is_last_for_tile(const rct_tile_element *element) +bool tile_element_is_last_for_tile(const rct_tile_element *element) { - return element->flags & TILE_ELEMENT_FLAG_LAST_TILE; + return (element->flags & TILE_ELEMENT_FLAG_LAST_TILE) != 0; } bool tile_element_is_ghost(const rct_tile_element *element) @@ -715,7 +715,7 @@ void sub_68B089() * Checks if the tile at coordinate at height counts as connected. * @return 1 if connected, 0 otherwise */ -sint32 map_coord_is_connected(sint32 x, sint32 y, sint32 z, uint8 faceDirection) +bool map_coord_is_connected(sint32 x, sint32 y, sint32 z, uint8 faceDirection) { rct_tile_element *tileElement = map_get_first_element_at(x, y); @@ -730,17 +730,17 @@ sint32 map_coord_is_connected(sint32 x, sint32 y, sint32 z, uint8 faceDirection) if (pathType & 1) { if (pathDirection == faceDirection) { if (z == tileElement->base_height + 2) - return 1; + return true; } else if ((pathDirection ^ 2) == faceDirection && z == tileElement->base_height) { - return 1; + return true; } } else { if (z == tileElement->base_height) - return 1; + return true; } } while (!tile_element_is_last_for_tile(tileElement++)); - return 0; + return false; } /** diff --git a/src/openrct2/world/Map.h b/src/openrct2/world/Map.h index 41109e77e8..1a76199839 100644 --- a/src/openrct2/world/Map.h +++ b/src/openrct2/world/Map.h @@ -417,7 +417,7 @@ void map_update_tile_pointers(); rct_tile_element *map_get_first_element_at(sint32 x, sint32 y); rct_tile_element *map_get_nth_element_at(sint32 x, sint32 y, sint32 n); void map_set_tile_elements(sint32 x, sint32 y, rct_tile_element *elements); -sint32 tile_element_is_last_for_tile(const rct_tile_element *element); +bool tile_element_is_last_for_tile(const rct_tile_element *element); bool tile_element_is_ghost(const rct_tile_element *element); uint8 tile_element_get_scenery_quadrant(const rct_tile_element *element); sint32 tile_element_get_type(const rct_tile_element *element); @@ -438,7 +438,7 @@ rct_tile_element * map_get_ride_entrance_element_at(sint32 x, sint32 y, sint32 z rct_tile_element * map_get_ride_exit_element_at(sint32 x, sint32 y, sint32 z, bool ghost); sint32 tile_element_height(sint32 x, sint32 y); void sub_68B089(); -sint32 map_coord_is_connected(sint32 x, sint32 y, sint32 z, uint8 faceDirection); +bool map_coord_is_connected(sint32 x, sint32 y, sint32 z, uint8 faceDirection); void map_remove_provisional_elements(); void map_restore_provisional_elements(); void map_update_path_wide_flags(); diff --git a/test/testpaint/compat.c b/test/testpaint/compat.c index f51920613e..2e8f5c2704 100644 --- a/test/testpaint/compat.c +++ b/test/testpaint/compat.c @@ -119,8 +119,8 @@ rct_sprite *get_sprite(size_t sprite_idx) { return &sprite_list[sprite_idx]; } -int tile_element_is_last_for_tile(const rct_tile_element *element) { - return element->flags & TILE_ELEMENT_FLAG_LAST_TILE; +bool tile_element_is_last_for_tile(const rct_tile_element *element) { + return (element->flags & TILE_ELEMENT_FLAG_LAST_TILE) != 0; } int tile_element_get_type(const rct_tile_element *element) { @@ -293,4 +293,4 @@ void track_element_set_cable_lift(rct_tile_element * trackElement) void track_element_clear_cable_lift(rct_tile_element * trackElement) { trackElement->properties.track.colour &= ~TRACK_ELEMENT_COLOUR_FLAG_CABLE_LIFT; -} \ No newline at end of file +}