From e799dc2962c4edb47dd365040c6dcb1278b6b33a Mon Sep 17 00:00:00 2001 From: Nick Overdijk Date: Sat, 10 Mar 2018 15:09:44 +0100 Subject: [PATCH] Document the code by using named functions/variables/comments --- src/openrct2/peep/Peep.cpp | 12 +++++++----- src/openrct2/world/Map.cpp | 3 +-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/openrct2/peep/Peep.cpp b/src/openrct2/peep/Peep.cpp index be6f808826..5e07aa4674 100644 --- a/src/openrct2/peep/Peep.cpp +++ b/src/openrct2/peep/Peep.cpp @@ -5916,6 +5916,7 @@ static sint32 peep_update_walking_find_bench(rct_peep * peep) uint16 sprite_id = sprite_get_first_in_quadrant(peep->x, peep->y); uint8 free_edge = 3; + // Check if there is no peep sitting in chosen_edge for (rct_sprite * sprite; sprite_id != SPRITE_INDEX_NULL; sprite_id = sprite->unknown.next_in_quadrant) { sprite = get_sprite(sprite_id); @@ -7236,7 +7237,7 @@ static void peep_update_walking(rct_peep * peep) } } - sint32 ebp = 15; + sint32 positions_free = 15; if (footpath_element_has_path_scenery(tile_element)) { @@ -7249,7 +7250,7 @@ static void peep_update_walking(rct_peep * peep) } if (!(sceneryEntry->path_bit.flags & PATH_BIT_FLAG_IS_BENCH)) - ebp = 9; + positions_free = 9; } } @@ -7266,6 +7267,7 @@ static void peep_update_walking(rct_peep * peep) if (!peep_find_ride_to_look_at(peep, chosen_edge, &ride_to_view, &ride_seat_to_view)) return; + // Check if there is a peep watching (and if there is place for us) uint16 sprite_id = sprite_get_first_in_quadrant(peep->x, peep->y); for (rct_sprite * sprite; sprite_id != SPRITE_INDEX_NULL; sprite_id = sprite->unknown.next_in_quadrant) { @@ -7283,15 +7285,15 @@ static void peep_update_walking(rct_peep * peep) if ((sprite->peep.var_37 & 0x3) != chosen_edge) continue; - ebp &= ~(1 << ((sprite->peep.var_37 & 0x1C) >> 2)); + positions_free &= ~(1 << ((sprite->peep.var_37 & 0x1C) >> 2)); } - if (!ebp) + if (!positions_free) return; uint8 chosen_position = peep_rand() & 0x3; - for (; !(ebp & (1 << chosen_position));) + for (; !(positions_free & (1 << chosen_position));) chosen_position = (chosen_position + 1) & 3; peep->current_ride = ride_to_view; diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index fa68151575..379dfadbc6 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -730,10 +730,9 @@ bool map_coord_is_connected(sint32 x, sint32 y, sint32 z, uint8 faceDirection) continue; rct_tile_element_path_properties props = tileElement->properties.path; - uint8 pathType = props.type >> 2; uint8 pathDirection = props.type & 3; - if (pathType & 1) { + if (footpath_element_is_sloped(tileElement)) { if (pathDirection == faceDirection) { if (z == tileElement->base_height + 2) return true;