From 9d04593734dfad8338aa62fd1e08f4d3dfcfe5c0 Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Sun, 28 Jan 2018 19:31:51 +0100 Subject: [PATCH] Slightly refactor staff_can_ignore_wide_flag() This should also take care of some compilers failing. --- src/openrct2/peep/Staff.cpp | 22 ++++++++-------------- src/openrct2/peep/Staff.h | 2 +- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/openrct2/peep/Staff.cpp b/src/openrct2/peep/Staff.cpp index 722f2139f5..ade5daf2d7 100644 --- a/src/openrct2/peep/Staff.cpp +++ b/src/openrct2/peep/Staff.cpp @@ -674,7 +674,7 @@ sint32 staff_is_location_on_patrol_edge(rct_peep * mechanic, sint32 x, sint32 y) return onZoneEdge; } -sint32 staff_can_ignore_wide_flag(rct_peep * staff, sint32 x, sint32 y, uint8 z, rct_tile_element * path) +bool staff_can_ignore_wide_flag(rct_peep * staff, sint32 x, sint32 y, uint8 z, rct_tile_element * path) { /* Wide flags can potentially wall off parts of a staff patrol zone * for the heuristic search. @@ -686,7 +686,7 @@ sint32 staff_can_ignore_wide_flag(rct_peep * staff, sint32 x, sint32 y, uint8 z, * Basic points of interest are: * - how many such tiles there are; * - whether there are connected paths on those tiles; - * - whether the conected paths have the wide flag set. + * - whether the connected paths have the wide flag set. * If there are no such tiles, the path is a concave corner of * the patrol zone and the wide flag can be ignored. * If there is one such tile, the path is on a straight side of the @@ -698,11 +698,11 @@ sint32 staff_can_ignore_wide_flag(rct_peep * staff, sint32 x, sint32 y, uint8 z, * ignored. */ if (staff->type != PEEP_TYPE_STAFF) - return 0; + return false; if (!staff_is_location_on_patrol_edge(staff, x, y)) { - return 0; + return false; } /* Check the connected adjacent paths that are also inside the patrol @@ -778,22 +778,16 @@ sint32 staff_can_ignore_wide_flag(rct_peep * staff, sint32 x, sint32 y, uint8 z, switch (total) { case 0: /* Concave corner */ - return 1; - break; + return true; case 1: /* Straight side */ case 2: /* Convex corner */ if (pathcount <= total - 1 || widecount == total) { - return 1; + return true; } - else - { - return 0; - } - break; - default: - return 0; } + + return false; } /** diff --git a/src/openrct2/peep/Staff.h b/src/openrct2/peep/Staff.h index bf3b28eb8d..60b687e2d4 100644 --- a/src/openrct2/peep/Staff.h +++ b/src/openrct2/peep/Staff.h @@ -106,7 +106,7 @@ uint16 hire_new_staff_member(uint8 staffType); void staff_update_greyed_patrol_areas(); sint32 staff_is_location_in_patrol(rct_peep * mechanic, sint32 x, sint32 y); sint32 staff_is_location_on_patrol_edge(rct_peep * mechanic, sint32 x, sint32 y); -sint32 staff_can_ignore_wide_flag(rct_peep * mechanic, sint32 x, sint32 y, uint8 z, rct_tile_element * path); +bool staff_can_ignore_wide_flag(rct_peep * mechanic, sint32 x, sint32 y, uint8 z, rct_tile_element * path); sint32 staff_path_finding(rct_peep * peep); void staff_reset_stats(); bool staff_is_patrol_area_set(sint32 staffIndex, sint32 x, sint32 y);