diff --git a/src/openrct2/peep/Guest.cpp b/src/openrct2/peep/Guest.cpp index 8caacdd925..bfe210b8f1 100644 --- a/src/openrct2/peep/Guest.cpp +++ b/src/openrct2/peep/Guest.cpp @@ -7,19 +7,19 @@ * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ +#include "../Context.h" +#include "../Game.h" +#include "../OpenRCT2.h" #include "../audio/audio.h" #include "../config/Config.h" #include "../core/Guard.hpp" #include "../core/Math.hpp" #include "../core/Util.hpp" #include "../localisation/Localisation.h" -#include "../network/network.h" #include "../management/Finance.h" #include "../management/Marketing.h" #include "../management/NewsItem.h" -#include "../Context.h" -#include "../Game.h" -#include "../OpenRCT2.h" +#include "../network/network.h" #include "../ride/Ride.h" #include "../ride/RideData.h" #include "../ride/ShopItem.h" @@ -27,6 +27,7 @@ #include "../ride/Track.h" #include "../scenario/Scenario.h" #include "../util/Util.h" +#include "../windows/Intent.h" #include "../world/Climate.h" #include "../world/Footpath.h" #include "../world/LargeScenery.h" @@ -34,7 +35,6 @@ #include "../world/Scenery.h" #include "../world/Sprite.h" #include "../world/Surface.h" -#include "../windows/Intent.h" #include "Peep.h" // Locations of the spiral slide platform that a peep walks from the entrance of the ride to the @@ -348,25 +348,25 @@ static constexpr const ride_rating NauseaMinimumThresholds[] = { }; // clang-format on -static bool peep_has_voucher_for_free_ride(rct_peep * peep, int32_t rideIndex); -static void peep_ride_is_too_intense(rct_peep * peep, int32_t rideIndex, bool peepAtRide); -static void peep_reset_ride_heading(rct_peep * peep); -static void peep_tried_to_enter_full_queue(rct_peep * peep, int32_t rideIndex); -static int16_t peep_calculate_ride_satisfaction(rct_peep * peep, Ride * ride); -static void peep_update_favourite_ride(rct_peep * peep, Ride * ride); -static int16_t peep_calculate_ride_value_satisfaction(rct_peep * peep, Ride * ride); -static int16_t peep_calculate_ride_intensity_nausea_satisfaction(rct_peep * peep, Ride * ride); -static void peep_update_ride_nausea_growth(rct_peep * peep, Ride * ride); -static bool peep_should_go_on_ride_again(rct_peep * peep, Ride * ride); -static bool peep_should_preferred_intensity_increase(rct_peep * peep); -static bool peep_really_liked_ride(rct_peep * peep, Ride * ride); -static uint8_t peep_assess_surroundings(int16_t centre_x, int16_t centre_y, int16_t centre_z); -static void peep_update_hunger(rct_peep * peep); -static void peep_decide_whether_to_leave_park(rct_peep * peep); -static void peep_leave_park(rct_peep * peep); -static void peep_head_for_nearest_ride_type(rct_peep * peep, int32_t rideType); -static void peep_head_for_nearest_ride_with_flags(rct_peep * peep, int32_t rideTypeFlags); -bool loc_690FD0(rct_peep * peep, uint8_t * rideToView, uint8_t * rideSeatToView, rct_tile_element * tileElement); +static bool peep_has_voucher_for_free_ride(rct_peep* peep, int32_t rideIndex); +static void peep_ride_is_too_intense(rct_peep* peep, int32_t rideIndex, bool peepAtRide); +static void peep_reset_ride_heading(rct_peep* peep); +static void peep_tried_to_enter_full_queue(rct_peep* peep, int32_t rideIndex); +static int16_t peep_calculate_ride_satisfaction(rct_peep* peep, Ride* ride); +static void peep_update_favourite_ride(rct_peep* peep, Ride* ride); +static int16_t peep_calculate_ride_value_satisfaction(rct_peep* peep, Ride* ride); +static int16_t peep_calculate_ride_intensity_nausea_satisfaction(rct_peep* peep, Ride* ride); +static void peep_update_ride_nausea_growth(rct_peep* peep, Ride* ride); +static bool peep_should_go_on_ride_again(rct_peep* peep, Ride* ride); +static bool peep_should_preferred_intensity_increase(rct_peep* peep); +static bool peep_really_liked_ride(rct_peep* peep, Ride* ride); +static uint8_t peep_assess_surroundings(int16_t centre_x, int16_t centre_y, int16_t centre_z); +static void peep_update_hunger(rct_peep* peep); +static void peep_decide_whether_to_leave_park(rct_peep* peep); +static void peep_leave_park(rct_peep* peep); +static void peep_head_for_nearest_ride_type(rct_peep* peep, int32_t rideType); +static void peep_head_for_nearest_ride_with_flags(rct_peep* peep, int32_t rideTypeFlags); +bool loc_690FD0(rct_peep* peep, uint8_t* rideToView, uint8_t* rideSeatToView, rct_tile_element* tileElement); void rct_peep::Tick128UpdateGuest(int32_t index) { @@ -438,7 +438,6 @@ void rct_peep::Tick128UpdateGuest(int32_t index) surroundings_thought_timeout = 0; if (x != LOCATION_NULL) { - uint8_t thought_type = peep_assess_surroundings(x & 0xFFE0, y & 0xFFE0, z); if (thought_type != PEEP_THOUGHT_TYPE_NONE) @@ -467,20 +466,19 @@ void rct_peep::Tick128UpdateGuest(int32_t index) if (time_on_ride > 22) { - Ride * ride = get_ride(current_ride); + Ride* ride = get_ride(current_ride); uint8_t thought_type = ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_IN_RIDE) ? PEEP_THOUGHT_TYPE_GET_OUT - : PEEP_THOUGHT_TYPE_GET_OFF; + : PEEP_THOUGHT_TYPE_GET_OFF; peep_insert_new_thought(this, thought_type, current_ride); } } } - if (state == PEEP_STATE_WALKING && outside_of_park == 0 && !(peep_flags & PEEP_FLAGS_LEAVING_PARK) && - no_of_rides == 0 && guest_heading_to_ride_id == 0xFF) + if (state == PEEP_STATE_WALKING && outside_of_park == 0 && !(peep_flags & PEEP_FLAGS_LEAVING_PARK) && no_of_rides == 0 + && guest_heading_to_ride_id == 0xFF) { - uint32_t time_duration = gScenarioTicks - time_in_park; time_duration /= 2048; @@ -513,8 +511,7 @@ void rct_peep::Tick128UpdateGuest(int32_t index) if (outside_of_park == 0 && (state == PEEP_STATE_WALKING || state == PEEP_STATE_SITTING)) { - - uint8_t num_thoughts = 0; + uint8_t num_thoughts = 0; uint8_t possible_thoughts[5] = { 0 }; if (peep_flags & PEEP_FLAGS_LEAVING_PARK) @@ -543,8 +540,8 @@ void rct_peep::Tick128UpdateGuest(int32_t index) possible_thoughts[num_thoughts++] = PEEP_THOUGHT_TYPE_BATHROOM; } - if (!(gParkFlags & PARK_FLAGS_NO_MONEY) && cash_in_pocket <= MONEY(9, 00) && happiness >= 105 && - energy >= 70) + if (!(gParkFlags & PARK_FLAGS_NO_MONEY) && cash_in_pocket <= MONEY(9, 00) && happiness >= 105 + && energy >= 70) { /* The energy check was originally a second check on happiness. * This was superfluous so should probably check something else. @@ -565,18 +562,18 @@ void rct_peep::Tick128UpdateGuest(int32_t index) switch (chosen_thought) { - case PEEP_THOUGHT_TYPE_HUNGRY: - peep_head_for_nearest_ride_with_flags(this, RIDE_TYPE_FLAG_SELLS_FOOD); - break; - case PEEP_THOUGHT_TYPE_THIRSTY: - peep_head_for_nearest_ride_with_flags(this, RIDE_TYPE_FLAG_SELLS_DRINKS); - break; - case PEEP_THOUGHT_TYPE_BATHROOM: - peep_head_for_nearest_ride_with_flags(this, RIDE_TYPE_FLAG_IS_BATHROOM); - break; - case PEEP_THOUGHT_TYPE_RUNNING_OUT: - peep_head_for_nearest_ride_type(this, RIDE_TYPE_CASH_MACHINE); - break; + case PEEP_THOUGHT_TYPE_HUNGRY: + peep_head_for_nearest_ride_with_flags(this, RIDE_TYPE_FLAG_SELLS_FOOD); + break; + case PEEP_THOUGHT_TYPE_THIRSTY: + peep_head_for_nearest_ride_with_flags(this, RIDE_TYPE_FLAG_SELLS_DRINKS); + break; + case PEEP_THOUGHT_TYPE_BATHROOM: + peep_head_for_nearest_ride_with_flags(this, RIDE_TYPE_FLAG_IS_BATHROOM); + break; + case PEEP_THOUGHT_TYPE_RUNNING_OUT: + peep_head_for_nearest_ride_type(this, RIDE_TYPE_CASH_MACHINE); + break; } } } @@ -601,87 +598,88 @@ void rct_peep::Tick128UpdateGuest(int32_t index) switch (state) { - case PEEP_STATE_WALKING: - case PEEP_STATE_LEAVING_PARK: - case PEEP_STATE_ENTERING_PARK: - peep_decide_whether_to_leave_park(this); - peep_update_hunger(this); - break; - - case PEEP_STATE_SITTING: - if (energy_target <= 135) - energy_target += 5; - - if (thirst >= 5) - { - thirst -= 4; - toilet = std::min(255, toilet + 3); - } - - if (nausea_target >= 50) - nausea_target -= 6; - - // In the original this branched differently - // but it would mean setting the peep happiness from - // a thought type entry which i think is incorrect. - peep_update_hunger(this); - break; - - case PEEP_STATE_QUEUING: - if (time_in_queue >= 2000) - { - /* Peep happiness is affected once the peep has been waiting - * too long in a queue. */ - rct_tile_element * tileElement = map_get_first_element_at(next_x / 32, next_y / 32); - bool found = false; - do - { - if (tileElement->GetType() != TILE_ELEMENT_TYPE_PATH) - continue; - if (tileElement->base_height != next_z) - continue; - - // Check if the footpath has a queue line TV monitor on it - if (footpath_element_has_path_scenery(tileElement) && !footpath_element_path_scenery_is_ghost(tileElement)) - { - uint8_t pathSceneryIndex = footpath_element_get_path_scenery_index(tileElement); - rct_scenery_entry * sceneryEntry = get_footpath_item_entry(pathSceneryIndex); - if (sceneryEntry->path_bit.flags & PATH_BIT_FLAG_IS_QUEUE_SCREEN) - { - found = true; - } - } - break; - } while (!(tileElement++)->IsLastForTile()); - - if (found) - { - /* Queue line TV monitors make the peeps waiting in the queue - * slowly happier, up to a certain level. */ - /* Why don't queue line TV monitors start affecting the peeps - * as soon as they join the queue?? */ - if (happiness_target < 90) - happiness_target = 90; - - if (happiness_target < 165) - happiness_target += 2; - } - else - { - /* Without a queue line TV monitor peeps waiting too long - * in a queue get less happy. */ - happiness_target = std::max(happiness_target - 4, 0); - } - } - peep_update_hunger(this); - break; - case PEEP_STATE_ENTERING_RIDE: - if (sub_state == 17 || sub_state == 15) - { + case PEEP_STATE_WALKING: + case PEEP_STATE_LEAVING_PARK: + case PEEP_STATE_ENTERING_PARK: peep_decide_whether_to_leave_park(this); - } - peep_update_hunger(this); - break; + peep_update_hunger(this); + break; + + case PEEP_STATE_SITTING: + if (energy_target <= 135) + energy_target += 5; + + if (thirst >= 5) + { + thirst -= 4; + toilet = std::min(255, toilet + 3); + } + + if (nausea_target >= 50) + nausea_target -= 6; + + // In the original this branched differently + // but it would mean setting the peep happiness from + // a thought type entry which i think is incorrect. + peep_update_hunger(this); + break; + + case PEEP_STATE_QUEUING: + if (time_in_queue >= 2000) + { + /* Peep happiness is affected once the peep has been waiting + * too long in a queue. */ + rct_tile_element* tileElement = map_get_first_element_at(next_x / 32, next_y / 32); + bool found = false; + do + { + if (tileElement->GetType() != TILE_ELEMENT_TYPE_PATH) + continue; + if (tileElement->base_height != next_z) + continue; + + // Check if the footpath has a queue line TV monitor on it + if (footpath_element_has_path_scenery(tileElement) + && !footpath_element_path_scenery_is_ghost(tileElement)) + { + uint8_t pathSceneryIndex = footpath_element_get_path_scenery_index(tileElement); + rct_scenery_entry* sceneryEntry = get_footpath_item_entry(pathSceneryIndex); + if (sceneryEntry->path_bit.flags & PATH_BIT_FLAG_IS_QUEUE_SCREEN) + { + found = true; + } + } + break; + } while (!(tileElement++)->IsLastForTile()); + + if (found) + { + /* Queue line TV monitors make the peeps waiting in the queue + * slowly happier, up to a certain level. */ + /* Why don't queue line TV monitors start affecting the peeps + * as soon as they join the queue?? */ + if (happiness_target < 90) + happiness_target = 90; + + if (happiness_target < 165) + happiness_target += 2; + } + else + { + /* Without a queue line TV monitor peeps waiting too long + * in a queue get less happy. */ + happiness_target = std::max(happiness_target - 4, 0); + } + } + peep_update_hunger(this); + break; + case PEEP_STATE_ENTERING_RIDE: + if (sub_state == 17 || sub_state == 15) + { + peep_decide_whether_to_leave_park(this); + } + peep_update_hunger(this); + break; } loc_68F9F3: @@ -715,16 +713,15 @@ void rct_peep::Tick128UpdateGuest(int32_t index) if (state == PEEP_STATE_WALKING && nausea_target >= 128) { - if ((scenario_rand() & 0xFF) <= (uint8_t)((nausea - 128) / 2)) { if (action >= PEEP_ACTION_NONE_1) { - action = PEEP_ACTION_THROW_UP; - action_frame = 0; + action = PEEP_ACTION_THROW_UP; + action_frame = 0; action_sprite_image_offset = 0; UpdateCurrentActionSpriteType(); - invalidate_sprite_2((rct_sprite *)this); + invalidate_sprite_2((rct_sprite*)this); } } } @@ -740,7 +737,6 @@ void rct_peep::Tick128UpdateGuest(int32_t index) if (time_to_consume != 0 && state != PEEP_STATE_ON_RIDE) { - time_to_consume = std::max(time_to_consume - 3, 0); if (HasDrink()) @@ -792,7 +788,7 @@ void rct_peep::Tick128UpdateGuest(int32_t index) } } - uint8_t newEnergy = energy; + uint8_t newEnergy = energy; uint8_t newTargetEnergy = energy_target; if (newEnergy >= newTargetEnergy) { @@ -819,7 +815,7 @@ void rct_peep::Tick128UpdateGuest(int32_t index) window_invalidate_flags |= PEEP_INVALIDATE_PEEP_2; } - uint8_t newHappiness = happiness; + uint8_t newHappiness = happiness; uint8_t newHappinessGrowth = happiness_target; if (newHappiness >= newHappinessGrowth) { @@ -840,7 +836,7 @@ void rct_peep::Tick128UpdateGuest(int32_t index) window_invalidate_flags |= PEEP_INVALIDATE_PEEP_2; } - uint8_t newNausea = nausea; + uint8_t newNausea = nausea; uint8_t newNauseaGrowth = nausea_target; if (newNausea >= newNauseaGrowth) { @@ -879,8 +875,8 @@ void rct_peep::TryGetUpFromSitting() SetState(PEEP_STATE_WALKING); // Set destination to the centre of the tile. - destination_x = (x & 0xFFE0) + 16; - destination_y = (y & 0xFFE0) + 16; + destination_x = (x & 0xFFE0) + 16; + destination_y = (y & 0xFFE0) + 16; destination_tolerance = 5; UpdateCurrentActionSpriteType(); } @@ -902,19 +898,16 @@ void rct_peep::UpdateSitting() if (!(pathingResult & PATHING_DESTINATION_REACHED)) return; - LocationXYZ16 loc = - { - (int16_t)((x & 0xFFE0) + BenchUseOffsets[var_37 & 0x7].x), - (int16_t)((y & 0xFFE0) + BenchUseOffsets[var_37 & 0x7].y), - z - }; + LocationXYZ16 loc = { (int16_t)((x & 0xFFE0) + BenchUseOffsets[var_37 & 0x7].x), + (int16_t)((y & 0xFFE0) + BenchUseOffsets[var_37 & 0x7].y), + z }; Invalidate(); MoveTo(loc.x, loc.y, loc.z); sprite_direction = ((var_37 + 2) & 3) * 8; Invalidate(); - action = PEEP_ACTION_NONE_1; + action = PEEP_ACTION_NONE_1; next_action_sprite_type = 7; SwitchNextActionSpriteType(); @@ -941,8 +934,8 @@ void rct_peep::UpdateSitting() SetState(PEEP_STATE_WALKING); // Set destination to the centre of the tile - destination_x = (x & 0xFFE0) + 16; - destination_y = (y & 0xFFE0) + 16; + destination_x = (x & 0xFFE0) + 16; + destination_y = (y & 0xFFE0) + 16; destination_tolerance = 5; UpdateCurrentActionSpriteType(); return; @@ -961,8 +954,8 @@ void rct_peep::UpdateSitting() TryGetUpFromSitting(); return; } - action = PEEP_ACTION_SITTING_EAT_FOOD; - action_frame = 0; + action = PEEP_ACTION_SITTING_EAT_FOOD; + action_frame = 0; action_sprite_image_offset = 0; UpdateCurrentActionSpriteType(); Invalidate(); @@ -991,7 +984,7 @@ void rct_peep::UpdateSitting() { action = PEEP_ACTION_SITTING_CHECK_WATCH; } - action_frame = 0; + action_frame = 0; action_sprite_image_offset = 0; UpdateCurrentActionSpriteType(); Invalidate(); @@ -1005,7 +998,7 @@ void rct_peep::UpdateSitting() */ void rct_peep::RemoveFromQueue() { - Ride * ride = get_ride(current_ride); + Ride* ride = get_ride(current_ride); uint8_t cur_station = current_ride_station; // Make sure we don't underflow, building while paused might reset it to 0 where peeps have @@ -1024,7 +1017,7 @@ void rct_peep::RemoveFromQueue() uint16_t spriteId = ride->last_peep_in_queue[cur_station]; while (spriteId != SPRITE_INDEX_NULL) { - rct_peep * other_peep = GET_PEEP(spriteId); + rct_peep* other_peep = GET_PEEP(spriteId); if (sprite_index == other_peep->next_in_queue) { other_peep->next_in_queue = next_in_queue; @@ -1048,18 +1041,19 @@ bool rct_peep::HasItem(int32_t peepItem) const int32_t rct_peep::HasFoodStandardFlag() const { - return item_standard_flags & - (PEEP_ITEM_DRINK | PEEP_ITEM_BURGER | PEEP_ITEM_CHIPS | PEEP_ITEM_ICE_CREAM | PEEP_ITEM_CANDYFLOSS | - PEEP_ITEM_PIZZA | PEEP_ITEM_POPCORN | PEEP_ITEM_HOT_DOG | PEEP_ITEM_TENTACLE | PEEP_ITEM_TOFFEE_APPLE | - PEEP_ITEM_DOUGHNUT | PEEP_ITEM_COFFEE | PEEP_ITEM_CHICKEN | PEEP_ITEM_LEMONADE); + return item_standard_flags + & (PEEP_ITEM_DRINK | PEEP_ITEM_BURGER | PEEP_ITEM_CHIPS | PEEP_ITEM_ICE_CREAM | PEEP_ITEM_CANDYFLOSS | PEEP_ITEM_PIZZA + | PEEP_ITEM_POPCORN | PEEP_ITEM_HOT_DOG | PEEP_ITEM_TENTACLE | PEEP_ITEM_TOFFEE_APPLE | PEEP_ITEM_DOUGHNUT + | PEEP_ITEM_COFFEE | PEEP_ITEM_CHICKEN | PEEP_ITEM_LEMONADE); } int32_t rct_peep::HasFoodExtraFlag() const { - return item_extra_flags & (PEEP_ITEM_PRETZEL | PEEP_ITEM_CHOCOLATE | PEEP_ITEM_ICED_TEA | PEEP_ITEM_FUNNEL_CAKE | - PEEP_ITEM_BEEF_NOODLES | PEEP_ITEM_FRIED_RICE_NOODLES | PEEP_ITEM_WONTON_SOUP | - PEEP_ITEM_MEATBALL_SOUP | PEEP_ITEM_FRUIT_JUICE | PEEP_ITEM_SOYBEAN_MILK | PEEP_ITEM_SU_JONGKWA | - PEEP_ITEM_SUB_SANDWICH | PEEP_ITEM_COOKIE | PEEP_ITEM_ROAST_SAUSAGE); + return item_extra_flags + & (PEEP_ITEM_PRETZEL | PEEP_ITEM_CHOCOLATE | PEEP_ITEM_ICED_TEA | PEEP_ITEM_FUNNEL_CAKE | PEEP_ITEM_BEEF_NOODLES + | PEEP_ITEM_FRIED_RICE_NOODLES | PEEP_ITEM_WONTON_SOUP | PEEP_ITEM_MEATBALL_SOUP | PEEP_ITEM_FRUIT_JUICE + | PEEP_ITEM_SOYBEAN_MILK | PEEP_ITEM_SU_JONGKWA | PEEP_ITEM_SUB_SANDWICH | PEEP_ITEM_COOKIE + | PEEP_ITEM_ROAST_SAUSAGE); } bool rct_peep::HasDrinkStandardFlag() const @@ -1069,8 +1063,8 @@ bool rct_peep::HasDrinkStandardFlag() const bool rct_peep::HasDrinkExtraFlag() const { - return item_extra_flags & - (PEEP_ITEM_CHOCOLATE | PEEP_ITEM_ICED_TEA | PEEP_ITEM_FRUIT_JUICE | PEEP_ITEM_SOYBEAN_MILK | PEEP_ITEM_SU_JONGKWA); + return item_extra_flags + & (PEEP_ITEM_CHOCOLATE | PEEP_ITEM_ICED_TEA | PEEP_ITEM_FRUIT_JUICE | PEEP_ITEM_SOYBEAN_MILK | PEEP_ITEM_SU_JONGKWA); } /** @@ -1084,14 +1078,15 @@ bool rct_peep::HasDrink() const int32_t rct_peep::HasEmptyContainerStandardFlag() const { - return item_standard_flags & (PEEP_ITEM_EMPTY_CAN | PEEP_ITEM_EMPTY_BURGER_BOX | PEEP_ITEM_EMPTY_CUP | PEEP_ITEM_RUBBISH | - PEEP_ITEM_EMPTY_BOX | PEEP_ITEM_EMPTY_BOTTLE); + return item_standard_flags + & (PEEP_ITEM_EMPTY_CAN | PEEP_ITEM_EMPTY_BURGER_BOX | PEEP_ITEM_EMPTY_CUP | PEEP_ITEM_RUBBISH | PEEP_ITEM_EMPTY_BOX + | PEEP_ITEM_EMPTY_BOTTLE); } int32_t rct_peep::HasEmptyContainerExtraFlag() const { - return item_extra_flags & - (PEEP_ITEM_EMPTY_BOWL_RED | PEEP_ITEM_EMPTY_DRINK_CARTON | PEEP_ITEM_EMPTY_JUICE_CUP | PEEP_ITEM_EMPTY_BOWL_BLUE); + return item_extra_flags + & (PEEP_ITEM_EMPTY_BOWL_RED | PEEP_ITEM_EMPTY_DRINK_CARTON | PEEP_ITEM_EMPTY_JUICE_CUP | PEEP_ITEM_EMPTY_BOWL_BLUE); } bool rct_peep::HasEmptyContainer() const @@ -1147,7 +1142,7 @@ void rct_peep::CheckCantFindRide() return; guest_heading_to_ride_id = 0xFF; - rct_window * w = window_find_by_number(WC_PEEP, sprite_index); + rct_window* w = window_find_by_number(WC_PEEP, sprite_index); if (w) { @@ -1193,13 +1188,13 @@ void rct_peep::CheckCantFindExit() */ bool rct_peep::DecideAndBuyItem(uint8_t rideIndex, int32_t shopItem, money32 price) { - Ride * ride = get_ride(rideIndex); + Ride* ride = get_ride(rideIndex); money32 itemValue; bool hasVoucher = false; - if ((item_standard_flags & PEEP_ITEM_VOUCHER) && (voucher_type == VOUCHER_TYPE_FOOD_OR_DRINK_FREE) && - (voucher_arguments == shopItem)) + if ((item_standard_flags & PEEP_ITEM_VOUCHER) && (voucher_type == VOUCHER_TYPE_FOOD_OR_DRINK_FREE) + && (voucher_arguments == shopItem)) { hasVoucher = true; } @@ -1227,8 +1222,8 @@ bool rct_peep::DecideAndBuyItem(uint8_t rideIndex, int32_t shopItem, money32 pri return false; } - if ((shopItem == SHOP_ITEM_BALLOON) || (shopItem == SHOP_ITEM_ICE_CREAM) || (shopItem == SHOP_ITEM_CANDYFLOSS) || - (shopItem == SHOP_ITEM_SUNGLASSES)) + if ((shopItem == SHOP_ITEM_BALLOON) || (shopItem == SHOP_ITEM_ICE_CREAM) || (shopItem == SHOP_ITEM_CANDYFLOSS) + || (shopItem == SHOP_ITEM_SUNGLASSES)) { if (climate_is_raining()) return false; @@ -1306,9 +1301,9 @@ loc_69B119: if (itemValue > ((money16)(scenario_rand() & 0x07))) { // "I'm not paying that much for x" - uint8_t thought_type = - (shopItem >= 32 ? (PEEP_THOUGHT_TYPE_PHOTO2_MUCH + (shopItem - 32)) - : (PEEP_THOUGHT_TYPE_BALLOON_MUCH + shopItem)); + uint8_t thought_type + = (shopItem >= 32 ? (PEEP_THOUGHT_TYPE_PHOTO2_MUCH + (shopItem - 32)) + : (PEEP_THOUGHT_TYPE_BALLOON_MUCH + shopItem)); peep_insert_new_thought(this, thought_type, rideIndex); return false; } @@ -1323,16 +1318,16 @@ loc_69B119: if (itemValue >= (money32)(scenario_rand() & 0x07)) { // "This x is a really good value" - uint8_t thought_item = - (shopItem >= 32 ? (PEEP_THOUGHT_TYPE_PHOTO2 + (shopItem - 32)) - : (PEEP_THOUGHT_TYPE_BALLOON + shopItem)); + uint8_t thought_item + = (shopItem >= 32 ? (PEEP_THOUGHT_TYPE_PHOTO2 + (shopItem - 32)) + : (PEEP_THOUGHT_TYPE_BALLOON + shopItem)); peep_insert_new_thought(this, thought_item, rideIndex); } } int32_t happinessGrowth = itemValue * 4; - happiness_target = std::min((happiness_target + happinessGrowth), PEEP_MAX_HAPPINESS); - happiness = std::min((happiness + happinessGrowth), PEEP_MAX_HAPPINESS); + happiness_target = std::min((happiness_target + happinessGrowth), PEEP_MAX_HAPPINESS); + happiness = std::min((happiness + happinessGrowth), PEEP_MAX_HAPPINESS); } } @@ -1385,7 +1380,7 @@ loc_69B221: peep_reset_pathfind_goal(this); uint16_t consumptionTime = item_consumption_time[shopItem]; - time_to_consume = std::min((time_to_consume + consumptionTime), 255); + time_to_consume = std::min((time_to_consume + consumptionTime), 255); if (shopItem == SHOP_ITEM_PHOTO) photo1_ride_ref = rideIndex; @@ -1421,18 +1416,18 @@ loc_69B221: if (shop_item_is_souvenir(shopItem)) no_of_souvenirs++; - money16 * expend_type = &paid_on_souvenirs; + money16* expend_type = &paid_on_souvenirs; gCommandExpenditureType = RCT_EXPENDITURE_TYPE_SHOP_STOCK; if (shop_item_is_food(shopItem)) { - expend_type = &paid_on_food; + expend_type = &paid_on_food; gCommandExpenditureType = RCT_EXPENDITURE_TYPE_FOODDRINK_STOCK; } if (shop_item_is_drink(shopItem)) { - expend_type = &paid_on_drink; + expend_type = &paid_on_drink; gCommandExpenditureType = RCT_EXPENDITURE_TYPE_FOODDRINK_STOCK; } @@ -1466,7 +1461,7 @@ loc_69B221: */ void rct_peep::OnEnterRide(uint8_t rideIndex) { - Ride * ride = get_ride(rideIndex); + Ride* ride = get_ride(rideIndex); // Calculate how satisfying the ride is for the peep. Can range from -140 to +105. int16_t satisfaction = peep_calculate_ride_satisfaction(this, ride); @@ -1498,7 +1493,7 @@ void rct_peep::OnEnterRide(uint8_t rideIndex) */ void rct_peep::OnExitRide(uint8_t rideIndex) { - Ride * ride = get_ride(rideIndex); + Ride* ride = get_ride(rideIndex); if (peep_flags & PEEP_FLAGS_RIDE_SHOULD_BE_MARKED_AS_FAVOURITE) { @@ -1508,7 +1503,7 @@ void rct_peep::OnExitRide(uint8_t rideIndex) window_invalidate_flags |= PEEP_INVALIDATE_STAFF_STATS; } happiness = happiness_target; - nausea = nausea_target; + nausea = nausea_target; window_invalidate_flags |= PEEP_INVALIDATE_PEEP_STATS; if (peep_flags & PEEP_FLAGS_LEAVING_PARK) @@ -1517,10 +1512,10 @@ void rct_peep::OnExitRide(uint8_t rideIndex) if (peep_should_go_on_ride_again(this, ride)) { guest_heading_to_ride_id = rideIndex; - peep_is_lost_countdown = 200; + peep_is_lost_countdown = 200; peep_reset_pathfind_goal(this); - rct_window * w = window_find_by_number(WC_PEEP, sprite_index); + rct_window* w = window_find_by_number(WC_PEEP, sprite_index); if (w != nullptr) { window_event_invalidate_call(w); @@ -1574,12 +1569,12 @@ bool rct_peep::HasFood() const } /** -* -* rct2: 0x00695DD2 -*/ + * + * rct2: 0x00695DD2 + */ void rct_peep::PickRideToGoOn() { - Ride * ride; + Ride* ride; if (state != PEEP_STATE_WALKING) return; @@ -1601,7 +1596,7 @@ void rct_peep::PickRideToGoOn() { // Consider rides that peep hasn't been on yet int32_t i; - FOR_ALL_RIDES(i, ride) + FOR_ALL_RIDES (i, ride) { if (!HasRidden(i)) { @@ -1620,7 +1615,7 @@ void rct_peep::PickRideToGoOn() { if (tileX >= 0 && tileY >= 0 && tileX < (256 * 32) && tileY < (256 * 32)) { - rct_tile_element * tileElement = map_get_first_element_at(tileX >> 5, tileY >> 5); + rct_tile_element* tileElement = map_get_first_element_at(tileX >> 5, tileY >> 5); do { if (tileElement->GetType() != TILE_ELEMENT_TYPE_TRACK) @@ -1635,7 +1630,7 @@ void rct_peep::PickRideToGoOn() // Always take the tall rides into consideration (realistic as you can usually see them from anywhere in the park) int32_t i; - FOR_ALL_RIDES(i, ride) + FOR_ALL_RIDES (i, ride) { if (ride->status != RIDE_STATUS_OPEN) continue; @@ -1650,8 +1645,8 @@ void rct_peep::PickRideToGoOn() // Filter the considered rides uint8_t potentialRides[256]; - uint8_t * nextPotentialRide = &potentialRides[0]; - int32_t numPotentialRides = 0; + uint8_t* nextPotentialRide = &potentialRides[0]; + int32_t numPotentialRides = 0; for (int32_t i = 0; i < MAX_RIDES; i++) { if (!(rideConsideration[i >> 5] & (1u << (i & 0x1F)))) @@ -1669,7 +1664,7 @@ void rct_peep::PickRideToGoOn() } // Pick the most exciting ride - int32_t mostExcitingRideIndex = -1; + int32_t mostExcitingRideIndex = -1; ride_rating mostExcitingRideRating = 0; for (int32_t i = 0; i < numPotentialRides; i++) { @@ -1691,7 +1686,7 @@ void rct_peep::PickRideToGoOn() peep_reset_pathfind_goal(this); // Invalidate windows - rct_window * w = window_find_by_number(WC_PEEP, sprite_index); + rct_window* w = window_find_by_number(WC_PEEP, sprite_index); if (w != nullptr) { window_event_invalidate_call(w); @@ -1706,24 +1701,23 @@ void rct_peep::PickRideToGoOn() } /** -* This function is called whenever a peep is deciding whether or not they want -* to go on a ride or visit a shop. They may be physically present at the -* ride/shop, or they may just be thinking about it. -* rct2: 0x006960AB -*/ + * This function is called whenever a peep is deciding whether or not they want + * to go on a ride or visit a shop. They may be physically present at the + * ride/shop, or they may just be thinking about it. + * rct2: 0x006960AB + */ bool rct_peep::ShouldGoOnRide(int32_t rideIndex, int32_t entranceNum, bool atQueue, bool thinking) { - Ride * ride = get_ride(rideIndex); + Ride* ride = get_ride(rideIndex); // Indicates whether a peep is physically at the ride, or is just thinking about going on the ride. bool peepAtRide = !thinking; if (ride->status == RIDE_STATUS_OPEN && !(ride->lifecycle_flags & RIDE_LIFECYCLE_BROKEN_DOWN)) { - // Peeps that are leaving the park will refuse to go on any rides, with the exception of free transport rides. - if (!(RideData4[ride->type].flags & RIDE_TYPE_FLAG4_TRANSPORT_RIDE) || ride->value == 0xFFFF || - ride_get_price(ride) != 0) + if (!(RideData4[ride->type].flags & RIDE_TYPE_FLAG4_TRANSPORT_RIDE) || ride->value == 0xFFFF + || ride_get_price(ride) != 0) { if (peep_flags & PEEP_FLAGS_LEAVING_PARK) { @@ -1762,7 +1756,7 @@ bool rct_peep::ShouldGoOnRide(int32_t rideIndex, int32_t entranceNum, bool atQue // Check if there's room in the queue for the peep to enter. if (ride->last_peep_in_queue[entranceNum] != 0xFFFF) { - rct_peep * lastPeepInQueue = GET_PEEP(ride->last_peep_in_queue[entranceNum]); + rct_peep* lastPeepInQueue = GET_PEEP(ride->last_peep_in_queue[entranceNum]); if (abs(lastPeepInQueue->z - z) <= 6) { int32_t dx = abs(lastPeepInQueue->x - x); @@ -1802,7 +1796,6 @@ bool rct_peep::ShouldGoOnRide(int32_t rideIndex, int32_t entranceNum, bool atQue // Basic price checks if (ridePrice != 0 && !peep_has_voucher_for_free_ride(this, rideIndex)) { - if (ridePrice > cash_in_pocket) { if (peepAtRide) @@ -1933,8 +1926,8 @@ bool rct_peep::ShouldGoOnRide(int32_t rideIndex, int32_t entranceNum, bool atQue if (!gCheatsIgnoreRideIntensity) { - if (ride->max_positive_vertical_g > FIXED_2DP(5, 00) || ride->max_negative_vertical_g < FIXED_2DP(-4, 00) || - ride->max_lateral_g > FIXED_2DP(4, 00)) + if (ride->max_positive_vertical_g > FIXED_2DP(5, 00) || ride->max_negative_vertical_g < FIXED_2DP(-4, 00) + || ride->max_lateral_g > FIXED_2DP(4, 00)) { ChoseNotToGoOnRide(rideIndex, peepAtRide, false); return false; @@ -1947,7 +1940,6 @@ bool rct_peep::ShouldGoOnRide(int32_t rideIndex, int32_t entranceNum, bool atQue // If the value of the ride hasn't yet been calculated, peeps will be willing to pay any amount for the ride. if (value != 0xFFFF && !peep_has_voucher_for_free_ride(this, rideIndex) && !(gParkFlags & PARK_FLAGS_NO_MONEY)) { - // The amount peeps are willing to pay is decreased by 75% if they had to pay to enter the park. if (peep_flags & PEEP_FLAGS_HAS_PAID_FOR_PARK_ENTRY) value /= 4; @@ -2004,7 +1996,7 @@ bool rct_peep::ShouldGoOnRide(int32_t rideIndex, int32_t entranceNum, bool atQue bool rct_peep::ShouldGoToShop(int32_t rideIndex, bool peepAtShop) { - Ride * ride = get_ride(rideIndex); + Ride* ride = get_ride(rideIndex); // Peeps won't go to the same shop twice in a row. if (rideIndex == previous_ride) @@ -2089,7 +2081,7 @@ void rct_peep::SpendMoney(money32 amount) * rct2: 0x0069926C * Expend type was previously an offset saved in 0x00F1AEC0 */ -void rct_peep::SpendMoney(money16 & peep_expend_type, money32 amount) +void rct_peep::SpendMoney(money16& peep_expend_type, money32 amount) { assert(!(gParkFlags & PARK_FLAGS_NO_MONEY)); @@ -2119,7 +2111,7 @@ void rct_peep::SpendMoney(money16 & peep_expend_type, money32 amount) void rct_peep::SetHasRidden(int32_t rideIndex) { rides_been_on[rideIndex / 8] |= 1 << (rideIndex % 8); - Ride * ride = get_ride(rideIndex); + Ride* ride = get_ride(rideIndex); SetHasRiddenRideType(ride->type); } @@ -2164,10 +2156,10 @@ void rct_peep::ReadMap() } } -static bool peep_has_voucher_for_free_ride(rct_peep * peep, int32_t rideIndex) +static bool peep_has_voucher_for_free_ride(rct_peep* peep, int32_t rideIndex) { - return peep->item_standard_flags & PEEP_ITEM_VOUCHER && peep->voucher_type == VOUCHER_TYPE_RIDE_FREE && - peep->voucher_arguments == rideIndex; + return peep->item_standard_flags & PEEP_ITEM_VOUCHER && peep->voucher_type == VOUCHER_TYPE_RIDE_FREE + && peep->voucher_arguments == rideIndex; } /** @@ -2175,12 +2167,12 @@ static bool peep_has_voucher_for_free_ride(rct_peep * peep, int32_t rideIndex) * Does not effect peeps that walk up to the queue entrance. * This flag is reset the next time a peep successfully joins the queue. */ -static void peep_tried_to_enter_full_queue(rct_peep * peep, int32_t rideIndex) +static void peep_tried_to_enter_full_queue(rct_peep* peep, int32_t rideIndex) { - Ride * ride = get_ride(rideIndex); + Ride* ride = get_ride(rideIndex); ride->lifecycle_flags |= RIDE_LIFECYCLE_QUEUE_FULL; - peep->previous_ride = rideIndex; + peep->previous_ride = rideIndex; peep->previous_ride_time_out = 0; // Change status "Heading to" to "Walking" if queue is full if (rideIndex == peep->guest_heading_to_ride_id) @@ -2189,12 +2181,12 @@ static void peep_tried_to_enter_full_queue(rct_peep * peep, int32_t rideIndex) } } -static void peep_reset_ride_heading(rct_peep * peep) +static void peep_reset_ride_heading(rct_peep* peep) { - rct_window * w; + rct_window* w; peep->guest_heading_to_ride_id = 255; - w = window_find_by_number(WC_PEEP, peep->sprite_index); + w = window_find_by_number(WC_PEEP, peep->sprite_index); if (w != nullptr) { window_event_invalidate_call(w); @@ -2202,9 +2194,9 @@ static void peep_reset_ride_heading(rct_peep * peep) } } -static void peep_ride_is_too_intense(rct_peep * peep, int32_t rideIndex, bool peepAtRide) +static void peep_ride_is_too_intense(rct_peep* peep, int32_t rideIndex, bool peepAtRide) { - Ride * ride = get_ride(rideIndex); + Ride* ride = get_ride(rideIndex); if (peepAtRide) { @@ -2222,7 +2214,7 @@ static void peep_ride_is_too_intense(rct_peep * peep, int32_t rideIndex, bool pe * * rct2: 0x00691C6E */ -static rct_vehicle * peep_choose_car_from_ride(rct_peep * peep, Ride * ride, std::vector &car_array) +static rct_vehicle* peep_choose_car_from_ride(rct_peep* peep, Ride* ride, std::vector& car_array) { uint8_t chosen_car = scenario_rand(); if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_HAS_G_FORCES) && ((chosen_car & 0xC) != 0xC)) @@ -2236,7 +2228,7 @@ static rct_vehicle * peep_choose_car_from_ride(rct_peep * peep, Ride * ride, std peep->current_car = car_array[chosen_car]; - rct_vehicle * vehicle = GET_VEHICLE(ride->vehicles[peep->current_train]); + rct_vehicle* vehicle = GET_VEHICLE(ride->vehicles[peep->current_train]); for (int32_t i = peep->current_car; i > 0; --i) { @@ -2250,13 +2242,12 @@ static rct_vehicle * peep_choose_car_from_ride(rct_peep * peep, Ride * ride, std * * rct2: 0x00691CD1 */ -static void peep_choose_seat_from_car(rct_peep * peep, Ride * ride, rct_vehicle * vehicle) +static void peep_choose_seat_from_car(rct_peep* peep, Ride* ride, rct_vehicle* vehicle) { uint8_t chosen_seat = vehicle->next_free_seat; if (ride->mode == RIDE_MODE_FORWARD_ROTATION || ride->mode == RIDE_MODE_BACKWARD_ROTATION) { - chosen_seat = (((~vehicle->vehicle_sprite_type + 1) >> 3) & 0xF) * 2; if (vehicle->next_free_seat & 1) { @@ -2266,7 +2257,7 @@ static void peep_choose_seat_from_car(rct_peep * peep, Ride * ride, rct_vehicle peep->current_seat = chosen_seat; vehicle->next_free_seat++; - vehicle->peep[peep->current_seat] = peep->sprite_index; + vehicle->peep[peep->current_seat] = peep->sprite_index; vehicle->peep_tshirt_colours[peep->current_seat] = peep->tshirt_colour; } @@ -2274,7 +2265,7 @@ static void peep_choose_seat_from_car(rct_peep * peep, Ride * ride, rct_vehicle * * rct2: 0x00691D27 */ -static void peep_go_to_ride_entrance(rct_peep * peep, Ride * ride) +static void peep_go_to_ride_entrance(rct_peep* peep, Ride* ride) { TileCoordsXYZD location = ride_get_entrance_location(peep->current_ride, peep->current_ride_station); Guard::Assert(!location.isNull()); @@ -2291,12 +2282,13 @@ static void peep_go_to_ride_entrance(rct_peep * peep, Ride * ride) int16_t x_shift = word_981D6C[direction].x; int16_t y_shift = word_981D6C[direction].y; - uint8_t shift_multiplier = 21; - rct_ride_entry * rideEntry = get_ride_entry(ride->subtype); + uint8_t shift_multiplier = 21; + rct_ride_entry* rideEntry = get_ride_entry(ride->subtype); if (rideEntry != nullptr) { - if (rideEntry->vehicles[rideEntry->default_vehicle].flags & VEHICLE_ENTRY_FLAG_MINI_GOLF || - rideEntry->vehicles[rideEntry->default_vehicle].flags & (VEHICLE_ENTRY_FLAG_CHAIRLIFT | VEHICLE_ENTRY_FLAG_GO_KART)) + if (rideEntry->vehicles[rideEntry->default_vehicle].flags & VEHICLE_ENTRY_FLAG_MINI_GOLF + || rideEntry->vehicles[rideEntry->default_vehicle].flags + & (VEHICLE_ENTRY_FLAG_CHAIRLIFT | VEHICLE_ENTRY_FLAG_GO_KART)) { shift_multiplier = 32; } @@ -2308,20 +2300,20 @@ static void peep_go_to_ride_entrance(rct_peep * peep, Ride * ride) x += x_shift; y += y_shift; - peep->destination_x = x; - peep->destination_y = y; + peep->destination_x = x; + peep->destination_y = y; peep->destination_tolerance = 2; peep->SetState(PEEP_STATE_ENTERING_RIDE); peep->sub_state = PEEP_RIDE_IN_ENTRANCE; - peep->rejoin_queue_timeout = 0; + peep->rejoin_queue_timeout = 0; peep->time_on_ride = 0; peep->RemoveFromQueue(); } -static bool peep_find_vehicle_to_enter(rct_peep * peep, Ride * ride, std::vector &car_array) +static bool peep_find_vehicle_to_enter(rct_peep* peep, Ride* ride, std::vector& car_array) { uint8_t chosen_train = 0xFF; @@ -2332,7 +2324,7 @@ static bool peep_find_vehicle_to_enter(rct_peep * peep, Ride * ride, std::vector for (int32_t i = 0; i < ride->num_vehicles; ++i) { - rct_vehicle * vehicle = GET_VEHICLE(ride->vehicles[i]); + rct_vehicle* vehicle = GET_VEHICLE(ride->vehicles[i]); if (vehicle->next_free_seat >= vehicle->num_seats) continue; @@ -2356,8 +2348,8 @@ static bool peep_find_vehicle_to_enter(rct_peep * peep, Ride * ride, std::vector int32_t i = 0; - uint16_t vehicle_id = ride->vehicles[chosen_train]; - rct_vehicle * vehicle = GET_VEHICLE(vehicle_id); + uint16_t vehicle_id = ride->vehicles[chosen_train]; + rct_vehicle* vehicle = GET_VEHICLE(vehicle_id); for (; vehicle_id != SPRITE_INDEX_NULL; vehicle_id = vehicle->next_vehicle_on_train, i++) { @@ -2390,7 +2382,7 @@ static bool peep_find_vehicle_to_enter(rct_peep * peep, Ride * ride, std::vector return !car_array.empty(); } -static void peep_update_ride_at_entrance_try_leave(rct_peep * peep) +static void peep_update_ride_at_entrance_try_leave(rct_peep* peep) { // Destination Tolerance is zero when peep has completely // entered entrance @@ -2401,13 +2393,12 @@ static void peep_update_ride_at_entrance_try_leave(rct_peep * peep) } } -static bool peep_check_ride_price_at_entrance(rct_peep * peep, Ride * ride, money32 ridePrice) +static bool peep_check_ride_price_at_entrance(rct_peep* peep, Ride* ride, money32 ridePrice) { - if ((peep->item_standard_flags & PEEP_ITEM_VOUCHER) && - peep->voucher_type == VOUCHER_TYPE_RIDE_FREE && - peep->voucher_arguments == peep->current_ride) + if ((peep->item_standard_flags & PEEP_ITEM_VOUCHER) && peep->voucher_type == VOUCHER_TYPE_RIDE_FREE + && peep->voucher_arguments == peep->current_ride) return true; - + if (peep->cash_in_pocket <= 0) { peep_insert_new_thought(peep, PEEP_THOUGHT_TYPE_SPENT_MONEY, PEEP_THOUGHT_ITEM_NONE); @@ -2443,7 +2434,7 @@ static bool peep_check_ride_price_at_entrance(rct_peep * peep, Ride * ride, mone * - How long the peep was waiting in the queue * - If the peep has been on the ride before, or on another ride of the same type */ -static int16_t peep_calculate_ride_satisfaction(rct_peep * peep, Ride * ride) +static int16_t peep_calculate_ride_satisfaction(rct_peep* peep, Ride* ride) { int16_t satisfaction = peep_calculate_ride_value_satisfaction(peep, ride); satisfaction += peep_calculate_ride_intensity_nausea_satisfaction(peep, ride); @@ -2479,7 +2470,7 @@ static int16_t peep_calculate_ride_satisfaction(rct_peep * peep, Ride * ride) * the ride becomes the peep's favourite. (This doesn't happen right away, but will be updated once the peep * exits the ride.) */ -static void peep_update_favourite_ride(rct_peep * peep, Ride * ride) +static void peep_update_favourite_ride(rct_peep* peep, Ride* ride) { peep->peep_flags &= ~PEEP_FLAGS_RIDE_SHOULD_BE_MARKED_AS_FAVOURITE; uint8_t peepRideRating = Math::Clamp(0, (ride->excitement / 4) + peep->happiness, PEEP_MAX_HAPPINESS); @@ -2494,7 +2485,7 @@ static void peep_update_favourite_ride(rct_peep * peep, Ride * ride) } /* rct2: 0x00695555 */ -static int16_t peep_calculate_ride_value_satisfaction(rct_peep * peep, Ride * ride) +static int16_t peep_calculate_ride_value_satisfaction(rct_peep* peep, Ride* ride) { if (gParkFlags & PARK_FLAGS_NO_MONEY) { @@ -2526,17 +2517,17 @@ static int16_t peep_calculate_ride_value_satisfaction(rct_peep * peep, Ride * ri * of the ride fall exactly within the peep's preferences, but lower scores can still be achieved * if the peep's happiness is enough to offset it. */ -static int16_t peep_calculate_ride_intensity_nausea_satisfaction(rct_peep * peep, Ride * ride) +static int16_t peep_calculate_ride_intensity_nausea_satisfaction(rct_peep* peep, Ride* ride) { if (!ride_has_ratings(ride)) { return 70; } - uint8_t intensitySatisfaction = 3; - uint8_t nauseaSatisfaction = 3; - ride_rating maxIntensity = (peep->intensity >> 4) * 100; - ride_rating minIntensity = (peep->intensity & 0xF) * 100; + uint8_t intensitySatisfaction = 3; + uint8_t nauseaSatisfaction = 3; + ride_rating maxIntensity = (peep->intensity >> 4) * 100; + ride_rating minIntensity = (peep->intensity & 0xF) * 100; if (minIntensity <= ride->intensity && maxIntensity >= ride->intensity) { intensitySatisfaction--; @@ -2576,46 +2567,46 @@ static int16_t peep_calculate_ride_intensity_nausea_satisfaction(rct_peep * peep } uint8_t highestSatisfaction = std::max(intensitySatisfaction, nauseaSatisfaction); - uint8_t lowestSatisfaction = std::min(intensitySatisfaction, nauseaSatisfaction); + uint8_t lowestSatisfaction = std::min(intensitySatisfaction, nauseaSatisfaction); switch (highestSatisfaction) { - default: - case 0: - return 70; - case 1: - switch (lowestSatisfaction) - { default: case 0: - return 50; + return 70; case 1: - return 35; - } - case 2: - switch (lowestSatisfaction) - { - default: - case 0: - return 35; - case 1: - return 20; + switch (lowestSatisfaction) + { + default: + case 0: + return 50; + case 1: + return 35; + } case 2: - return 10; - } - case 3: - switch (lowestSatisfaction) - { - default: - case 0: - return -35; - case 1: - return -50; - case 2: - return -60; + switch (lowestSatisfaction) + { + default: + case 0: + return 35; + case 1: + return 20; + case 2: + return 10; + } case 3: - return -60; - } + switch (lowestSatisfaction) + { + default: + case 0: + return -35; + case 1: + return -50; + case 2: + return -60; + case 3: + return -60; + } } } @@ -2626,16 +2617,16 @@ static int16_t peep_calculate_ride_intensity_nausea_satisfaction(rct_peep * peep * - How hungry the peep is (+0% nausea at 50% hunger up to +100% nausea at 100% hunger) * - The peep's nausea tolerance (Final modifier: none: 100%, low: 50%, average: 25%, high: 12.5%) */ -static void peep_update_ride_nausea_growth(rct_peep * peep, Ride * ride) +static void peep_update_ride_nausea_growth(rct_peep* peep, Ride* ride) { - uint32_t nauseaMultiplier = Math::Clamp(64, 256 - peep->happiness_target, 200); + uint32_t nauseaMultiplier = Math::Clamp(64, 256 - peep->happiness_target, 200); uint32_t nauseaGrowthRateChange = (ride->nausea * nauseaMultiplier) / 512; nauseaGrowthRateChange *= std::max(static_cast(128), peep->hunger) / 64; nauseaGrowthRateChange >>= (peep->nausea_tolerance & 3); peep->nausea_target = (uint8_t)std::min(peep->nausea_target + nauseaGrowthRateChange, 255u); } -static bool peep_should_go_on_ride_again(rct_peep * peep, Ride * ride) +static bool peep_should_go_on_ride_again(rct_peep* peep, Ride* ride) { if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_PEEP_WILL_RIDE_AGAIN)) return false; @@ -2668,7 +2659,7 @@ static bool peep_should_go_on_ride_again(rct_peep * peep, Ride * ride) return true; } -static bool peep_should_preferred_intensity_increase(rct_peep * peep) +static bool peep_should_preferred_intensity_increase(rct_peep* peep) { if (gParkFlags & PARK_FLAGS_PREF_LESS_INTENSE_RIDES) return false; @@ -2678,7 +2669,7 @@ static bool peep_should_preferred_intensity_increase(rct_peep * peep) return (scenario_rand() & 0xFF) >= peep->intensity; } -static bool peep_really_liked_ride(rct_peep * peep, Ride * ride) +static bool peep_really_liked_ride(rct_peep* peep, Ride* ride) { if (peep->happiness < 215) return false; @@ -2700,86 +2691,86 @@ static uint8_t peep_assess_surroundings(int16_t centre_x, int16_t centre_y, int1 if ((tile_element_height(centre_x, centre_y) & 0xFFFF) > centre_z) return PEEP_THOUGHT_TYPE_NONE; - uint16_t num_scenery = 0; + uint16_t num_scenery = 0; uint16_t num_fountains = 0; - uint16_t nearby_music = 0; - uint16_t num_rubbish = 0; + uint16_t nearby_music = 0; + uint16_t num_rubbish = 0; int16_t initial_x = std::max(centre_x - 160, 0); int16_t initial_y = std::max(centre_y - 160, 0); - int16_t final_x = std::min(centre_x + 160, 8192); - int16_t final_y = std::min(centre_y + 160, 8192); + int16_t final_x = std::min(centre_x + 160, 8192); + int16_t final_y = std::min(centre_y + 160, 8192); for (int16_t x = initial_x; x < final_x; x += 32) { for (int16_t y = initial_y; y < final_y; y += 32) { - rct_tile_element * tileElement = map_get_first_element_at(x / 32, y / 32); + rct_tile_element* tileElement = map_get_first_element_at(x / 32, y / 32); do { - Ride * ride; - rct_scenery_entry * scenery; + Ride* ride; + rct_scenery_entry* scenery; switch (tileElement->GetType()) { - case TILE_ELEMENT_TYPE_PATH: - if (!footpath_element_has_path_scenery(tileElement)) - break; + case TILE_ELEMENT_TYPE_PATH: + if (!footpath_element_has_path_scenery(tileElement)) + break; - scenery = get_footpath_item_entry(footpath_element_get_path_scenery_index(tileElement)); - if (scenery == nullptr) - { - return PEEP_THOUGHT_TYPE_NONE; - } - if (footpath_element_path_scenery_is_ghost(tileElement)) - break; - - if (scenery->path_bit.flags & (PATH_BIT_FLAG_JUMPING_FOUNTAIN_WATER | PATH_BIT_FLAG_JUMPING_FOUNTAIN_SNOW)) - { - num_fountains++; - break; - } - if (tileElement->flags & TILE_ELEMENT_FLAG_BROKEN) - { - num_rubbish++; - } - break; - case TILE_ELEMENT_TYPE_LARGE_SCENERY: - case TILE_ELEMENT_TYPE_SMALL_SCENERY: - num_scenery++; - break; - case TILE_ELEMENT_TYPE_TRACK: - ride = get_ride(track_element_get_ride_index(tileElement)); - if (ride->lifecycle_flags & RIDE_LIFECYCLE_MUSIC && ride->status != RIDE_STATUS_CLOSED && - !(ride->lifecycle_flags & (RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED))) - { - - if (ride->type == RIDE_TYPE_MERRY_GO_ROUND) + scenery = get_footpath_item_entry(footpath_element_get_path_scenery_index(tileElement)); + if (scenery == nullptr) { - nearby_music |= 1; + return PEEP_THOUGHT_TYPE_NONE; + } + if (footpath_element_path_scenery_is_ghost(tileElement)) + break; + + if (scenery->path_bit.flags + & (PATH_BIT_FLAG_JUMPING_FOUNTAIN_WATER | PATH_BIT_FLAG_JUMPING_FOUNTAIN_SNOW)) + { + num_fountains++; break; } - - if (ride->music == MUSIC_STYLE_ORGAN) + if (tileElement->flags & TILE_ELEMENT_FLAG_BROKEN) { - nearby_music |= 1; - break; + num_rubbish++; } - - if (ride->type == RIDE_TYPE_DODGEMS) + break; + case TILE_ELEMENT_TYPE_LARGE_SCENERY: + case TILE_ELEMENT_TYPE_SMALL_SCENERY: + num_scenery++; + break; + case TILE_ELEMENT_TYPE_TRACK: + ride = get_ride(track_element_get_ride_index(tileElement)); + if (ride->lifecycle_flags & RIDE_LIFECYCLE_MUSIC && ride->status != RIDE_STATUS_CLOSED + && !(ride->lifecycle_flags & (RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED))) { - // Dodgems drown out music? - nearby_music |= 2; + if (ride->type == RIDE_TYPE_MERRY_GO_ROUND) + { + nearby_music |= 1; + break; + } + + if (ride->music == MUSIC_STYLE_ORGAN) + { + nearby_music |= 1; + break; + } + + if (ride->type == RIDE_TYPE_DODGEMS) + { + // Dodgems drown out music? + nearby_music |= 2; + } } - } - break; + break; } } while (!(tileElement++)->IsLastForTile()); } } - rct_litter * litter; + rct_litter* litter; for (uint16_t sprite_idx = gSpriteListHead[SPRITE_LIST_LITTER]; sprite_idx != SPRITE_INDEX_NULL; sprite_idx = litter->next) { litter = &(get_sprite(sprite_idx)->litter); @@ -2812,14 +2803,14 @@ static uint8_t peep_assess_surroundings(int16_t centre_x, int16_t centre_y, int1 * * rct2: 0x0068F9A9 */ -static void peep_update_hunger(rct_peep * peep) +static void peep_update_hunger(rct_peep* peep) { if (peep->hunger >= 3) { peep->hunger -= 2; peep->energy_target = std::min(peep->energy_target + 2, PEEP_MAX_ENERGY_TARGET); - peep->toilet = std::min(peep->toilet + 1, 255); + peep->toilet = std::min(peep->toilet + 1, 255); } } @@ -2829,7 +2820,7 @@ static void peep_update_hunger(rct_peep * peep) * * rct2: 0x0068F8CD */ -static void peep_decide_whether_to_leave_park(rct_peep * peep) +static void peep_decide_whether_to_leave_park(rct_peep* peep) { if (peep->energy_target >= 33) { @@ -2881,7 +2872,7 @@ static void peep_decide_whether_to_leave_park(rct_peep * peep) * * rct2: 0x0068F93E */ -static void peep_leave_park(rct_peep * peep) +static void peep_leave_park(rct_peep* peep) { peep->guest_heading_to_ride_id = 0xFF; if (peep->peep_flags & PEEP_FLAGS_LEAVING_PARK) @@ -2900,7 +2891,7 @@ static void peep_leave_park(rct_peep * peep) peep_insert_new_thought(peep, PEEP_THOUGHT_TYPE_GO_HOME, PEEP_THOUGHT_ITEM_NONE); - rct_window * w = window_find_by_number(WC_PEEP, peep->sprite_index); + rct_window* w = window_find_by_number(WC_PEEP, peep->sprite_index); if (w != nullptr) window_event_invalidate_call(w); window_invalidate_by_number(WC_PEEP, peep->sprite_index); @@ -2910,9 +2901,9 @@ static void peep_leave_park(rct_peep * peep) * * rct2: 0x00695B70 */ -static void peep_head_for_nearest_ride_type(rct_peep * peep, int32_t rideType) +static void peep_head_for_nearest_ride_type(rct_peep* peep, int32_t rideType) { - Ride * ride; + Ride* ride; if (peep->state != PEEP_STATE_SITTING && peep->state != PEEP_STATE_WATCHING && peep->state != PEEP_STATE_WALKING) { @@ -2938,7 +2929,7 @@ static void peep_head_for_nearest_ride_type(rct_peep * peep, int32_t rideType) { // Consider all rides in the park int32_t i; - FOR_ALL_RIDES(i, ride) + FOR_ALL_RIDES (i, ride) { if (ride->type == rideType) { @@ -2957,14 +2948,14 @@ static void peep_head_for_nearest_ride_type(rct_peep * peep, int32_t rideType) { if (x >= 0 && y >= 0 && x < (256 * 32) && y < (256 * 32)) { - rct_tile_element * tileElement = map_get_first_element_at(x >> 5, y >> 5); + rct_tile_element* tileElement = map_get_first_element_at(x >> 5, y >> 5); do { if (tileElement->GetType() != TILE_ELEMENT_TYPE_TRACK) continue; int32_t rideIndex = track_element_get_ride_index(tileElement); - ride = get_ride(rideIndex); + ride = get_ride(rideIndex); if (ride->type == rideType) { rideConsideration[rideIndex >> 5] |= (1u << (rideIndex & 0x1F)); @@ -2976,9 +2967,9 @@ static void peep_head_for_nearest_ride_type(rct_peep * peep, int32_t rideType) } // Filter the considered rides - uint8_t potentialRides[256]; - uint8_t * nextPotentialRide = &potentialRides[0]; - int32_t numPotentialRides = 0; + uint8_t potentialRides[256]; + uint8_t* nextPotentialRide = &potentialRides[0]; + int32_t numPotentialRides = 0; for (int32_t i = 0; i < MAX_RIDES; i++) { if (!(rideConsideration[i >> 5] & (1u << (i & 0x1F)))) @@ -2996,17 +2987,17 @@ static void peep_head_for_nearest_ride_type(rct_peep * peep, int32_t rideType) } // Pick the closest ride - int32_t closestRideIndex = -1; + int32_t closestRideIndex = -1; int32_t closestRideDistance = std::numeric_limits::max(); for (int32_t i = 0; i < numPotentialRides; i++) { - ride = get_ride(potentialRides[i]); - int32_t rideX = ride->station_starts[0].x * 32; - int32_t rideY = ride->station_starts[0].y * 32; + ride = get_ride(potentialRides[i]); + int32_t rideX = ride->station_starts[0].x * 32; + int32_t rideY = ride->station_starts[0].y * 32; int32_t distance = abs(rideX - peep->x) + abs(rideY - peep->y); if (distance < closestRideDistance) { - closestRideIndex = potentialRides[i]; + closestRideIndex = potentialRides[i]; closestRideDistance = distance; } } @@ -3015,11 +3006,11 @@ static void peep_head_for_nearest_ride_type(rct_peep * peep, int32_t rideType) // Head to that ride peep->guest_heading_to_ride_id = closestRideIndex; - peep->peep_is_lost_countdown = 200; + peep->peep_is_lost_countdown = 200; peep_reset_pathfind_goal(peep); // Invalidate windows - rct_window * w = window_find_by_number(WC_PEEP, peep->sprite_index); + rct_window* w = window_find_by_number(WC_PEEP, peep->sprite_index); if (w != nullptr) { window_event_invalidate_call(w); @@ -3033,9 +3024,9 @@ static void peep_head_for_nearest_ride_type(rct_peep * peep, int32_t rideType) * * rct2: 0x006958D0 */ -static void peep_head_for_nearest_ride_with_flags(rct_peep * peep, int32_t rideTypeFlags) +static void peep_head_for_nearest_ride_with_flags(rct_peep* peep, int32_t rideTypeFlags) { - Ride * ride; + Ride* ride; if (peep->state != PEEP_STATE_SITTING && peep->state != PEEP_STATE_WATCHING && peep->state != PEEP_STATE_WALKING) { @@ -3067,7 +3058,7 @@ static void peep_head_for_nearest_ride_with_flags(rct_peep * peep, int32_t rideT { // Consider all rides in the park int32_t i; - FOR_ALL_RIDES(i, ride) + FOR_ALL_RIDES (i, ride) { if (ride_type_has_flag(ride->type, rideTypeFlags)) { @@ -3086,14 +3077,14 @@ static void peep_head_for_nearest_ride_with_flags(rct_peep * peep, int32_t rideT { if (x >= 0 && y >= 0 && x < (256 * 32) && y < (256 * 32)) { - rct_tile_element * tileElement = map_get_first_element_at(x >> 5, y >> 5); + rct_tile_element* tileElement = map_get_first_element_at(x >> 5, y >> 5); do { if (tileElement->GetType() != TILE_ELEMENT_TYPE_TRACK) continue; int32_t rideIndex = track_element_get_ride_index(tileElement); - ride = get_ride(rideIndex); + ride = get_ride(rideIndex); if (ride_type_has_flag(ride->type, rideTypeFlags)) { rideConsideration[rideIndex >> 5] |= (1u << (rideIndex & 0x1F)); @@ -3105,9 +3096,9 @@ static void peep_head_for_nearest_ride_with_flags(rct_peep * peep, int32_t rideT } // Filter the considered rides - uint8_t potentialRides[256]; - uint8_t * nextPotentialRide = &potentialRides[0]; - int32_t numPotentialRides = 0; + uint8_t potentialRides[256]; + uint8_t* nextPotentialRide = &potentialRides[0]; + int32_t numPotentialRides = 0; for (int32_t i = 0; i < MAX_RIDES; i++) { if (!(rideConsideration[i >> 5] & (1u << (i & 0x1F)))) @@ -3125,17 +3116,17 @@ static void peep_head_for_nearest_ride_with_flags(rct_peep * peep, int32_t rideT } // Pick the closest ride - int32_t closestRideIndex = -1; + int32_t closestRideIndex = -1; int32_t closestRideDistance = std::numeric_limits::max(); for (int32_t i = 0; i < numPotentialRides; i++) { - ride = get_ride(potentialRides[i]); - int32_t rideX = ride->station_starts[0].x * 32; - int32_t rideY = ride->station_starts[0].y * 32; + ride = get_ride(potentialRides[i]); + int32_t rideX = ride->station_starts[0].x * 32; + int32_t rideY = ride->station_starts[0].y * 32; int32_t distance = abs(rideX - peep->x) + abs(rideY - peep->y); if (distance < closestRideDistance) { - closestRideIndex = potentialRides[i]; + closestRideIndex = potentialRides[i]; closestRideDistance = distance; } } @@ -3144,11 +3135,11 @@ static void peep_head_for_nearest_ride_with_flags(rct_peep * peep, int32_t rideT // Head to that ride peep->guest_heading_to_ride_id = closestRideIndex; - peep->peep_is_lost_countdown = 200; + peep->peep_is_lost_countdown = 200; peep_reset_pathfind_goal(peep); // Invalidate windows - rct_window * w = window_find_by_number(WC_PEEP, peep->sprite_index); + rct_window* w = window_find_by_number(WC_PEEP, peep->sprite_index); if (w != nullptr) { window_event_invalidate_call(w); @@ -3167,7 +3158,6 @@ static void peep_head_for_nearest_ride_with_flags(rct_peep * peep, int32_t rideT */ void rct_peep::StopPurchaseThought(uint8_t ride_type) { - uint8_t thoughtType = PEEP_THOUGHT_TYPE_HUNGRY; if (!ride_type_has_flag(ride_type, RIDE_TYPE_FLAG_SELLS_FOOD)) @@ -3190,7 +3180,7 @@ void rct_peep::StopPurchaseThought(uint8_t ride_type) // Remove the related thought for (int32_t i = 0; i < PEEP_MAX_THOUGHTS; ++i) { - rct_peep_thought * thought = &thoughts[i]; + rct_peep_thought* thought = &thoughts[i]; if (thought->type == PEEP_THOUGHT_TYPE_NONE) break; @@ -3214,7 +3204,7 @@ void rct_peep::StopPurchaseThought(uint8_t ride_type) * * rct2: 0x0069AEB7 */ -static bool peep_should_use_cash_machine(rct_peep * peep, int32_t rideIndex) +static bool peep_should_use_cash_machine(rct_peep* peep, int32_t rideIndex) { if (gParkFlags & PARK_FLAGS_NO_MONEY) return false; @@ -3227,7 +3217,7 @@ static bool peep_should_use_cash_machine(rct_peep * peep, int32_t rideIndex) if (peep->energy < 80) return false; - Ride * ride = get_ride(rideIndex); + Ride* ride = get_ride(rideIndex); ride_update_satisfaction(ride, peep->happiness >> 6); ride->cur_num_customers++; ride->total_customers++; @@ -3244,7 +3234,7 @@ void rct_peep::UpdateBuying() if (!CheckForPath()) return; - Ride * ride = get_ride(current_ride); + Ride* ride = get_ride(current_ride); if (ride->type == RIDE_TYPE_NULL || ride->status != RIDE_STATUS_OPEN) { SetState(PEEP_STATE_FALLING); @@ -3305,7 +3295,7 @@ void rct_peep::UpdateBuying() } else { - rct_ride_entry * ride_type = get_ride_entry(ride->subtype); + rct_ride_entry* ride_type = get_ride_entry(ride->subtype); if (ride_type == nullptr) { return; @@ -3353,11 +3343,11 @@ void rct_peep::UpdateBuying() */ void rct_peep::UpdateRideAtEntrance() { - Ride * ride = get_ride(current_ride); + Ride* ride = get_ride(current_ride); // The peep will keep advancing in the entranceway // whilst in this state. When it has reached the very - // front of the queue destination tolerance is set to + // front of the queue destination tolerance is set to // zero to indicate it is final decision time (try_leave will pass). // When a peep has to return to the queue without getting on a ride // this is the state it will return to. @@ -3416,7 +3406,7 @@ void rct_peep::UpdateRideAtEntrance() if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_NO_VEHICLES)) { - rct_vehicle * vehicle = peep_choose_car_from_ride(this, ride, carArray); + rct_vehicle* vehicle = peep_choose_car_from_ride(this, ride, carArray); peep_choose_seat_from_car(this, ride, vehicle); } peep_go_to_ride_entrance(this, ride); @@ -3430,7 +3420,7 @@ static constexpr const LocationXY16 _MazeEntranceStart[] = { { 24, 8 }, }; -static void peep_update_ride_leave_entrance_maze(rct_peep * peep, Ride * ride, TileCoordsXYZD &entrance_loc) +static void peep_update_ride_leave_entrance_maze(rct_peep* peep, Ride* ride, TileCoordsXYZD& entrance_loc) { peep->maze_last_edge = entrance_loc.direction + 1; entrance_loc.x *= 32; @@ -3463,12 +3453,12 @@ static void peep_update_ride_leave_entrance_maze(rct_peep * peep, Ride * ride, T peep->sub_state = PEEP_RIDE_MAZE_PATHFINDING; } -static void peep_update_ride_leave_entrance_spiral_slide(rct_peep * peep, Ride * ride, TileCoordsXYZD &entrance_loc) +static void peep_update_ride_leave_entrance_spiral_slide(rct_peep* peep, Ride* ride, TileCoordsXYZD& entrance_loc) { entrance_loc.x = ride->station_starts[peep->current_ride_station].x * 32; entrance_loc.y = ride->station_starts[peep->current_ride_station].y * 32; - rct_tile_element * tile_element = ride_get_station_start_track_element(ride, peep->current_ride_station); + rct_tile_element* tile_element = ride_get_station_start_track_element(ride, peep->current_ride_station); uint8_t direction_track = (tile_element == nullptr ? 0 : tile_element_get_direction(tile_element)); @@ -3488,7 +3478,8 @@ static void peep_update_ride_leave_entrance_spiral_slide(rct_peep * peep, Ride * peep->sub_state = PEEP_RIDE_APPROACH_SPIRAL_SLIDE; } -static uint8_t peep_get_waypointed_seat_location(rct_peep * peep, Ride * ride, rct_ride_entry_vehicle * vehicle_type, uint8_t track_direction) +static uint8_t + peep_get_waypointed_seat_location(rct_peep* peep, Ride* ride, rct_ride_entry_vehicle* vehicle_type, uint8_t track_direction) { // The seatlocation can be split into segments around the ride base // to decide the segment first split off the segmentable seat location @@ -3513,7 +3504,7 @@ static uint8_t peep_get_waypointed_seat_location(rct_peep * peep, Ride * ride, r return seatLocationSegment + seatLocationFixed; } -static void peep_update_ride_leave_entrance_waypoints(rct_peep * peep, Ride * ride) +static void peep_update_ride_leave_entrance_waypoints(rct_peep* peep, Ride* ride) { TileCoordsXYZD entranceLocation = ride_get_entrance_location(peep->current_ride, peep->current_ride_station); Guard::Assert(!entranceLocation.isNull()); @@ -3523,7 +3514,7 @@ static void peep_update_ride_leave_entrance_waypoints(rct_peep * peep, Ride * ri waypoint.x = ride->station_starts[peep->current_ride_station].x * 32 + 16; waypoint.y = ride->station_starts[peep->current_ride_station].y * 32 + 16; - rct_tile_element * tile_element = ride_get_station_start_track_element(ride, peep->current_ride_station); + rct_tile_element* tile_element = ride_get_station_start_track_element(ride, peep->current_ride_station); uint8_t direction_track = (tile_element == nullptr ? 0 : tile_element_get_direction(tile_element)); @@ -3556,8 +3547,8 @@ void rct_peep::UpdateRideAdvanceThroughEntrance() { int16_t actionX, actionY, actionZ, xy_distance; - Ride * ride = get_ride(current_ride); - rct_ride_entry * ride_entry = get_ride_entry(ride->subtype); + Ride* ride = get_ride(current_ride); + rct_ride_entry* ride_entry = get_ride_entry(ride->subtype); if (UpdateAction(&actionX, &actionY, &xy_distance)) { @@ -3565,8 +3556,8 @@ void rct_peep::UpdateRideAdvanceThroughEntrance() if (ride_entry != nullptr) { uint8_t vehicle = ride_entry->default_vehicle; - if (ride_entry->vehicles[vehicle].flags & VEHICLE_ENTRY_FLAG_MINI_GOLF || - ride_entry->vehicles[vehicle].flags & (VEHICLE_ENTRY_FLAG_CHAIRLIFT | VEHICLE_ENTRY_FLAG_GO_KART)) + if (ride_entry->vehicles[vehicle].flags & VEHICLE_ENTRY_FLAG_MINI_GOLF + || ride_entry->vehicles[vehicle].flags & (VEHICLE_ENTRY_FLAG_CHAIRLIFT | VEHICLE_ENTRY_FLAG_GO_KART)) { distanceThreshold = 28; } @@ -3609,7 +3600,7 @@ void rct_peep::UpdateRideAdvanceThroughEntrance() return; } - rct_vehicle * vehicle = GET_VEHICLE(ride->vehicles[current_train]); + rct_vehicle* vehicle = GET_VEHICLE(ride->vehicles[current_train]); for (int32_t i = current_car; i != 0; --i) { vehicle = GET_VEHICLE(vehicle->next_vehicle_on_train); @@ -3621,7 +3612,7 @@ void rct_peep::UpdateRideAdvanceThroughEntrance() return; } - rct_ride_entry_vehicle * vehicle_type = &ride_entry->vehicles[vehicle->vehicle_type]; + rct_ride_entry_vehicle* vehicle_type = &ride_entry->vehicles[vehicle->vehicle_type]; if (vehicle_type->flags & VEHICLE_ENTRY_FLAG_LOADING_WAYPOINTS) { @@ -3631,10 +3622,10 @@ void rct_peep::UpdateRideAdvanceThroughEntrance() if (vehicle_type->flags & VEHICLE_ENTRY_FLAG_DODGEM_CAR_PLACEMENT) { - destination_x = vehicle->x; - destination_y = vehicle->y; + destination_x = vehicle->x; + destination_y = vehicle->y; destination_tolerance = 15; - sub_state = PEEP_RIDE_APPROACH_VEHICLE; + sub_state = PEEP_RIDE_APPROACH_VEHICLE; return; } @@ -3653,18 +3644,18 @@ void rct_peep::UpdateRideAdvanceThroughEntrance() switch (vehicle->sprite_direction / 8) { - case 0: - destination_x = vehicle->x - load_position; - break; - case 1: - destination_y = vehicle->y + load_position; - break; - case 2: - destination_x = vehicle->x + load_position; - break; - case 3: - destination_y = vehicle->y - load_position; - break; + case 0: + destination_x = vehicle->x - load_position; + break; + case 1: + destination_y = vehicle->y + load_position; + break; + case 2: + destination_x = vehicle->x + load_position; + break; + case 3: + destination_y = vehicle->y - load_position; + break; } sub_state = PEEP_RIDE_APPROACH_VEHICLE; @@ -3674,11 +3665,11 @@ void rct_peep::UpdateRideAdvanceThroughEntrance() * * rct2: 0x0069321D */ -static void peep_go_to_ride_exit(rct_peep * peep, Ride * ride, int16_t x, int16_t y, int16_t z, uint8_t exit_direction) +static void peep_go_to_ride_exit(rct_peep* peep, Ride* ride, int16_t x, int16_t y, int16_t z, uint8_t exit_direction) { z += RideData5[ride->type].z; - sprite_move(x, y, z, (rct_sprite *)peep); + sprite_move(x, y, z, (rct_sprite*)peep); peep->Invalidate(); Guard::Assert(peep->current_ride_station < MAX_STATIONS); @@ -3696,12 +3687,12 @@ static void peep_go_to_ride_exit(rct_peep * peep, Ride * ride, int16_t x, int16_ int16_t shift_multiplier = 20; - rct_ride_entry * rideEntry = get_ride_entry(ride->subtype); + rct_ride_entry* rideEntry = get_ride_entry(ride->subtype); if (rideEntry != nullptr) { - rct_ride_entry_vehicle * vehicle_entry = &rideEntry->vehicles[rideEntry->default_vehicle]; - if (vehicle_entry->flags & VEHICLE_ENTRY_FLAG_MINI_GOLF || - vehicle_entry->flags & (VEHICLE_ENTRY_FLAG_CHAIRLIFT | VEHICLE_ENTRY_FLAG_GO_KART)) + rct_ride_entry_vehicle* vehicle_entry = &rideEntry->vehicles[rideEntry->default_vehicle]; + if (vehicle_entry->flags & VEHICLE_ENTRY_FLAG_MINI_GOLF + || vehicle_entry->flags & (VEHICLE_ENTRY_FLAG_CHAIRLIFT | VEHICLE_ENTRY_FLAG_GO_KART)) { shift_multiplier = 32; } @@ -3713,8 +3704,8 @@ static void peep_go_to_ride_exit(rct_peep * peep, Ride * ride, int16_t x, int16_ x -= x_shift; y -= y_shift; - peep->destination_x = x; - peep->destination_y = y; + peep->destination_x = x; + peep->destination_y = y; peep->destination_tolerance = 2; peep->sprite_direction = exit_direction * 8; @@ -3725,15 +3716,14 @@ static void peep_go_to_ride_exit(rct_peep * peep, Ride * ride, int16_t x, int16_ * * rct2: 0x006920B4 */ -void rct_peep::UpdateRideFreeVehicleEnterRide(Ride * ride) +void rct_peep::UpdateRideFreeVehicleEnterRide(Ride* ride) { money16 ridePrice = ride_get_price(ride); if (ridePrice != 0) { - if ((item_standard_flags & PEEP_ITEM_VOUCHER) && (voucher_type == VOUCHER_TYPE_RIDE_FREE) && - (voucher_arguments == current_ride)) + if ((item_standard_flags & PEEP_ITEM_VOUCHER) && (voucher_type == VOUCHER_TYPE_RIDE_FREE) + && (voucher_arguments == current_ride)) { - item_standard_flags &= ~PEEP_ITEM_VOUCHER; window_invalidate_flags |= PEEP_INVALIDATE_PEEP_INVENTORY; } @@ -3789,7 +3779,7 @@ void rct_peep::UpdateRideFreeVehicleEnterRide(Ride * ride) * * rct2: 0x00691FD4 */ -static void peep_update_ride_no_free_vehicle_rejoin_queue(rct_peep * peep, Ride * ride) +static void peep_update_ride_no_free_vehicle_rejoin_queue(rct_peep* peep, Ride* ride) { TileCoordsXYZD entranceLocation = ride_get_entrance_location(peep->current_ride, peep->current_ride_station); @@ -3798,8 +3788,8 @@ static void peep_update_ride_no_free_vehicle_rejoin_queue(rct_peep * peep, Ride x += 16 - word_981D6C[entranceLocation.direction].x * 20; y += 16 - word_981D6C[entranceLocation.direction].y * 20; - peep->destination_x = x; - peep->destination_y = y; + peep->destination_x = x; + peep->destination_y = y; peep->destination_tolerance = 2; peep->SetState(PEEP_STATE_QUEUING_FRONT); @@ -3819,13 +3809,12 @@ static void peep_update_ride_no_free_vehicle_rejoin_queue(rct_peep * peep, Ride */ void rct_peep::UpdateRideFreeVehicleCheck() { - Ride * ride = get_ride(current_ride); + Ride* ride = get_ride(current_ride); if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_NO_VEHICLES)) { if (ride->status != RIDE_STATUS_OPEN || ride->vehicle_change_timeout != 0 || (++rejoin_queue_timeout) == 0) { - peep_update_ride_no_free_vehicle_rejoin_queue(this, ride); return; } @@ -3834,13 +3823,13 @@ void rct_peep::UpdateRideFreeVehicleCheck() return; } - rct_vehicle * vehicle = GET_VEHICLE(ride->vehicles[current_train]); + rct_vehicle* vehicle = GET_VEHICLE(ride->vehicles[current_train]); for (int32_t i = current_car; i != 0; --i) { vehicle = GET_VEHICLE(vehicle->next_vehicle_on_train); } - rct_ride_entry * ride_entry = get_ride_entry(vehicle->ride_subtype); + rct_ride_entry* ride_entry = get_ride_entry(vehicle->ride_subtype); if (ride_entry == nullptr) { return; @@ -3855,8 +3844,8 @@ void rct_peep::UpdateRideFreeVehicleCheck() if (ride->vehicles[i] == SPRITE_INDEX_NULL) continue; - rct_vehicle * train = GET_VEHICLE(ride->vehicles[i]); - rct_vehicle * second_vehicle = GET_VEHICLE(train->next_vehicle_on_train); + rct_vehicle* train = GET_VEHICLE(ride->vehicles[i]); + rct_vehicle* second_vehicle = GET_VEHICLE(train->next_vehicle_on_train); if (second_vehicle->num_peeps == 0) continue; @@ -3892,9 +3881,9 @@ void rct_peep::UpdateRideFreeVehicleCheck() } } - rct_vehicle * currentTrain = GET_VEHICLE(ride->vehicles[current_train]); - if (ride->status == RIDE_STATUS_OPEN && ++rejoin_queue_timeout != 0 && - !(currentTrain->update_flags & VEHICLE_UPDATE_FLAG_TRAIN_READY_DEPART)) + rct_vehicle* currentTrain = GET_VEHICLE(ride->vehicles[current_train]); + if (ride->status == RIDE_STATUS_OPEN && ++rejoin_queue_timeout != 0 + && !(currentTrain->update_flags & VEHICLE_UPDATE_FLAG_TRAIN_READY_DEPART)) { return; } @@ -3927,9 +3916,9 @@ void rct_peep::UpdateRideApproachVehicle() void rct_peep::UpdateRideEnterVehicle() { - Ride * ride = get_ride(current_ride); + Ride* ride = get_ride(current_ride); - rct_vehicle * vehicle = GET_VEHICLE(ride->vehicles[current_train]); + rct_vehicle* vehicle = GET_VEHICLE(ride->vehicles[current_train]); for (int32_t i = current_car; i != 0; --i) { vehicle = GET_VEHICLE(vehicle->next_vehicle_on_train); @@ -3943,7 +3932,7 @@ void rct_peep::UpdateRideEnterVehicle() if (vehicle_is_used_in_pairs(vehicle)) { - rct_peep * seated_peep = GET_PEEP(vehicle->peep[current_seat ^ 1]); + rct_peep* seated_peep = GET_PEEP(vehicle->peep[current_seat ^ 1]); if (seated_peep->sub_state != PEEP_RIDE_ENTER_VEHICLE) return; @@ -3952,11 +3941,11 @@ void rct_peep::UpdateRideEnterVehicle() vehicle->mass += seated_peep->mass; seated_peep->Invalidate(); - sprite_move(LOCATION_NULL, 0, 0, (rct_sprite *)seated_peep); + sprite_move(LOCATION_NULL, 0, 0, (rct_sprite*)seated_peep); seated_peep->SetState(PEEP_STATE_ON_RIDE); seated_peep->time_on_ride = 0; - seated_peep->sub_state = PEEP_RIDE_ON_RIDE; + seated_peep->sub_state = PEEP_RIDE_ON_RIDE; seated_peep->OnEnterRide(current_ride); } @@ -3964,7 +3953,7 @@ void rct_peep::UpdateRideEnterVehicle() ride->cur_num_customers++; vehicle->mass += mass; - invalidate_sprite_2((rct_sprite *)vehicle); + invalidate_sprite_2((rct_sprite*)vehicle); Invalidate(); MoveTo(LOCATION_NULL, 0, 0); @@ -3972,7 +3961,7 @@ void rct_peep::UpdateRideEnterVehicle() SetState(PEEP_STATE_ON_RIDE); time_on_ride = 0; - sub_state = PEEP_RIDE_ON_RIDE; + sub_state = PEEP_RIDE_ON_RIDE; OnEnterRide(current_ride); } @@ -3982,10 +3971,10 @@ void rct_peep::UpdateRideEnterVehicle() */ void rct_peep::UpdateRideLeaveVehicle() { - Ride * ride = get_ride(current_ride); + Ride* ride = get_ride(current_ride); - rct_vehicle * vehicle = GET_VEHICLE(ride->vehicles[current_train]); - uint8_t ride_station = vehicle->current_station; + rct_vehicle* vehicle = GET_VEHICLE(ride->vehicles[current_train]); + uint8_t ride_station = vehicle->current_station; for (int32_t i = current_car; i != 0; --i) { @@ -4007,7 +3996,7 @@ void rct_peep::UpdateRideLeaveVehicle() vehicle->num_peeps--; vehicle->mass -= mass; - invalidate_sprite_2((rct_sprite *)vehicle); + invalidate_sprite_2((rct_sprite*)vehicle); if (ride_station >= MAX_STATIONS) { @@ -4019,14 +4008,14 @@ void rct_peep::UpdateRideLeaveVehicle() } ride_station = bestStationIndex; } - current_ride_station = ride_station; - rct_ride_entry * rideEntry = get_ride_entry(vehicle->ride_subtype); + current_ride_station = ride_station; + rct_ride_entry* rideEntry = get_ride_entry(vehicle->ride_subtype); if (rideEntry == nullptr) { return; } - rct_ride_entry_vehicle * vehicle_entry = &rideEntry->vehicles[vehicle->vehicle_type]; + rct_ride_entry_vehicle* vehicle_entry = &rideEntry->vehicles[vehicle->vehicle_type]; if (!(vehicle_entry->flags & VEHICLE_ENTRY_FLAG_LOADING_WAYPOINTS)) { @@ -4039,14 +4028,13 @@ void rct_peep::UpdateRideLeaveVehicle() if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_16)) { - for (; vehicle->is_child; vehicle = GET_VEHICLE(vehicle->prev_vehicle_on_ride)) { uint16_t trackType = vehicle->track_type >> 2; if (trackType == TRACK_ELEM_FLAT || trackType > TRACK_ELEM_MIDDLE_STATION) continue; - rct_tile_element * inner_map = map_get_first_element_at(vehicle->track_x / 32, vehicle->track_y / 32); + rct_tile_element* inner_map = map_get_first_element_at(vehicle->track_x / 32, vehicle->track_y / 32); for (;; inner_map++) { if (inner_map->GetType() != TILE_ELEMENT_TYPE_TRACK) @@ -4061,7 +4049,7 @@ void rct_peep::UpdateRideLeaveVehicle() } uint8_t shiftMultiplier = 12; - uint8_t specialDirection = platformLocation.direction; + uint8_t specialDirection = platformLocation.direction; rideEntry = get_ride_entry(ride->subtype); @@ -4091,7 +4079,8 @@ void rct_peep::UpdateRideLeaveVehicle() platformLocation.y = vehicle->y + yShift * shiftMultiplier; platformLocation.z *= 8; - peep_go_to_ride_exit(this, ride, platformLocation.x, platformLocation.y, platformLocation.z, platformLocation.direction); + peep_go_to_ride_exit( + this, ride, platformLocation.x, platformLocation.y, platformLocation.z, platformLocation.direction); return; } @@ -4102,23 +4091,24 @@ void rct_peep::UpdateRideLeaveVehicle() switch (vehicle->sprite_direction / 8) { - case 0: - platformLocation.x -= loadPosition; - break; - case 1: - platformLocation.y += loadPosition; - break; - case 2: - platformLocation.x += loadPosition; - break; - case 3: - platformLocation.y -= loadPosition; - break; + case 0: + platformLocation.x -= loadPosition; + break; + case 1: + platformLocation.y += loadPosition; + break; + case 2: + platformLocation.x += loadPosition; + break; + case 3: + platformLocation.y -= loadPosition; + break; } platformLocation.z = ride->station_heights[current_ride_station] * 8; - peep_go_to_ride_exit(this, ride, platformLocation.x, platformLocation.y, platformLocation.z, platformLocation.direction); + peep_go_to_ride_exit( + this, ride, platformLocation.x, platformLocation.y, platformLocation.z, platformLocation.direction); return; } @@ -4130,16 +4120,17 @@ void rct_peep::UpdateRideLeaveVehicle() waypointLoc.x = ride->station_starts[current_ride_station].x * 32 + 16; waypointLoc.y = ride->station_starts[current_ride_station].y * 32 + 16; - rct_tile_element * trackElement = ride_get_station_start_track_element(ride, current_ride_station); + rct_tile_element* trackElement = ride_get_station_start_track_element(ride, current_ride_station); uint8_t station_direction = (trackElement == nullptr ? 0 : tile_element_get_direction(trackElement)); vehicle = GET_VEHICLE(ride->vehicles[current_train]); - rideEntry = get_ride_entry(vehicle->ride_subtype); - rct_ride_entry_vehicle * vehicleEntry = &rideEntry->vehicles[vehicle->vehicle_type]; + rideEntry = get_ride_entry(vehicle->ride_subtype); + rct_ride_entry_vehicle* vehicleEntry = &rideEntry->vehicles[vehicle->vehicle_type]; - var_37 = ((exitLocation.direction | peep_get_waypointed_seat_location(this, ride, vehicleEntry, station_direction) * 4) * 4) | 1; + var_37 = ((exitLocation.direction | peep_get_waypointed_seat_location(this, ride, vehicleEntry, station_direction) * 4) * 4) + | 1; if (ride->type == RIDE_TYPE_ENTERPRISE) { @@ -4162,19 +4153,19 @@ void rct_peep::UpdateRideLeaveVehicle() waypointLoc.x += vehicleEntry->peep_loading_waypoints[var_37 / 4][1].x; waypointLoc.y += vehicleEntry->peep_loading_waypoints[var_37 / 4][1].y; - destination_x = waypointLoc.x; - destination_y = waypointLoc.y; + destination_x = waypointLoc.x; + destination_y = waypointLoc.y; destination_tolerance = 2; - sub_state = PEEP_RIDE_APPROACH_EXIT_WAYPOINTS; + sub_state = PEEP_RIDE_APPROACH_EXIT_WAYPOINTS; } /** * * rct2: 0x0069376A */ -static void peep_update_ride_prepare_for_exit(rct_peep * peep) +static void peep_update_ride_prepare_for_exit(rct_peep* peep) { - Ride * ride = get_ride(peep->current_ride); + Ride* ride = get_ride(peep->current_ride); Guard::Assert(peep->current_ride_station < Util::CountOf(ride->exits), GUARD_LINE); auto exit = ride_get_exit_location(peep->current_ride, peep->current_ride_station); @@ -4192,10 +4183,10 @@ static void peep_update_ride_prepare_for_exit(rct_peep * peep) int16_t shift_multiplier = 20; - rct_ride_entry * ride_type = get_ride_entry(ride->subtype); + rct_ride_entry* ride_type = get_ride_entry(ride->subtype); if (ride_type != nullptr) { - rct_ride_entry_vehicle * vehicle_entry = &ride_type->vehicles[ride_type->default_vehicle]; + rct_ride_entry_vehicle* vehicle_entry = &ride_type->vehicles[ride_type->default_vehicle]; if (vehicle_entry->flags & (VEHICLE_ENTRY_FLAG_CHAIRLIFT | VEHICLE_ENTRY_FLAG_GO_KART)) { shift_multiplier = 32; @@ -4208,10 +4199,10 @@ static void peep_update_ride_prepare_for_exit(rct_peep * peep) x -= x_shift; y -= y_shift; - peep->destination_x = x; - peep->destination_y = y; + peep->destination_x = x; + peep->destination_y = y; peep->destination_tolerance = 2; - peep->sub_state = PEEP_RIDE_IN_EXIT; + peep->sub_state = PEEP_RIDE_IN_EXIT; } /** @@ -4239,7 +4230,7 @@ void rct_peep::UpdateRideApproachExit() void rct_peep::UpdateRideInExit() { int16_t actionX, actionY, xy_distance; - Ride * ride = get_ride(current_ride); + Ride* ride = get_ride(current_ride); if (UpdateAction(&actionX, &actionY, &xy_distance)) { @@ -4278,7 +4269,7 @@ void rct_peep::UpdateRideInExit() void rct_peep::UpdateRideApproachVehicleWaypoints() { int16_t actionX, actionY, xy_distance; - Ride * ride = get_ride(current_ride); + Ride* ride = get_ride(current_ride); uint8_t waypoint = var_37 & 3; if (UpdateAction(&actionX, &actionY, &xy_distance)) @@ -4321,7 +4312,7 @@ void rct_peep::UpdateRideApproachVehicleWaypoints() // This is incrementing the actual peep waypoint var_37++; - rct_vehicle * vehicle = GET_VEHICLE(ride->vehicles[current_train]); + rct_vehicle* vehicle = GET_VEHICLE(ride->vehicles[current_train]); actionX = ride->station_starts[current_ride_station].x * 32 + 16; actionY = ride->station_starts[current_ride_station].y * 32 + 16; @@ -4332,13 +4323,13 @@ void rct_peep::UpdateRideApproachVehicleWaypoints() actionY = vehicle->y; } - rct_ride_entry * ride_entry = get_ride_entry(vehicle->ride_subtype); + rct_ride_entry* ride_entry = get_ride_entry(vehicle->ride_subtype); if (ride_entry == nullptr) { return; } - rct_ride_entry_vehicle * vehicle_type = &ride_entry->vehicles[vehicle->vehicle_type]; + rct_ride_entry_vehicle* vehicle_type = &ride_entry->vehicles[vehicle->vehicle_type]; Guard::Assert(waypoint < 3); actionX += vehicle_type->peep_loading_waypoints[var_37 / 4][waypoint].x; actionY += vehicle_type->peep_loading_waypoints[var_37 / 4][waypoint].y; @@ -4354,7 +4345,7 @@ void rct_peep::UpdateRideApproachVehicleWaypoints() void rct_peep::UpdateRideApproachExitWaypoints() { int16_t actionX, actionY, xy_distance; - Ride * ride = get_ride(current_ride); + Ride* ride = get_ride(current_ride); if (UpdateAction(&actionX, &actionY, &xy_distance)) { @@ -4365,7 +4356,6 @@ void rct_peep::UpdateRideApproachExitWaypoints() if ((var_37 & 3) == 1) { - if (xy_distance > 15) xy_distance = 15; @@ -4391,7 +4381,7 @@ void rct_peep::UpdateRideApproachExitWaypoints() } var_37--; - rct_vehicle * vehicle = GET_VEHICLE(ride->vehicles[current_train]); + rct_vehicle* vehicle = GET_VEHICLE(ride->vehicles[current_train]); actionX = ride->station_starts[current_ride_station].x * 32 + 16; actionY = ride->station_starts[current_ride_station].y * 32 + 16; @@ -4402,8 +4392,8 @@ void rct_peep::UpdateRideApproachExitWaypoints() actionY = vehicle->y; } - rct_ride_entry * rideEntry = get_ride_entry(vehicle->ride_subtype); - rct_ride_entry_vehicle * vehicleEntry = &rideEntry->vehicles[vehicle->vehicle_type]; + rct_ride_entry* rideEntry = get_ride_entry(vehicle->ride_subtype); + rct_ride_entry_vehicle* vehicleEntry = &rideEntry->vehicles[vehicle->vehicle_type]; Guard::Assert((var_37 & 3) < 3); actionX += vehicleEntry->peep_loading_waypoints[var_37 / 4][var_37 & 3].x; @@ -4431,8 +4421,8 @@ void rct_peep::UpdateRideApproachExitWaypoints() int16_t shift_multiplier = 20; - rct_ride_entry * ride_type = get_ride_entry(ride->subtype); - rct_ride_entry_vehicle * vehicle_entry = &ride_type->vehicles[ride_type->default_vehicle]; + rct_ride_entry* ride_type = get_ride_entry(ride->subtype); + rct_ride_entry_vehicle* vehicle_entry = &ride_type->vehicles[ride_type->default_vehicle]; if (vehicle_entry->flags & (VEHICLE_ENTRY_FLAG_CHAIRLIFT | VEHICLE_ENTRY_FLAG_GO_KART)) { shift_multiplier = 32; @@ -4455,7 +4445,7 @@ void rct_peep::UpdateRideApproachExitWaypoints() void rct_peep::UpdateRideApproachSpiralSlide() { int16_t actionX, actionY, xy_distance; - Ride * ride = get_ride(current_ride); + Ride* ride = get_ride(current_ride); if (UpdateAction(&actionX, &actionY, &xy_distance)) { @@ -4469,10 +4459,10 @@ void rct_peep::UpdateRideApproachSpiralSlide() if (waypoint == 3) { - sub_state = 15; + sub_state = 15; destination_x = 0; destination_y = 0; - var_37 = (var_37 / 4) & 0xC; + var_37 = (var_37 / 4) & 0xC; MoveTo(LOCATION_NULL, actionY, z); return; } @@ -4494,8 +4484,8 @@ void rct_peep::UpdateRideApproachSpiralSlide() auto exit = ride_get_exit_location(current_ride, current_ride_station); waypoint = 1; var_37 = (exit.direction * 4) | (var_37 & 0x30) | waypoint; - actionX = ride->station_starts[current_ride_station].x * 32; - actionY = ride->station_starts[current_ride_station].y * 32; + actionX = ride->station_starts[current_ride_station].x * 32; + actionY = ride->station_starts[current_ride_station].y * 32; assert(ride->type == RIDE_TYPE_SPIRAL_SLIDE); const CoordsXY slidePlatformDestination = SpiralSlideWalkingPath[var_37]; @@ -4505,7 +4495,7 @@ void rct_peep::UpdateRideApproachSpiralSlide() destination_x = actionX; destination_y = actionY; - sub_state = PEEP_RIDE_LEAVE_SPIRAL_SLIDE; + sub_state = PEEP_RIDE_LEAVE_SPIRAL_SLIDE; return; } } @@ -4548,7 +4538,7 @@ static constexpr const CoordsXY _SpiralSlideEndWaypoint[] = { */ void rct_peep::UpdateRideOnSpiralSlide() { - Ride * ride = get_ride(current_ride); + Ride* ride = get_ride(current_ride); if (ride->type != RIDE_TYPE_SPIRAL_SLIDE) return; @@ -4557,47 +4547,47 @@ void rct_peep::UpdateRideOnSpiralSlide() { switch (destination_x) { - case 0: - destination_y++; - if (destination_y >= 30) - destination_x++; - return; - case 1: - if (ride->slide_in_use != 0) + case 0: + destination_y++; + if (destination_y >= 30) + destination_x++; return; + case 1: + if (ride->slide_in_use != 0) + return; - ride->slide_in_use++; - ride->slide_peep = sprite_index; - ride->slide_peep_t_shirt_colour = tshirt_colour; - ride->spiral_slide_progress = 0; - destination_x++; - return; - case 2: - return; - case 3: - { - int16_t newX = ride->station_starts[current_ride_station].x * 32; - int16_t newY = ride->station_starts[current_ride_station].y * 32; - uint8_t dir = (var_37 / 4) & 3; + ride->slide_in_use++; + ride->slide_peep = sprite_index; + ride->slide_peep_t_shirt_colour = tshirt_colour; + ride->spiral_slide_progress = 0; + destination_x++; + return; + case 2: + return; + case 3: + { + int16_t newX = ride->station_starts[current_ride_station].x * 32; + int16_t newY = ride->station_starts[current_ride_station].y * 32; + uint8_t dir = (var_37 / 4) & 3; - // Set the location that the peep walks to go on slide again - destination_x = newX + _SpiralSlideEndWaypoint[dir].x; - destination_y = newY + _SpiralSlideEndWaypoint[dir].y; + // Set the location that the peep walks to go on slide again + destination_x = newX + _SpiralSlideEndWaypoint[dir].x; + destination_y = newY + _SpiralSlideEndWaypoint[dir].y; - // Move the peep sprite to just at the end of the slide - newX += _SpiralSlideEnd[dir].x; - newY += _SpiralSlideEnd[dir].y; + // Move the peep sprite to just at the end of the slide + newX += _SpiralSlideEnd[dir].x; + newY += _SpiralSlideEnd[dir].y; - MoveTo(newX, newY, z); + MoveTo(newX, newY, z); - sprite_direction = (var_37 & 0xC) * 2; - Invalidate(); + sprite_direction = (var_37 & 0xC) * 2; + Invalidate(); - var_37++; - return; - } - default: - return; + var_37++; + return; + } + default: + return; } } @@ -4624,7 +4614,7 @@ void rct_peep::UpdateRideOnSpiralSlide() destination_x = actionX; destination_y = actionY; - sub_state = PEEP_RIDE_APPROACH_SPIRAL_SLIDE; + sub_state = PEEP_RIDE_APPROACH_SPIRAL_SLIDE; } /** @@ -4633,7 +4623,7 @@ void rct_peep::UpdateRideOnSpiralSlide() */ void rct_peep::UpdateRideLeaveSpiralSlide() { - // Iterates through the spiral slide waypoints until it reaches + // Iterates through the spiral slide waypoints until it reaches // waypoint 0. Then it readies to leave the ride by the entrance. int16_t actionX, actionY, xy_distance; @@ -4645,7 +4635,7 @@ void rct_peep::UpdateRideLeaveSpiralSlide() return; } - Ride * ride = get_ride(current_ride); + Ride* ride = get_ride(current_ride); uint8_t waypoint = var_37 & 3; @@ -4678,8 +4668,8 @@ void rct_peep::UpdateRideLeaveSpiralSlide() var_37 |= 3; auto exit = ride_get_exit_location(current_ride, current_ride_station); - actionX = exit.x * 32 + 16; - actionY = exit.y * 32 + 16; + actionX = exit.x * 32 + 16; + actionY = exit.y * 32 + 16; exit.direction ^= 2; @@ -4729,7 +4719,7 @@ void rct_peep::UpdateRideMazePathfinding() return; } - Ride * ride = get_ride(current_ride); + Ride* ride = get_ride(current_ride); if (var_37 == 16) { peep_update_ride_prepare_for_exit(this); @@ -4740,21 +4730,20 @@ void rct_peep::UpdateRideMazePathfinding() { if (energy > 64 && (scenario_rand() & 0xFFFF) <= 2427) { - - action = PEEP_ACTION_JUMP; - action_frame = 0; + action = PEEP_ACTION_JUMP; + action_frame = 0; action_sprite_image_offset = 0; UpdateCurrentActionSpriteType(); Invalidate(); } } - actionX = destination_x & 0xFFE0; - actionY = destination_y & 0xFFE0; + actionX = destination_x & 0xFFE0; + actionY = destination_y & 0xFFE0; int16_t stationHeight = ride->station_heights[0]; // Find the station track element - rct_tile_element * tileElement = map_get_first_element_at(actionX / 32, actionY / 32); + rct_tile_element* tileElement = map_get_first_element_at(actionX / 32, actionY / 32); do { if (tileElement->GetType() == TILE_ELEMENT_TYPE_TRACK && stationHeight == tileElement->base_height) @@ -4762,7 +4751,7 @@ void rct_peep::UpdateRideMazePathfinding() } while (!(tileElement++)->IsLastForTile()); - uint16_t mazeEntry = track_element_get_maze_entry(tileElement); + uint16_t mazeEntry = track_element_get_maze_entry(tileElement); uint16_t openHedges = 0; // var_37 is 3, 7, 11 or 15 @@ -4827,8 +4816,8 @@ void rct_peep::UpdateRideMazePathfinding() break; } - if (tileElement->GetType() == TILE_ELEMENT_TYPE_ENTRANCE && - tileElement->properties.entrance.type == ENTRANCE_TYPE_RIDE_EXIT) + if (tileElement->GetType() == TILE_ELEMENT_TYPE_ENTRANCE + && tileElement->properties.entrance.type == ENTRANCE_TYPE_RIDE_EXIT) { mazeType = maze_type::entrance_or_exit; break; @@ -4837,35 +4826,35 @@ void rct_peep::UpdateRideMazePathfinding() switch (mazeType) { - case maze_type::invalid: - maze_last_edge++; - maze_last_edge &= 3; - return; - case maze_type::hedge: - destination_x = actionX; - destination_y = actionY; + case maze_type::invalid: + maze_last_edge++; + maze_last_edge &= 3; + return; + case maze_type::hedge: + destination_x = actionX; + destination_y = actionY; - var_37 = _MazeGetNewDirectionFromEdge[var_37 / 4][chosenEdge]; - maze_last_edge = chosenEdge; - break; - case maze_type::entrance_or_exit: - actionX = destination_x; - actionY = destination_y; - if (chosenEdge & 1) - { - actionX &= 0xFFE0; - actionX += 16; - } - else - { - actionY &= 0xFFE0; - actionY += 16; - } - destination_x = actionX; - destination_y = actionY; - var_37 = 16; - maze_last_edge = chosenEdge; - break; + var_37 = _MazeGetNewDirectionFromEdge[var_37 / 4][chosenEdge]; + maze_last_edge = chosenEdge; + break; + case maze_type::entrance_or_exit: + actionX = destination_x; + actionY = destination_y; + if (chosenEdge & 1) + { + actionX &= 0xFFE0; + actionX += 16; + } + else + { + actionY &= 0xFFE0; + actionY += 16; + } + destination_x = actionX; + destination_y = actionY; + var_37 = 16; + maze_last_edge = chosenEdge; + break; } if (UpdateAction(&actionX, &actionY, &xy_distance)) @@ -4884,7 +4873,7 @@ void rct_peep::UpdateRideMazePathfinding() void rct_peep::UpdateRideLeaveExit() { int16_t actionX, actionY, xy_distance; - Ride * ride = get_ride(current_ride); + Ride* ride = get_ride(current_ride); if (UpdateAction(&actionX, &actionY, &xy_distance)) { @@ -4916,7 +4905,7 @@ void rct_peep::UpdateRideLeaveExit() actionY = y & 0xFFE0; // Find the station track element - rct_tile_element * tileElement = map_get_first_element_at(actionX / 32, actionY / 32); + rct_tile_element* tileElement = map_get_first_element_at(actionX / 32, actionY / 32); do { if (tileElement->GetType() != TILE_ELEMENT_TYPE_PATH) @@ -4962,7 +4951,7 @@ void rct_peep::UpdateRideShopInteract() { const int16_t tileCenterX = next_x + 16; const int16_t tileCenterY = next_y + 16; - Ride * ride = get_ride(current_ride); + Ride* ride = get_ride(current_ride); if (ride->type == RIDE_TYPE_FIRST_AID) { @@ -4970,11 +4959,11 @@ void rct_peep::UpdateRideShopInteract() { sub_state = PEEP_SHOP_LEAVE; - destination_x = tileCenterX; - destination_y = tileCenterY; + destination_x = tileCenterX; + destination_y = tileCenterY; destination_tolerance = 3; - happiness_target = std::min(happiness_target + 30, PEEP_MAX_HAPPINESS); - happiness = happiness_target; + happiness_target = std::min(happiness_target + 30, PEEP_MAX_HAPPINESS); + happiness = happiness_target; } else { @@ -4998,12 +4987,12 @@ void rct_peep::UpdateRideShopInteract() sub_state = PEEP_SHOP_LEAVE; - destination_x = tileCenterX; - destination_y = tileCenterY; + destination_x = tileCenterX; + destination_y = tileCenterY; destination_tolerance = 3; happiness_target = std::min(happiness_target + 30, PEEP_MAX_HAPPINESS); - happiness = happiness_target; + happiness = happiness_target; StopPurchaseThought(ride->type); } @@ -5031,7 +5020,7 @@ void rct_peep::UpdateRideShopLeave() SetState(PEEP_STATE_WALKING); - Ride * ride = get_ride(current_ride); + Ride* ride = get_ride(current_ride); ride->total_customers++; ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_CUSTOMER; @@ -5048,75 +5037,75 @@ void rct_peep::UpdateRide() switch (sub_state) { - case PEEP_RIDE_AT_ENTRANCE: - UpdateRideAtEntrance(); - break; - case PEEP_RIDE_IN_ENTRANCE: - UpdateRideAdvanceThroughEntrance(); - break; - case PEEP_RIDE_FREE_VEHICLE_CHECK: - UpdateRideFreeVehicleCheck(); - break; - case PEEP_RIDE_LEAVE_ENTRANCE: - UpdateRideAdvanceThroughEntrance(); - break; - case PEEP_RIDE_APPROACH_VEHICLE: - UpdateRideApproachVehicle(); - break; - case PEEP_RIDE_ENTER_VEHICLE: - UpdateRideEnterVehicle(); - break; - case PEEP_RIDE_ON_RIDE: - // No action, on ride. - break; - case PEEP_RIDE_LEAVE_VEHICLE: - UpdateRideLeaveVehicle(); - break; - case PEEP_RIDE_APPROACH_EXIT: - UpdateRideApproachExit(); - break; - case PEEP_RIDE_IN_EXIT: - UpdateRideInExit(); - break; - case PEEP_RIDE_APPROACH_VEHICLE_WAYPOINTS: - UpdateRideApproachVehicleWaypoints(); - break; - case PEEP_RIDE_APPROACH_EXIT_WAYPOINTS: - UpdateRideApproachExitWaypoints(); - break; - case PEEP_RIDE_APPROACH_SPIRAL_SLIDE: - UpdateRideApproachSpiralSlide(); - break; - case PEEP_RIDE_ON_SPIRAL_SLIDE: - UpdateRideOnSpiralSlide(); - break; - case PEEP_RIDE_LEAVE_SPIRAL_SLIDE: - UpdateRideLeaveSpiralSlide(); - break; - case PEEP_RIDE_MAZE_PATHFINDING: - UpdateRideMazePathfinding(); - break; - case PEEP_RIDE_LEAVE_EXIT: - UpdateRideLeaveExit(); - break; - case PEEP_SHOP_APPROACH: - UpdateRideShopApproach(); - break; - case PEEP_SHOP_INTERACT: - UpdateRideShopInteract(); - break; - case PEEP_SHOP_LEAVE: - UpdateRideShopLeave(); - break; - default: - // Invalid peep sub-state - assert(false); - break; + case PEEP_RIDE_AT_ENTRANCE: + UpdateRideAtEntrance(); + break; + case PEEP_RIDE_IN_ENTRANCE: + UpdateRideAdvanceThroughEntrance(); + break; + case PEEP_RIDE_FREE_VEHICLE_CHECK: + UpdateRideFreeVehicleCheck(); + break; + case PEEP_RIDE_LEAVE_ENTRANCE: + UpdateRideAdvanceThroughEntrance(); + break; + case PEEP_RIDE_APPROACH_VEHICLE: + UpdateRideApproachVehicle(); + break; + case PEEP_RIDE_ENTER_VEHICLE: + UpdateRideEnterVehicle(); + break; + case PEEP_RIDE_ON_RIDE: + // No action, on ride. + break; + case PEEP_RIDE_LEAVE_VEHICLE: + UpdateRideLeaveVehicle(); + break; + case PEEP_RIDE_APPROACH_EXIT: + UpdateRideApproachExit(); + break; + case PEEP_RIDE_IN_EXIT: + UpdateRideInExit(); + break; + case PEEP_RIDE_APPROACH_VEHICLE_WAYPOINTS: + UpdateRideApproachVehicleWaypoints(); + break; + case PEEP_RIDE_APPROACH_EXIT_WAYPOINTS: + UpdateRideApproachExitWaypoints(); + break; + case PEEP_RIDE_APPROACH_SPIRAL_SLIDE: + UpdateRideApproachSpiralSlide(); + break; + case PEEP_RIDE_ON_SPIRAL_SLIDE: + UpdateRideOnSpiralSlide(); + break; + case PEEP_RIDE_LEAVE_SPIRAL_SLIDE: + UpdateRideLeaveSpiralSlide(); + break; + case PEEP_RIDE_MAZE_PATHFINDING: + UpdateRideMazePathfinding(); + break; + case PEEP_RIDE_LEAVE_EXIT: + UpdateRideLeaveExit(); + break; + case PEEP_SHOP_APPROACH: + UpdateRideShopApproach(); + break; + case PEEP_SHOP_INTERACT: + UpdateRideShopInteract(); + break; + case PEEP_SHOP_LEAVE: + UpdateRideShopLeave(); + break; + default: + // Invalid peep sub-state + assert(false); + break; } } -static void peep_update_walking_break_scenery(rct_peep * peep); -static bool peep_find_ride_to_look_at(rct_peep * peep, uint8_t edge, uint8_t * rideToView, uint8_t * rideSeatToView); +static void peep_update_walking_break_scenery(rct_peep* peep); +static bool peep_find_ride_to_look_at(rct_peep* peep, uint8_t edge, uint8_t* rideToView, uint8_t* rideSeatToView); /** * @@ -5135,8 +5124,8 @@ void rct_peep::UpdateWalking() { Invalidate(); - action = PEEP_ACTION_WAVE_2; - action_frame = 0; + action = PEEP_ACTION_WAVE_2; + action_frame = 0; action_sprite_image_offset = 0; UpdateCurrentActionSpriteType(); @@ -5153,8 +5142,8 @@ void rct_peep::UpdateWalking() { Invalidate(); - action = PEEP_ACTION_TAKE_PHOTO; - action_frame = 0; + action = PEEP_ACTION_TAKE_PHOTO; + action_frame = 0; action_sprite_image_offset = 0; UpdateCurrentActionSpriteType(); @@ -5171,8 +5160,8 @@ void rct_peep::UpdateWalking() { Invalidate(); - action = PEEP_ACTION_DRAW_PICTURE; - action_frame = 0; + action = PEEP_ACTION_DRAW_PICTURE; + action_frame = 0; action_sprite_image_offset = 0; UpdateCurrentActionSpriteType(); @@ -5193,9 +5182,9 @@ void rct_peep::UpdateWalking() LITTER_TYPE_EMPTY_BURGER_BOX, LITTER_TYPE_EMPTY_CUP, }; - int32_t ebp = litter_types[scenario_rand() & 0x3]; - int32_t litterX = x + (scenario_rand() & 0x7) - 3; - int32_t litterY = y + (scenario_rand() & 0x7) - 3; + int32_t ebp = litter_types[scenario_rand() & 0x3]; + int32_t litterX = x + (scenario_rand() & 0x7) - 3; + int32_t litterY = y + (scenario_rand() & 0x7) - 3; int32_t litterDirection = (scenario_rand() & 0x3); litter_create(litterX, litterY, z, litterDirection, ebp); @@ -5204,10 +5193,9 @@ void rct_peep::UpdateWalking() } else if (HasEmptyContainer()) { - if ((!GetNextIsSurface()) && ((uint32_t)(sprite_index & 0x1FF) == (gCurrentTicks & 0x1FF)) && - ((0xFFFF & scenario_rand()) <= 4096)) + if ((!GetNextIsSurface()) && ((uint32_t)(sprite_index & 0x1FF) == (gCurrentTicks & 0x1FF)) + && ((0xFFFF & scenario_rand()) <= 4096)) { - uint8_t pos_stnd = 0; for (int32_t container = HasEmptyContainerStandardFlag(); pos_stnd < 32; pos_stnd++) if (container & (1u << pos_stnd)) @@ -5233,8 +5221,8 @@ void rct_peep::UpdateWalking() window_invalidate_flags |= PEEP_INVALIDATE_PEEP_INVENTORY; UpdateSpriteType(); - int32_t litterX = x + (scenario_rand() & 0x7) - 3; - int32_t litterY = y + (scenario_rand() & 0x7) - 3; + int32_t litterX = x + (scenario_rand() & 0x7) - 3; + int32_t litterY = y + (scenario_rand() & 0x7) - 3; int32_t litterDirection = (scenario_rand() & 0x3); litter_create(litterX, litterY, z, litterDirection, bp); @@ -5242,8 +5230,8 @@ void rct_peep::UpdateWalking() } // Check if vehicle is blocking the destination tile - auto curPos = TileCoordsXYZ(CoordsXYZ { x, y, z }); - auto dstPos = TileCoordsXYZ(CoordsXY { destination_x, destination_y }, next_z); + auto curPos = TileCoordsXYZ(CoordsXYZ{ x, y, z }); + auto dstPos = TileCoordsXYZ(CoordsXY{ destination_x, destination_y }, next_z); if (curPos.x != dstPos.x || curPos.y != dstPos.y) { if (footpath_is_blocked_by_vehicle(dstPos)) @@ -5260,7 +5248,7 @@ void rct_peep::UpdateWalking() if (GetNextIsSurface()) { - rct_tile_element * tile_element = map_get_surface_element_at({next_x, next_y}); + rct_tile_element* tile_element = map_get_surface_element_at({ next_x, next_y }); int32_t water_height = surface_get_water_height(tile_element); if (water_height) @@ -5310,7 +5298,7 @@ void rct_peep::UpdateWalking() if (GetNextIsSurface() || GetNextIsSloped()) return; - rct_tile_element * tileElement = map_get_first_element_at(next_x / 32, next_y / 32); + rct_tile_element* tileElement = map_get_first_element_at(next_x / 32, next_y / 32); for (;; tileElement++) { @@ -5331,7 +5319,7 @@ void rct_peep::UpdateWalking() { if (!footpath_element_path_scenery_is_ghost(tileElement)) { - rct_scenery_entry * sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(tileElement)); + rct_scenery_entry* sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(tileElement)); if (sceneryEntry == nullptr) { return; @@ -5357,7 +5345,7 @@ void rct_peep::UpdateWalking() // Check if there is a peep watching (and if there is place for us) uint16_t sprite_id = sprite_get_first_in_quadrant(x, y); - for (rct_sprite * sprite; sprite_id != SPRITE_INDEX_NULL; sprite_id = sprite->unknown.next_in_quadrant) + for (rct_sprite* sprite; sprite_id != SPRITE_INDEX_NULL; sprite_id = sprite->unknown.next_in_quadrant) { sprite = get_sprite(sprite_id); @@ -5386,7 +5374,7 @@ void rct_peep::UpdateWalking() current_ride = ride_to_view; current_seat = ride_seat_to_view; - var_37 = chosen_edge | (chosen_position << 2); + var_37 = chosen_edge | (chosen_position << 2); SetState(PEEP_STATE_WATCHING); sub_state = 0; @@ -5394,8 +5382,8 @@ void rct_peep::UpdateWalking() int32_t destX = (x & 0xFFE0) + _WatchingPositionOffsets[var_37 & 0x1F].x; int32_t destY = (y & 0xFFE0) + _WatchingPositionOffsets[var_37 & 0x1F].y; - destination_x = destX; - destination_y = destY; + destination_x = destX; + destination_y = destY; destination_tolerance = 3; if (current_seat & 1) @@ -5419,7 +5407,7 @@ void rct_peep::UpdateQueuing() RemoveFromQueue(); return; } - Ride * ride = get_ride(current_ride); + Ride* ride = get_ride(current_ride); if (ride->status == RIDE_STATUS_CLOSED || ride->status == RIDE_STATUS_TESTING) { RemoveFromQueue(); @@ -5437,7 +5425,7 @@ void rct_peep::UpdateQueuing() // first check if the next in queue is actually nearby // if they are not then it's safe to assume that this is // the front of the queue. - rct_peep * next_peep = GET_PEEP(next_in_queue); + rct_peep* next_peep = GET_PEEP(next_in_queue); if (abs(next_peep->x - x) < 32 && abs(next_peep->y - y) < 32) { is_front = false; @@ -5470,8 +5458,8 @@ void rct_peep::UpdateQueuing() if (time_in_queue >= 2000 && (0xFFFF & scenario_rand()) <= 119) { // Eat Food/Look at watch - action = PEEP_ACTION_EAT_FOOD; - action_frame = 0; + action = PEEP_ACTION_EAT_FOOD; + action_frame = 0; action_sprite_image_offset = 0; UpdateCurrentActionSpriteType(); Invalidate(); @@ -5488,35 +5476,35 @@ void rct_peep::UpdateQueuing() { switch (sprite_type) { - case PEEP_SPRITE_TYPE_ICE_CREAM: - case PEEP_SPRITE_TYPE_CHIPS: - case PEEP_SPRITE_TYPE_BURGER: - case PEEP_SPRITE_TYPE_DRINK: - case PEEP_SPRITE_TYPE_CANDYFLOSS: - case PEEP_SPRITE_TYPE_PIZZA: - case PEEP_SPRITE_TYPE_POPCORN: - case PEEP_SPRITE_TYPE_HOT_DOG: - case PEEP_SPRITE_TYPE_TENTACLE: - case PEEP_SPRITE_TYPE_TOFFEE_APPLE: - case PEEP_SPRITE_TYPE_DOUGHNUT: - case PEEP_SPRITE_TYPE_COFFEE: - case PEEP_SPRITE_TYPE_CHICKEN: - case PEEP_SPRITE_TYPE_LEMONADE: - case PEEP_SPRITE_TYPE_PRETZEL: - case PEEP_SPRITE_TYPE_SU_JONGKWA: - case PEEP_SPRITE_TYPE_JUICE: - case PEEP_SPRITE_TYPE_FUNNEL_CAKE: - case PEEP_SPRITE_TYPE_NOODLES: - case PEEP_SPRITE_TYPE_SAUSAGE: - case PEEP_SPRITE_TYPE_SOUP: - case PEEP_SPRITE_TYPE_SANDWICH: - // Eat food - action = PEEP_ACTION_EAT_FOOD; - action_frame = 0; - action_sprite_image_offset = 0; - UpdateCurrentActionSpriteType(); - Invalidate(); - break; + case PEEP_SPRITE_TYPE_ICE_CREAM: + case PEEP_SPRITE_TYPE_CHIPS: + case PEEP_SPRITE_TYPE_BURGER: + case PEEP_SPRITE_TYPE_DRINK: + case PEEP_SPRITE_TYPE_CANDYFLOSS: + case PEEP_SPRITE_TYPE_PIZZA: + case PEEP_SPRITE_TYPE_POPCORN: + case PEEP_SPRITE_TYPE_HOT_DOG: + case PEEP_SPRITE_TYPE_TENTACLE: + case PEEP_SPRITE_TYPE_TOFFEE_APPLE: + case PEEP_SPRITE_TYPE_DOUGHNUT: + case PEEP_SPRITE_TYPE_COFFEE: + case PEEP_SPRITE_TYPE_CHICKEN: + case PEEP_SPRITE_TYPE_LEMONADE: + case PEEP_SPRITE_TYPE_PRETZEL: + case PEEP_SPRITE_TYPE_SU_JONGKWA: + case PEEP_SPRITE_TYPE_JUICE: + case PEEP_SPRITE_TYPE_FUNNEL_CAKE: + case PEEP_SPRITE_TYPE_NOODLES: + case PEEP_SPRITE_TYPE_SAUSAGE: + case PEEP_SPRITE_TYPE_SOUP: + case PEEP_SPRITE_TYPE_SANDWICH: + // Eat food + action = PEEP_ACTION_EAT_FOOD; + action_frame = 0; + action_sprite_image_offset = 0; + UpdateCurrentActionSpriteType(); + Invalidate(); + break; } } } @@ -5562,7 +5550,7 @@ void rct_peep::UpdateEnteringPark() SetState(PEEP_STATE_FALLING); outside_of_park = 0; - time_in_park = gScenarioTicks; + time_in_park = gScenarioTicks; increment_guests_in_park(); decrement_guests_heading_for_park(); auto intent = Intent(INTENT_ACTION_UPDATE_GUEST_COUNT); @@ -5596,7 +5584,7 @@ void rct_peep::UpdateLeavingPark() return; } - outside_of_park = 1; + outside_of_park = 1; destination_tolerance = 5; decrement_guests_in_park(); auto intent = Intent(INTENT_ACTION_UPDATE_GUEST_COUNT); @@ -5632,7 +5620,7 @@ void rct_peep::UpdateWatching() sprite_direction = (var_37 & 3) * 8; Invalidate(); - action = 0xFE; + action = 0xFE; next_action_sprite_type = 2; SwitchNextActionSpriteType(); @@ -5662,8 +5650,8 @@ void rct_peep::UpdateWatching() { if ((scenario_rand() & 0xFFFF) <= 1310) { - action = PEEP_ACTION_EAT_FOOD; - action_frame = 0; + action = PEEP_ACTION_EAT_FOOD; + action_frame = 0; action_sprite_image_offset = 0; UpdateCurrentActionSpriteType(); Invalidate(); @@ -5673,8 +5661,8 @@ void rct_peep::UpdateWatching() if ((scenario_rand() & 0xFFFF) <= 655) { - action = PEEP_ACTION_TAKE_PHOTO; - action_frame = 0; + action = PEEP_ACTION_TAKE_PHOTO; + action_frame = 0; action_sprite_image_offset = 0; UpdateCurrentActionSpriteType(); Invalidate(); @@ -5685,8 +5673,8 @@ void rct_peep::UpdateWatching() { if ((scenario_rand() & 0xFFFF) <= 655) { - action = PEEP_ACTION_WAVE; - action_frame = 0; + action = PEEP_ACTION_WAVE; + action_frame = 0; action_sprite_image_offset = 0; UpdateCurrentActionSpriteType(); Invalidate(); @@ -5706,8 +5694,8 @@ void rct_peep::UpdateWatching() SetState(PEEP_STATE_WALKING); UpdateSpriteType(); // Send peep to the centre of current tile. - destination_x = (x & 0xFFE0) + 16; - destination_y = (y & 0xFFE0) + 16; + destination_x = (x & 0xFFE0) + 16; + destination_y = (y & 0xFFE0) + 16; destination_tolerance = 5; UpdateCurrentActionSpriteType(); } @@ -5721,154 +5709,154 @@ void rct_peep::UpdateUsingBin() { switch (sub_state) { - case PEEP_USING_BIN_WALKING_TO_BIN: - { - if (!CheckForPath()) - return; - - uint8_t pathingResult; - PerformNextAction(pathingResult); - if (pathingResult & PATHING_DESTINATION_REACHED) + case PEEP_USING_BIN_WALKING_TO_BIN: { - sub_state = PEEP_USING_BIN_GOING_BACK; - } - break; - } - case PEEP_USING_BIN_GOING_BACK: - { - if (action != PEEP_ACTION_NONE_2) - { - int16_t actionX, actionY, xy_distance; - UpdateAction(&actionX, &actionY, &xy_distance); - return; - } + if (!CheckForPath()) + return; - rct_tile_element * tileElement = map_get_first_element_at(next_x / 32, next_y / 32); - - for (;; tileElement++) - { - if (tileElement->GetType() != TILE_ELEMENT_TYPE_PATH) + uint8_t pathingResult; + PerformNextAction(pathingResult); + if (pathingResult & PATHING_DESTINATION_REACHED) { - continue; + sub_state = PEEP_USING_BIN_GOING_BACK; + } + break; + } + case PEEP_USING_BIN_GOING_BACK: + { + if (action != PEEP_ACTION_NONE_2) + { + int16_t actionX, actionY, xy_distance; + UpdateAction(&actionX, &actionY, &xy_distance); + return; } - if (tileElement->base_height == next_z) - break; + rct_tile_element* tileElement = map_get_first_element_at(next_x / 32, next_y / 32); - if (tileElement->IsLastForTile()) + for (;; tileElement++) + { + if (tileElement->GetType() != TILE_ELEMENT_TYPE_PATH) + { + continue; + } + + if (tileElement->base_height == next_z) + break; + + if (tileElement->IsLastForTile()) + { + StateReset(); + return; + } + } + + if (!footpath_element_has_path_scenery(tileElement)) { StateReset(); return; } - } - if (!footpath_element_has_path_scenery(tileElement)) - { - StateReset(); - return; - } - - rct_scenery_entry * sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(tileElement)); - if (!(sceneryEntry->path_bit.flags & PATH_BIT_FLAG_IS_BIN)) - { - StateReset(); - return; - } - - if (tileElement->flags & TILE_ELEMENT_FLAG_BROKEN) - { - StateReset(); - return; - } - - if (footpath_element_path_scenery_is_ghost(tileElement)) - { - StateReset(); - return; - } - - // Bin selection is one of 4 corners - uint8_t selected_bin = var_37 * 2; - - // This counts down 2 = No rubbish, 0 = full - uint8_t space_left_in_bin = 0x3 & (tileElement->properties.path.addition_status >> selected_bin); - uint32_t empty_containers = HasEmptyContainerStandardFlag(); - - for (uint8_t cur_container = 0; cur_container < 32; cur_container++) - { - if (!(empty_containers & (1u << cur_container))) - continue; - - if (space_left_in_bin != 0) + rct_scenery_entry* sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(tileElement)); + if (!(sceneryEntry->path_bit.flags & PATH_BIT_FLAG_IS_BIN)) { - // OpenRCT2 modification: This previously used - // the tick count as a simple random function - // switched to scenario_rand as it is more reliable - if ((scenario_rand() & 7) == 0) - space_left_in_bin--; + StateReset(); + return; + } + + if (tileElement->flags & TILE_ELEMENT_FLAG_BROKEN) + { + StateReset(); + return; + } + + if (footpath_element_path_scenery_is_ghost(tileElement)) + { + StateReset(); + return; + } + + // Bin selection is one of 4 corners + uint8_t selected_bin = var_37 * 2; + + // This counts down 2 = No rubbish, 0 = full + uint8_t space_left_in_bin = 0x3 & (tileElement->properties.path.addition_status >> selected_bin); + uint32_t empty_containers = HasEmptyContainerStandardFlag(); + + for (uint8_t cur_container = 0; cur_container < 32; cur_container++) + { + if (!(empty_containers & (1u << cur_container))) + continue; + + if (space_left_in_bin != 0) + { + // OpenRCT2 modification: This previously used + // the tick count as a simple random function + // switched to scenario_rand as it is more reliable + if ((scenario_rand() & 7) == 0) + space_left_in_bin--; + item_standard_flags &= ~(1 << cur_container); + window_invalidate_flags |= PEEP_INVALIDATE_PEEP_INVENTORY; + UpdateSpriteType(); + continue; + } + uint8_t bp = item_standard_litter[cur_container]; + + int32_t litterX = x + (scenario_rand() & 7) - 3; + int32_t litterY = y + (scenario_rand() & 7) - 3; + + litter_create(litterX, litterY, z, scenario_rand() & 3, bp); item_standard_flags &= ~(1 << cur_container); window_invalidate_flags |= PEEP_INVALIDATE_PEEP_INVENTORY; + UpdateSpriteType(); - continue; } - uint8_t bp = item_standard_litter[cur_container]; - int32_t litterX = x + (scenario_rand() & 7) - 3; - int32_t litterY = y + (scenario_rand() & 7) - 3; + // Original bug: This would clear any rubbish placed by the previous function + // space_left_in_bin = 0x3 & (tile_element->properties.path.addition_status >> selected_bin); + empty_containers = HasEmptyContainerExtraFlag(); - litter_create(litterX, litterY, z, scenario_rand() & 3, bp); - item_standard_flags &= ~(1 << cur_container); - window_invalidate_flags |= PEEP_INVALIDATE_PEEP_INVENTORY; - - UpdateSpriteType(); - } - - // Original bug: This would clear any rubbish placed by the previous function - // space_left_in_bin = 0x3 & (tile_element->properties.path.addition_status >> selected_bin); - empty_containers = HasEmptyContainerExtraFlag(); - - for (uint8_t cur_container = 0; cur_container < 32; cur_container++) - { - if (!(empty_containers & (1u << cur_container))) - continue; - - if (space_left_in_bin != 0) + for (uint8_t cur_container = 0; cur_container < 32; cur_container++) { - // OpenRCT2 modification: This previously used - // the tick count as a simple random function - // switched to scenario_rand as it is more reliable - if ((scenario_rand() & 7) == 0) - space_left_in_bin--; + if (!(empty_containers & (1u << cur_container))) + continue; + + if (space_left_in_bin != 0) + { + // OpenRCT2 modification: This previously used + // the tick count as a simple random function + // switched to scenario_rand as it is more reliable + if ((scenario_rand() & 7) == 0) + space_left_in_bin--; + item_extra_flags &= ~(1 << cur_container); + window_invalidate_flags |= PEEP_INVALIDATE_PEEP_INVENTORY; + + UpdateSpriteType(); + continue; + } + uint8_t bp = item_extra_litter[cur_container]; + + int32_t litterX = x + (scenario_rand() & 7) - 3; + int32_t litterY = y + (scenario_rand() & 7) - 3; + + litter_create(litterX, litterY, z, scenario_rand() & 3, bp); item_extra_flags &= ~(1 << cur_container); window_invalidate_flags |= PEEP_INVALIDATE_PEEP_INVENTORY; UpdateSpriteType(); - continue; } - uint8_t bp = item_extra_litter[cur_container]; - int32_t litterX = x + (scenario_rand() & 7) - 3; - int32_t litterY = y + (scenario_rand() & 7) - 3; + // Place new amount in bin by first clearing the value + tileElement->properties.path.addition_status &= ~(3 << selected_bin); + // Then placing the new value. + tileElement->properties.path.addition_status |= space_left_in_bin << selected_bin; - litter_create(litterX, litterY, z, scenario_rand() & 3, bp); - item_extra_flags &= ~(1 << cur_container); - window_invalidate_flags |= PEEP_INVALIDATE_PEEP_INVENTORY; - - UpdateSpriteType(); + map_invalidate_tile_zoom0(next_x, next_y, tileElement->base_height << 3, tileElement->clearance_height << 3); + StateReset(); + break; } - - // Place new amount in bin by first clearing the value - tileElement->properties.path.addition_status &= ~(3 << selected_bin); - // Then placing the new value. - tileElement->properties.path.addition_status |= space_left_in_bin << selected_bin; - - map_invalidate_tile_zoom0(next_x, next_y, tileElement->base_height << 3, tileElement->clearance_height << 3); - StateReset(); - break; - } - default: - Guard::Assert(false, "Invalid sub state"); - break; + default: + Guard::Assert(false, "Invalid sub state"); + break; } } @@ -5914,7 +5902,7 @@ bool rct_peep::UpdateWalkingFindBench() if (!ShouldFindBench()) return false; - rct_tile_element * tileElement = map_get_first_element_at(next_x / 32, next_y / 32); + rct_tile_element* tileElement = map_get_first_element_at(next_x / 32, next_y / 32); for (;; tileElement++) { @@ -5931,7 +5919,7 @@ bool rct_peep::UpdateWalkingFindBench() if (!footpath_element_has_path_scenery(tileElement)) return false; - rct_scenery_entry * sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(tileElement)); + rct_scenery_entry* sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(tileElement)); if (sceneryEntry == nullptr || !(sceneryEntry->path_bit.flags & PATH_BIT_FLAG_IS_BENCH)) return false; @@ -5952,10 +5940,10 @@ bool rct_peep::UpdateWalkingFindBench() chosen_edge = (chosen_edge + 1) & 0x3; uint16_t sprite_id = sprite_get_first_in_quadrant(x, y); - uint8_t free_edge = 3; + uint8_t 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) + for (rct_sprite* sprite; sprite_id != SPRITE_INDEX_NULL; sprite_id = sprite->unknown.next_in_quadrant) { sprite = get_sprite(sprite_id); @@ -5993,8 +5981,8 @@ bool rct_peep::UpdateWalkingFindBench() int32_t benchX = (x & 0xFFE0) + BenchUseOffsets[var_37 & 0x7].x; int32_t benchY = (y & 0xFFE0) + BenchUseOffsets[var_37 & 0x7].y; - destination_x = benchX; - destination_y = benchY; + destination_x = benchX; + destination_y = benchY; destination_tolerance = 3; return true; @@ -6009,7 +5997,7 @@ bool rct_peep::UpdateWalkingFindBin() if (peep->GetNextIsSurface()) return false; - rct_tile_element * tileElement = map_get_first_element_at(peep->next_x / 32, peep->next_y / 32); + rct_tile_element* tileElement = map_get_first_element_at(peep->next_x / 32, peep->next_y / 32); for (;; tileElement++) { @@ -6026,7 +6014,7 @@ bool rct_peep::UpdateWalkingFindBin() if (!footpath_element_has_path_scenery(tileElement)) return false; - rct_scenery_entry * sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(tileElement)); + rct_scenery_entry* sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(tileElement)); if (sceneryEntry == nullptr) { return false; @@ -6061,7 +6049,7 @@ bool rct_peep::UpdateWalkingFindBin() if (edges & (1 << chosen_edge)) break; } - chosen_edge = (chosen_edge + 1) & 0x3; + chosen_edge = (chosen_edge + 1) & 0x3; bin_quantities = ror8(bin_quantities, 2); if ((free_edge - 1) == 0) return 0; @@ -6075,8 +6063,8 @@ bool rct_peep::UpdateWalkingFindBin() int32_t binX = (peep->x & 0xFFE0) + BinUseOffsets[peep->var_37 & 0x3].x; int32_t binY = (peep->y & 0xFFE0) + BinUseOffsets[peep->var_37 & 0x3].y; - peep->destination_x = binX; - peep->destination_y = binY; + peep->destination_x = binX; + peep->destination_y = binY; peep->destination_tolerance = 3; return true; @@ -6086,7 +6074,7 @@ bool rct_peep::UpdateWalkingFindBin() * * rct2: 0x00690848 */ -static void peep_update_walking_break_scenery(rct_peep * peep) +static void peep_update_walking_break_scenery(rct_peep* peep) { if (gCheatsDisableVandalism) return; @@ -6110,7 +6098,7 @@ static void peep_update_walking_break_scenery(rct_peep * peep) if (peep->GetNextIsSurface()) return; - rct_tile_element * tileElement = map_get_first_element_at(peep->next_x / 32, peep->next_y / 32); + rct_tile_element* tileElement = map_get_first_element_at(peep->next_x / 32, peep->next_y / 32); for (;; tileElement++) { @@ -6127,7 +6115,7 @@ static void peep_update_walking_break_scenery(rct_peep * peep) if (!footpath_element_has_path_scenery(tileElement)) return; - rct_scenery_entry * sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(tileElement)); + rct_scenery_entry* sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(tileElement)); if (!(sceneryEntry->path_bit.flags & PATH_BIT_FLAG_BREAKABLE)) return; @@ -6145,12 +6133,12 @@ static void peep_update_walking_break_scenery(rct_peep * peep) uint16_t sprite_id = sprite_get_first_in_quadrant(peep->x, peep->y); // Check if a peep is already sitting on the bench. If so, do not vandalise it. - for (rct_sprite * sprite; sprite_id != SPRITE_INDEX_NULL; sprite_id = sprite->unknown.next_in_quadrant) + for (rct_sprite* sprite; sprite_id != SPRITE_INDEX_NULL; sprite_id = sprite->unknown.next_in_quadrant) { sprite = get_sprite(sprite_id); - if ((sprite->unknown.linked_list_type_offset != SPRITE_LIST_PEEP * 2) || (sprite->peep.state != PEEP_STATE_SITTING) || - (peep->z != sprite->peep.z)) + if ((sprite->unknown.linked_list_type_offset != SPRITE_LIST_PEEP * 2) || (sprite->peep.state != PEEP_STATE_SITTING) + || (peep->z != sprite->peep.z)) { continue; } @@ -6158,10 +6146,10 @@ static void peep_update_walking_break_scenery(rct_peep * peep) return; } - rct_peep * inner_peep; - uint16_t sprite_index; + rct_peep* inner_peep; + uint16_t sprite_index; - FOR_ALL_STAFF(sprite_index, inner_peep) + FOR_ALL_STAFF (sprite_index, inner_peep) { if (inner_peep->staff_type != STAFF_TYPE_SECURITY) continue; @@ -6188,9 +6176,9 @@ static void peep_update_walking_break_scenery(rct_peep * peep) * * @return (CF) */ -static bool peep_should_watch_ride(rct_tile_element * tileElement) +static bool peep_should_watch_ride(rct_tile_element* tileElement) { - Ride * ride = get_ride(track_element_get_ride_index(tileElement)); + Ride* ride = get_ride(track_element_get_ride_index(tileElement)); // Ghosts are purely this-client-side and should not cause any interaction, // as that may lead to a desync. @@ -6243,9 +6231,9 @@ static bool peep_should_watch_ride(rct_tile_element * tileElement) return true; } -bool loc_690FD0(rct_peep * peep, uint8_t * rideToView, uint8_t * rideSeatToView, rct_tile_element * tileElement) +bool loc_690FD0(rct_peep* peep, uint8_t* rideToView, uint8_t* rideSeatToView, rct_tile_element* tileElement) { - Ride * ride = get_ride(track_element_get_ride_index(tileElement)); + Ride* ride = get_ride(track_element_get_ride_index(tileElement)); *rideToView = track_element_get_ride_index(tileElement); if (ride->excitement == RIDE_RATING_UNDEFINED) @@ -6288,11 +6276,11 @@ bool loc_690FD0(rct_peep * peep, uint8_t * rideToView, uint8_t * rideSeatToView, * @param[out] rideSeatToView (ch) * @return !CF */ -static bool peep_find_ride_to_look_at(rct_peep * peep, uint8_t edge, uint8_t * rideToView, uint8_t * rideSeatToView) +static bool peep_find_ride_to_look_at(rct_peep* peep, uint8_t edge, uint8_t* rideToView, uint8_t* rideSeatToView) { rct_tile_element *tileElement, *surfaceElement; - surfaceElement = map_get_surface_element_at({peep->next_x, peep->next_y}); + surfaceElement = map_get_surface_element_at({ peep->next_x, peep->next_y }); tileElement = surfaceElement; do @@ -6326,7 +6314,7 @@ static bool peep_find_ride_to_look_at(rct_peep * peep, uint8_t edge, uint8_t * r return false; } - surfaceElement = map_get_surface_element_at({x, y}); + surfaceElement = map_get_surface_element_at({ x, y }); tileElement = surfaceElement; do @@ -6381,8 +6369,8 @@ static bool peep_find_ride_to_look_at(rct_peep * peep, uint8_t edge, uint8_t * r if (tileElement->GetType() == TILE_ELEMENT_TYPE_LARGE_SCENERY) { - if (!(get_large_scenery_entry(scenery_large_get_type(tileElement))->large_scenery.flags & - LARGE_SCENERY_FLAG_PHOTOGENIC)) + if (!(get_large_scenery_entry(scenery_large_get_type(tileElement))->large_scenery.flags + & LARGE_SCENERY_FLAG_PHOTOGENIC)) { continue; } @@ -6438,7 +6426,7 @@ static bool peep_find_ride_to_look_at(rct_peep * peep, uint8_t edge, uint8_t * r return false; } - surfaceElement = map_get_surface_element_at({x, y}); + surfaceElement = map_get_surface_element_at({ x, y }); // TODO: extract loop A tileElement = surfaceElement; @@ -6493,8 +6481,7 @@ static bool peep_find_ride_to_look_at(rct_peep * peep, uint8_t edge, uint8_t * r if (tileElement->GetType() == TILE_ELEMENT_TYPE_LARGE_SCENERY) { auto sceneryEntry = get_large_scenery_entry(scenery_large_get_type(tileElement)); - if (!(sceneryEntry == nullptr || sceneryEntry->large_scenery.flags & - LARGE_SCENERY_FLAG_PHOTOGENIC)) + if (!(sceneryEntry == nullptr || sceneryEntry->large_scenery.flags & LARGE_SCENERY_FLAG_PHOTOGENIC)) { continue; } @@ -6550,7 +6537,7 @@ static bool peep_find_ride_to_look_at(rct_peep * peep, uint8_t edge, uint8_t * r return false; } - surfaceElement = map_get_surface_element_at({x, y}); + surfaceElement = map_get_surface_element_at({ x, y }); // TODO: extract loop A tileElement = surfaceElement; @@ -6604,8 +6591,8 @@ static bool peep_find_ride_to_look_at(rct_peep * peep, uint8_t edge, uint8_t * r if (tileElement->GetType() == TILE_ELEMENT_TYPE_LARGE_SCENERY) { - if (!(get_large_scenery_entry(scenery_large_get_type(tileElement))->large_scenery.flags & - LARGE_SCENERY_FLAG_PHOTOGENIC)) + if (!(get_large_scenery_entry(scenery_large_get_type(tileElement))->large_scenery.flags + & LARGE_SCENERY_FLAG_PHOTOGENIC)) { continue; } @@ -6631,9 +6618,9 @@ void rct_peep::SetSpriteType(uint8_t new_sprite_type) if (sprite_type == new_sprite_type) return; - sprite_type = new_sprite_type; + sprite_type = new_sprite_type; action_sprite_image_offset = 0; - no_action_frame_num = 0; + no_action_frame_num = 0; if (action >= PEEP_ACTION_NONE_1) action = PEEP_ACTION_NONE_2; @@ -6650,13 +6637,13 @@ void rct_peep::SetSpriteType(uint8_t new_sprite_type) if (state == PEEP_STATE_SITTING) { - action = PEEP_ACTION_NONE_1; + action = PEEP_ACTION_NONE_1; next_action_sprite_type = 7; SwitchNextActionSpriteType(); } if (state == PEEP_STATE_WATCHING) { - action = PEEP_ACTION_NONE_1; + action = PEEP_ACTION_NONE_1; next_action_sprite_type = 2; SwitchNextActionSpriteType(); } @@ -6664,9 +6651,9 @@ void rct_peep::SetSpriteType(uint8_t new_sprite_type) struct item_pref_t { - uint8_t type; // 0 for standard, 1 for extra + uint8_t type; // 0 for standard, 1 for extra uint32_t item; // And this with the relevant flags - uint8_t sprite_type; + uint8_t sprite_type; }; // clang-format off @@ -6732,7 +6719,7 @@ void rct_peep::UpdateSpriteType() { if ((x & 0xFFE0) < 0x1FFF && (y & 0xFFE0) < 0x1FFF) { - rct_tile_element * tileElement = map_get_first_element_at(x / 32, y / 32); + rct_tile_element* tileElement = map_get_first_element_at(x / 32, y / 32); while (true) { if ((z / 8) < tileElement->base_height) @@ -6748,7 +6735,7 @@ void rct_peep::UpdateSpriteType() } } - for (item_pref_t * item_pref = item_order_preference; item_pref->type != 0xFF; item_pref++) + for (item_pref_t* item_pref = item_order_preference; item_pref->type != 0xFF; item_pref++) { if (item_pref->type == 0) { diff --git a/src/openrct2/peep/GuestPathfinding.cpp b/src/openrct2/peep/GuestPathfinding.cpp index 3a38f41efa..b775b994c9 100644 --- a/src/openrct2/peep/GuestPathfinding.cpp +++ b/src/openrct2/peep/GuestPathfinding.cpp @@ -7,31 +7,32 @@ * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ -#include "Peep.h" -#include -#include "../scenario/Scenario.h" -#include "../world/Footpath.h" -#include "../world/Entrance.h" #include "../ride/Station.h" #include "../ride/Track.h" +#include "../scenario/Scenario.h" #include "../util/Util.h" +#include "../world/Entrance.h" +#include "../world/Footpath.h" +#include "Peep.h" -static bool _peepPathFindIsStaff; -static int8_t _peepPathFindNumJunctions; -static int8_t _peepPathFindMaxJunctions; +#include + +static bool _peepPathFindIsStaff; +static int8_t _peepPathFindNumJunctions; +static int8_t _peepPathFindMaxJunctions; static int32_t _peepPathFindTilesChecked; -static uint8_t _peepPathFindFewestNumSteps; +static uint8_t _peepPathFindFewestNumSteps; -static int32_t guest_surface_path_finding(rct_peep * peep); +static int32_t guest_surface_path_finding(rct_peep* peep); /* A junction history for the peep pathfinding heuristic search -* The magic number 16 is the largest value returned by -* peep_pathfind_get_max_number_junctions() which should eventually -* be declared properly. */ + * The magic number 16 is the largest value returned by + * peep_pathfind_get_max_number_junctions() which should eventually + * be declared properly. */ static struct { TileCoordsXYZ location; - uint8_t direction; + uint8_t direction; } _peepPathFindHistory[16]; enum @@ -51,14 +52,14 @@ enum PATH_SEARCH_FAILED }; -static rct_tile_element * get_banner_on_path(rct_tile_element * path_element) +static rct_tile_element* get_banner_on_path(rct_tile_element* path_element) { // This is an improved version of original. // That only checked for one fence in the way. if (path_element->IsLastForTile()) return nullptr; - rct_tile_element * bannerElement = path_element + 1; + rct_tile_element* bannerElement = path_element + 1; do { // Path on top, so no banners @@ -76,11 +77,11 @@ static rct_tile_element * get_banner_on_path(rct_tile_element * path_element) return nullptr; } -static int32_t banner_clear_path_edges(rct_tile_element * tileElement, int32_t edges) +static int32_t banner_clear_path_edges(rct_tile_element* tileElement, int32_t edges) { if (_peepPathFindIsStaff) return edges; - rct_tile_element * bannerElement = get_banner_on_path(tileElement); + rct_tile_element* bannerElement = get_banner_on_path(tileElement); if (bannerElement != nullptr) { do @@ -94,7 +95,7 @@ static int32_t banner_clear_path_edges(rct_tile_element * tileElement, int32_t e /** * Gets the connected edges of a path that are permitted (i.e. no 'no entry' signs) */ -static int32_t path_get_permitted_edges(rct_tile_element * tileElement) +static int32_t path_get_permitted_edges(rct_tile_element* tileElement) { return banner_clear_path_edges(tileElement, tileElement->properties.path.edges) & 0x0F; } @@ -103,7 +104,7 @@ static int32_t path_get_permitted_edges(rct_tile_element * tileElement) * * rct2: 0x0069524E */ -static int32_t peep_move_one_tile(uint8_t direction, rct_peep * peep) +static int32_t peep_move_one_tile(uint8_t direction, rct_peep* peep) { assert(direction <= 3); int16_t x = peep->next_x; @@ -117,9 +118,9 @@ static int32_t peep_move_one_tile(uint8_t direction, rct_peep * peep) return guest_surface_path_finding(peep); } - peep->direction = direction; - peep->destination_x = x + 16; - peep->destination_y = y + 16; + peep->direction = direction; + peep->destination_x = x + 16; + peep->destination_y = y + 16; peep->destination_tolerance = 2; if (peep->state != PEEP_STATE_QUEUING) { @@ -132,12 +133,12 @@ static int32_t peep_move_one_tile(uint8_t direction, rct_peep * peep) * * rct2: 0x00694C41 */ -static int32_t guest_surface_path_finding(rct_peep * peep) +static int32_t guest_surface_path_finding(rct_peep* peep) { - int16_t x = peep->next_x; - int16_t y = peep->next_y; - int16_t z = peep->next_z; - uint8_t randDirection = scenario_rand() & 3; + int16_t x = peep->next_x; + int16_t y = peep->next_y; + int16_t z = peep->next_z; + uint8_t randDirection = scenario_rand() & 3; if (!fence_in_the_way(x, y, z, z + 4, randDirection)) { @@ -221,10 +222,9 @@ static int32_t guest_surface_path_finding(rct_peep * peep) * Returns the type of the next footpath tile a peep can get to from x,y,z / * inputTileElement in the given direction. */ -static uint8_t footpath_element_next_in_direction(TileCoordsXYZ loc, rct_tile_element * tileElement, - uint8_t chosenDirection) +static uint8_t footpath_element_next_in_direction(TileCoordsXYZ loc, rct_tile_element* tileElement, uint8_t chosenDirection) { - rct_tile_element * nextTileElement; + rct_tile_element* nextTileElement; if (footpath_element_is_sloped(tileElement)) { @@ -281,8 +281,8 @@ static uint8_t footpath_element_dest_in_dir( uint8_t* outRideIndex, int32_t level) { - rct_tile_element * tileElement; - int32_t direction; + rct_tile_element* tileElement; + int32_t direction; if (level > 25) return PATH_SEARCH_LIMIT_REACHED; @@ -300,73 +300,73 @@ static uint8_t footpath_element_dest_in_dir( switch (tileElement->GetType()) { - case TILE_ELEMENT_TYPE_TRACK: - { - if (loc.z != tileElement->base_height) - continue; - int32_t rideIndex = track_element_get_ride_index(tileElement); - Ride * ride = get_ride(rideIndex); - if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_IS_SHOP)) + case TILE_ELEMENT_TYPE_TRACK: { - *outRideIndex = rideIndex; - return PATH_SEARCH_SHOP_ENTRANCE; - } - } - break; - case TILE_ELEMENT_TYPE_ENTRANCE: - if (loc.z != tileElement->base_height) - continue; - switch (tileElement->properties.entrance.type) - { - case ENTRANCE_TYPE_RIDE_ENTRANCE: - direction = tile_element_get_direction(tileElement); - if (direction == chosenDirection) + if (loc.z != tileElement->base_height) + continue; + int32_t rideIndex = track_element_get_ride_index(tileElement); + Ride* ride = get_ride(rideIndex); + if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_IS_SHOP)) { - *outRideIndex = tileElement->properties.entrance.ride_index; - return PATH_SEARCH_RIDE_ENTRANCE; + *outRideIndex = rideIndex; + return PATH_SEARCH_SHOP_ENTRANCE; } - break; - case ENTRANCE_TYPE_RIDE_EXIT: - direction = tile_element_get_direction(tileElement); - if (direction == chosenDirection) - { - *outRideIndex = tileElement->properties.entrance.ride_index; - return PATH_SEARCH_RIDE_EXIT; - } - break; - case ENTRANCE_TYPE_PARK_ENTRANCE: - return PATH_SEARCH_PARK_EXIT; } break; - case TILE_ELEMENT_TYPE_PATH: - if (!is_valid_path_z_and_direction(tileElement, loc.z, chosenDirection)) - continue; - if (footpath_element_is_wide(tileElement)) - return PATH_SEARCH_WIDE; - - uint8_t edges = path_get_permitted_edges(tileElement); - edges &= ~(1 << (chosenDirection ^ 2)); - loc.z = tileElement->base_height; - - for (direction = 0; direction < 4; direction++) - { - if (!(edges & (1 << direction))) + case TILE_ELEMENT_TYPE_ENTRANCE: + if (loc.z != tileElement->base_height) continue; - - edges &= ~(1 << direction); - if (edges != 0) - return PATH_SEARCH_JUNCTION; - - if (footpath_element_is_sloped(tileElement)) + switch (tileElement->properties.entrance.type) { - if (footpath_element_get_slope_direction(tileElement) == direction) - { - loc.z += 2; - } + case ENTRANCE_TYPE_RIDE_ENTRANCE: + direction = tile_element_get_direction(tileElement); + if (direction == chosenDirection) + { + *outRideIndex = tileElement->properties.entrance.ride_index; + return PATH_SEARCH_RIDE_ENTRANCE; + } + break; + case ENTRANCE_TYPE_RIDE_EXIT: + direction = tile_element_get_direction(tileElement); + if (direction == chosenDirection) + { + *outRideIndex = tileElement->properties.entrance.ride_index; + return PATH_SEARCH_RIDE_EXIT; + } + break; + case ENTRANCE_TYPE_PARK_ENTRANCE: + return PATH_SEARCH_PARK_EXIT; } - return footpath_element_dest_in_dir(loc, tileElement, direction, outRideIndex, level + 1); - } - return PATH_SEARCH_DEAD_END; + break; + case TILE_ELEMENT_TYPE_PATH: + if (!is_valid_path_z_and_direction(tileElement, loc.z, chosenDirection)) + continue; + if (footpath_element_is_wide(tileElement)) + return PATH_SEARCH_WIDE; + + uint8_t edges = path_get_permitted_edges(tileElement); + edges &= ~(1 << (chosenDirection ^ 2)); + loc.z = tileElement->base_height; + + for (direction = 0; direction < 4; direction++) + { + if (!(edges & (1 << direction))) + continue; + + edges &= ~(1 << direction); + if (edges != 0) + return PATH_SEARCH_JUNCTION; + + if (footpath_element_is_sloped(tileElement)) + { + if (footpath_element_get_slope_direction(tileElement) == direction) + { + loc.z += 2; + } + } + return footpath_element_dest_in_dir(loc, tileElement, direction, outRideIndex, level + 1); + } + return PATH_SEARCH_DEAD_END; } } while (!(tileElement++)->IsLastForTile()); @@ -396,8 +396,8 @@ static uint8_t footpath_element_dest_in_dir( * This is useful for finding out what is at the end of a short single * width path, for example that leads from a ride exit back to the main path. */ -static uint8_t footpath_element_destination_in_direction(TileCoordsXYZ loc, rct_tile_element * inputTileElement, - uint8_t chosenDirection, uint8_t * outRideIndex) +static uint8_t footpath_element_destination_in_direction( + TileCoordsXYZ loc, rct_tile_element* inputTileElement, uint8_t chosenDirection, uint8_t* outRideIndex) { if (footpath_element_is_sloped(inputTileElement)) { @@ -414,7 +414,7 @@ static uint8_t footpath_element_destination_in_direction(TileCoordsXYZ loc, rct_ * * rct2: 0x00695225 */ -static int32_t guest_path_find_aimless(rct_peep * peep, uint8_t edges) +static int32_t guest_path_find_aimless(rct_peep* peep, uint8_t edges) { if (scenario_rand() & 1) { @@ -440,7 +440,7 @@ static int32_t guest_path_find_aimless(rct_peep * peep, uint8_t edges) * * rct2: 0x0069A60A */ -static uint8_t peep_pathfind_get_max_number_junctions(rct_peep * peep) +static uint8_t peep_pathfind_get_max_number_junctions(rct_peep* peep) { if (peep->type == PEEP_TYPE_STAFF) return 8; @@ -476,7 +476,7 @@ static uint8_t peep_pathfind_get_max_number_junctions(rct_peep * peep) * since entrances and ride queues coming off a path should not result in * the path being considered a junction. */ -static bool path_is_thin_junction(rct_tile_element * path, TileCoordsXYZ loc) +static bool path_is_thin_junction(rct_tile_element* path, TileCoordsXYZ loc) { uint8_t edges = footpath_get_edges(path); @@ -484,8 +484,8 @@ static bool path_is_thin_junction(rct_tile_element * path, TileCoordsXYZ loc) if (test_edge == -1) return false; - bool thin_junction = false; - int32_t thin_count = 0; + bool thin_junction = false; + int32_t thin_count = 0; do { int32_t fp_result = footpath_element_next_in_direction(loc, path, test_edge); @@ -584,15 +584,25 @@ static bool path_is_thin_junction(rct_tile_element * path, TileCoordsXYZ loc) * * rct2: 0x0069A997 */ -static void peep_pathfind_heuristic_search(TileCoordsXYZ loc, rct_peep * peep, rct_tile_element * currentTileElement, - bool inPatrolArea, uint8_t counter, uint16_t * endScore, int32_t test_edge, - uint8_t * endJunctions, TileCoordsXYZ junctionList[16], uint8_t directionList[16], - TileCoordsXYZ * endXYZ, uint8_t * endSteps) +static void peep_pathfind_heuristic_search( + TileCoordsXYZ loc, + rct_peep* peep, + rct_tile_element* currentTileElement, + bool inPatrolArea, + uint8_t counter, + uint16_t* endScore, + int32_t test_edge, + uint8_t* endJunctions, + TileCoordsXYZ junctionList[16], + uint8_t directionList[16], + TileCoordsXYZ* endXYZ, + uint8_t* endSteps) { uint8_t searchResult = PATH_SEARCH_FAILED; - bool currentElementIsWide = - (footpath_element_is_wide(currentTileElement) && !staff_can_ignore_wide_flag(peep, loc.x * 32, loc.y * 32, loc.z, currentTileElement)); + bool currentElementIsWide + = (footpath_element_is_wide(currentTileElement) + && !staff_can_ignore_wide_flag(peep, loc.x * 32, loc.y * 32, loc.z, currentTileElement)); loc += TileDirectionDelta[test_edge]; @@ -602,8 +612,8 @@ static void peep_pathfind_heuristic_search(TileCoordsXYZ loc, rct_peep * peep, r /* If this is where the search started this is a search loop and the * current search path ends here. * Return without updating the parameters (best result so far). */ - if ((_peepPathFindHistory[0].location.x == (uint8_t)loc.x) && (_peepPathFindHistory[0].location.y == (uint8_t)loc.y) && - (_peepPathFindHistory[0].location.z == loc.z)) + if ((_peepPathFindHistory[0].location.x == (uint8_t)loc.x) && (_peepPathFindHistory[0].location.y == (uint8_t)loc.y) + && (_peepPathFindHistory[0].location.z == loc.z)) { #if defined(DEBUG_LEVEL_2) && DEBUG_LEVEL_2 if (gPathFindDebug) @@ -634,8 +644,8 @@ static void peep_pathfind_heuristic_search(TileCoordsXYZ loc, rct_peep * peep, r } /* Get the next map element of interest in the direction of test_edge. */ - bool found = false; - rct_tile_element * tileElement = map_get_first_element_at(loc.x, loc.y); + bool found = false; + rct_tile_element* tileElement = map_get_first_element_at(loc.x, loc.y); if (tileElement == nullptr) { return; @@ -651,133 +661,138 @@ static void peep_pathfind_heuristic_search(TileCoordsXYZ loc, rct_peep * peep, r uint8_t rideIndex = 0xFF; switch (tileElement->GetType()) { - case TILE_ELEMENT_TYPE_TRACK: - { - if (loc.z != tileElement->base_height) - continue; - /* For peeps heading for a shop, the goal is the shop - * tile. */ - rideIndex = track_element_get_ride_index(tileElement); - Ride * ride = get_ride(rideIndex); - if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_IS_SHOP)) + case TILE_ELEMENT_TYPE_TRACK: { - found = true; - searchResult = PATH_SEARCH_SHOP_ENTRANCE; + if (loc.z != tileElement->base_height) + continue; + /* For peeps heading for a shop, the goal is the shop + * tile. */ + rideIndex = track_element_get_ride_index(tileElement); + Ride* ride = get_ride(rideIndex); + if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_IS_SHOP)) + { + found = true; + searchResult = PATH_SEARCH_SHOP_ENTRANCE; + break; + } + else + { + continue; + } + } + case TILE_ELEMENT_TYPE_ENTRANCE: + if (loc.z != tileElement->base_height) + continue; + int32_t direction; + searchResult = PATH_SEARCH_OTHER; + switch (tileElement->properties.entrance.type) + { + case ENTRANCE_TYPE_RIDE_ENTRANCE: + /* For peeps heading for a ride without a queue, the + * goal is the ride entrance tile. + * For mechanics heading for the ride entrance + * (in the case when the station has no exit), + * the goal is the ride entrance tile. */ + direction = tile_element_get_direction(tileElement); + if (direction == test_edge) + { + /* The rideIndex will be useful for + * adding transport rides later. */ + rideIndex = tileElement->properties.entrance.ride_index; + searchResult = PATH_SEARCH_RIDE_ENTRANCE; + found = true; + break; + } + continue; // Ride entrance is not facing the right direction. + case ENTRANCE_TYPE_PARK_ENTRANCE: + /* For peeps leaving the park, the goal is the park + * entrance/exit tile. */ + searchResult = PATH_SEARCH_PARK_EXIT; + found = true; + break; + case ENTRANCE_TYPE_RIDE_EXIT: + /* For mechanics heading for the ride exit, the + * goal is the ride exit tile. */ + direction = tile_element_get_direction(tileElement); + if (direction == test_edge) + { + searchResult = PATH_SEARCH_RIDE_EXIT; + found = true; + break; + } + continue; // Ride exit is not facing the right direction. + default: + continue; + } break; - } - else + case TILE_ELEMENT_TYPE_PATH: { - continue; - } - } - case TILE_ELEMENT_TYPE_ENTRANCE: - if (loc.z != tileElement->base_height) - continue; - int32_t direction; - searchResult = PATH_SEARCH_OTHER; - switch (tileElement->properties.entrance.type) - { - case ENTRANCE_TYPE_RIDE_ENTRANCE: - /* For peeps heading for a ride without a queue, the - * goal is the ride entrance tile. - * For mechanics heading for the ride entrance - * (in the case when the station has no exit), - * the goal is the ride entrance tile. */ - direction = tile_element_get_direction(tileElement); - if (direction == test_edge) + /* For peeps heading for a ride with a queue, the goal is the last + * queue path. + * Otherwise, peeps walk on path tiles to get to the goal. */ + + if (!is_valid_path_z_and_direction(tileElement, loc.z, test_edge)) + continue; + + // Path may be sloped, so set z to path base height. + loc.z = tileElement->base_height; + + if (footpath_element_is_wide(tileElement)) { - /* The rideIndex will be useful for - * adding transport rides later. */ - rideIndex = tileElement->properties.entrance.ride_index; - searchResult = PATH_SEARCH_RIDE_ENTRANCE; - found = true; - break; - } - continue; // Ride entrance is not facing the right direction. - case ENTRANCE_TYPE_PARK_ENTRANCE: - /* For peeps leaving the park, the goal is the park - * entrance/exit tile. */ - searchResult = PATH_SEARCH_PARK_EXIT; - found = true; - break; - case ENTRANCE_TYPE_RIDE_EXIT: - /* For mechanics heading for the ride exit, the - * goal is the ride exit tile. */ - direction = tile_element_get_direction(tileElement); - if (direction == test_edge) - { - searchResult = PATH_SEARCH_RIDE_EXIT; - found = true; - break; - } - continue; // Ride exit is not facing the right direction. - default: - continue; - } - break; - case TILE_ELEMENT_TYPE_PATH: - { - /* For peeps heading for a ride with a queue, the goal is the last - * queue path. - * Otherwise, peeps walk on path tiles to get to the goal. */ - - if (!is_valid_path_z_and_direction(tileElement, loc.z, test_edge)) - continue; - - // Path may be sloped, so set z to path base height. - loc.z = tileElement->base_height; - - if (footpath_element_is_wide(tileElement)) - { - /* Check if staff can ignore this wide flag. */ - if (!staff_can_ignore_wide_flag(peep, loc.x * 32, loc.y * 32, loc.z, tileElement)) - { - searchResult = PATH_SEARCH_WIDE; - found = true; - break; - } - } - - searchResult = PATH_SEARCH_THIN; - - uint8_t numEdges = bitcount(footpath_get_edges(tileElement)); - - if (numEdges < 2) - { - searchResult = PATH_SEARCH_DEAD_END; - } - else if (numEdges > 2) - { - searchResult = PATH_SEARCH_JUNCTION; - } - else - { // numEdges == 2 - if (footpath_element_is_queue(tileElement) && - tileElement->properties.path.ride_index != gPeepPathFindQueueRideIndex) - { - if (gPeepPathFindIgnoreForeignQueues && (tileElement->properties.path.ride_index != 0xFF)) + /* Check if staff can ignore this wide flag. */ + if (!staff_can_ignore_wide_flag(peep, loc.x * 32, loc.y * 32, loc.z, tileElement)) { - // Path is a queue we aren't interested in - /* The rideIndex will be useful for - * adding transport rides later. */ - rideIndex = tileElement->properties.path.ride_index; - searchResult = PATH_SEARCH_RIDE_QUEUE; + searchResult = PATH_SEARCH_WIDE; + found = true; + break; } } + + searchResult = PATH_SEARCH_THIN; + + uint8_t numEdges = bitcount(footpath_get_edges(tileElement)); + + if (numEdges < 2) + { + searchResult = PATH_SEARCH_DEAD_END; + } + else if (numEdges > 2) + { + searchResult = PATH_SEARCH_JUNCTION; + } + else + { // numEdges == 2 + if (footpath_element_is_queue(tileElement) + && tileElement->properties.path.ride_index != gPeepPathFindQueueRideIndex) + { + if (gPeepPathFindIgnoreForeignQueues && (tileElement->properties.path.ride_index != 0xFF)) + { + // Path is a queue we aren't interested in + /* The rideIndex will be useful for + * adding transport rides later. */ + rideIndex = tileElement->properties.path.ride_index; + searchResult = PATH_SEARCH_RIDE_QUEUE; + } + } + } + found = true; } - found = true; - } - break; - default: - continue; + break; + default: + continue; } # #if defined(DEBUG_LEVEL_2) && DEBUG_LEVEL_2 if (gPathFindDebug) { - log_info("[%03d] Checking map element at %d,%d,%d; Type: %s", counter, x >> 5, y >> 5, z, - gPathFindSearchText[searchResult]); + log_info( + "[%03d] Checking map element at %d,%d,%d; Type: %s", + counter, + x >> 5, + y >> 5, + z, + gPathFindSearchText[searchResult]); } #endif // defined(DEBUG_LEVEL_2) && DEBUG_LEVEL_2 @@ -796,7 +811,7 @@ static void peep_pathfind_heuristic_search(TileCoordsXYZ loc, rct_peep * peep, r else y_delta >>= 4; uint16_t new_score = x_delta + y_delta; - uint16_t z_delta = abs(gPeepPathFindGoalPosition.z - loc.z); + uint16_t z_delta = abs(gPeepPathFindGoalPosition.z - loc.z); z_delta <<= 1; new_score += z_delta; @@ -816,11 +831,11 @@ static void peep_pathfind_heuristic_search(TileCoordsXYZ loc, rct_peep * peep, r *endJunctions = _peepPathFindMaxJunctions - _peepPathFindNumJunctions; for (uint8_t junctInd = 0; junctInd < *endJunctions; junctInd++) { - uint8_t histIdx = _peepPathFindMaxJunctions - junctInd; + uint8_t histIdx = _peepPathFindMaxJunctions - junctInd; junctionList[junctInd].x = _peepPathFindHistory[histIdx].location.x; junctionList[junctInd].y = _peepPathFindHistory[histIdx].location.y; junctionList[junctInd].z = _peepPathFindHistory[histIdx].location.z; - directionList[junctInd] = _peepPathFindHistory[histIdx].direction; + directionList[junctInd] = _peepPathFindHistory[histIdx].direction; } } #if defined(DEBUG_LEVEL_2) && DEBUG_LEVEL_2 @@ -836,8 +851,8 @@ static void peep_pathfind_heuristic_search(TileCoordsXYZ loc, rct_peep * peep, r /* If this map element is not a path, the search cannot be continued. * Continue to the next map element without updating the parameters (best result so far). */ - if (searchResult != PATH_SEARCH_DEAD_END && searchResult != PATH_SEARCH_THIN && searchResult != PATH_SEARCH_JUNCTION && - searchResult != PATH_SEARCH_WIDE) + if (searchResult != PATH_SEARCH_DEAD_END && searchResult != PATH_SEARCH_THIN && searchResult != PATH_SEARCH_JUNCTION + && searchResult != PATH_SEARCH_WIDE) { #if defined(DEBUG_LEVEL_2) && DEBUG_LEVEL_2 if (gPathFindDebug) @@ -874,11 +889,11 @@ static void peep_pathfind_heuristic_search(TileCoordsXYZ loc, rct_peep * peep, r *endJunctions = _peepPathFindMaxJunctions - _peepPathFindNumJunctions; for (uint8_t junctInd = 0; junctInd < *endJunctions; junctInd++) { - uint8_t histIdx = _peepPathFindMaxJunctions - junctInd; + uint8_t histIdx = _peepPathFindMaxJunctions - junctInd; junctionList[junctInd].x = _peepPathFindHistory[histIdx].location.x; junctionList[junctInd].y = _peepPathFindHistory[histIdx].location.y; junctionList[junctInd].z = _peepPathFindHistory[histIdx].location.z; - directionList[junctInd] = _peepPathFindHistory[histIdx].direction; + directionList[junctInd] = _peepPathFindHistory[histIdx].direction; } } #if defined(DEBUG_LEVEL_2) && DEBUG_LEVEL_2 @@ -898,8 +913,17 @@ static void peep_pathfind_heuristic_search(TileCoordsXYZ loc, rct_peep * peep, r #if defined(DEBUG_LEVEL_2) && DEBUG_LEVEL_2 if (gPathFindDebug) { - log_info("[%03d] Path element at %d,%d,%d; Edges (0123):%d%d%d%d; Reverse: %d", counter, x >> 5, y >> 5, z, - edges & 1, (edges & 2) >> 1, (edges & 4) >> 2, (edges & 8) >> 3, test_edge ^ 2); + log_info( + "[%03d] Path element at %d,%d,%d; Edges (0123):%d%d%d%d; Reverse: %d", + counter, + x >> 5, + y >> 5, + z, + edges & 1, + (edges & 2) >> 1, + (edges & 4) >> 2, + (edges & 8) >> 3, + test_edge ^ 2); } #endif // defined(DEBUG_LEVEL_2) && DEBUG_LEVEL_2 @@ -940,18 +964,23 @@ static void peep_pathfind_heuristic_search(TileCoordsXYZ loc, rct_peep * peep, r *endJunctions = _peepPathFindMaxJunctions - _peepPathFindNumJunctions; for (uint8_t junctInd = 0; junctInd < *endJunctions; junctInd++) { - uint8_t histIdx = _peepPathFindMaxJunctions - junctInd; + uint8_t histIdx = _peepPathFindMaxJunctions - junctInd; junctionList[junctInd].x = _peepPathFindHistory[histIdx].location.x; junctionList[junctInd].y = _peepPathFindHistory[histIdx].location.y; junctionList[junctInd].z = _peepPathFindHistory[histIdx].location.z; - directionList[junctInd] = _peepPathFindHistory[histIdx].direction; + directionList[junctInd] = _peepPathFindHistory[histIdx].direction; } } #if defined(DEBUG_LEVEL_2) && DEBUG_LEVEL_2 if (gPathFindDebug) { - log_info("[%03d] Search path ends at %d,%d,%d; Search limit reached; Score: %d", counter, x >> 5, y >> 5, z, - new_score); + log_info( + "[%03d] Search path ends at %d,%d,%d; Search limit reached; Score: %d", + counter, + x >> 5, + y >> 5, + z, + new_score); } #endif // defined(DEBUG_LEVEL_2) && DEBUG_LEVEL_2 continue; @@ -980,10 +1009,9 @@ static void peep_pathfind_heuristic_search(TileCoordsXYZ loc, rct_peep * peep, r bool pathLoop = false; /* Check the peep->pathfind_history to see if this junction has * already been visited by the peep while heading for this goal. */ - for (auto &pathfindHistory : peep->pathfind_history) + for (auto& pathfindHistory : peep->pathfind_history) { - if (pathfindHistory.x == loc.x && pathfindHistory.y == loc.y && - pathfindHistory.z == loc.z) + if (pathfindHistory.x == loc.x && pathfindHistory.y == loc.y && pathfindHistory.z == loc.z) { if (pathfindHistory.direction == 0) { @@ -1010,9 +1038,9 @@ static void peep_pathfind_heuristic_search(TileCoordsXYZ loc, rct_peep * peep, r for (int32_t junctionNum = _peepPathFindNumJunctions + 1; junctionNum <= _peepPathFindMaxJunctions; junctionNum++) { - if ((_peepPathFindHistory[junctionNum].location.x == (uint8_t)loc.x) && - (_peepPathFindHistory[junctionNum].location.y == (uint8_t)loc.y) && - (_peepPathFindHistory[junctionNum].location.z == loc.z)) + if ((_peepPathFindHistory[junctionNum].location.x == (uint8_t)loc.x) + && (_peepPathFindHistory[junctionNum].location.y == (uint8_t)loc.y) + && (_peepPathFindHistory[junctionNum].location.z == loc.z)) { pathLoop = true; break; @@ -1050,18 +1078,23 @@ static void peep_pathfind_heuristic_search(TileCoordsXYZ loc, rct_peep * peep, r *endJunctions = _peepPathFindMaxJunctions; // - _peepPathFindNumJunctions; for (uint8_t junctInd = 0; junctInd < *endJunctions; junctInd++) { - uint8_t histIdx = _peepPathFindMaxJunctions - junctInd; + uint8_t histIdx = _peepPathFindMaxJunctions - junctInd; junctionList[junctInd].x = _peepPathFindHistory[histIdx].location.x; junctionList[junctInd].y = _peepPathFindHistory[histIdx].location.y; junctionList[junctInd].z = _peepPathFindHistory[histIdx].location.z; - directionList[junctInd] = _peepPathFindHistory[histIdx].direction; + directionList[junctInd] = _peepPathFindHistory[histIdx].direction; } } #if defined(DEBUG_LEVEL_2) && DEBUG_LEVEL_2 if (gPathFindDebug) { - log_info("[%03d] Search path ends at %d,%d,%d; NumJunctions < 0; Score: %d", counter, x >> 5, y >> 5, z, - new_score); + log_info( + "[%03d] Search path ends at %d,%d,%d; NumJunctions < 0; Score: %d", + counter, + x >> 5, + y >> 5, + z, + new_score); } #endif // defined(DEBUG_LEVEL_2) && DEBUG_LEVEL_2 continue; @@ -1096,11 +1129,11 @@ static void peep_pathfind_heuristic_search(TileCoordsXYZ loc, rct_peep * peep, r if (searchResult == PATH_SEARCH_JUNCTION) { if (thin_junction) - log_info("[%03d] Recurse from %d,%d,%d edge: %d; Thin-Junction", counter, x >> 5, y >> 5, z, - next_test_edge); + log_info( + "[%03d] Recurse from %d,%d,%d edge: %d; Thin-Junction", counter, x >> 5, y >> 5, z, next_test_edge); else - log_info("[%03d] Recurse from %d,%d,%d edge: %d; Wide-Junction", counter, x >> 5, y >> 5, z, - next_test_edge); + log_info( + "[%03d] Recurse from %d,%d,%d edge: %d; Wide-Junction", counter, x >> 5, y >> 5, z, next_test_edge); } else { @@ -1115,15 +1148,26 @@ static void peep_pathfind_heuristic_search(TileCoordsXYZ loc, rct_peep * peep, r _peepPathFindHistory[_peepPathFindNumJunctions + 1].direction = next_test_edge; } - peep_pathfind_heuristic_search({ loc.x, loc.y, height }, peep, tileElement, nextInPatrolArea, counter, endScore, next_test_edge, - endJunctions, junctionList, directionList, endXYZ, endSteps); + peep_pathfind_heuristic_search( + { loc.x, loc.y, height }, + peep, + tileElement, + nextInPatrolArea, + counter, + endScore, + next_test_edge, + endJunctions, + junctionList, + directionList, + endXYZ, + endSteps); _peepPathFindNumJunctions = savedNumJunctions; #if defined(DEBUG_LEVEL_2) && DEBUG_LEVEL_2 if (gPathFindDebug) { - log_info("[%03d] Returned to %d,%d,%d edge: %d; Score: %d", counter, x >> 5, y >> 5, z, next_test_edge, - *endScore); + log_info( + "[%03d] Returned to %d,%d,%d edge: %d; Score: %d", counter, x >> 5, y >> 5, z, next_test_edge, *endScore); } #endif // defined(DEBUG_LEVEL_2) && DEBUG_LEVEL_2 } while ((next_test_edge = bitscanforward(edges)) != -1); @@ -1159,7 +1203,7 @@ static void peep_pathfind_heuristic_search(TileCoordsXYZ loc, rct_peep * peep, r * * rct2: 0x0069A5F0 */ -int32_t peep_pathfind_choose_direction(TileCoordsXYZ loc, rct_peep * peep) +int32_t peep_pathfind_choose_direction(TileCoordsXYZ loc, rct_peep* peep) { // The max number of thin junctions searched - a per-search-path limit. _peepPathFindMaxJunctions = peep_pathfind_get_max_number_junctions(peep); @@ -1175,13 +1219,20 @@ int32_t peep_pathfind_choose_direction(TileCoordsXYZ loc, rct_peep * peep) #if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 if (gPathFindDebug) { - log_verbose("Choose direction for %s for goal %d,%d,%d from %d,%d,%d", gPathFindDebugPeepName, goal.x, goal.y, goal.z, - loc.x, loc.y, loc.z); + log_verbose( + "Choose direction for %s for goal %d,%d,%d from %d,%d,%d", + gPathFindDebugPeepName, + goal.x, + goal.y, + goal.z, + loc.x, + loc.y, + loc.z); } #endif // defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 // Get the path element at this location - rct_tile_element * dest_tile_element = map_get_first_element_at(loc.x, loc.y); + rct_tile_element* dest_tile_element = map_get_first_element_at(loc.x, loc.y); /* Where there are multiple matching map elements placed with zero * clearance, save the first one for later use to determine the path * slope - this maintains the original behaviour (which only processes @@ -1197,11 +1248,11 @@ int32_t peep_pathfind_choose_direction(TileCoordsXYZ loc, rct_peep * peep) * EXPECT to experience path finding irregularities due to those paths! * In particular common edges at different heights will not work * in a useful way. Simply do not do it! :-) */ - rct_tile_element * first_tile_element = nullptr; + rct_tile_element* first_tile_element = nullptr; - bool found = false; + bool found = false; uint8_t permitted_edges = 0; - bool isThin = false; + bool isThin = false; do { if (dest_tile_element->base_height != loc.z) @@ -1248,12 +1299,10 @@ int32_t peep_pathfind_choose_direction(TileCoordsXYZ loc, rct_peep * peep) /* If the peep remembers walking through this junction * previously while heading for its goal, retrieve the * directions it has not yet tried. */ - for (auto &pathfindHistory : peep->pathfind_history) + for (auto& pathfindHistory : peep->pathfind_history) { - if (pathfindHistory.x == loc.x && pathfindHistory.y == loc.y && - pathfindHistory.z == loc.z) + if (pathfindHistory.x == loc.x && pathfindHistory.y == loc.y && pathfindHistory.z == loc.z) { - /* Fix broken pathfind_history[i].direction * which have untried directions that are not * currently possible - could be due to pathing @@ -1267,9 +1316,15 @@ int32_t peep_pathfind_choose_direction(TileCoordsXYZ loc, rct_peep * peep) #if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 if (gPathFindDebug) { - log_verbose("Getting untried edges from pf_history for %d,%d,%d: %s,%s,%s,%s", loc.x, loc.y, loc.z, - (edges & 1) ? "0" : "-", (edges & 2) ? "1" : "-", (edges & 4) ? "2" : "-", - (edges & 8) ? "3" : "-"); + log_verbose( + "Getting untried edges from pf_history for %d,%d,%d: %s,%s,%s,%s", + loc.x, + loc.y, + loc.z, + (edges & 1) ? "0" : "-", + (edges & 2) ? "1" : "-", + (edges & 4) ? "2" : "-", + (edges & 8) ? "3" : "-"); } #endif // defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 @@ -1284,7 +1339,7 @@ int32_t peep_pathfind_choose_direction(TileCoordsXYZ loc, rct_peep * peep) * has changed (been fixed) since * the game was saved. */ pathfindHistory.direction = permitted_edges; - edges = pathfindHistory.direction; + edges = pathfindHistory.direction; #if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 if (gPathFindDebug) @@ -1300,12 +1355,12 @@ int32_t peep_pathfind_choose_direction(TileCoordsXYZ loc, rct_peep * peep) /* If this is a new goal for the peep. Store it and reset the peep's * pathfind_history. */ - if (peep->pathfind_goal.direction > 3 || peep->pathfind_goal.x != goal.x || peep->pathfind_goal.y != goal.y || - peep->pathfind_goal.z != goal.z) + if (peep->pathfind_goal.direction > 3 || peep->pathfind_goal.x != goal.x || peep->pathfind_goal.y != goal.y + || peep->pathfind_goal.z != goal.z) { - peep->pathfind_goal.x = goal.x; - peep->pathfind_goal.y = goal.y; - peep->pathfind_goal.z = goal.z; + peep->pathfind_goal.x = goal.x; + peep->pathfind_goal.y = goal.y; + peep->pathfind_goal.z = goal.z; peep->pathfind_goal.direction = 0; // Clear pathfinding history @@ -1328,12 +1383,12 @@ int32_t peep_pathfind_choose_direction(TileCoordsXYZ loc, rct_peep * peep) if (edges & ~(1 << chosen_edge)) { uint16_t best_score = 0xFFFF; - uint8_t best_sub = 0xFF; + uint8_t best_sub = 0xFF; #if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 - uint8_t bestJunctions = 0; + uint8_t bestJunctions = 0; TileCoordsXYZ bestJunctionList[16]; - uint8_t bestDirectionList[16]; + uint8_t bestDirectionList[16]; TileCoordsXYZ bestXYZ; if (gPathFindDebug) @@ -1352,8 +1407,8 @@ int32_t peep_pathfind_choose_direction(TileCoordsXYZ loc, rct_peep * peep) edges &= ~(1 << test_edge); uint8_t height = loc.z; - if (footpath_element_is_sloped(first_tile_element) && - footpath_element_get_slope_direction(first_tile_element) == test_edge) + if (footpath_element_is_sloped(first_tile_element) + && footpath_element_get_slope_direction(first_tile_element) == test_edge) { height += 0x2; } @@ -1374,7 +1429,7 @@ int32_t peep_pathfind_choose_direction(TileCoordsXYZ loc, rct_peep * peep) _peepPathFindHistory[0].location.x = (uint8_t)(loc.x); _peepPathFindHistory[0].location.y = (uint8_t)(loc.y); _peepPathFindHistory[0].location.z = loc.z; - _peepPathFindHistory[0].direction = 0xF; + _peepPathFindHistory[0].direction = 0xF; uint16_t score = 0xFFFF; /* Variable endXYZ contains the end location of the @@ -1393,9 +1448,9 @@ int32_t peep_pathfind_choose_direction(TileCoordsXYZ loc, rct_peep * peep) * of the search path. * In the future these could be used to visualise the * pathfinding on the map. */ - uint8_t endJunctions = 0; + uint8_t endJunctions = 0; TileCoordsXYZ endJunctionList[16]; - uint8_t endDirectionList[16] = { 0 }; + uint8_t endDirectionList[16] = { 0 }; bool inPatrolArea = false; if (peep->type == PEEP_TYPE_STAFF && peep->staff_type == STAFF_TYPE_MECHANIC) @@ -1413,18 +1468,41 @@ int32_t peep_pathfind_choose_direction(TileCoordsXYZ loc, rct_peep * peep) } #endif // defined(DEBUG_LEVEL_2) && DEBUG_LEVEL_2 - peep_pathfind_heuristic_search({ loc.x, loc.y, height }, peep, first_tile_element, inPatrolArea, 0, &score, test_edge, - &endJunctions, endJunctionList, endDirectionList, &endXYZ, &endSteps); + peep_pathfind_heuristic_search( + { loc.x, loc.y, height }, + peep, + first_tile_element, + inPatrolArea, + 0, + &score, + test_edge, + &endJunctions, + endJunctionList, + endDirectionList, + &endXYZ, + &endSteps); #if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 if (gPathFindDebug) { - log_verbose("Pathfind test edge: %d score: %d steps: %d end: %d,%d,%d junctions: %d", test_edge, score, - endSteps, endXYZ.x, endXYZ.y, endXYZ.z, endJunctions); + log_verbose( + "Pathfind test edge: %d score: %d steps: %d end: %d,%d,%d junctions: %d", + test_edge, + score, + endSteps, + endXYZ.x, + endXYZ.y, + endXYZ.z, + endJunctions); for (uint8_t listIdx = 0; listIdx < endJunctions; listIdx++) { - log_info("Junction#%d %d,%d,%d Direction %d", listIdx + 1, endJunctionList[listIdx].x, - endJunctionList[listIdx].y, endJunctionList[listIdx].z, endDirectionList[listIdx]); + log_info( + "Junction#%d %d,%d,%d Direction %d", + listIdx + 1, + endJunctionList[listIdx].x, + endJunctionList[listIdx].y, + endJunctionList[listIdx].z, + endDirectionList[listIdx]); } } #endif // defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 @@ -1432,8 +1510,8 @@ int32_t peep_pathfind_choose_direction(TileCoordsXYZ loc, rct_peep * peep) if (score < best_score || (score == best_score && endSteps < best_sub)) { chosen_edge = test_edge; - best_score = score; - best_sub = endSteps; + best_score = score; + best_sub = endSteps; #if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 bestJunctions = endJunctions; for (uint8_t index = 0; index < endJunctions; index++) @@ -1441,7 +1519,7 @@ int32_t peep_pathfind_choose_direction(TileCoordsXYZ loc, rct_peep * peep) bestJunctionList[index].x = endJunctionList[index].x; bestJunctionList[index].y = endJunctionList[index].y; bestJunctionList[index].z = endJunctionList[index].z; - bestDirectionList[index] = endDirectionList[index]; + bestDirectionList[index] = endDirectionList[index]; } bestXYZ.x = endXYZ.x; bestXYZ.y = endXYZ.y; @@ -1469,8 +1547,13 @@ int32_t peep_pathfind_choose_direction(TileCoordsXYZ loc, rct_peep * peep) log_verbose("Pathfind best edge %d with score %d steps %d", chosen_edge, best_score, best_sub); for (uint8_t listIdx = 0; listIdx < bestJunctions; listIdx++) { - log_verbose("Junction#%d %d,%d,%d Direction %d", listIdx + 1, bestJunctionList[listIdx].x, - bestJunctionList[listIdx].y, bestJunctionList[listIdx].z, bestDirectionList[listIdx]); + log_verbose( + "Junction#%d %d,%d,%d Direction %d", + listIdx + 1, + bestJunctionList[listIdx].x, + bestJunctionList[listIdx].y, + bestJunctionList[listIdx].z, + bestDirectionList[listIdx]); } log_verbose("End at %d,%d,%d", bestXYZ.x, bestXYZ.y, bestXYZ.z); } @@ -1481,8 +1564,8 @@ int32_t peep_pathfind_choose_direction(TileCoordsXYZ loc, rct_peep * peep) { for (int32_t i = 0; i < 4; ++i) { - if (peep->pathfind_history[i].x == loc.x && peep->pathfind_history[i].y == loc.y && - peep->pathfind_history[i].z == loc.z) + if (peep->pathfind_history[i].x == loc.x && peep->pathfind_history[i].y == loc.y + && peep->pathfind_history[i].z == loc.z) { /* Peep remembers this junction, so remove the * chosen_edge from those left to try. */ @@ -1494,8 +1577,13 @@ int32_t peep_pathfind_choose_direction(TileCoordsXYZ loc, rct_peep * peep) if (gPathFindDebug) { log_verbose( - "Updating existing pf_history (in index: %d) for %d,%d,%d without entry edge %d & exit edge %d.", i, - loc.x, loc.y, loc.z, peep->direction ^ 2, chosen_edge); + "Updating existing pf_history (in index: %d) for %d,%d,%d without entry edge %d & exit edge %d.", + i, + loc.x, + loc.y, + loc.z, + peep->direction ^ 2, + chosen_edge); } #endif // defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 return chosen_edge; @@ -1506,9 +1594,9 @@ int32_t peep_pathfind_choose_direction(TileCoordsXYZ loc, rct_peep * peep) * and remember this junction. */ int32_t i = peep->pathfind_goal.direction++; peep->pathfind_goal.direction &= 3; - peep->pathfind_history[i].x = (uint8_t)loc.x; - peep->pathfind_history[i].y = (uint8_t)loc.y; - peep->pathfind_history[i].z = loc.z; + peep->pathfind_history[i].x = (uint8_t)loc.x; + peep->pathfind_history[i].y = (uint8_t)loc.y; + peep->pathfind_history[i].z = loc.z; peep->pathfind_history[i].direction = permitted_edges; /* Remove the chosen_edge from those left to try. */ peep->pathfind_history[i].direction &= ~(1 << chosen_edge); @@ -1518,8 +1606,14 @@ int32_t peep_pathfind_choose_direction(TileCoordsXYZ loc, rct_peep * peep) #if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 if (gPathFindDebug) { - log_verbose("Storing new pf_history (in index: %d) for %d,%d,%d without entry edge %d & exit edge %d.", i, loc.x, - loc.y, loc.z, peep->direction ^ 2, chosen_edge); + log_verbose( + "Storing new pf_history (in index: %d) for %d,%d,%d without entry edge %d & exit edge %d.", + i, + loc.x, + loc.y, + loc.z, + peep->direction ^ 2, + chosen_edge); } #endif // defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 } @@ -1535,8 +1629,8 @@ int32_t peep_pathfind_choose_direction(TileCoordsXYZ loc, rct_peep * peep) */ static uint8_t get_nearest_park_entrance_index(uint16_t x, uint16_t y) { - uint8_t chosenEntrance = 0xFF; - uint16_t nearestDist = 0xFFFF; + uint8_t chosenEntrance = 0xFF; + uint16_t nearestDist = 0xFFFF; for (uint8_t i = 0; i < MAX_PARK_ENTRANCES; i++) { if (gParkEntrances[i].x == LOCATION_NULL) @@ -1547,7 +1641,7 @@ static uint8_t get_nearest_park_entrance_index(uint16_t x, uint16_t y) if (dist >= nearestDist) continue; - nearestDist = dist; + nearestDist = dist; chosenEntrance = i; } return chosenEntrance; @@ -1570,9 +1664,9 @@ static int32_t guest_path_find_entering_park(rct_peep* peep, [[maybe_unused]] rc int16_t y = gParkEntrances[chosenEntrance].y; int16_t z = gParkEntrances[chosenEntrance].z; - gPeepPathFindGoalPosition = { x / 32, y / 32, z >> 3 }; + gPeepPathFindGoalPosition = { x / 32, y / 32, z >> 3 }; gPeepPathFindIgnoreForeignQueues = true; - gPeepPathFindQueueRideIndex = 255; + gPeepPathFindQueueRideIndex = 255; int32_t chosenDirection = peep_pathfind_choose_direction({ peep->next_x / 32, peep->next_y / 32, peep->next_z }, peep); @@ -1590,7 +1684,7 @@ static int32_t guest_path_find_entering_park(rct_peep* peep, [[maybe_unused]] rc */ static uint8_t get_nearest_peep_spawn_index(uint16_t x, uint16_t y) { - uint8_t chosenSpawn = 0xFF; + uint8_t chosenSpawn = 0xFF; uint16_t nearestDist = 0xFFFF; for (uint8_t i = 0; i < MAX_PEEP_SPAWNS; ++i) { @@ -1621,12 +1715,12 @@ static int32_t guest_path_find_leaving_park(rct_peep* peep, [[maybe_unused]] rct if (chosenSpawn == 0xFF) return guest_path_find_aimless(peep, edges); - PeepSpawn * peepSpawn = &gPeepSpawns[chosenSpawn]; + PeepSpawn* peepSpawn = &gPeepSpawns[chosenSpawn]; - int16_t x = peepSpawn->x & 0xFFE0; - int16_t y = peepSpawn->y & 0xFFE0; - uint8_t z = peepSpawn->z / 8; - uint8_t direction = peepSpawn->direction; + int16_t x = peepSpawn->x & 0xFFE0; + int16_t y = peepSpawn->y & 0xFFE0; + uint8_t z = peepSpawn->z / 8; + uint8_t direction = peepSpawn->direction; gPeepPathFindGoalPosition = { x / 32, y / 32, z }; if (x == peep->next_x && y == peep->next_y) @@ -1635,8 +1729,8 @@ static int32_t guest_path_find_leaving_park(rct_peep* peep, [[maybe_unused]] rct } gPeepPathFindIgnoreForeignQueues = true; - gPeepPathFindQueueRideIndex = 255; - direction = peep_pathfind_choose_direction({ peep->next_x / 32, peep->next_y / 32, peep->next_z }, peep); + gPeepPathFindQueueRideIndex = 255; + direction = peep_pathfind_choose_direction({ peep->next_x / 32, peep->next_y / 32, peep->next_z }, peep); if (direction == 0xFF) return guest_path_find_aimless(peep, edges); else @@ -1652,27 +1746,28 @@ static int32_t guest_path_find_park_entrance(rct_peep* peep, [[maybe_unused]] rc uint8_t entranceNum; // Resolves already-corrupt guests (e.g. loaded from save) - if (peep->peep_flags & PEEP_FLAGS_PARK_ENTRANCE_CHOSEN && - (peep->current_ride >= 4 || gParkEntrances[peep->current_ride].x == LOCATION_NULL)) + if (peep->peep_flags & PEEP_FLAGS_PARK_ENTRANCE_CHOSEN + && (peep->current_ride >= 4 || gParkEntrances[peep->current_ride].x == LOCATION_NULL)) { peep->peep_flags &= ~(PEEP_FLAGS_PARK_ENTRANCE_CHOSEN); } if (!(peep->peep_flags & PEEP_FLAGS_PARK_ENTRANCE_CHOSEN)) { - uint8_t chosenEntrance = 0xFF; - uint16_t nearestDist = 0xFFFF; + uint8_t chosenEntrance = 0xFF; + uint16_t nearestDist = 0xFFFF; for (entranceNum = 0; entranceNum < MAX_PARK_ENTRANCES; ++entranceNum) { if (gParkEntrances[entranceNum].x == LOCATION_NULL) continue; - uint16_t dist = abs(gParkEntrances[entranceNum].x - peep->next_x) + abs(gParkEntrances[entranceNum].y - peep->next_y); + uint16_t dist + = abs(gParkEntrances[entranceNum].x - peep->next_x) + abs(gParkEntrances[entranceNum].y - peep->next_y); if (dist >= nearestDist) continue; - nearestDist = dist; + nearestDist = dist; chosenEntrance = entranceNum; } @@ -1684,13 +1779,13 @@ static int32_t guest_path_find_park_entrance(rct_peep* peep, [[maybe_unused]] rc } entranceNum = peep->current_ride; - int16_t x = gParkEntrances[entranceNum].x; - int16_t y = gParkEntrances[entranceNum].y; - int16_t z = gParkEntrances[entranceNum].z; + int16_t x = gParkEntrances[entranceNum].x; + int16_t y = gParkEntrances[entranceNum].y; + int16_t z = gParkEntrances[entranceNum].z; - gPeepPathFindGoalPosition = { x / 32, y / 32, z >> 3 }; + gPeepPathFindGoalPosition = { x / 32, y / 32, z >> 3 }; gPeepPathFindIgnoreForeignQueues = true; - gPeepPathFindQueueRideIndex = 255; + gPeepPathFindQueueRideIndex = 255; #if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 pathfind_logging_enable(peep); @@ -1716,10 +1811,10 @@ static int32_t guest_path_find_park_entrance(rct_peep* peep, [[maybe_unused]] rc * In case where the map element at (x, y) is invalid or there is no entrance * or queue leading to it the function will not update its arguments. */ -static void get_ride_queue_end(TileCoordsXYZ &loc) +static void get_ride_queue_end(TileCoordsXYZ& loc) { - TileCoordsXY queueEnd = { 0, 0 }; - rct_tile_element * tileElement = map_get_first_element_at(loc.x, loc.y); + TileCoordsXY queueEnd = { 0, 0 }; + rct_tile_element* tileElement = map_get_first_element_at(loc.x, loc.y); if (tileElement == nullptr) { @@ -1742,9 +1837,9 @@ static void get_ride_queue_end(TileCoordsXYZ &loc) if (!found) return; - uint8_t direction = tile_element_get_direction_with_offset(tileElement, 2); - rct_tile_element * lastPathElement = nullptr; - rct_tile_element * firstPathElement = nullptr; + uint8_t direction = tile_element_get_direction_with_offset(tileElement, 2); + rct_tile_element* lastPathElement = nullptr; + rct_tile_element* firstPathElement = nullptr; int16_t baseZ = tileElement->base_height; TileCoordsXY nextTile = { loc.x, loc.y }; @@ -1755,7 +1850,7 @@ static void get_ride_queue_end(TileCoordsXYZ &loc) { lastPathElement = tileElement; // Update the current queue end - queueEnd = nextTile; + queueEnd = nextTile; // queueEnd.direction = direction; if (footpath_element_is_sloped(tileElement)) { @@ -1768,7 +1863,7 @@ static void get_ride_queue_end(TileCoordsXYZ &loc) nextTile += TileDirectionDelta[direction]; tileElement = map_get_first_element_at(nextTile.x, nextTile.y); - found = false; + found = false; do { if (tileElement == firstPathElement) @@ -1853,9 +1948,9 @@ static void get_ride_queue_end(TileCoordsXYZ &loc) * * rct2: 0x00694C35 */ -int32_t guest_path_finding(rct_peep * peep) +int32_t guest_path_finding(rct_peep* peep) { - //int16_t x, y, z; + // int16_t x, y, z; #if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 pathfind_logging_enable(peep); @@ -1870,16 +1965,16 @@ int32_t guest_path_finding(rct_peep * peep) return guest_surface_path_finding(peep); } - TileCoordsXYZ loc = { peep->next_x / 32, peep->next_y / 32, peep->next_z}; + TileCoordsXYZ loc = { peep->next_x / 32, peep->next_y / 32, peep->next_z }; - rct_tile_element * tileElement = map_get_path_element_at(loc.x, loc.y, loc.z); + rct_tile_element* tileElement = map_get_path_element_at(loc.x, loc.y, loc.z); if (tileElement == nullptr) { return 1; } _peepPathFindIsStaff = false; - uint8_t edges = path_get_permitted_edges(tileElement); + uint8_t edges = path_get_permitted_edges(tileElement); if (edges == 0) { @@ -1899,8 +1994,7 @@ int32_t guest_path_finding(rct_peep * peep) /* If there is a wide path in that direction, remove that edge and try another */ - if (footpath_element_next_in_direction(loc, tileElement, chosenDirection) == - PATH_SEARCH_WIDE) + if (footpath_element_next_in_direction(loc, tileElement, chosenDirection) == PATH_SEARCH_WIDE) { adjustedEdges &= ~(1 << chosenDirection); } @@ -1932,8 +2026,10 @@ int32_t guest_path_finding(rct_peep * peep) #if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 if (gPathFindDebug) { - log_info("Completed guest_path_finding for %s - taking only direction available: %d.", gPathFindDebugPeepName, - direction); + log_info( + "Completed guest_path_finding for %s - taking only direction available: %d.", + gPathFindDebugPeepName, + direction); } pathfind_logging_disable(); #endif // defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 @@ -1955,12 +2051,12 @@ int32_t guest_path_finding(rct_peep * peep) #endif // defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 switch (peep->state) { - case PEEP_STATE_ENTERING_PARK: - return guest_path_find_entering_park(peep, tileElement, edges); - case PEEP_STATE_LEAVING_PARK: - return guest_path_find_leaving_park(peep, tileElement, edges); - default: - return guest_path_find_aimless(peep, edges); + case PEEP_STATE_ENTERING_PARK: + return guest_path_find_entering_park(peep, tileElement, edges); + case PEEP_STATE_LEAVING_PARK: + return guest_path_find_leaving_park(peep, tileElement, edges); + default: + return guest_path_find_aimless(peep, edges); } } @@ -1980,15 +2076,14 @@ int32_t guest_path_finding(rct_peep * peep) continue; uint8_t rideIndex, pathSearchResult; - pathSearchResult = footpath_element_destination_in_direction(loc, tileElement, - chosenDirection, &rideIndex); + pathSearchResult = footpath_element_destination_in_direction(loc, tileElement, chosenDirection, &rideIndex); switch (pathSearchResult) { - case PATH_SEARCH_DEAD_END: - case PATH_SEARCH_RIDE_EXIT: - case PATH_SEARCH_WIDE: - adjustedEdges &= ~(1 << chosenDirection); - break; + case PATH_SEARCH_DEAD_END: + case PATH_SEARCH_RIDE_EXIT: + case PATH_SEARCH_WIDE: + adjustedEdges &= ~(1 << chosenDirection); + break; } } if (adjustedEdges != 0) @@ -2040,16 +2135,16 @@ int32_t guest_path_finding(rct_peep * peep) } // Peep is heading for a ride. - uint8_t rideIndex = peep->guest_heading_to_ride_id; - Ride * ride = get_ride(rideIndex); + uint8_t rideIndex = peep->guest_heading_to_ride_id; + Ride* ride = get_ride(rideIndex); if (ride->status != RIDE_STATUS_OPEN) { #if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 if (gPathFindDebug) { - log_info("Completed guest_path_finding for %s - peep is heading to closed ride == aimless.", - gPathFindDebugPeepName); + log_info( + "Completed guest_path_finding for %s - peep is heading to closed ride == aimless.", gPathFindDebugPeepName); } pathfind_logging_disable(); #endif // defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 @@ -2062,11 +2157,11 @@ int32_t guest_path_finding(rct_peep * peep) /* Find the ride's closest entrance station to the peep. * At the same time, count how many entrance stations there are and * which stations are entrance stations. */ - uint16_t closestDist = 0xFFFF; - uint8_t closestStationNum = 0; + uint16_t closestDist = 0xFFFF; + uint8_t closestStationNum = 0; int32_t numEntranceStations = 0; - uint8_t entranceStations = 0; + uint8_t entranceStations = 0; for (uint8_t stationNum = 0; stationNum < MAX_STATIONS; ++stationNum) { @@ -2081,11 +2176,11 @@ int32_t guest_path_finding(rct_peep * peep) int16_t stationX = (int16_t)(entranceLocation.x * 32); int16_t stationY = (int16_t)(entranceLocation.y * 32); - uint16_t dist = abs(stationX - peep->next_x) + abs(stationY - peep->next_y); + uint16_t dist = abs(stationX - peep->next_x) + abs(stationY - peep->next_y); if (dist < closestDist) { - closestDist = dist; + closestDist = dist; closestStationNum = stationNum; continue; } @@ -2135,7 +2230,7 @@ int32_t guest_path_finding(rct_peep * peep) get_ride_queue_end(loc); - gPeepPathFindGoalPosition = loc; + gPeepPathFindGoalPosition = loc; gPeepPathFindIgnoreForeignQueues = true; direction = peep_pathfind_choose_direction({ peep->next_x / 32, peep->next_y / 32, peep->next_z }, peep); diff --git a/src/openrct2/peep/Peep.cpp b/src/openrct2/peep/Peep.cpp index 4ae3c533cd..12776c92c2 100644 --- a/src/openrct2/peep/Peep.cpp +++ b/src/openrct2/peep/Peep.cpp @@ -7,30 +7,30 @@ * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ -#include +#include "Peep.h" +#include "../Cheats.h" #include "../Context.h" +#include "../Game.h" +#include "../Input.h" #include "../OpenRCT2.h" #include "../audio/AudioMixer.h" #include "../audio/audio.h" -#include "../Cheats.h" #include "../config/Config.h" #include "../core/Guard.hpp" #include "../core/Math.hpp" #include "../core/Util.hpp" -#include "../Game.h" -#include "../Input.h" #include "../interface/Window.h" #include "../localisation/Localisation.h" #include "../management/Finance.h" #include "../management/Marketing.h" #include "../management/NewsItem.h" #include "../network/network.h" -#include "../ride/Station.h" -#include "../ride/Track.h" #include "../ride/Ride.h" #include "../ride/RideData.h" #include "../ride/ShopItem.h" +#include "../ride/Station.h" +#include "../ride/Track.h" #include "../scenario/Scenario.h" #include "../sprites.h" #include "../util/Util.h" @@ -38,50 +38,50 @@ #include "../world/Climate.h" #include "../world/Entrance.h" #include "../world/Footpath.h" -#include "../world/Map.h" #include "../world/LargeScenery.h" +#include "../world/Map.h" #include "../world/Park.h" #include "../world/Scenery.h" #include "../world/SmallScenery.h" #include "../world/Sprite.h" #include "../world/Surface.h" -#include "Peep.h" #include "Staff.h" +#include + #if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 bool gPathFindDebug = false; utf8 gPathFindDebugPeepName[256]; #endif // defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 -uint8_t gGuestChangeModifier; +uint8_t gGuestChangeModifier; uint16_t gNumGuestsInPark; uint16_t gNumGuestsInParkLastWeek; uint16_t gNumGuestsHeadingForPark; money16 gGuestInitialCash; -uint8_t gGuestInitialHappiness; -uint8_t gGuestInitialHunger; -uint8_t gGuestInitialThirst; +uint8_t gGuestInitialHappiness; +uint8_t gGuestInitialHunger; +uint8_t gGuestInitialThirst; uint32_t gNextGuestNumber; uint8_t gPeepWarningThrottle[16]; TileCoordsXYZ gPeepPathFindGoalPosition; -bool gPeepPathFindIgnoreForeignQueues; -uint8_t gPeepPathFindQueueRideIndex; +bool gPeepPathFindIgnoreForeignQueues; +uint8_t gPeepPathFindQueueRideIndex; // uint32_t gPeepPathFindAltStationNum; +static uint8_t _unk_F1AEF0; +static rct_tile_element* _peepRideEntranceExitElement; -static uint8_t _unk_F1AEF0; -static rct_tile_element * _peepRideEntranceExitElement; +static void* _crowdSoundChannel = nullptr; -static void * _crowdSoundChannel = nullptr; - -static void peep_128_tick_update(rct_peep * peep, int32_t index); -static void peep_easter_egg_peep_interactions(rct_peep * peep); -static void peep_give_real_name(rct_peep * peep); -static void peep_release_balloon(rct_peep * peep, int16_t spawn_height); +static void peep_128_tick_update(rct_peep* peep, int32_t index); +static void peep_easter_egg_peep_interactions(rct_peep* peep); +static void peep_give_real_name(rct_peep* peep); +static void peep_release_balloon(rct_peep* peep, int16_t spawn_height); // clang-format off static constexpr const char *gPeepEasterEggNames[] = { @@ -349,12 +349,12 @@ bool rct_sprite::IsPeep() return peep.sprite_identifier == SPRITE_IDENTIFIER_PEEP; } -rct_peep * rct_sprite::AsPeep() +rct_peep* rct_sprite::AsPeep() { - rct_peep * result = nullptr; + rct_peep* result = nullptr; if (IsPeep()) { - return (rct_peep *)this; + return (rct_peep*)this; } return result; } @@ -391,9 +391,9 @@ void rct_peep::SetNextFlags(uint8_t next_direction, bool is_sloped, bool is_surf next_flags |= is_surface ? PEEP_NEXT_FLAG_IS_SURFACE : 0; } -rct_peep * try_get_guest(uint16_t spriteIndex) +rct_peep* try_get_guest(uint16_t spriteIndex) { - rct_sprite * sprite = try_get_sprite(spriteIndex); + rct_sprite* sprite = try_get_sprite(spriteIndex); if (sprite == nullptr) return nullptr; if (sprite->unknown.sprite_identifier != SPRITE_IDENTIFIER_PEEP) @@ -405,12 +405,12 @@ rct_peep * try_get_guest(uint16_t spriteIndex) int32_t peep_get_staff_count() { - uint16_t spriteIndex; - rct_peep * peep; - int32_t count = 0; + uint16_t spriteIndex; + rct_peep* peep; + int32_t count = 0; - FOR_ALL_STAFF(spriteIndex, peep) - count++; + FOR_ALL_STAFF (spriteIndex, peep) + count++; return count; } @@ -421,18 +421,18 @@ int32_t peep_get_staff_count() */ void peep_update_all() { - int32_t i; - uint16_t spriteIndex; - rct_peep * peep; + int32_t i; + uint16_t spriteIndex; + rct_peep* peep; if (gScreenFlags & (SCREEN_FLAGS_SCENARIO_EDITOR | SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)) return; spriteIndex = gSpriteListHead[SPRITE_LIST_PEEP]; - i = 0; + i = 0; while (spriteIndex != SPRITE_INDEX_NULL) { - peep = &(get_sprite(spriteIndex)->peep); + peep = &(get_sprite(spriteIndex)->peep); spriteIndex = peep->next; if ((uint32_t)(i & 0x7F) != (gCurrentTicks & 0x7F)) @@ -457,7 +457,7 @@ void peep_update_all() * rct2: 0x0068F41A * Called every 128 ticks */ -static void peep_128_tick_update(rct_peep * peep, int32_t index) +static void peep_128_tick_update(rct_peep* peep, int32_t index) { if (peep->type == PEEP_TYPE_STAFF) { @@ -484,7 +484,7 @@ bool rct_peep::CheckForPath() return true; } - rct_tile_element * tile_element = map_get_first_element_at(next_x / 32, next_y / 32); + rct_tile_element* tile_element = map_get_first_element_at(next_x / 32, next_y / 32); uint8_t map_type = TILE_ELEMENT_TYPE_PATH; if (GetNextIsSurface()) @@ -523,8 +523,10 @@ uint8_t rct_peep::GetActionSpriteType() } else { - openrct2_assert(action >= Util::CountOf(PeepActionToSpriteTypeMap) && action < PEEP_ACTION_NONE_1, - "Invalid peep action %u", action); + openrct2_assert( + action >= Util::CountOf(PeepActionToSpriteTypeMap) && action < PEEP_ACTION_NONE_1, + "Invalid peep action %u", + action); return 0; } } @@ -547,10 +549,10 @@ void rct_peep::UpdateCurrentActionSpriteType() Invalidate(); action_sprite_type = newActionSpriteType; - const rct_sprite_bounds * spriteBounds = g_peep_animation_entries[sprite_type].sprite_bounds; - sprite_width = spriteBounds[action_sprite_type].sprite_width; - sprite_height_negative = spriteBounds[action_sprite_type].sprite_height_negative; - sprite_height_positive = spriteBounds[action_sprite_type].sprite_height_positive; + const rct_sprite_bounds* spriteBounds = g_peep_animation_entries[sprite_type].sprite_bounds; + sprite_width = spriteBounds[action_sprite_type].sprite_width; + sprite_height_negative = spriteBounds[action_sprite_type].sprite_height_negative; + sprite_height_positive = spriteBounds[action_sprite_type].sprite_height_positive; Invalidate(); } @@ -594,7 +596,7 @@ bool rct_peep::UpdateAction() * has not yet been reached. xy_distance is how close the * peep is to the target. */ -bool rct_peep::UpdateAction(int16_t * actionX, int16_t * actionY, int16_t * xy_distance) +bool rct_peep::UpdateAction(int16_t* actionX, int16_t* actionY, int16_t* xy_distance) { _unk_F1AEF0 = action_sprite_image_offset; if (action == PEEP_ACTION_NONE_1) @@ -634,11 +636,11 @@ bool rct_peep::UpdateAction(int16_t * actionX, int16_t * actionY, int16_t * xy_d } } sprite_direction = nextDirection; - *actionX = x + word_981D7C[nextDirection / 8].x; - *actionY = y + word_981D7C[nextDirection / 8].y; + *actionX = x + word_981D7C[nextDirection / 8].x; + *actionY = y + word_981D7C[nextDirection / 8].y; no_action_frame_num++; - const rct_peep_animation * peepAnimation = g_peep_animation_entries[sprite_type].sprite_animation; - const uint8_t * imageOffset = peepAnimation[action_sprite_type].frame_offsets; + const rct_peep_animation* peepAnimation = g_peep_animation_entries[sprite_type].sprite_animation; + const uint8_t* imageOffset = peepAnimation[action_sprite_type].frame_offsets; if (no_action_frame_num >= peepAnimation[action_sprite_type].num_frames) { no_action_frame_num = 0; @@ -647,14 +649,14 @@ bool rct_peep::UpdateAction(int16_t * actionX, int16_t * actionY, int16_t * xy_d return true; } - const rct_peep_animation * peepAnimation = g_peep_animation_entries[sprite_type].sprite_animation; + const rct_peep_animation* peepAnimation = g_peep_animation_entries[sprite_type].sprite_animation; action_frame++; // If last frame of action if (action_frame >= peepAnimation[action_sprite_type].num_frames) { action_sprite_image_offset = 0; - action = 0xFF; + action = 0xFF; UpdateCurrentActionSpriteType(); Invalidate(); *actionX = x; @@ -684,8 +686,7 @@ bool rct_peep::UpdateAction(int16_t * actionX, int16_t * actionY, int16_t * xy_d window_invalidate_flags |= PEEP_INVALIDATE_PEEP_2; // Create sick at location - litter_create(x, y, z, sprite_direction, - (sprite_index & 1) ? LITTER_TYPE_SICK_ALT : LITTER_TYPE_SICK); + litter_create(x, y, z, sprite_direction, (sprite_index & 1) ? LITTER_TYPE_SICK_ALT : LITTER_TYPE_SICK); int32_t sound_id = SOUND_COUGH_1 + (scenario_rand() & 3); audio_play_sound_at_location(sound_id, x, y, z); @@ -700,12 +701,11 @@ bool rct_peep::UpdateAction(int16_t * actionX, int16_t * actionY, int16_t * xy_d * rct2: 0x0069A409 * Decreases rider count if on/entering a ride. */ -void peep_decrement_num_riders(rct_peep * peep) +void peep_decrement_num_riders(rct_peep* peep) { if (peep->state == PEEP_STATE_ON_RIDE || peep->state == PEEP_STATE_ENTERING_RIDE) { - - Ride * ride = get_ride(peep->current_ride); + Ride* ride = get_ride(peep->current_ride); ride->num_riders = std::max(0, ride->num_riders - 1); ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_MAIN | RIDE_INVALIDATE_RIDE_LIST; } @@ -716,9 +716,9 @@ void peep_decrement_num_riders(rct_peep * peep) * Note also increase ride count if on/entering a ride. * rct2: 0x0069A42F */ -void peep_window_state_update(rct_peep * peep) +void peep_window_state_update(rct_peep* peep) { - rct_window * w = window_find_by_number(WC_PEEP, peep->sprite_index); + rct_window* w = window_find_by_number(WC_PEEP, peep->sprite_index); if (w != nullptr) window_event_invalidate_call(w); @@ -726,7 +726,7 @@ void peep_window_state_update(rct_peep * peep) { if (peep->state == PEEP_STATE_ON_RIDE || peep->state == PEEP_STATE_ENTERING_RIDE) { - Ride * ride = get_ride(peep->current_ride); + Ride* ride = get_ride(peep->current_ride); ride->num_riders++; ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_MAIN | RIDE_INVALIDATE_RIDE_LIST; } @@ -746,7 +746,7 @@ void rct_peep::Pickup() RemoveFromRide(); Invalidate(); - sprite_move(LOCATION_NULL, y, z, (rct_sprite *)this); + sprite_move(LOCATION_NULL, y, z, (rct_sprite*)this); SetState(PEEP_STATE_PICKED); sub_state = 0; } @@ -756,17 +756,17 @@ void rct_peep::PickupAbort(int32_t old_x) if (state != PEEP_STATE_PICKED) return; - sprite_move(old_x, y, z + 8, (rct_sprite *)this); + sprite_move(old_x, y, z + 8, (rct_sprite*)this); Invalidate(); if (x != (int16_t)LOCATION_NULL) { SetState(PEEP_STATE_FALLING); - action = 0xFF; - special_sprite = 0; + action = 0xFF; + special_sprite = 0; action_sprite_image_offset = 0; - action_sprite_type = 0; - path_check_optimisation = 0; + action_sprite_type = 0; + path_check_optimisation = 0; } gPickupPeepImage = UINT32_MAX; @@ -775,7 +775,7 @@ void rct_peep::PickupAbort(int32_t old_x) // Returns true when a peep can be dropped at the given location. When apply is set to true the peep gets dropped. bool rct_peep::Place(TileCoordsXYZ location, bool apply) { - rct_tile_element * tileElement = map_get_path_element_at(location.x, location.y, location.z); + rct_tile_element* tileElement = map_get_path_element_at(location.x, location.y, location.z); if (!tileElement) { @@ -813,20 +813,20 @@ bool rct_peep::Place(TileCoordsXYZ location, bool apply) if (apply) { - sprite_move(destination.x, destination.y, destination.z, (rct_sprite *)this); + sprite_move(destination.x, destination.y, destination.z, (rct_sprite*)this); Invalidate(); SetState(PEEP_STATE_FALLING); - action = 0xFF; - special_sprite = 0; + action = 0xFF; + special_sprite = 0; action_sprite_image_offset = 0; - action_sprite_type = 0; - path_check_optimisation = 0; + action_sprite_type = 0; + path_check_optimisation = 0; sprite_position_tween_reset(); if (type == PEEP_TYPE_GUEST) { action_sprite_type = 0xFF; - happiness_target = std::max(happiness_target - 10, 0); + happiness_target = std::max(happiness_target - 10, 0); UpdateCurrentActionSpriteType(); } @@ -844,7 +844,7 @@ bool peep_pickup_command(uint32_t peepnum, int32_t x, int32_t y, int32_t z, int3 return false; } - rct_peep * const peep = GET_PEEP(peepnum); + rct_peep* const peep = GET_PEEP(peepnum); if (!peep || peep->sprite_identifier != SPRITE_IDENTIFIER_PEEP) { return false; @@ -852,61 +852,61 @@ bool peep_pickup_command(uint32_t peepnum, int32_t x, int32_t y, int32_t z, int3 switch (action) { - case 0: // pickup - { - if (!peep_can_be_picked_up(peep)) + case 0: // pickup { - return false; - } - rct_peep * existing = network_get_pickup_peep(game_command_playerid); - if (existing) - { - // already picking up a peep - bool result = peep_pickup_command(existing->sprite_index, network_get_pickup_peep_old_x(game_command_playerid), 0, - 0, 1, apply); - if (existing == peep) + if (!peep_can_be_picked_up(peep)) { - return result; + return false; } - if (game_command_playerid == network_get_current_player_id()) + rct_peep* existing = network_get_pickup_peep(game_command_playerid); + if (existing) { - // prevent tool_cancel() - input_set_flag(INPUT_FLAG_TOOL_ACTIVE, false); - } - } - - if (apply) - { - network_set_pickup_peep(game_command_playerid, peep); - network_set_pickup_peep_old_x(game_command_playerid, peep->x); - peep->Pickup(); - } - } - break; - case 1: // cancel - if (apply) - { - // TODO: Verify if this is really needed or that we can use `peep` instead - rct_peep * const pickedUpPeep = network_get_pickup_peep(game_command_playerid); - if (pickedUpPeep) - { - pickedUpPeep->PickupAbort(x); + // already picking up a peep + bool result = peep_pickup_command( + existing->sprite_index, network_get_pickup_peep_old_x(game_command_playerid), 0, 0, 1, apply); + if (existing == peep) + { + return result; + } + if (game_command_playerid == network_get_current_player_id()) + { + // prevent tool_cancel() + input_set_flag(INPUT_FLAG_TOOL_ACTIVE, false); + } } - network_set_pickup_peep(game_command_playerid, nullptr); + if (apply) + { + network_set_pickup_peep(game_command_playerid, peep); + network_set_pickup_peep_old_x(game_command_playerid, peep->x); + peep->Pickup(); + } } break; - case 2: // place - if (network_get_pickup_peep(game_command_playerid) != peep) - { - return false; - } + case 1: // cancel + if (apply) + { + // TODO: Verify if this is really needed or that we can use `peep` instead + rct_peep* const pickedUpPeep = network_get_pickup_peep(game_command_playerid); + if (pickedUpPeep) + { + pickedUpPeep->PickupAbort(x); + } - if (!peep->Place({ x / 32, y / 32, z }, apply)) - { - return false; - } - break; + network_set_pickup_peep(game_command_playerid, nullptr); + } + break; + case 2: // place + if (network_get_pickup_peep(game_command_playerid) != peep) + { + return false; + } + + if (!peep->Place({ x / 32, y / 32, z }, apply)) + { + return false; + } + break; } return true; } @@ -915,10 +915,10 @@ void game_command_pickup_guest( int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, [[maybe_unused]] int32_t* esi, int32_t* edi, int32_t* ebp) { int32_t peepnum = *eax; - int32_t x = *edi; - int32_t y = *ebp; - int32_t z = *edx; - int32_t action = *ecx; + int32_t x = *edi; + int32_t y = *ebp; + int32_t z = *edx; + int32_t action = *ecx; if (peep_pickup_command(peepnum, x, y, z, action, *ebx & GAME_COMMAND_FLAG_APPLY)) { *ebx = 0; @@ -933,7 +933,7 @@ void game_command_pickup_guest( * * rct2: 0x0069A535 */ -void peep_sprite_remove(rct_peep * peep) +void peep_sprite_remove(rct_peep* peep) { peep->RemoveFromRide(); peep->Invalidate(); @@ -953,13 +953,13 @@ void peep_sprite_remove(rct_peep * peep) window_invalidate_by_class(WC_STAFF_LIST); gStaffModes[peep->staff_id] = 0; - peep->type = 0xFF; + peep->type = 0xFF; staff_update_greyed_patrol_areas(); peep->type = PEEP_TYPE_STAFF; news_item_disable_news(NEWS_ITEM_PEEP, peep->sprite_index); } - sprite_remove((rct_sprite *)peep); + sprite_remove((rct_sprite*)peep); } /** @@ -1011,9 +1011,9 @@ void rct_peep::UpdateFalling() } // If not drowning then falling. Note: peeps 'fall' after leaving a ride/enter the park. - rct_tile_element * tile_element = map_get_first_element_at(x / 32, y / 32); - rct_tile_element * saved_map = nullptr; - int32_t saved_height = 0; + rct_tile_element* tile_element = map_get_first_element_at(x / 32, y / 32); + rct_tile_element* saved_map = nullptr; + int32_t saved_height = 0; if (tile_element != nullptr) { @@ -1022,14 +1022,14 @@ void rct_peep::UpdateFalling() // If a path check if we are on it if (tile_element->GetType() == TILE_ELEMENT_TYPE_PATH) { - int32_t height = map_height_from_slope(x, y, tile_element->properties.surface.slope) + - tile_element->base_height * 8; + int32_t height + = map_height_from_slope(x, y, tile_element->properties.surface.slope) + tile_element->base_height * 8; if (height < z - 1 || height > z + 4) continue; saved_height = height; - saved_map = tile_element; + saved_map = tile_element; break; } // If a surface get the height and see if we are on it else if (tile_element->GetType() == TILE_ELEMENT_TYPE_SURFACE) @@ -1049,8 +1049,8 @@ void rct_peep::UpdateFalling() peep_insert_new_thought(this, PEEP_THOUGHT_TYPE_DROWNING, PEEP_THOUGHT_ITEM_NONE); - action = PEEP_ACTION_DROWNING; - action_frame = 0; + action = PEEP_ACTION_DROWNING; + action_frame = 0; action_sprite_image_offset = 0; UpdateCurrentActionSpriteType(); @@ -1063,7 +1063,7 @@ void rct_peep::UpdateFalling() if (map_height < z || map_height - 4 > z) continue; saved_height = map_height; - saved_map = tile_element; + saved_map = tile_element; } // If not a path or surface go see next element else continue; @@ -1122,10 +1122,10 @@ void rct_peep::Update1() SetState(PEEP_STATE_PATROLLING); } - destination_x = x; - destination_y = y; + destination_x = x; + destination_y = y; destination_tolerance = 10; - direction = sprite_direction >> 3; + direction = sprite_direction >> 3; } void rct_peep::SetState(uint8_t new_state) @@ -1151,13 +1151,13 @@ void rct_peep::UpdatePicked() } /* From peep_update */ -static void peep_update_thoughts(rct_peep * peep) +static void peep_update_thoughts(rct_peep* peep) { // Thoughts must always have a gap of at least // 220 ticks in age between them. In order to // allow this when a thought is new it enters // a holding zone. Before it becomes fresh. - int32_t add_fresh = 1; + int32_t add_fresh = 1; int32_t fresh_thought = -1; for (int32_t i = 0; i < PEEP_MAX_THOUGHTS; i++) { @@ -1189,8 +1189,8 @@ static void peep_update_thoughts(rct_peep * peep) // Clear top thought, push others up if (i < PEEP_MAX_THOUGHTS - 2) { - memmove(&peep->thoughts[i], &peep->thoughts[i + 1], - sizeof(rct_peep_thought) * (PEEP_MAX_THOUGHTS - i - 1)); + memmove( + &peep->thoughts[i], &peep->thoughts[i + 1], sizeof(rct_peep_thought) * (PEEP_MAX_THOUGHTS - i - 1)); } peep->thoughts[PEEP_MAX_THOUGHTS - 1].type = PEEP_THOUGHT_TYPE_NONE; } @@ -1240,7 +1240,7 @@ void rct_peep::Update() } uint32_t carryCheck = step_progress + stepsToTake; - step_progress = carryCheck; + step_progress = carryCheck; if (carryCheck <= 255) { peep_easter_egg_peep_interactions(this); @@ -1250,82 +1250,82 @@ void rct_peep::Update() // loc_68FD2F switch (state) { - case PEEP_STATE_FALLING: - UpdateFalling(); - break; - case PEEP_STATE_1: - Update1(); - break; - case PEEP_STATE_QUEUING_FRONT: - UpdateRide(); - break; - case PEEP_STATE_ON_RIDE: - // No action - break; - case PEEP_STATE_LEAVING_RIDE: - UpdateRide(); - break; - case PEEP_STATE_WALKING: - UpdateWalking(); - break; - case PEEP_STATE_QUEUING: - UpdateQueuing(); - break; - case PEEP_STATE_ENTERING_RIDE: - UpdateRide(); - break; - case PEEP_STATE_SITTING: - UpdateSitting(); - break; - case PEEP_STATE_PICKED: - UpdatePicked(); - break; - case PEEP_STATE_PATROLLING: - UpdatePatrolling(); - break; - case PEEP_STATE_MOWING: - UpdateMowing(); - break; - case PEEP_STATE_SWEEPING: - UpdateSweeping(); - break; - case PEEP_STATE_ENTERING_PARK: - UpdateEnteringPark(); - break; - case PEEP_STATE_LEAVING_PARK: - UpdateLeavingPark(); - break; - case PEEP_STATE_ANSWERING: - UpdateAnswering(); - break; - case PEEP_STATE_FIXING: - UpdateFixing(stepsToTake); - break; - case PEEP_STATE_BUYING: - UpdateBuying(); - break; - case PEEP_STATE_WATCHING: - UpdateWatching(); - break; - case PEEP_STATE_EMPTYING_BIN: - UpdateEmptyingBin(); - break; - case PEEP_STATE_USING_BIN: - UpdateUsingBin(); - break; - case PEEP_STATE_WATERING: - UpdateWatering(); - break; - case PEEP_STATE_HEADING_TO_INSPECTION: - UpdateHeadingToInspect(); - break; - case PEEP_STATE_INSPECTING: - UpdateFixing(stepsToTake); - break; - // There shouldn't be any more - default: - assert(0); - break; + case PEEP_STATE_FALLING: + UpdateFalling(); + break; + case PEEP_STATE_1: + Update1(); + break; + case PEEP_STATE_QUEUING_FRONT: + UpdateRide(); + break; + case PEEP_STATE_ON_RIDE: + // No action + break; + case PEEP_STATE_LEAVING_RIDE: + UpdateRide(); + break; + case PEEP_STATE_WALKING: + UpdateWalking(); + break; + case PEEP_STATE_QUEUING: + UpdateQueuing(); + break; + case PEEP_STATE_ENTERING_RIDE: + UpdateRide(); + break; + case PEEP_STATE_SITTING: + UpdateSitting(); + break; + case PEEP_STATE_PICKED: + UpdatePicked(); + break; + case PEEP_STATE_PATROLLING: + UpdatePatrolling(); + break; + case PEEP_STATE_MOWING: + UpdateMowing(); + break; + case PEEP_STATE_SWEEPING: + UpdateSweeping(); + break; + case PEEP_STATE_ENTERING_PARK: + UpdateEnteringPark(); + break; + case PEEP_STATE_LEAVING_PARK: + UpdateLeavingPark(); + break; + case PEEP_STATE_ANSWERING: + UpdateAnswering(); + break; + case PEEP_STATE_FIXING: + UpdateFixing(stepsToTake); + break; + case PEEP_STATE_BUYING: + UpdateBuying(); + break; + case PEEP_STATE_WATCHING: + UpdateWatching(); + break; + case PEEP_STATE_EMPTYING_BIN: + UpdateEmptyingBin(); + break; + case PEEP_STATE_USING_BIN: + UpdateUsingBin(); + break; + case PEEP_STATE_WATERING: + UpdateWatering(); + break; + case PEEP_STATE_HEADING_TO_INSPECTION: + UpdateHeadingToInspect(); + break; + case PEEP_STATE_INSPECTING: + UpdateFixing(stepsToTake); + break; + // There shouldn't be any more + default: + assert(0); + break; } } } @@ -1336,74 +1336,74 @@ void rct_peep::Update() */ void peep_problem_warnings_update() { - rct_peep * peep; - Ride * ride; - uint16_t spriteIndex; - uint16_t guests_in_park = gNumGuestsInPark; - int32_t hunger_counter = 0, lost_counter = 0, noexit_counter = 0, thirst_counter = 0, litter_counter = 0, - disgust_counter = 0, bathroom_counter = 0, vandalism_counter = 0; - uint8_t * warning_throttle = gPeepWarningThrottle; + rct_peep* peep; + Ride* ride; + uint16_t spriteIndex; + uint16_t guests_in_park = gNumGuestsInPark; + int32_t hunger_counter = 0, lost_counter = 0, noexit_counter = 0, thirst_counter = 0, litter_counter = 0, + disgust_counter = 0, bathroom_counter = 0, vandalism_counter = 0; + uint8_t* warning_throttle = gPeepWarningThrottle; gRideCount = ride_get_count(); // refactor this to somewhere else - FOR_ALL_GUESTS(spriteIndex, peep) + FOR_ALL_GUESTS (spriteIndex, peep) { if (peep->outside_of_park != 0 || peep->thoughts[0].freshness > 5) continue; switch (peep->thoughts[0].type) { - case PEEP_THOUGHT_TYPE_LOST: // 0x10 - lost_counter++; - break; - - case PEEP_THOUGHT_TYPE_HUNGRY: // 0x14 - if (peep->guest_heading_to_ride_id == 0xFF) - { - hunger_counter++; + case PEEP_THOUGHT_TYPE_LOST: // 0x10 + lost_counter++; break; - } - ride = get_ride(peep->guest_heading_to_ride_id); - if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_FLAT_RIDE)) - hunger_counter++; - break; - case PEEP_THOUGHT_TYPE_THIRSTY: - if (peep->guest_heading_to_ride_id == 0xFF) - { - thirst_counter++; + case PEEP_THOUGHT_TYPE_HUNGRY: // 0x14 + if (peep->guest_heading_to_ride_id == 0xFF) + { + hunger_counter++; + break; + } + ride = get_ride(peep->guest_heading_to_ride_id); + if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_FLAT_RIDE)) + hunger_counter++; break; - } - ride = get_ride(peep->guest_heading_to_ride_id); - if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_SELLS_DRINKS)) - thirst_counter++; - break; - case PEEP_THOUGHT_TYPE_BATHROOM: - if (peep->guest_heading_to_ride_id == 0xFF) - { - bathroom_counter++; + case PEEP_THOUGHT_TYPE_THIRSTY: + if (peep->guest_heading_to_ride_id == 0xFF) + { + thirst_counter++; + break; + } + ride = get_ride(peep->guest_heading_to_ride_id); + if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_SELLS_DRINKS)) + thirst_counter++; break; - } - ride = get_ride(peep->guest_heading_to_ride_id); - if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_IS_BATHROOM)) - bathroom_counter++; - break; - case PEEP_THOUGHT_TYPE_BAD_LITTER: // 0x1a - litter_counter++; - break; - case PEEP_THOUGHT_TYPE_CANT_FIND_EXIT: // 0x1b - noexit_counter++; - break; - case PEEP_THOUGHT_TYPE_PATH_DISGUSTING: // 0x1f - disgust_counter++; - break; - case PEEP_THOUGHT_TYPE_VANDALISM: // 0x21 - vandalism_counter++; - break; - default: - break; + case PEEP_THOUGHT_TYPE_BATHROOM: + if (peep->guest_heading_to_ride_id == 0xFF) + { + bathroom_counter++; + break; + } + ride = get_ride(peep->guest_heading_to_ride_id); + if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_IS_BATHROOM)) + bathroom_counter++; + break; + + case PEEP_THOUGHT_TYPE_BAD_LITTER: // 0x1a + litter_counter++; + break; + case PEEP_THOUGHT_TYPE_CANT_FIND_EXIT: // 0x1b + noexit_counter++; + break; + case PEEP_THOUGHT_TYPE_PATH_DISGUSTING: // 0x1f + disgust_counter++; + break; + case PEEP_THOUGHT_TYPE_VANDALISM: // 0x21 + vandalism_counter++; + break; + default: + break; } } // could maybe be packed into a loop, would lose a lot of clarity though @@ -1508,10 +1508,10 @@ void peep_stop_crowd_noise() */ void peep_update_crowd_noise() { - rct_viewport * viewport; - uint16_t spriteIndex; - rct_peep * peep; - int32_t visiblePeeps; + rct_viewport* viewport; + uint16_t spriteIndex; + rct_peep* peep; + int32_t visiblePeeps; if (gGameSoundsOff) return; @@ -1529,7 +1529,7 @@ void peep_update_crowd_noise() // Count the number of peeps visible visiblePeeps = 0; - FOR_ALL_GUESTS(spriteIndex, peep) + FOR_ALL_GUESTS (spriteIndex, peep) { if (peep->sprite_left == LOCATION_NULL) continue; @@ -1592,10 +1592,10 @@ void peep_update_crowd_noise() */ void peep_applause() { - uint16_t spriteIndex; - rct_peep * peep; + uint16_t spriteIndex; + rct_peep* peep; - FOR_ALL_GUESTS(spriteIndex, peep) + FOR_ALL_GUESTS (spriteIndex, peep) { if (peep->outside_of_park != 0) continue; @@ -1606,8 +1606,8 @@ void peep_applause() // Clap if ((peep->state == PEEP_STATE_WALKING || peep->state == PEEP_STATE_QUEUING) && peep->action >= 254) { - peep->action = PEEP_ACTION_CLAP; - peep->action_frame = 0; + peep->action = PEEP_ACTION_CLAP; + peep->action_frame = 0; peep->action_sprite_image_offset = 0; peep->UpdateCurrentActionSpriteType(); peep->Invalidate(); @@ -1624,10 +1624,10 @@ void peep_applause() */ void peep_update_days_in_queue() { - uint16_t sprite_index; - rct_peep * peep; + uint16_t sprite_index; + rct_peep* peep; - FOR_ALL_GUESTS(sprite_index, peep) + FOR_ALL_GUESTS (sprite_index, peep) { if (peep->outside_of_park == 0 && peep->state == PEEP_STATE_QUEUING) { @@ -1719,44 +1719,44 @@ static constexpr const uint8_t tshirt_colours[] = { * * rct2: 0x0069A05D */ -rct_peep * peep_generate(int32_t x, int32_t y, int32_t z) +rct_peep* peep_generate(int32_t x, int32_t y, int32_t z) { if (gSpriteListCount[SPRITE_LIST_NULL] < 400) return nullptr; - rct_peep * peep = (rct_peep *)create_sprite(1); + rct_peep* peep = (rct_peep*)create_sprite(1); - move_sprite_to_list((rct_sprite *)peep, SPRITE_LIST_PEEP * 2); + move_sprite_to_list((rct_sprite*)peep, SPRITE_LIST_PEEP * 2); - peep->sprite_identifier = SPRITE_IDENTIFIER_PEEP; - peep->sprite_type = PEEP_SPRITE_TYPE_NORMAL; - peep->outside_of_park = 1; - peep->state = PEEP_STATE_FALLING; - peep->action = PEEP_ACTION_NONE_2; - peep->special_sprite = 0; + peep->sprite_identifier = SPRITE_IDENTIFIER_PEEP; + peep->sprite_type = PEEP_SPRITE_TYPE_NORMAL; + peep->outside_of_park = 1; + peep->state = PEEP_STATE_FALLING; + peep->action = PEEP_ACTION_NONE_2; + peep->special_sprite = 0; peep->action_sprite_image_offset = 0; - peep->no_action_frame_num = 0; - peep->action_sprite_type = 0; - peep->peep_flags = 0; - peep->favourite_ride = RIDE_ID_NULL; - peep->favourite_ride_rating = 0; + peep->no_action_frame_num = 0; + peep->action_sprite_type = 0; + peep->peep_flags = 0; + peep->favourite_ride = RIDE_ID_NULL; + peep->favourite_ride_rating = 0; - const rct_sprite_bounds * spriteBounds = g_peep_animation_entries[peep->sprite_type].sprite_bounds; - peep->sprite_width = spriteBounds[peep->action_sprite_type].sprite_width; - peep->sprite_height_negative = spriteBounds[peep->action_sprite_type].sprite_height_negative; - peep->sprite_height_positive = spriteBounds[peep->action_sprite_type].sprite_height_positive; + const rct_sprite_bounds* spriteBounds = g_peep_animation_entries[peep->sprite_type].sprite_bounds; + peep->sprite_width = spriteBounds[peep->action_sprite_type].sprite_width; + peep->sprite_height_negative = spriteBounds[peep->action_sprite_type].sprite_height_negative; + peep->sprite_height_positive = spriteBounds[peep->action_sprite_type].sprite_height_positive; peep->sprite_direction = 0; - sprite_move(x, y, z, (rct_sprite *)peep); + sprite_move(x, y, z, (rct_sprite*)peep); peep->Invalidate(); - peep->mass = (scenario_rand() & 0x1F) + 45; - peep->path_check_optimisation = 0; - peep->interaction_ride_index = 0xFF; - peep->type = PEEP_TYPE_GUEST; - peep->previous_ride = 0xFF; - peep->thoughts->type = PEEP_THOUGHT_TYPE_NONE; + peep->mass = (scenario_rand() & 0x1F) + 45; + peep->path_check_optimisation = 0; + peep->interaction_ride_index = 0xFF; + peep->type = PEEP_TYPE_GUEST; + peep->previous_ride = 0xFF; + peep->thoughts->type = PEEP_THOUGHT_TYPE_NONE; peep->window_invalidate_flags = 0; uint8_t intensityHighest = (scenario_rand() & 0x7) + 3; @@ -1807,10 +1807,10 @@ rct_peep * peep_generate(int32_t x, int32_t y, int32_t z) /* Initial value will vary by -15..16 */ int8_t happiness_delta = (scenario_rand() & 0x1F) - 15; /* Adjust by the delta, clamping at min=0 and max=255. */ - peep->happiness = Math::Clamp(0, peep->happiness + happiness_delta, PEEP_MAX_HAPPINESS); + peep->happiness = Math::Clamp(0, peep->happiness + happiness_delta, PEEP_MAX_HAPPINESS); peep->happiness_target = peep->happiness; - peep->nausea = 0; - peep->nausea_target = 0; + peep->nausea = 0; + peep->nausea_target = 0; /* Scenario editor limits initial guest hunger to between 37..253. * To be on the safe side, assume the value could have been hacked @@ -1831,12 +1831,12 @@ rct_peep * peep_generate(int32_t x, int32_t y, int32_t z) peep->thirst = Math::Clamp(0, peep->thirst + thirst_delta, 0xFF); peep->toilet = 0; - peep->time_to_consume = 0; + peep->time_to_consume = 0; memset(&peep->rides_been_on, 0, 32); peep->no_of_rides = 0; memset(&peep->ride_types_been_on, 0, 16); - peep->id = gNextGuestNumber++; + peep->id = gNextGuestNumber++; peep->name_string_idx = STR_GUEST_X; money32 cash = (scenario_rand() & 0x3) * 100 - 100 + gGuestInitialCash; @@ -1858,30 +1858,30 @@ rct_peep * peep_generate(int32_t x, int32_t y, int32_t z) cash = 0; } - peep->cash_in_pocket = cash; - peep->cash_spent = 0; - peep->time_in_park = -1; - peep->pathfind_goal.x = 0xFF; - peep->pathfind_goal.y = 0xFF; - peep->pathfind_goal.z = 0xFF; - peep->pathfind_goal.direction = 0xFF; - peep->item_standard_flags = 0; - peep->item_extra_flags = 0; + peep->cash_in_pocket = cash; + peep->cash_spent = 0; + peep->time_in_park = -1; + peep->pathfind_goal.x = 0xFF; + peep->pathfind_goal.y = 0xFF; + peep->pathfind_goal.z = 0xFF; + peep->pathfind_goal.direction = 0xFF; + peep->item_standard_flags = 0; + peep->item_extra_flags = 0; peep->guest_heading_to_ride_id = 0xFF; - peep->litter_count = 0; - peep->disgusting_count = 0; - peep->vandalism_seen = 0; - peep->paid_to_enter = 0; - peep->paid_on_rides = 0; - peep->paid_on_food = 0; - peep->paid_on_drink = 0; - peep->paid_on_souvenirs = 0; - peep->no_of_food = 0; - peep->no_of_drinks = 0; - peep->no_of_souvenirs = 0; + peep->litter_count = 0; + peep->disgusting_count = 0; + peep->vandalism_seen = 0; + peep->paid_to_enter = 0; + peep->paid_on_rides = 0; + peep->paid_on_food = 0; + peep->paid_on_drink = 0; + peep->paid_on_souvenirs = 0; + peep->no_of_food = 0; + peep->no_of_drinks = 0; + peep->no_of_souvenirs = 0; peep->surroundings_thought_timeout = 0; - peep->angriness = 0; - peep->time_lost = 0; + peep->angriness = 0; + peep->time_lost = 0; uint8_t tshirt_colour = static_cast(scenario_rand() % Util::CountOf(tshirt_colours)); peep->tshirt_colour = tshirt_colours[tshirt_colour]; @@ -1891,8 +1891,8 @@ rct_peep * peep_generate(int32_t x, int32_t y, int32_t z) /* Minimum energy is capped at 32 and maximum at 128, so this initialises * a peep with approx 34%-100% energy. (65 - 32) / (128 - 32) ≈ 34% */ - uint8_t energy = (scenario_rand() % 64) + 65; - peep->energy = energy; + uint8_t energy = (scenario_rand() % 64) + 65; + peep->energy = energy; peep->energy_target = energy; if (gParkFlags & PARK_FLAGS_SHOW_REAL_GUEST_NAMES) @@ -1913,135 +1913,135 @@ rct_peep * peep_generate(int32_t x, int32_t y, int32_t z) * argument_1 (ecx & ebx) * argument_2 (edx) */ -void get_arguments_from_action(rct_peep * peep, uint32_t * argument_1, uint32_t * argument_2) +void get_arguments_from_action(rct_peep* peep, uint32_t* argument_1, uint32_t* argument_2) { - Ride * ride; + Ride* ride; switch (peep->state) { - case PEEP_STATE_FALLING: - *argument_1 = peep->action == PEEP_ACTION_DROWNING ? STR_DROWNING : STR_WALKING; - *argument_2 = 0; - break; - case PEEP_STATE_1: - *argument_1 = STR_WALKING; - *argument_2 = 0; - break; - case PEEP_STATE_ON_RIDE: - case PEEP_STATE_LEAVING_RIDE: - case PEEP_STATE_ENTERING_RIDE: - *argument_1 = STR_ON_RIDE; - ride = get_ride(peep->current_ride); - if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_IN_RIDE)) - *argument_1 = STR_IN_RIDE; - *argument_1 |= ((uint32_t)ride->name << 16); - *argument_2 = ride->name_arguments; - break; - case PEEP_STATE_BUYING: - ride = get_ride(peep->current_ride); - *argument_1 = STR_AT_RIDE | ((uint32_t)ride->name << 16); - *argument_2 = ride->name_arguments; - break; - case PEEP_STATE_WALKING: - case PEEP_STATE_USING_BIN: - if (peep->guest_heading_to_ride_id != 0xFF) - { - ride = get_ride(peep->guest_heading_to_ride_id); - *argument_1 = STR_HEADING_FOR | ((uint32_t)ride->name << 16); - *argument_2 = ride->name_arguments; - } - else - { - *argument_1 = (peep->peep_flags & PEEP_FLAGS_LEAVING_PARK) ? STR_LEAVING_PARK : STR_WALKING; + case PEEP_STATE_FALLING: + *argument_1 = peep->action == PEEP_ACTION_DROWNING ? STR_DROWNING : STR_WALKING; *argument_2 = 0; - } - break; - case PEEP_STATE_QUEUING_FRONT: - case PEEP_STATE_QUEUING: - ride = get_ride(peep->current_ride); - *argument_1 = STR_QUEUING_FOR | ((uint32_t)ride->name << 16); - *argument_2 = ride->name_arguments; - break; - case PEEP_STATE_SITTING: - *argument_1 = STR_SITTING; - *argument_2 = 0; - break; - case PEEP_STATE_WATCHING: - if (peep->current_ride != 0xFF) - { - ride = get_ride(peep->current_ride); - *argument_1 = STR_WATCHING_RIDE | ((uint32_t)ride->name << 16); - *argument_2 = ride->name_arguments; - if (peep->current_seat & 0x1) - *argument_1 = STR_WATCHING_CONSTRUCTION_OF | ((uint32_t)ride->name << 16); - else - *argument_1 = STR_WATCHING_RIDE | ((uint32_t)ride->name << 16); - } - else - { - *argument_1 = (peep->current_seat & 0x1) ? STR_WATCHING_NEW_RIDE_BEING_CONSTRUCTED : STR_LOOKING_AT_SCENERY; - *argument_2 = 0; - } - break; - case PEEP_STATE_PICKED: - *argument_1 = STR_SELECT_LOCATION; - *argument_2 = 0; - break; - case PEEP_STATE_PATROLLING: - case PEEP_STATE_ENTERING_PARK: - case PEEP_STATE_LEAVING_PARK: - *argument_1 = STR_WALKING; - *argument_2 = 0; - break; - case PEEP_STATE_MOWING: - *argument_1 = STR_MOWING_GRASS; - *argument_2 = 0; - break; - case PEEP_STATE_SWEEPING: - *argument_1 = STR_SWEEPING_FOOTPATH; - *argument_2 = 0; - break; - case PEEP_STATE_WATERING: - *argument_1 = STR_WATERING_GARDENS; - *argument_2 = 0; - break; - case PEEP_STATE_EMPTYING_BIN: - *argument_1 = STR_EMPTYING_LITTER_BIN; - *argument_2 = 0; - break; - case PEEP_STATE_ANSWERING: - if (peep->sub_state == 0) - { + break; + case PEEP_STATE_1: *argument_1 = STR_WALKING; *argument_2 = 0; - } - else if (peep->sub_state == 1) - { - *argument_1 = STR_ANSWERING_RADIO_CALL; - *argument_2 = 0; - } - else - { - ride = get_ride(peep->current_ride); - *argument_1 = STR_RESPONDING_TO_RIDE_BREAKDOWN_CALL | ((uint32_t)ride->name << 16); + break; + case PEEP_STATE_ON_RIDE: + case PEEP_STATE_LEAVING_RIDE: + case PEEP_STATE_ENTERING_RIDE: + *argument_1 = STR_ON_RIDE; + ride = get_ride(peep->current_ride); + if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_IN_RIDE)) + *argument_1 = STR_IN_RIDE; + *argument_1 |= ((uint32_t)ride->name << 16); *argument_2 = ride->name_arguments; - } - break; - case PEEP_STATE_FIXING: - ride = get_ride(peep->current_ride); - *argument_1 = STR_FIXING_RIDE | ((uint32_t)ride->name << 16); - *argument_2 = ride->name_arguments; - break; - case PEEP_STATE_HEADING_TO_INSPECTION: - ride = get_ride(peep->current_ride); - *argument_1 = STR_HEADING_TO_RIDE_FOR_INSPECTION | ((uint32_t)ride->name << 16); - *argument_2 = ride->name_arguments; - break; - case PEEP_STATE_INSPECTING: - ride = get_ride(peep->current_ride); - *argument_1 = STR_INSPECTING_RIDE | ((uint32_t)ride->name << 16); - *argument_2 = ride->name_arguments; - break; + break; + case PEEP_STATE_BUYING: + ride = get_ride(peep->current_ride); + *argument_1 = STR_AT_RIDE | ((uint32_t)ride->name << 16); + *argument_2 = ride->name_arguments; + break; + case PEEP_STATE_WALKING: + case PEEP_STATE_USING_BIN: + if (peep->guest_heading_to_ride_id != 0xFF) + { + ride = get_ride(peep->guest_heading_to_ride_id); + *argument_1 = STR_HEADING_FOR | ((uint32_t)ride->name << 16); + *argument_2 = ride->name_arguments; + } + else + { + *argument_1 = (peep->peep_flags & PEEP_FLAGS_LEAVING_PARK) ? STR_LEAVING_PARK : STR_WALKING; + *argument_2 = 0; + } + break; + case PEEP_STATE_QUEUING_FRONT: + case PEEP_STATE_QUEUING: + ride = get_ride(peep->current_ride); + *argument_1 = STR_QUEUING_FOR | ((uint32_t)ride->name << 16); + *argument_2 = ride->name_arguments; + break; + case PEEP_STATE_SITTING: + *argument_1 = STR_SITTING; + *argument_2 = 0; + break; + case PEEP_STATE_WATCHING: + if (peep->current_ride != 0xFF) + { + ride = get_ride(peep->current_ride); + *argument_1 = STR_WATCHING_RIDE | ((uint32_t)ride->name << 16); + *argument_2 = ride->name_arguments; + if (peep->current_seat & 0x1) + *argument_1 = STR_WATCHING_CONSTRUCTION_OF | ((uint32_t)ride->name << 16); + else + *argument_1 = STR_WATCHING_RIDE | ((uint32_t)ride->name << 16); + } + else + { + *argument_1 = (peep->current_seat & 0x1) ? STR_WATCHING_NEW_RIDE_BEING_CONSTRUCTED : STR_LOOKING_AT_SCENERY; + *argument_2 = 0; + } + break; + case PEEP_STATE_PICKED: + *argument_1 = STR_SELECT_LOCATION; + *argument_2 = 0; + break; + case PEEP_STATE_PATROLLING: + case PEEP_STATE_ENTERING_PARK: + case PEEP_STATE_LEAVING_PARK: + *argument_1 = STR_WALKING; + *argument_2 = 0; + break; + case PEEP_STATE_MOWING: + *argument_1 = STR_MOWING_GRASS; + *argument_2 = 0; + break; + case PEEP_STATE_SWEEPING: + *argument_1 = STR_SWEEPING_FOOTPATH; + *argument_2 = 0; + break; + case PEEP_STATE_WATERING: + *argument_1 = STR_WATERING_GARDENS; + *argument_2 = 0; + break; + case PEEP_STATE_EMPTYING_BIN: + *argument_1 = STR_EMPTYING_LITTER_BIN; + *argument_2 = 0; + break; + case PEEP_STATE_ANSWERING: + if (peep->sub_state == 0) + { + *argument_1 = STR_WALKING; + *argument_2 = 0; + } + else if (peep->sub_state == 1) + { + *argument_1 = STR_ANSWERING_RADIO_CALL; + *argument_2 = 0; + } + else + { + ride = get_ride(peep->current_ride); + *argument_1 = STR_RESPONDING_TO_RIDE_BREAKDOWN_CALL | ((uint32_t)ride->name << 16); + *argument_2 = ride->name_arguments; + } + break; + case PEEP_STATE_FIXING: + ride = get_ride(peep->current_ride); + *argument_1 = STR_FIXING_RIDE | ((uint32_t)ride->name << 16); + *argument_2 = ride->name_arguments; + break; + case PEEP_STATE_HEADING_TO_INSPECTION: + ride = get_ride(peep->current_ride); + *argument_1 = STR_HEADING_TO_RIDE_FOR_INSPECTION | ((uint32_t)ride->name << 16); + *argument_2 = ride->name_arguments; + break; + case PEEP_STATE_INSPECTING: + ride = get_ride(peep->current_ride); + *argument_1 = STR_INSPECTING_RIDE | ((uint32_t)ride->name << 16); + *argument_2 = ride->name_arguments; + break; } } @@ -2052,14 +2052,14 @@ void get_arguments_from_action(rct_peep * peep, uint32_t * argument_1, uint32_t * argument_1 (esi & ebx) * argument_2 (esi+2) */ -void peep_thought_set_format_args(rct_peep_thought * thought) +void peep_thought_set_format_args(rct_peep_thought* thought) { set_format_arg(0, rct_string_id, PeepThoughts[thought->type]); uint8_t flags = PeepThoughtToActionMap[thought->type].flags; if (flags & 1) { - Ride * ride = get_ride(thought->item); + Ride* ride = get_ride(thought->item); set_format_arg(2, rct_string_id, ride->name); set_format_arg(4, uint32_t, ride->name_arguments); } @@ -2109,7 +2109,7 @@ static constexpr const bool peep_allow_pick_up[] = { * rct2: 0x00698827 * returns 1 on pickup (CF not set) */ -bool peep_can_be_picked_up(rct_peep * peep) +bool peep_can_be_picked_up(rct_peep* peep) { return peep_allow_pick_up[peep->state]; } @@ -2163,9 +2163,8 @@ static constexpr const int32_t face_sprite_large[] = { SPR_PEEP_LARGE_FACE_VERY_VERY_HAPPY, }; -static int32_t get_face_sprite_offset(rct_peep * peep) +static int32_t get_face_sprite_offset(rct_peep* peep) { - // ANGRY if (peep->angriness > 0) return PEEP_FACE_OFFSET_ANGRY; @@ -2204,7 +2203,7 @@ static int32_t get_face_sprite_offset(rct_peep * peep) * Function split into large and small sprite * rct2: 0x00698721 */ -int32_t get_peep_face_sprite_small(rct_peep * peep) +int32_t get_peep_face_sprite_small(rct_peep* peep) { return face_sprite_small[get_face_sprite_offset(peep)]; } @@ -2213,7 +2212,7 @@ int32_t get_peep_face_sprite_small(rct_peep * peep) * Function split into large and small sprite * rct2: 0x00698721 */ -int32_t get_peep_face_sprite_large(rct_peep * peep) +int32_t get_peep_face_sprite_large(rct_peep* peep) { return face_sprite_large[get_face_sprite_offset(peep)]; } @@ -2223,7 +2222,7 @@ int32_t get_peep_face_sprite_large(rct_peep * peep) * rct2: 0x0069A5A0 * tests if a peep's name matches a cheat code, normally returns using a register flag */ -int32_t peep_check_easteregg_name(int32_t index, rct_peep * peep) +int32_t peep_check_easteregg_name(int32_t index, rct_peep* peep) { char buffer[256]; @@ -2231,7 +2230,7 @@ int32_t peep_check_easteregg_name(int32_t index, rct_peep * peep) return _stricmp(buffer, gPeepEasterEggNames[index]) == 0; } -int32_t peep_get_easteregg_name_id(rct_peep * peep) +int32_t peep_get_easteregg_name_id(rct_peep* peep) { char buffer[256]; @@ -2251,13 +2250,13 @@ int32_t peep_get_easteregg_name_id(rct_peep * peep) * ah:thought_arguments * esi: peep */ -void peep_insert_new_thought(rct_peep * peep, uint8_t thought_type, uint8_t thought_arguments) +void peep_insert_new_thought(rct_peep* peep, uint8_t thought_type, uint8_t thought_arguments) { uint8_t action = PeepThoughtToActionMap[thought_type].action; if (action != 0xFF && peep->action >= 254) { - peep->action = action; - peep->action_frame = 0; + peep->action = action; + peep->action_frame = 0; peep->action_sprite_image_offset = 0; peep->UpdateCurrentActionSpriteType(); peep->Invalidate(); @@ -2265,7 +2264,7 @@ void peep_insert_new_thought(rct_peep * peep, uint8_t thought_type, uint8_t thou for (int32_t i = 0; i < PEEP_MAX_THOUGHTS; ++i) { - rct_peep_thought * thought = &peep->thoughts[i]; + rct_peep_thought* thought = &peep->thoughts[i]; // Remove the oldest thought by setting it to NONE. if (thought->type == PEEP_THOUGHT_TYPE_NONE) break; @@ -2285,20 +2284,20 @@ void peep_insert_new_thought(rct_peep * peep, uint8_t thought_type, uint8_t thou memmove(&peep->thoughts[1], &peep->thoughts[0], sizeof(rct_peep_thought) * (PEEP_MAX_THOUGHTS - 1)); - peep->thoughts[0].type = thought_type; - peep->thoughts[0].item = thought_arguments; + peep->thoughts[0].type = thought_type; + peep->thoughts[0].item = thought_arguments; peep->thoughts[0].freshness = 0; peep->thoughts[0].fresh_timeout = 0; peep->window_invalidate_flags |= PEEP_INVALIDATE_PEEP_THOUGHTS; } -void peep_set_map_tooltip(rct_peep * peep) +void peep_set_map_tooltip(rct_peep* peep) { if (peep->type == PEEP_TYPE_GUEST) { - set_map_tooltip_format_arg(0, rct_string_id, - (peep->peep_flags & PEEP_FLAGS_TRACKING) ? STR_TRACKED_GUEST_MAP_TIP : STR_GUEST_MAP_TIP); + set_map_tooltip_format_arg( + 0, rct_string_id, (peep->peep_flags & PEEP_FLAGS_TRACKING) ? STR_TRACKED_GUEST_MAP_TIP : STR_GUEST_MAP_TIP); set_map_tooltip_format_arg(2, uint32_t, get_peep_face_sprite_small(peep)); set_map_tooltip_format_arg(6, rct_string_id, peep->name_string_idx); set_map_tooltip_format_arg(8, uint32_t, peep->id); @@ -2330,11 +2329,11 @@ void rct_peep::SwitchNextActionSpriteType() if (next_action_sprite_type != action_sprite_type) { Invalidate(); - action_sprite_type = next_action_sprite_type; - const rct_sprite_bounds * spriteBounds = g_peep_animation_entries[sprite_type].sprite_bounds; - sprite_width = spriteBounds[next_action_sprite_type].sprite_width; - sprite_height_negative = spriteBounds[next_action_sprite_type].sprite_height_negative; - sprite_height_positive = spriteBounds[next_action_sprite_type].sprite_height_positive; + action_sprite_type = next_action_sprite_type; + const rct_sprite_bounds* spriteBounds = g_peep_animation_entries[sprite_type].sprite_bounds; + sprite_width = spriteBounds[next_action_sprite_type].sprite_width; + sprite_height_negative = spriteBounds[next_action_sprite_type].sprite_height_negative; + sprite_height_positive = spriteBounds[next_action_sprite_type].sprite_height_positive; Invalidate(); } } @@ -2343,13 +2342,13 @@ void rct_peep::SwitchNextActionSpriteType() * * rct2: 0x00693CBB */ -static bool peep_update_queue_position(rct_peep * peep, uint8_t previous_action) +static bool peep_update_queue_position(rct_peep* peep, uint8_t previous_action) { peep->time_in_queue++; if (peep->next_in_queue == SPRITE_INDEX_NULL) return false; - rct_peep * peep_next = GET_PEEP(peep->next_in_queue); + rct_peep* peep_next = GET_PEEP(peep->next_in_queue); int16_t x_diff = abs(peep_next->x - peep->x); int16_t y_diff = abs(peep_next->y - peep->y); @@ -2361,8 +2360,8 @@ static bool peep_update_queue_position(rct_peep * peep, uint8_t previous_action) if (x_diff < y_diff) { int16_t temp_x = x_diff; - x_diff = y_diff; - y_diff = temp_x; + x_diff = y_diff; + y_diff = temp_x; } x_diff += y_diff / 2; @@ -2379,22 +2378,22 @@ static bool peep_update_queue_position(rct_peep * peep, uint8_t previous_action) switch (peep_next->sprite_direction / 8) { - case 0: - if (peep->x >= peep_next->x) - return false; - break; - case 1: - if (peep->y <= peep_next->y) - return false; - break; - case 2: - if (peep->x <= peep_next->x) - return false; - break; - case 3: - if (peep->y >= peep_next->y) - return false; - break; + case 0: + if (peep->x >= peep_next->x) + return false; + break; + case 1: + if (peep->y <= peep_next->y) + return false; + break; + case 2: + if (peep->x <= peep_next->x) + return false; + break; + case 3: + if (peep->y >= peep_next->y) + return false; + break; } } @@ -2405,7 +2404,7 @@ static bool peep_update_queue_position(rct_peep * peep, uint8_t previous_action) if (peep->action != PEEP_ACTION_NONE_2) return true; - peep->action = PEEP_ACTION_NONE_1; + peep->action = PEEP_ACTION_NONE_1; peep->next_action_sprite_type = 2; if (previous_action != PEEP_ACTION_NONE_1) peep->Invalidate(); @@ -2416,11 +2415,11 @@ static bool peep_update_queue_position(rct_peep * peep, uint8_t previous_action) * * rct2: 0x00693EF2 */ -static void peep_return_to_centre_of_tile(rct_peep * peep) +static void peep_return_to_centre_of_tile(rct_peep* peep) { peep->direction ^= (1 << 1); - peep->destination_x = (peep->x & 0xFFE0) + 16; - peep->destination_y = (peep->y & 0xFFE0) + 16; + peep->destination_x = (peep->x & 0xFFE0) + 16; + peep->destination_y = (peep->y & 0xFFE0) + 16; peep->destination_tolerance = 5; } @@ -2428,10 +2427,11 @@ static void peep_return_to_centre_of_tile(rct_peep * peep) * * rct2: 0x00693f2C */ -static void peep_interact_with_entrance(rct_peep * peep, int16_t x, int16_t y, rct_tile_element * tile_element, uint8_t & pathing_result) +static void + peep_interact_with_entrance(rct_peep* peep, int16_t x, int16_t y, rct_tile_element* tile_element, uint8_t& pathing_result) { uint8_t entranceType = tile_element->properties.entrance.type; - uint8_t rideIndex = tile_element->properties.entrance.ride_index; + uint8_t rideIndex = tile_element->properties.entrance.ride_index; // Store some details to determine when to override the default // behaviour (defined below) for when staff attempt to enter a ride @@ -2470,7 +2470,7 @@ static void peep_interact_with_entrance(rct_peep * peep, int16_t x, int16_t y, r if (peep->state == PEEP_STATE_QUEUING) { // Guest is in the ride queue. - peep->sub_state = 11; + peep->sub_state = 11; peep->action_sprite_image_offset = _unk_F1AEF0; return; } @@ -2486,7 +2486,7 @@ static void peep_interact_with_entrance(rct_peep * peep, int16_t x, int16_t y, r return; } - peep->time_lost = 0; + peep->time_lost = 0; uint8_t stationNum = (tile_element->properties.entrance.index >> 4) & 0x7; // Guest walks up to the ride for the first time since entering // the path tile or since considering another ride attached to @@ -2502,19 +2502,19 @@ static void peep_interact_with_entrance(rct_peep * peep, int16_t x, int16_t y, r // Guest has decided to go on the ride. peep->action_sprite_image_offset = _unk_F1AEF0; - peep->interaction_ride_index = rideIndex; + peep->interaction_ride_index = rideIndex; - Ride * ride = get_ride(rideIndex); - uint16_t previous_last = ride->last_peep_in_queue[stationNum]; + Ride* ride = get_ride(rideIndex); + uint16_t previous_last = ride->last_peep_in_queue[stationNum]; ride->last_peep_in_queue[stationNum] = peep->sprite_index; - peep->next_in_queue = previous_last; + peep->next_in_queue = previous_last; ride->queue_length[stationNum]++; - peep->current_ride = rideIndex; + peep->current_ride = rideIndex; peep->current_ride_station = stationNum; - peep->days_in_queue = 0; + peep->days_in_queue = 0; peep->SetState(PEEP_STATE_QUEUING); - peep->sub_state = 11; + peep->sub_state = 11; peep->time_in_queue = 0; if (peep->peep_flags & PEEP_FLAGS_TRACKING) { @@ -2575,7 +2575,7 @@ static void peep_interact_with_entrance(rct_peep * peep, int16_t x, int16_t y, r peep->destination_y += CoordsDirectionDelta[peep->direction].y; peep->destination_tolerance = 9; peep->Invalidate(); - sprite_move(x, y, peep->z, (rct_sprite *)peep); + sprite_move(x, y, peep->z, (rct_sprite*)peep); peep->Invalidate(); peep->SetState(PEEP_STATE_LEAVING_PARK); @@ -2603,7 +2603,7 @@ static void peep_interact_with_entrance(rct_peep * peep, int16_t x, int16_t y, r if (!(gParkFlags & PARK_FLAGS_PARK_OPEN)) { - peep->state = PEEP_STATE_LEAVING_PARK; + peep->state = PEEP_STATE_LEAVING_PARK; peep->var_37 = 1; decrement_guests_heading_for_park(); peep_window_state_update(peep); @@ -2618,15 +2618,15 @@ static void peep_interact_with_entrance(rct_peep * peep, int16_t x, int16_t y, r break; } - int16_t z = gParkEntrances[entranceIndex].z / 8; + int16_t z = gParkEntrances[entranceIndex].z / 8; entranceDirection = gParkEntrances[entranceIndex].direction; int16_t next_x = (x & 0xFFE0) + CoordsDirectionDelta[entranceDirection].x; int16_t next_y = (y & 0xFFE0) + CoordsDirectionDelta[entranceDirection].y; // Make sure there is a path right behind the entrance, otherwise turn around - bool found = false; - rct_tile_element * nextTileElement = map_get_first_element_at(next_x / 32, next_y / 32); + bool found = false; + rct_tile_element* nextTileElement = map_get_first_element_at(next_x / 32, next_y / 32); do { if (nextTileElement->GetType() != TILE_ELEMENT_TYPE_PATH) @@ -2669,7 +2669,7 @@ static void peep_interact_with_entrance(rct_peep * peep, int16_t x, int16_t y, r if (!found) { - peep->state = PEEP_STATE_LEAVING_PARK; + peep->state = PEEP_STATE_LEAVING_PARK; peep->var_37 = 1; decrement_guests_heading_for_park(); peep_window_state_update(peep); @@ -2697,7 +2697,7 @@ static void peep_interact_with_entrance(rct_peep * peep, int16_t x, int16_t y, r } if (entranceFee > peep->cash_in_pocket) { - peep->state = PEEP_STATE_LEAVING_PARK; + peep->state = PEEP_STATE_LEAVING_PARK; peep->var_37 = 1; decrement_guests_heading_for_park(); peep_window_state_update(peep); @@ -2720,7 +2720,7 @@ static void peep_interact_with_entrance(rct_peep * peep, int16_t x, int16_t y, r peep->destination_tolerance = 7; peep->Invalidate(); - sprite_move(x, y, peep->z, (rct_sprite *)peep); + sprite_move(x, y, peep->z, (rct_sprite*)peep); peep->Invalidate(); } } @@ -2729,11 +2729,11 @@ static void peep_interact_with_entrance(rct_peep * peep, int16_t x, int16_t y, r * * rct2: 0x006946D8 */ -static void peep_footpath_move_forward(rct_peep * peep, int16_t x, int16_t y, rct_tile_element * tile_element, bool vandalism) +static void peep_footpath_move_forward(rct_peep* peep, int16_t x, int16_t y, rct_tile_element* tile_element, bool vandalism) { - peep->next_x = (x & 0xFFE0); - peep->next_y = (y & 0xFFE0); - peep->next_z = tile_element->base_height; + peep->next_x = (x & 0xFFE0); + peep->next_y = (y & 0xFFE0); + peep->next_z = tile_element->base_height; peep->SetNextFlags(tile_element->properties.path.type & 3, tile_element->properties.path.type & 4, false); int16_t z = peep->GetZOnSlope(x, y); @@ -2741,7 +2741,7 @@ static void peep_footpath_move_forward(rct_peep * peep, int16_t x, int16_t y, rc if (peep->type == PEEP_TYPE_STAFF) { peep->Invalidate(); - sprite_move(x, y, z, (rct_sprite *)peep); + sprite_move(x, y, z, (rct_sprite*)peep); peep->Invalidate(); return; } @@ -2757,7 +2757,6 @@ static void peep_footpath_move_forward(rct_peep * peep, int16_t x, int16_t y, rc // If there has been 2 vandalised tiles in the last 6 if (vandalisedTiles & 0x3E && (vandalThoughtTimeout == 0)) { - if ((scenario_rand() & 0xFFFF) <= 10922) { peep_insert_new_thought(peep, PEEP_THOUGHT_TYPE_VANDALISM, PEEP_THOUGHT_ITEM_NONE); @@ -2773,16 +2772,16 @@ static void peep_footpath_move_forward(rct_peep * peep, int16_t x, int16_t y, rc } peep->vandalism_seen = (vandalThoughtTimeout << 6) | vandalisedTiles; - uint16_t crowded = 0; - uint8_t litter_count = 0; - uint8_t sick_count = 0; - uint16_t sprite_id = sprite_get_first_in_quadrant(x, y); - for (rct_sprite * sprite; sprite_id != SPRITE_INDEX_NULL; sprite_id = sprite->unknown.next_in_quadrant) + uint16_t crowded = 0; + uint8_t litter_count = 0; + uint8_t sick_count = 0; + uint16_t sprite_id = sprite_get_first_in_quadrant(x, y); + for (rct_sprite* sprite; sprite_id != SPRITE_INDEX_NULL; sprite_id = sprite->unknown.next_in_quadrant) { sprite = get_sprite(sprite_id); if (sprite->unknown.sprite_identifier == SPRITE_IDENTIFIER_PEEP) { - rct_peep * other_peep = (rct_peep *)sprite; + rct_peep* other_peep = (rct_peep*)sprite; if (other_peep->state != PEEP_STATE_WALKING) continue; @@ -2793,7 +2792,7 @@ static void peep_footpath_move_forward(rct_peep * peep, int16_t x, int16_t y, rc } else if (sprite->unknown.sprite_identifier == SPRITE_IDENTIFIER_LITTER) { - rct_litter * litter = (rct_litter *)sprite; + rct_litter* litter = (rct_litter*)sprite; if (abs(litter->z - peep->next_z * 8) > 16) continue; @@ -2808,15 +2807,14 @@ static void peep_footpath_move_forward(rct_peep * peep, int16_t x, int16_t y, rc if (crowded >= 10 && peep->state == PEEP_STATE_WALKING && (scenario_rand() & 0xFFFF) <= 21845) { - peep_insert_new_thought(peep, PEEP_THOUGHT_TYPE_CROWDED, PEEP_THOUGHT_ITEM_NONE); peep->happiness_target = std::max(0, peep->happiness_target - 14); } litter_count = std::min(static_cast(3), litter_count); - sick_count = std::min(static_cast(3), sick_count); + sick_count = std::min(static_cast(3), sick_count); - uint8_t disgusting_time = peep->disgusting_count & 0xC0; + uint8_t disgusting_time = peep->disgusting_count & 0xC0; uint8_t disgusting_count = ((peep->disgusting_count & 0xF) << 2) | sick_count; peep->disgusting_count = disgusting_count | disgusting_time; @@ -2842,8 +2840,8 @@ static void peep_footpath_move_forward(rct_peep * peep, int16_t x, int16_t y, rc } } - uint8_t litter_time = peep->litter_count & 0xC0; - litter_count = ((peep->litter_count & 0xF) << 2) | litter_count; + uint8_t litter_time = peep->litter_count & 0xC0; + litter_count = ((peep->litter_count & 0xF) << 2) | litter_count; peep->litter_count = litter_count | litter_time; if (litter_time & 0xC0 && (scenario_rand() & 0xFFFF) <= 4369) @@ -2869,7 +2867,7 @@ static void peep_footpath_move_forward(rct_peep * peep, int16_t x, int16_t y, rc } peep->Invalidate(); - sprite_move(x, y, z, (rct_sprite *)peep); + sprite_move(x, y, z, (rct_sprite*)peep); peep->Invalidate(); } @@ -2877,12 +2875,12 @@ static void peep_footpath_move_forward(rct_peep * peep, int16_t x, int16_t y, rc * * rct2: 0x0069455E */ -static void peep_interact_with_path(rct_peep * peep, int16_t x, int16_t y, rct_tile_element * tile_element) +static void peep_interact_with_path(rct_peep* peep, int16_t x, int16_t y, rct_tile_element* tile_element) { // 0x00F1AEE2 bool vandalism_present = false; - if (footpath_element_has_path_scenery(tile_element) && (tile_element->flags & TILE_ELEMENT_FLAG_BROKEN) && - (tile_element->properties.path.edges & 0xF) != 0xF) + if (footpath_element_has_path_scenery(tile_element) && (tile_element->flags & TILE_ELEMENT_FLAG_BROKEN) + && (tile_element->properties.path.edges & 0xF) != 0xF) { vandalism_present = true; } @@ -2907,7 +2905,6 @@ static void peep_interact_with_path(rct_peep * peep, int16_t x, int16_t y, rct_t if (peep->type == PEEP_TYPE_GUEST && footpath_element_is_queue(tile_element)) { - uint8_t rideIndex = tile_element->properties.path.ride_index; if (peep->state == PEEP_STATE_QUEUING) @@ -2929,12 +2926,12 @@ static void peep_interact_with_path(rct_peep * peep, int16_t x, int16_t y, rct_t } // Peep is not queuing. - peep->time_lost = 0; + peep->time_lost = 0; uint8_t stationNum = (tile_element->properties.path.additions & 0x70) >> 4; if ((tile_element->properties.path.type & (1 << 3)) // Queue has the ride sign on it - && (footpath_element_get_direction(tile_element) == - ((peep->direction) ^ 2)) // Ride sign is facing the direction the peep is walking + && (footpath_element_get_direction(tile_element) + == ((peep->direction) ^ 2)) // Ride sign is facing the direction the peep is walking ) { /* Peep is approaching the entrance of a ride queue. @@ -2956,24 +2953,24 @@ static void peep_interact_with_path(rct_peep * peep, int16_t x, int16_t y, rct_t // Peep has decided to go on the ride at the queue. peep->interaction_ride_index = rideIndex; - Ride * ride = get_ride(rideIndex); + Ride* ride = get_ride(rideIndex); // Add the peep to the ride queue. - uint16_t old_last_peep = ride->last_peep_in_queue[stationNum]; + uint16_t old_last_peep = ride->last_peep_in_queue[stationNum]; ride->last_peep_in_queue[stationNum] = peep->sprite_index; - peep->next_in_queue = old_last_peep; + peep->next_in_queue = old_last_peep; ride->queue_length[stationNum]++; peep_decrement_num_riders(peep); - peep->current_ride = rideIndex; + peep->current_ride = rideIndex; peep->current_ride_station = stationNum; - peep->state = PEEP_STATE_QUEUING; - peep->days_in_queue = 0; + peep->state = PEEP_STATE_QUEUING; + peep->days_in_queue = 0; peep_window_state_update(peep); - peep->sub_state = 10; + peep->sub_state = 10; peep->destination_tolerance = 2; - peep->time_in_queue = 0; + peep->time_in_queue = 0; if (peep->peep_flags & PEEP_FLAGS_TRACKING) { set_format_arg(0, rct_string_id, peep->name_string_idx); @@ -3004,10 +3001,10 @@ static void peep_interact_with_path(rct_peep * peep, int16_t x, int16_t y, rct_t * * rct2: 0x00693F70 */ -static bool peep_interact_with_shop(rct_peep * peep, int16_t x, int16_t y, rct_tile_element * tile_element) +static bool peep_interact_with_shop(rct_peep* peep, int16_t x, int16_t y, rct_tile_element* tile_element) { - uint8_t rideIndex = track_element_get_ride_index(tile_element); - Ride * ride = get_ride(rideIndex); + uint8_t rideIndex = track_element_get_ride_index(tile_element); + Ride* ride = get_ride(rideIndex); if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_IS_SHOP)) return false; @@ -3058,13 +3055,13 @@ static bool peep_interact_with_shop(rct_peep * peep, int16_t x, int16_t y, rct_t money16 money = 0; peep->SpendMoney(money, cost); } - peep->destination_x = (x & 0xFFE0) + 16; - peep->destination_y = (y & 0xFFE0) + 16; + peep->destination_x = (x & 0xFFE0) + 16; + peep->destination_y = (y & 0xFFE0) + 16; peep->destination_tolerance = 3; peep->current_ride = rideIndex; peep->SetState(PEEP_STATE_ENTERING_RIDE); - peep->sub_state = PEEP_SHOP_APPROACH; + peep->sub_state = PEEP_SHOP_APPROACH; peep->time_on_ride = 0; ride->cur_num_customers++; @@ -3089,13 +3086,13 @@ static bool peep_interact_with_shop(rct_peep * peep, int16_t x, int16_t y, rct_t peep->action_sprite_image_offset = _unk_F1AEF0; peep->SetState(PEEP_STATE_BUYING); peep->current_ride = rideIndex; - peep->sub_state = 0; + peep->sub_state = 0; } return true; } -bool is_valid_path_z_and_direction(rct_tile_element * tileElement, int32_t currentZ, int32_t currentDirection) +bool is_valid_path_z_and_direction(rct_tile_element* tileElement, int32_t currentZ, int32_t currentDirection) { if (footpath_element_is_sloped(tileElement)) { @@ -3122,9 +3119,9 @@ bool is_valid_path_z_and_direction(rct_tile_element * tileElement, int32_t curre return true; } -void rct_peep::PerformNextAction(uint8_t & pathing_result) +void rct_peep::PerformNextAction(uint8_t& pathing_result) { - rct_tile_element * tmpTile; + rct_tile_element* tmpTile; PerformNextAction(pathing_result, tmpTile); } @@ -3132,7 +3129,7 @@ void rct_peep::PerformNextAction(uint8_t & pathing_result) * * rct2: 0x00693C9E */ -void rct_peep::PerformNextAction(uint8_t & pathing_result, rct_tile_element * & tile_result) +void rct_peep::PerformNextAction(uint8_t& pathing_result, rct_tile_element*& tile_result) { pathing_result = 0; uint8_t previousAction = action; @@ -3186,9 +3183,9 @@ void rct_peep::PerformNextAction(uint8_t & pathing_result, rct_tile_element * & return; } - rct_tile_element * tileElement = map_get_first_element_at(actionX / 32, actionY / 32); - int16_t base_z = std::max(0, (z / 8) - 2); - int16_t top_z = (z / 8) + 1; + rct_tile_element* tileElement = map_get_first_element_at(actionX / 32, actionY / 32); + int16_t base_z = std::max(0, (z / 8) - 2); + int16_t top_z = (z / 8) + 1; do { @@ -3234,7 +3231,7 @@ void rct_peep::PerformNextAction(uint8_t & pathing_result, rct_tile_element * & SetState(PEEP_STATE_1); } - if (!map_is_location_in_park({actionX & 0xFFE0, actionY & 0xFFE0})) + if (!map_is_location_in_park({ actionX & 0xFFE0, actionY & 0xFFE0 })) { peep_return_to_centre_of_tile(this); return; @@ -3265,9 +3262,9 @@ void rct_peep::PerformNextAction(uint8_t & pathing_result, rct_tile_element * & } // The peep is on a surface and not on a path - next_x = actionX & 0xFFE0; - next_y = actionY & 0xFFE0; - next_z = tileElement->base_height; + next_x = actionX & 0xFFE0; + next_y = actionY & 0xFFE0; + next_z = tileElement->base_height; SetNextFlags(0, false, true); height = GetZOnSlope(actionX, actionY); @@ -3285,9 +3282,8 @@ void rct_peep::PerformNextAction(uint8_t & pathing_result, rct_tile_element * & * * rct2: 0x0069A98C */ -void peep_reset_pathfind_goal(rct_peep * peep) +void peep_reset_pathfind_goal(rct_peep* peep) { - #if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 if (gPathFindDebug) { @@ -3295,13 +3291,13 @@ void peep_reset_pathfind_goal(rct_peep * peep) } #endif // defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 - peep->pathfind_goal.x = 0xFF; - peep->pathfind_goal.y = 0xFF; - peep->pathfind_goal.z = 0xFF; + peep->pathfind_goal.x = 0xFF; + peep->pathfind_goal.y = 0xFF; + peep->pathfind_goal.z = 0xFF; peep->pathfind_goal.direction = 0xFF; } -static bool peep_has_valid_xy(rct_peep * peep) +static bool peep_has_valid_xy(rct_peep* peep) { if (peep->x != LOCATION_NULL) { @@ -3314,9 +3310,9 @@ static bool peep_has_valid_xy(rct_peep * peep) return false; } -using easter_egg_function = void (*)(rct_peep * peep, rct_peep * otherPeep); +using easter_egg_function = void (*)(rct_peep* peep, rct_peep* otherPeep); -static void peep_apply_easter_egg_to_nearby_guests(rct_peep * peep, easter_egg_function easter_egg) +static void peep_apply_easter_egg_to_nearby_guests(rct_peep* peep, easter_egg_function easter_egg) { if (!peep_has_valid_xy(peep)) return; @@ -3325,7 +3321,7 @@ static void peep_apply_easter_egg_to_nearby_guests(rct_peep * peep, easter_egg_f if (spriteIndex == SPRITE_INDEX_NULL) return; - rct_peep * otherPeep = GET_PEEP(spriteIndex); + rct_peep* otherPeep = GET_PEEP(spriteIndex); for (; spriteIndex != SPRITE_INDEX_NULL; spriteIndex = otherPeep->next_in_quadrant) { otherPeep = GET_PEEP(spriteIndex); @@ -3346,36 +3342,36 @@ static void peep_apply_easter_egg_to_nearby_guests(rct_peep * peep, easter_egg_f static void peep_give_passing_peeps_purple_clothes([[maybe_unused]] rct_peep* peep, rct_peep* otherPeep) { - otherPeep->tshirt_colour = COLOUR_BRIGHT_PURPLE; + otherPeep->tshirt_colour = COLOUR_BRIGHT_PURPLE; otherPeep->trousers_colour = COLOUR_BRIGHT_PURPLE; - invalidate_sprite_2((rct_sprite *)otherPeep); + invalidate_sprite_2((rct_sprite*)otherPeep); } -static void peep_give_passing_peeps_pizza(rct_peep * peep, rct_peep * otherPeep) +static void peep_give_passing_peeps_pizza(rct_peep* peep, rct_peep* otherPeep) { if ((otherPeep->item_standard_flags & PEEP_ITEM_PIZZA)) return; otherPeep->item_standard_flags |= PEEP_ITEM_PIZZA; - int32_t peepDirection = (peep->sprite_direction >> 3) ^ 2; + int32_t peepDirection = (peep->sprite_direction >> 3) ^ 2; int32_t otherPeepOppositeDirection = otherPeep->sprite_direction >> 3; if (peepDirection == otherPeepOppositeDirection) { if (otherPeep->action == PEEP_ACTION_NONE_1 || otherPeep->action == PEEP_ACTION_NONE_2) { peep->Invalidate(); - otherPeep->action = PEEP_ACTION_WAVE_2; - otherPeep->action_frame = 0; + otherPeep->action = PEEP_ACTION_WAVE_2; + otherPeep->action_frame = 0; otherPeep->action_sprite_image_offset = 0; otherPeep->UpdateCurrentActionSpriteType(); - invalidate_sprite_2((rct_sprite *)otherPeep); + invalidate_sprite_2((rct_sprite*)otherPeep); } } - invalidate_sprite_2((rct_sprite *)otherPeep); + invalidate_sprite_2((rct_sprite*)otherPeep); } -static void peep_make_passing_peeps_sick(rct_peep * peep, rct_peep * otherPeep) +static void peep_make_passing_peeps_sick(rct_peep* peep, rct_peep* otherPeep) { if (peep == otherPeep) return; @@ -3384,15 +3380,15 @@ static void peep_make_passing_peeps_sick(rct_peep * peep, rct_peep * otherPeep) if (otherPeep->action == PEEP_ACTION_NONE_1 || otherPeep->action == PEEP_ACTION_NONE_2) { - otherPeep->action = PEEP_ACTION_THROW_UP; - otherPeep->action_frame = 0; + otherPeep->action = PEEP_ACTION_THROW_UP; + otherPeep->action_frame = 0; otherPeep->action_sprite_image_offset = 0; otherPeep->UpdateCurrentActionSpriteType(); - invalidate_sprite_2((rct_sprite *)otherPeep); + invalidate_sprite_2((rct_sprite*)otherPeep); } } -static void peep_give_passing_peeps_ice_cream(rct_peep * peep, rct_peep * otherPeep) +static void peep_give_passing_peeps_ice_cream(rct_peep* peep, rct_peep* otherPeep) { if (peep == otherPeep) return; @@ -3407,7 +3403,7 @@ static void peep_give_passing_peeps_ice_cream(rct_peep * peep, rct_peep * otherP * * rct2: 0x0068FD3A */ -static void peep_easter_egg_peep_interactions(rct_peep * peep) +static void peep_easter_egg_peep_interactions(rct_peep* peep) { if (peep->peep_flags & PEEP_FLAGS_PURPLE) { @@ -3430,8 +3426,8 @@ static void peep_easter_egg_peep_interactions(rct_peep * peep) { if (peep->action == PEEP_ACTION_NONE_1 || peep->action == PEEP_ACTION_NONE_2) { - peep->action = PEEP_ACTION_JOY; - peep->action_frame = 0; + peep->action = PEEP_ACTION_JOY; + peep->action_frame = 0; peep->action_sprite_image_offset = 0; peep->UpdateCurrentActionSpriteType(); peep->Invalidate(); @@ -3470,7 +3466,7 @@ int32_t rct_peep::GetZOnSlope(int32_t tile_x, int32_t tile_y) * * rct2: 0x0069C483 */ -static void peep_give_real_name(rct_peep * peep) +static void peep_give_real_name(rct_peep* peep) { // Generate a name_string_idx from the peep id using bit twiddling uint16_t ax = (uint16_t)(peep->id + 0xF0B); @@ -3493,10 +3489,10 @@ static void peep_give_real_name(rct_peep * peep) peep->name_string_idx = dx; } -static int32_t peep_compare(const void * sprite_index_a, const void * sprite_index_b) +static int32_t peep_compare(const void* sprite_index_a, const void* sprite_index_b) { - rct_peep const * peep_a = GET_PEEP(*(uint16_t *)sprite_index_a); - rct_peep const * peep_b = GET_PEEP(*(uint16_t *)sprite_index_b); + rct_peep const* peep_a = GET_PEEP(*(uint16_t*)sprite_index_a); + rct_peep const* peep_b = GET_PEEP(*(uint16_t*)sprite_index_b); // Compare types if (peep_a->type != peep_b->type) @@ -3505,14 +3501,16 @@ static int32_t peep_compare(const void * sprite_index_a, const void * sprite_ind } // Simple ID comparison for when both peeps use a number or a generated name - const bool both_numbers = (peep_a->name_string_idx >= 767 && peep_a->name_string_idx <= 771 && - peep_b->name_string_idx >= 767 && peep_b->name_string_idx <= 771); + const bool both_numbers + = (peep_a->name_string_idx >= 767 && peep_a->name_string_idx <= 771 && peep_b->name_string_idx >= 767 + && peep_b->name_string_idx <= 771); if (both_numbers) { return peep_a->id - peep_b->id; } - const bool both_have_generated_names = (peep_a->name_string_idx >= REAL_NAME_START && peep_a->name_string_idx <= REAL_NAME_END && - peep_b->name_string_idx >= REAL_NAME_START && peep_b->name_string_idx <= REAL_NAME_END); + const bool both_have_generated_names + = (peep_a->name_string_idx >= REAL_NAME_START && peep_a->name_string_idx <= REAL_NAME_END + && peep_b->name_string_idx >= REAL_NAME_START && peep_b->name_string_idx <= REAL_NAME_END); if (both_have_generated_names) { rct_string_id peep_a_format = peep_a->name_string_idx + REAL_NAME_START; @@ -3535,8 +3533,8 @@ static int32_t peep_compare(const void * sprite_index_a, const void * sprite_ind // At least one of them has a custom name assigned // Compare their names as strings - utf8 name_a[256]; - utf8 name_b[256]; + utf8 name_a[256]; + utf8 name_b[256]; uint32_t peepIndex = peep_a->id; format_string(name_a, 256, peep_a->name_string_idx, &peepIndex); peepIndex = peep_b->id; @@ -3548,15 +3546,15 @@ static int32_t peep_compare(const void * sprite_index_a, const void * sprite_ind * * rct2: 0x00699115 */ -void peep_update_name_sort(rct_peep * peep) +void peep_update_name_sort(rct_peep* peep) { // Remove peep from sprite list uint16_t nextSpriteIndex = peep->next; uint16_t prevSpriteIndex = peep->previous; if (prevSpriteIndex != SPRITE_INDEX_NULL) { - rct_peep * prevPeep = GET_PEEP(prevSpriteIndex); - prevPeep->next = nextSpriteIndex; + rct_peep* prevPeep = GET_PEEP(prevSpriteIndex); + prevPeep->next = nextSpriteIndex; } else { @@ -3565,13 +3563,13 @@ void peep_update_name_sort(rct_peep * peep) if (nextSpriteIndex != SPRITE_INDEX_NULL) { - rct_peep * nextPeep = GET_PEEP(nextSpriteIndex); - nextPeep->previous = prevSpriteIndex; + rct_peep* nextPeep = GET_PEEP(nextSpriteIndex); + nextPeep->previous = prevSpriteIndex; } - rct_peep * otherPeep; - uint16_t spriteIndex; - FOR_ALL_PEEPS(spriteIndex, otherPeep) + rct_peep* otherPeep; + uint16_t spriteIndex; + FOR_ALL_PEEPS (spriteIndex, otherPeep) { // Check if peep should go before this one if (peep_compare(&peep->sprite_index, &otherPeep->sprite_index) >= 0) @@ -3580,37 +3578,37 @@ void peep_update_name_sort(rct_peep * peep) } // Place peep before this one - peep->previous = otherPeep->previous; + peep->previous = otherPeep->previous; otherPeep->previous = peep->sprite_index; if (peep->previous != SPRITE_INDEX_NULL) { - rct_peep * prevPeep = GET_PEEP(peep->previous); - peep->next = prevPeep->next; - prevPeep->next = peep->sprite_index; + rct_peep* prevPeep = GET_PEEP(peep->previous); + peep->next = prevPeep->next; + prevPeep->next = peep->sprite_index; } else { - peep->next = gSpriteListHead[SPRITE_LIST_PEEP]; + peep->next = gSpriteListHead[SPRITE_LIST_PEEP]; gSpriteListHead[SPRITE_LIST_PEEP] = peep->sprite_index; } goto finish_peep_sort; } // Place peep at the end - FOR_ALL_PEEPS(spriteIndex, otherPeep) + FOR_ALL_PEEPS (spriteIndex, otherPeep) { if (otherPeep->next == SPRITE_INDEX_NULL) { otherPeep->next = peep->sprite_index; - peep->previous = otherPeep->sprite_index; - peep->next = SPRITE_INDEX_NULL; + peep->previous = otherPeep->sprite_index; + peep->next = SPRITE_INDEX_NULL; goto finish_peep_sort; } } gSpriteListHead[SPRITE_LIST_PEEP] = peep->sprite_index; - peep->next = SPRITE_INDEX_NULL; - peep->previous = SPRITE_INDEX_NULL; + peep->next = SPRITE_INDEX_NULL; + peep->previous = SPRITE_INDEX_NULL; finish_peep_sort: // This is required at the moment because this function reorders peeps in the sprite list @@ -3620,9 +3618,9 @@ finish_peep_sort: void peep_sort() { // Count number of peeps - uint16_t sprite_index, num_peeps = 0; - rct_peep * peep; - FOR_ALL_PEEPS(sprite_index, peep) + uint16_t sprite_index, num_peeps = 0; + rct_peep* peep; + FOR_ALL_PEEPS (sprite_index, peep) { num_peeps++; } @@ -3632,9 +3630,9 @@ void peep_sort() return; // Create a copy of the peep list and sort it using peep_compare - uint16_t * peep_list = (uint16_t *)malloc(num_peeps * sizeof(uint16_t)); - int32_t i = 0; - FOR_ALL_PEEPS(sprite_index, peep) + uint16_t* peep_list = (uint16_t*)malloc(num_peeps * sizeof(uint16_t)); + int32_t i = 0; + FOR_ALL_PEEPS (sprite_index, peep) { peep_list[i++] = peep->sprite_index; } @@ -3643,9 +3641,9 @@ void peep_sort() // Set the correct peep->next and peep->previous using the sorted list for (i = 0; i < num_peeps; i++) { - peep = GET_PEEP(peep_list[i]); + peep = GET_PEEP(peep_list[i]); peep->previous = (i > 0) ? peep_list[i - 1] : SPRITE_INDEX_NULL; - peep->next = (i + 1 < num_peeps) ? peep_list[i + 1] : SPRITE_INDEX_NULL; + peep->next = (i + 1 < num_peeps) ? peep_list[i + 1] : SPRITE_INDEX_NULL; } // Make sure the first peep is set gSpriteListHead[SPRITE_LIST_PEEP] = peep_list[0]; @@ -3653,7 +3651,7 @@ void peep_sort() free(peep_list); i = 0; - FOR_ALL_PEEPS(sprite_index, peep) + FOR_ALL_PEEPS (sprite_index, peep) { i++; } @@ -3669,9 +3667,9 @@ void peep_update_names(bool realNames) if (realNames) { gParkFlags |= PARK_FLAGS_SHOW_REAL_GUEST_NAMES; - rct_peep * peep; - uint16_t spriteIndex; - FOR_ALL_GUESTS(spriteIndex, peep) + rct_peep* peep; + uint16_t spriteIndex; + FOR_ALL_GUESTS (spriteIndex, peep) { if (peep->name_string_idx == STR_GUEST_X) { @@ -3682,9 +3680,9 @@ void peep_update_names(bool realNames) else { gParkFlags &= ~PARK_FLAGS_SHOW_REAL_GUEST_NAMES; - rct_peep * peep; - uint16_t spriteIndex; - FOR_ALL_GUESTS(spriteIndex, peep) + rct_peep* peep; + uint16_t spriteIndex; + FOR_ALL_GUESTS (spriteIndex, peep) { if (peep->name_string_idx >= REAL_NAME_START && peep->name_string_idx <= REAL_NAME_END) { @@ -3702,7 +3700,7 @@ bool rct_peep::HeadingForRideOrParkExit() const return (peep_flags & PEEP_FLAGS_LEAVING_PARK) || (guest_heading_to_ride_id != 0xFF); } -void peep_handle_easteregg_name(rct_peep * peep) +void peep_handle_easteregg_name(rct_peep* peep) { peep->peep_flags &= ~PEEP_FLAGS_WAVING; if (peep_check_easteregg_name(EASTEREGG_PEEP_NAME_KATIE_BRAYSHAW, peep)) @@ -3730,12 +3728,12 @@ void peep_handle_easteregg_name(rct_peep * peep) if (peep_check_easteregg_name(EASTEREGG_PEEP_NAME_MELANIE_WARN, peep)) { - peep->happiness = 250; + peep->happiness = 250; peep->happiness_target = 250; - peep->energy = 127; - peep->energy_target = 127; - peep->nausea = 0; - peep->nausea_target = 0; + peep->energy = 127; + peep->energy_target = 127; + peep->nausea = 0; + peep->nausea_target = 0; } peep->peep_flags &= ~PEEP_FLAGS_LITTER; @@ -3909,7 +3907,7 @@ void decrement_guests_heading_for_park() } } -static void peep_release_balloon(rct_peep * peep, int16_t spawn_height) +static void peep_release_balloon(rct_peep* peep, int16_t spawn_height) { if (peep->item_standard_flags & PEEP_ITEM_BALLOON) { diff --git a/src/openrct2/peep/Peep.h b/src/openrct2/peep/Peep.h index e206861275..26e4c67482 100644 --- a/src/openrct2/peep/Peep.h +++ b/src/openrct2/peep/Peep.h @@ -42,174 +42,174 @@ enum PEEP_TYPE enum PEEP_THOUGHT_TYPE { - PEEP_THOUGHT_TYPE_CANT_AFFORD_0 = 0, // "I can't afford" - PEEP_THOUGHT_TYPE_SPENT_MONEY = 1, // "I've spent all my money" - PEEP_THOUGHT_TYPE_SICK = 2, // "I feel sick" - PEEP_THOUGHT_TYPE_VERY_SICK = 3, // "I feel very sick" - PEEP_THOUGHT_TYPE_MORE_THRILLING = 4, // "I want to go on something more thrilling than X" - PEEP_THOUGHT_TYPE_INTENSE = 5, // "X looks too intense for me" - PEEP_THOUGHT_TYPE_HAVENT_FINISHED = 6, // "I haven't finished my X yet" - PEEP_THOUGHT_TYPE_SICKENING = 7, // "Just looking at X makes me feel sick" - PEEP_THOUGHT_TYPE_BAD_VALUE = 8, // "I'm not paying that much to go on X" - PEEP_THOUGHT_TYPE_GO_HOME = 9, // "I want to go home" - PEEP_THOUGHT_TYPE_GOOD_VALUE = 10, // "X is really good value" - PEEP_THOUGHT_TYPE_ALREADY_GOT = 11, // "I've already got" - PEEP_THOUGHT_TYPE_CANT_AFFORD = 12, // "I can't afford" - PEEP_THOUGHT_TYPE_NOT_HUNGRY = 13, // "I'm not hungry" - PEEP_THOUGHT_TYPE_NOT_THIRSTY = 14, // "I'm not thirsty" - PEEP_THOUGHT_TYPE_DROWNING = 15, // "Help! I'm drowning!" - PEEP_THOUGHT_TYPE_LOST = 16, // "I'm lost!" - PEEP_THOUGHT_TYPE_WAS_GREAT = 17, // "X was great" - PEEP_THOUGHT_TYPE_QUEUING_AGES = 18, // "I've been queuing for X for ages" - PEEP_THOUGHT_TYPE_TIRED = 19, // "I'm tired" - PEEP_THOUGHT_TYPE_HUNGRY = 20, // "I'm hungry" - PEEP_THOUGHT_TYPE_THIRSTY = 21, // "I'm thirsty" - PEEP_THOUGHT_TYPE_BATHROOM = 22, // "I need to go to the bathroom" - PEEP_THOUGHT_TYPE_CANT_FIND = 23, // "I can't find X" - PEEP_THOUGHT_TYPE_NOT_PAYING = 24, // "I'm not paying that much to use X" + PEEP_THOUGHT_TYPE_CANT_AFFORD_0 = 0, // "I can't afford" + PEEP_THOUGHT_TYPE_SPENT_MONEY = 1, // "I've spent all my money" + PEEP_THOUGHT_TYPE_SICK = 2, // "I feel sick" + PEEP_THOUGHT_TYPE_VERY_SICK = 3, // "I feel very sick" + PEEP_THOUGHT_TYPE_MORE_THRILLING = 4, // "I want to go on something more thrilling than X" + PEEP_THOUGHT_TYPE_INTENSE = 5, // "X looks too intense for me" + PEEP_THOUGHT_TYPE_HAVENT_FINISHED = 6, // "I haven't finished my X yet" + PEEP_THOUGHT_TYPE_SICKENING = 7, // "Just looking at X makes me feel sick" + PEEP_THOUGHT_TYPE_BAD_VALUE = 8, // "I'm not paying that much to go on X" + PEEP_THOUGHT_TYPE_GO_HOME = 9, // "I want to go home" + PEEP_THOUGHT_TYPE_GOOD_VALUE = 10, // "X is really good value" + PEEP_THOUGHT_TYPE_ALREADY_GOT = 11, // "I've already got" + PEEP_THOUGHT_TYPE_CANT_AFFORD = 12, // "I can't afford" + PEEP_THOUGHT_TYPE_NOT_HUNGRY = 13, // "I'm not hungry" + PEEP_THOUGHT_TYPE_NOT_THIRSTY = 14, // "I'm not thirsty" + PEEP_THOUGHT_TYPE_DROWNING = 15, // "Help! I'm drowning!" + PEEP_THOUGHT_TYPE_LOST = 16, // "I'm lost!" + PEEP_THOUGHT_TYPE_WAS_GREAT = 17, // "X was great" + PEEP_THOUGHT_TYPE_QUEUING_AGES = 18, // "I've been queuing for X for ages" + PEEP_THOUGHT_TYPE_TIRED = 19, // "I'm tired" + PEEP_THOUGHT_TYPE_HUNGRY = 20, // "I'm hungry" + PEEP_THOUGHT_TYPE_THIRSTY = 21, // "I'm thirsty" + PEEP_THOUGHT_TYPE_BATHROOM = 22, // "I need to go to the bathroom" + PEEP_THOUGHT_TYPE_CANT_FIND = 23, // "I can't find X" + PEEP_THOUGHT_TYPE_NOT_PAYING = 24, // "I'm not paying that much to use X" PEEP_THOUGHT_TYPE_NOT_WHILE_RAINING = 25, // "I'm not going on X while it's raining" - PEEP_THOUGHT_TYPE_BAD_LITTER = 26, // "The litter here is really bad" - PEEP_THOUGHT_TYPE_CANT_FIND_EXIT = 27, // "I can't find the exit" - PEEP_THOUGHT_TYPE_GET_OFF = 28, // "I want to get off X" - PEEP_THOUGHT_TYPE_GET_OUT = 29, // "I want to get out of X" - PEEP_THOUGHT_TYPE_NOT_SAFE = 30, // "I'm not going on X - it isn't safe" - PEEP_THOUGHT_TYPE_PATH_DISGUSTING = 31, // "This path is disgusting" - PEEP_THOUGHT_TYPE_CROWDED = 32, // "It's too crowded here" - PEEP_THOUGHT_TYPE_VANDALISM = 33, // "The vandalism here is really bad" - PEEP_THOUGHT_TYPE_SCENERY = 34, // "Great scenery!" - PEEP_THOUGHT_TYPE_VERY_CLEAN = 35, // "This park is very clean and tidy" - PEEP_THOUGHT_TYPE_FOUNTAINS = 36, // "The jumping fountains are great" - PEEP_THOUGHT_TYPE_MUSIC = 37, // "The music is nice here" - PEEP_THOUGHT_TYPE_BALLOON = 38, // "This balloon from X is really good value" - PEEP_THOUGHT_TYPE_TOY = 39, // "This cuddly toy from X is really good value" - PEEP_THOUGHT_TYPE_MAP = 40, - PEEP_THOUGHT_TYPE_PHOTO = 41, // "This on ride photo from X is really good value" - PEEP_THOUGHT_TYPE_UMBRELLA = 42, - PEEP_THOUGHT_TYPE_DRINK = 43, - PEEP_THOUGHT_TYPE_BURGER = 44, - PEEP_THOUGHT_TYPE_CHIPS = 45, - PEEP_THOUGHT_TYPE_ICE_CREAM = 46, - PEEP_THOUGHT_TYPE_CANDYFLOSS = 47, + PEEP_THOUGHT_TYPE_BAD_LITTER = 26, // "The litter here is really bad" + PEEP_THOUGHT_TYPE_CANT_FIND_EXIT = 27, // "I can't find the exit" + PEEP_THOUGHT_TYPE_GET_OFF = 28, // "I want to get off X" + PEEP_THOUGHT_TYPE_GET_OUT = 29, // "I want to get out of X" + PEEP_THOUGHT_TYPE_NOT_SAFE = 30, // "I'm not going on X - it isn't safe" + PEEP_THOUGHT_TYPE_PATH_DISGUSTING = 31, // "This path is disgusting" + PEEP_THOUGHT_TYPE_CROWDED = 32, // "It's too crowded here" + PEEP_THOUGHT_TYPE_VANDALISM = 33, // "The vandalism here is really bad" + PEEP_THOUGHT_TYPE_SCENERY = 34, // "Great scenery!" + PEEP_THOUGHT_TYPE_VERY_CLEAN = 35, // "This park is very clean and tidy" + PEEP_THOUGHT_TYPE_FOUNTAINS = 36, // "The jumping fountains are great" + PEEP_THOUGHT_TYPE_MUSIC = 37, // "The music is nice here" + PEEP_THOUGHT_TYPE_BALLOON = 38, // "This balloon from X is really good value" + PEEP_THOUGHT_TYPE_TOY = 39, // "This cuddly toy from X is really good value" + PEEP_THOUGHT_TYPE_MAP = 40, + PEEP_THOUGHT_TYPE_PHOTO = 41, // "This on ride photo from X is really good value" + PEEP_THOUGHT_TYPE_UMBRELLA = 42, + PEEP_THOUGHT_TYPE_DRINK = 43, + PEEP_THOUGHT_TYPE_BURGER = 44, + PEEP_THOUGHT_TYPE_CHIPS = 45, + PEEP_THOUGHT_TYPE_ICE_CREAM = 46, + PEEP_THOUGHT_TYPE_CANDYFLOSS = 47, PEEP_THOUGHT_TYPE_PIZZA = 51, - PEEP_THOUGHT_TYPE_POPCORN = 53, - PEEP_THOUGHT_TYPE_HOT_DOG = 54, - PEEP_THOUGHT_TYPE_TENTACLE = 55, - PEEP_THOUGHT_TYPE_HAT = 56, + PEEP_THOUGHT_TYPE_POPCORN = 53, + PEEP_THOUGHT_TYPE_HOT_DOG = 54, + PEEP_THOUGHT_TYPE_TENTACLE = 55, + PEEP_THOUGHT_TYPE_HAT = 56, PEEP_THOUGHT_TYPE_TOFFEE_APPLE = 57, - PEEP_THOUGHT_TYPE_TSHIRT = 58, - PEEP_THOUGHT_TYPE_DOUGHNUT = 59, - PEEP_THOUGHT_TYPE_COFFEE = 60, + PEEP_THOUGHT_TYPE_TSHIRT = 58, + PEEP_THOUGHT_TYPE_DOUGHNUT = 59, + PEEP_THOUGHT_TYPE_COFFEE = 60, - PEEP_THOUGHT_TYPE_CHICKEN = 62, + PEEP_THOUGHT_TYPE_CHICKEN = 62, PEEP_THOUGHT_TYPE_LEMONADE = 63, PEEP_THOUGHT_TYPE_WOW = 67, // "Wow!" - PEEP_THOUGHT_TYPE_WOW2 = 70, // "Wow!" - PEEP_THOUGHT_TYPE_WATCHED = 71, // "I have the strangest feeling someone is watching me" - PEEP_THOUGHT_TYPE_BALLOON_MUCH = 72, // "I'm not paying that much to get a balloon from X" - PEEP_THOUGHT_TYPE_TOY_MUCH = 73, - PEEP_THOUGHT_TYPE_MAP_MUCH = 74, - PEEP_THOUGHT_TYPE_PHOTO_MUCH = 75, - PEEP_THOUGHT_TYPE_UMBRELLA_MUCH = 76, - PEEP_THOUGHT_TYPE_DRINK_MUCH = 77, - PEEP_THOUGHT_TYPE_BURGER_MUCH = 78, - PEEP_THOUGHT_TYPE_CHIPS_MUCH = 79, - PEEP_THOUGHT_TYPE_ICE_CREAM_MUCH = 80, + PEEP_THOUGHT_TYPE_WOW2 = 70, // "Wow!" + PEEP_THOUGHT_TYPE_WATCHED = 71, // "I have the strangest feeling someone is watching me" + PEEP_THOUGHT_TYPE_BALLOON_MUCH = 72, // "I'm not paying that much to get a balloon from X" + PEEP_THOUGHT_TYPE_TOY_MUCH = 73, + PEEP_THOUGHT_TYPE_MAP_MUCH = 74, + PEEP_THOUGHT_TYPE_PHOTO_MUCH = 75, + PEEP_THOUGHT_TYPE_UMBRELLA_MUCH = 76, + PEEP_THOUGHT_TYPE_DRINK_MUCH = 77, + PEEP_THOUGHT_TYPE_BURGER_MUCH = 78, + PEEP_THOUGHT_TYPE_CHIPS_MUCH = 79, + PEEP_THOUGHT_TYPE_ICE_CREAM_MUCH = 80, PEEP_THOUGHT_TYPE_CANDYFLOSS_MUCH = 81, PEEP_THOUGHT_TYPE_PIZZA_MUCH = 85, - PEEP_THOUGHT_TYPE_POPCORN_MUCH = 87, - PEEP_THOUGHT_TYPE_HOT_DOG_MUCH = 88, - PEEP_THOUGHT_TYPE_TENTACLE_MUCH = 89, - PEEP_THOUGHT_TYPE_HAT_MUCH = 90, + PEEP_THOUGHT_TYPE_POPCORN_MUCH = 87, + PEEP_THOUGHT_TYPE_HOT_DOG_MUCH = 88, + PEEP_THOUGHT_TYPE_TENTACLE_MUCH = 89, + PEEP_THOUGHT_TYPE_HAT_MUCH = 90, PEEP_THOUGHT_TYPE_TOFFEE_APPLE_MUCH = 91, - PEEP_THOUGHT_TYPE_TSHIRT_MUCH = 92, - PEEP_THOUGHT_TYPE_DOUGHNUT_MUCH = 93, - PEEP_THOUGHT_TYPE_COFFEE_MUCH = 94, + PEEP_THOUGHT_TYPE_TSHIRT_MUCH = 92, + PEEP_THOUGHT_TYPE_DOUGHNUT_MUCH = 93, + PEEP_THOUGHT_TYPE_COFFEE_MUCH = 94, - PEEP_THOUGHT_TYPE_CHICKEN_MUCH = 96, + PEEP_THOUGHT_TYPE_CHICKEN_MUCH = 96, PEEP_THOUGHT_TYPE_LEMONADE_MUCH = 97, - PEEP_THOUGHT_TYPE_PHOTO2 = 104, // "This on-ride photo from X is really good value" - PEEP_THOUGHT_TYPE_PHOTO3 = 105, - PEEP_THOUGHT_TYPE_PHOTO4 = 106, - PEEP_THOUGHT_TYPE_PRETZEL = 107, - PEEP_THOUGHT_TYPE_HOT_CHOCOLATE = 108, - PEEP_THOUGHT_TYPE_ICED_TEA = 109, - PEEP_THOUGHT_TYPE_FUNNEL_CAKE = 110, - PEEP_THOUGHT_TYPE_SUNGLASSES = 111, - PEEP_THOUGHT_TYPE_BEEF_NOODLES = 112, + PEEP_THOUGHT_TYPE_PHOTO2 = 104, // "This on-ride photo from X is really good value" + PEEP_THOUGHT_TYPE_PHOTO3 = 105, + PEEP_THOUGHT_TYPE_PHOTO4 = 106, + PEEP_THOUGHT_TYPE_PRETZEL = 107, + PEEP_THOUGHT_TYPE_HOT_CHOCOLATE = 108, + PEEP_THOUGHT_TYPE_ICED_TEA = 109, + PEEP_THOUGHT_TYPE_FUNNEL_CAKE = 110, + PEEP_THOUGHT_TYPE_SUNGLASSES = 111, + PEEP_THOUGHT_TYPE_BEEF_NOODLES = 112, PEEP_THOUGHT_TYPE_FRIED_RICE_NOODLES = 113, - PEEP_THOUGHT_TYPE_WONTON_SOUP = 114, - PEEP_THOUGHT_TYPE_MEATBALL_SOUP = 115, - PEEP_THOUGHT_TYPE_FRUIT_JUICE = 116, - PEEP_THOUGHT_TYPE_SOYBEAN_MILK = 117, - PEEP_THOUGHT_TYPE_SU_JONGKWA = 118, - PEEP_THOUGHT_TYPE_SUB_SANDWICH = 119, - PEEP_THOUGHT_TYPE_COOKIE = 120, + PEEP_THOUGHT_TYPE_WONTON_SOUP = 114, + PEEP_THOUGHT_TYPE_MEATBALL_SOUP = 115, + PEEP_THOUGHT_TYPE_FRUIT_JUICE = 116, + PEEP_THOUGHT_TYPE_SOYBEAN_MILK = 117, + PEEP_THOUGHT_TYPE_SU_JONGKWA = 118, + PEEP_THOUGHT_TYPE_SUB_SANDWICH = 119, + PEEP_THOUGHT_TYPE_COOKIE = 120, PEEP_THOUGHT_TYPE_ROAST_SAUSAGE = 124, - PEEP_THOUGHT_TYPE_PHOTO2_MUCH = 136, - PEEP_THOUGHT_TYPE_PHOTO3_MUCH = 137, - PEEP_THOUGHT_TYPE_PHOTO4_MUCH = 138, - PEEP_THOUGHT_TYPE_PRETZEL_MUCH = 139, - PEEP_THOUGHT_TYPE_HOT_CHOCOLATE_MUCH = 140, - PEEP_THOUGHT_TYPE_ICED_TEA_MUCH = 141, - PEEP_THOUGHT_TYPE_FUNNEL_CAKE_MUCH = 142, - PEEP_THOUGHT_TYPE_SUNGLASSES_MUCH = 143, - PEEP_THOUGHT_TYPE_BEEF_NOODLES_MUCH = 144, + PEEP_THOUGHT_TYPE_PHOTO2_MUCH = 136, + PEEP_THOUGHT_TYPE_PHOTO3_MUCH = 137, + PEEP_THOUGHT_TYPE_PHOTO4_MUCH = 138, + PEEP_THOUGHT_TYPE_PRETZEL_MUCH = 139, + PEEP_THOUGHT_TYPE_HOT_CHOCOLATE_MUCH = 140, + PEEP_THOUGHT_TYPE_ICED_TEA_MUCH = 141, + PEEP_THOUGHT_TYPE_FUNNEL_CAKE_MUCH = 142, + PEEP_THOUGHT_TYPE_SUNGLASSES_MUCH = 143, + PEEP_THOUGHT_TYPE_BEEF_NOODLES_MUCH = 144, PEEP_THOUGHT_TYPE_FRIED_RICE_NOODLES_MUCH = 145, - PEEP_THOUGHT_TYPE_WONTON_SOUP_MUCH = 146, - PEEP_THOUGHT_TYPE_MEATBALL_SOUP_MUCH = 147, - PEEP_THOUGHT_TYPE_FRUIT_JUICE_MUCH = 148, - PEEP_THOUGHT_TYPE_SOYBEAN_MILK_MUCH = 149, - PEEP_THOUGHT_TYPE_SU_JONGKWA_MUCH = 150, - PEEP_THOUGHT_TYPE_SUB_SANDWICH_MUCH = 151, - PEEP_THOUGHT_TYPE_COOKIE_MUCH = 152, + PEEP_THOUGHT_TYPE_WONTON_SOUP_MUCH = 146, + PEEP_THOUGHT_TYPE_MEATBALL_SOUP_MUCH = 147, + PEEP_THOUGHT_TYPE_FRUIT_JUICE_MUCH = 148, + PEEP_THOUGHT_TYPE_SOYBEAN_MILK_MUCH = 149, + PEEP_THOUGHT_TYPE_SU_JONGKWA_MUCH = 150, + PEEP_THOUGHT_TYPE_SUB_SANDWICH_MUCH = 151, + PEEP_THOUGHT_TYPE_COOKIE_MUCH = 152, PEEP_THOUGHT_TYPE_ROAST_SAUSAGE_MUCH = 156, - PEEP_THOUGHT_TYPE_HELP = 168, // "Help! Put me down!" - PEEP_THOUGHT_TYPE_RUNNING_OUT = 169, // "I'm running out of cash!" - PEEP_THOUGHT_TYPE_NEW_RIDE = 170, // "Wow! A new ride being built!" + PEEP_THOUGHT_TYPE_HELP = 168, // "Help! Put me down!" + PEEP_THOUGHT_TYPE_RUNNING_OUT = 169, // "I'm running out of cash!" + PEEP_THOUGHT_TYPE_NEW_RIDE = 170, // "Wow! A new ride being built!" PEEP_THOUGHT_TYPE_NICE_RIDE_DEPRECATED = 171, // "Nice ride! But not as good as the Phoenix..." - PEEP_THOUGHT_TYPE_EXCITED_DEPRECATED = 172, // "I'm so excited - It's an Intamin ride!" - PEEP_THOUGHT_TYPE_HERE_WE_ARE = 173, // "...and here we are on X!" + PEEP_THOUGHT_TYPE_EXCITED_DEPRECATED = 172, // "I'm so excited - It's an Intamin ride!" + PEEP_THOUGHT_TYPE_HERE_WE_ARE = 173, // "...and here we are on X!" PEEP_THOUGHT_TYPE_NONE = 255 }; enum PEEP_STATE { - PEEP_STATE_FALLING = 0, // Drowning is part of falling - PEEP_STATE_1 = 1, - PEEP_STATE_QUEUING_FRONT = 2, - PEEP_STATE_ON_RIDE = 3, - PEEP_STATE_LEAVING_RIDE = 4, - PEEP_STATE_WALKING = 5, - PEEP_STATE_QUEUING = 6, - PEEP_STATE_ENTERING_RIDE = 7, - PEEP_STATE_SITTING = 8, - PEEP_STATE_PICKED = 9, - PEEP_STATE_PATROLLING = 10, // Not sure - PEEP_STATE_MOWING = 11, - PEEP_STATE_SWEEPING = 12, - PEEP_STATE_ENTERING_PARK = 13, - PEEP_STATE_LEAVING_PARK = 14, - PEEP_STATE_ANSWERING = 15, - PEEP_STATE_FIXING = 16, - PEEP_STATE_BUYING = 17, - PEEP_STATE_WATCHING = 18, - PEEP_STATE_EMPTYING_BIN = 19, - PEEP_STATE_USING_BIN = 20, - PEEP_STATE_WATERING = 21, + PEEP_STATE_FALLING = 0, // Drowning is part of falling + PEEP_STATE_1 = 1, + PEEP_STATE_QUEUING_FRONT = 2, + PEEP_STATE_ON_RIDE = 3, + PEEP_STATE_LEAVING_RIDE = 4, + PEEP_STATE_WALKING = 5, + PEEP_STATE_QUEUING = 6, + PEEP_STATE_ENTERING_RIDE = 7, + PEEP_STATE_SITTING = 8, + PEEP_STATE_PICKED = 9, + PEEP_STATE_PATROLLING = 10, // Not sure + PEEP_STATE_MOWING = 11, + PEEP_STATE_SWEEPING = 12, + PEEP_STATE_ENTERING_PARK = 13, + PEEP_STATE_LEAVING_PARK = 14, + PEEP_STATE_ANSWERING = 15, + PEEP_STATE_FIXING = 16, + PEEP_STATE_BUYING = 17, + PEEP_STATE_WATCHING = 18, + PEEP_STATE_EMPTYING_BIN = 19, + PEEP_STATE_USING_BIN = 20, + PEEP_STATE_WATERING = 21, PEEP_STATE_HEADING_TO_INSPECTION = 22, - PEEP_STATE_INSPECTING = 23 + PEEP_STATE_INSPECTING = 23 }; enum PEEP_SITTING_SUB_STATE @@ -222,8 +222,8 @@ enum PEEP_RIDE_SUB_STATE { PEEP_RIDE_AT_ENTRANCE = 0, PEEP_RIDE_IN_ENTRANCE = 1, - PEEP_RIDE_FREE_VEHICLE_CHECK = 2, //Spend money on ride - PEEP_RIDE_LEAVE_ENTRANCE = 3, // Calculate what direction and where to go after commiting to entering vehicle + PEEP_RIDE_FREE_VEHICLE_CHECK = 2, // Spend money on ride + PEEP_RIDE_LEAVE_ENTRANCE = 3, // Calculate what direction and where to go after commiting to entering vehicle PEEP_RIDE_APPROACH_VEHICLE = 4, PEEP_RIDE_ENTER_VEHICLE = 5, PEEP_RIDE_ON_RIDE = 6, @@ -253,37 +253,37 @@ enum PEEP_ACTION_EVENTS { PEEP_ACTION_CHECK_TIME = 0, // If no food then check watch - PEEP_ACTION_EAT_FOOD = 1, - PEEP_ACTION_SHAKE_HEAD = 2, - PEEP_ACTION_EMPTY_POCKETS = 3, - PEEP_ACTION_SITTING_EAT_FOOD = 4, - PEEP_ACTION_SITTING_CHECK_WATCH = 4, - PEEP_ACTION_SITTING_LOOK_AROUND_LEFT = 5, + PEEP_ACTION_EAT_FOOD = 1, + PEEP_ACTION_SHAKE_HEAD = 2, + PEEP_ACTION_EMPTY_POCKETS = 3, + PEEP_ACTION_SITTING_EAT_FOOD = 4, + PEEP_ACTION_SITTING_CHECK_WATCH = 4, + PEEP_ACTION_SITTING_LOOK_AROUND_LEFT = 5, PEEP_ACTION_SITTING_LOOK_AROUND_RIGHT = 6, - PEEP_ACTION_WOW = 7, - PEEP_ACTION_THROW_UP = 8, - PEEP_ACTION_JUMP = 9, - PEEP_ACTION_STAFF_SWEEP = 10, - PEEP_ACTION_DROWNING = 11, - PEEP_ACTION_STAFF_ANSWER_CALL = 12, - PEEP_ACTION_STAFF_ANSWER_CALL_2 = 13, - PEEP_ACTION_STAFF_CHECKBOARD = 14, - PEEP_ACTION_STAFF_FIX = 15, - PEEP_ACTION_STAFF_FIX_2 = 16, - PEEP_ACTION_STAFF_FIX_GROUND = 17, - PEEP_ACTION_STAFF_FIX_3 = 18, - PEEP_ACTION_STAFF_WATERING = 19, - PEEP_ACTION_JOY = 20, - PEEP_ACTION_READ_MAP = 21, - PEEP_ACTION_WAVE = 22, - PEEP_ACTION_STAFF_EMPTY_BIN = 23, - PEEP_ACTION_WAVE_2 = 24, - PEEP_ACTION_TAKE_PHOTO = 25, - PEEP_ACTION_CLAP = 26, - PEEP_ACTION_DISGUST = 27, - PEEP_ACTION_DRAW_PICTURE = 28, - PEEP_ACTION_BEING_WATCHED = 29, - PEEP_ACTION_WITHDRAW_MONEY = 30, + PEEP_ACTION_WOW = 7, + PEEP_ACTION_THROW_UP = 8, + PEEP_ACTION_JUMP = 9, + PEEP_ACTION_STAFF_SWEEP = 10, + PEEP_ACTION_DROWNING = 11, + PEEP_ACTION_STAFF_ANSWER_CALL = 12, + PEEP_ACTION_STAFF_ANSWER_CALL_2 = 13, + PEEP_ACTION_STAFF_CHECKBOARD = 14, + PEEP_ACTION_STAFF_FIX = 15, + PEEP_ACTION_STAFF_FIX_2 = 16, + PEEP_ACTION_STAFF_FIX_GROUND = 17, + PEEP_ACTION_STAFF_FIX_3 = 18, + PEEP_ACTION_STAFF_WATERING = 19, + PEEP_ACTION_JOY = 20, + PEEP_ACTION_READ_MAP = 21, + PEEP_ACTION_WAVE = 22, + PEEP_ACTION_STAFF_EMPTY_BIN = 23, + PEEP_ACTION_WAVE_2 = 24, + PEEP_ACTION_TAKE_PHOTO = 25, + PEEP_ACTION_CLAP = 26, + PEEP_ACTION_DISGUST = 27, + PEEP_ACTION_DRAW_PICTURE = 28, + PEEP_ACTION_BEING_WATCHED = 29, + PEEP_ACTION_WITHDRAW_MONEY = 30, PEEP_ACTION_NONE_1 = 254, PEEP_ACTION_NONE_2 = 255 @@ -291,79 +291,79 @@ enum PEEP_ACTION_EVENTS enum PEEP_ACTION_SPRITE_TYPE { - PEEP_ACTION_SPRITE_TYPE_NONE = 0, - PEEP_ACTION_SPRITE_TYPE_CHECK_TIME = 1, - PEEP_ACTION_SPRITE_TYPE_2 = 2, - PEEP_ACTION_SPRITE_TYPE_EAT_FOOD = 3, - PEEP_ACTION_SPRITE_TYPE_SHAKE_HEAD = 4, - PEEP_ACTION_SPRITE_TYPE_EMPTY_POCKETS = 5, - PEEP_ACTION_SPRITE_TYPE_HOLD_MAT = 6, - PEEP_ACTION_SPRITE_TYPE_7 = 7, - PEEP_ACTION_SPRITE_TYPE_SITTING_EAT_FOOD = 8, - PEEP_ACTION_SPRITE_TYPE_SITTING_LOOK_AROUND_LEFT = 9, + PEEP_ACTION_SPRITE_TYPE_NONE = 0, + PEEP_ACTION_SPRITE_TYPE_CHECK_TIME = 1, + PEEP_ACTION_SPRITE_TYPE_2 = 2, + PEEP_ACTION_SPRITE_TYPE_EAT_FOOD = 3, + PEEP_ACTION_SPRITE_TYPE_SHAKE_HEAD = 4, + PEEP_ACTION_SPRITE_TYPE_EMPTY_POCKETS = 5, + PEEP_ACTION_SPRITE_TYPE_HOLD_MAT = 6, + PEEP_ACTION_SPRITE_TYPE_7 = 7, + PEEP_ACTION_SPRITE_TYPE_SITTING_EAT_FOOD = 8, + PEEP_ACTION_SPRITE_TYPE_SITTING_LOOK_AROUND_LEFT = 9, PEEP_ACTION_SPRITE_TYPE_SITTING_LOOK_AROUND_RIGHT = 10, - PEEP_ACTION_SPRITE_TYPE_UI = 11, - PEEP_ACTION_SPRITE_TYPE_STAFF_MOWER = 12, - PEEP_ACTION_SPRITE_TYPE_WOW = 13, - PEEP_ACTION_SPRITE_TYPE_THROW_UP = 14, - PEEP_ACTION_SPRITE_TYPE_JUMP = 15, - PEEP_ACTION_SPRITE_TYPE_STAFF_SWEEP = 16, - PEEP_ACTION_SPRITE_TYPE_DROWNING = 17, - PEEP_ACTION_SPRITE_TYPE_STAFF_ANSWER_CALL = 18, - PEEP_ACTION_SPRITE_TYPE_STAFF_ANSWER_CALL_2 = 19, - PEEP_ACTION_SPRITE_TYPE_STAFF_CHECKBOARD = 20, - PEEP_ACTION_SPRITE_TYPE_STAFF_FIX = 21, - PEEP_ACTION_SPRITE_TYPE_STAFF_FIX_2 = 22, - PEEP_ACTION_SPRITE_TYPE_STAFF_FIX_GROUND = 23, - PEEP_ACTION_SPRITE_TYPE_STAFF_FIX_3 = 24, - PEEP_ACTION_SPRITE_TYPE_STAFF_WATERING = 25, - PEEP_ACTION_SPRITE_TYPE_JOY = 26, - PEEP_ACTION_SPRITE_TYPE_READ_MAP = 27, - PEEP_ACTION_SPRITE_TYPE_WAVE = 28, - PEEP_ACTION_SPRITE_TYPE_STAFF_EMPTY_BIN = 29, - PEEP_ACTION_SPRITE_TYPE_WAVE_2 = 30, - PEEP_ACTION_SPRITE_TYPE_TAKE_PHOTO = 31, - PEEP_ACTION_SPRITE_TYPE_CLAP = 32, - PEEP_ACTION_SPRITE_TYPE_DISGUST = 33, - PEEP_ACTION_SPRITE_TYPE_DRAW_PICTURE = 34, - PEEP_ACTION_SPRITE_TYPE_BEING_WATCHED = 35, - PEEP_ACTION_SPRITE_TYPE_WITHDRAW_MONEY = 36 + PEEP_ACTION_SPRITE_TYPE_UI = 11, + PEEP_ACTION_SPRITE_TYPE_STAFF_MOWER = 12, + PEEP_ACTION_SPRITE_TYPE_WOW = 13, + PEEP_ACTION_SPRITE_TYPE_THROW_UP = 14, + PEEP_ACTION_SPRITE_TYPE_JUMP = 15, + PEEP_ACTION_SPRITE_TYPE_STAFF_SWEEP = 16, + PEEP_ACTION_SPRITE_TYPE_DROWNING = 17, + PEEP_ACTION_SPRITE_TYPE_STAFF_ANSWER_CALL = 18, + PEEP_ACTION_SPRITE_TYPE_STAFF_ANSWER_CALL_2 = 19, + PEEP_ACTION_SPRITE_TYPE_STAFF_CHECKBOARD = 20, + PEEP_ACTION_SPRITE_TYPE_STAFF_FIX = 21, + PEEP_ACTION_SPRITE_TYPE_STAFF_FIX_2 = 22, + PEEP_ACTION_SPRITE_TYPE_STAFF_FIX_GROUND = 23, + PEEP_ACTION_SPRITE_TYPE_STAFF_FIX_3 = 24, + PEEP_ACTION_SPRITE_TYPE_STAFF_WATERING = 25, + PEEP_ACTION_SPRITE_TYPE_JOY = 26, + PEEP_ACTION_SPRITE_TYPE_READ_MAP = 27, + PEEP_ACTION_SPRITE_TYPE_WAVE = 28, + PEEP_ACTION_SPRITE_TYPE_STAFF_EMPTY_BIN = 29, + PEEP_ACTION_SPRITE_TYPE_WAVE_2 = 30, + PEEP_ACTION_SPRITE_TYPE_TAKE_PHOTO = 31, + PEEP_ACTION_SPRITE_TYPE_CLAP = 32, + PEEP_ACTION_SPRITE_TYPE_DISGUST = 33, + PEEP_ACTION_SPRITE_TYPE_DRAW_PICTURE = 34, + PEEP_ACTION_SPRITE_TYPE_BEING_WATCHED = 35, + PEEP_ACTION_SPRITE_TYPE_WITHDRAW_MONEY = 36 }; enum PEEP_FLAGS : uint32_t { - PEEP_FLAGS_LEAVING_PARK = (1 << 0), - PEEP_FLAGS_SLOW_WALK = (1 << 1), - PEEP_FLAGS_2 = (1 << 2), - PEEP_FLAGS_TRACKING = (1 << 3), - PEEP_FLAGS_WAVING = (1 << 4), // Makes the peep wave - PEEP_FLAGS_HAS_PAID_FOR_PARK_ENTRY = (1 << 5), // Set on paying to enter park - PEEP_FLAGS_PHOTO = (1 << 6), // Makes the peep take a picture - PEEP_FLAGS_PAINTING = (1 << 7), - PEEP_FLAGS_WOW = (1 << 8), // Makes a peep WOW2 - PEEP_FLAGS_LITTER = (1 << 9), // Makes the peep throw litter - PEEP_FLAGS_LOST = (1 << 10), // Makes the peep feel lost (animation triggered) - PEEP_FLAGS_HUNGER = (1 << 11), // Makes the peep become hungry quicker - PEEP_FLAGS_BATHROOM = (1 << 12), // Makes the peep want to go to the bathroom - PEEP_FLAGS_CROWDED = (1 << 13), // The peep will start feeling crowded - PEEP_FLAGS_HAPPINESS = (1 << 14), // The peep will start increasing happiness - PEEP_FLAGS_NAUSEA = (1 << 15), // Makes the peep feel sick (e.g. after an extreme ride) - PEEP_FLAGS_PURPLE = (1 << 16), // Makes surrounding peeps purple - PEEP_FLAGS_PIZZA = (1 << 17), // Gives passing peeps pizza - PEEP_FLAGS_EXPLODE = (1 << 18), + PEEP_FLAGS_LEAVING_PARK = (1 << 0), + PEEP_FLAGS_SLOW_WALK = (1 << 1), + PEEP_FLAGS_2 = (1 << 2), + PEEP_FLAGS_TRACKING = (1 << 3), + PEEP_FLAGS_WAVING = (1 << 4), // Makes the peep wave + PEEP_FLAGS_HAS_PAID_FOR_PARK_ENTRY = (1 << 5), // Set on paying to enter park + PEEP_FLAGS_PHOTO = (1 << 6), // Makes the peep take a picture + PEEP_FLAGS_PAINTING = (1 << 7), + PEEP_FLAGS_WOW = (1 << 8), // Makes a peep WOW2 + PEEP_FLAGS_LITTER = (1 << 9), // Makes the peep throw litter + PEEP_FLAGS_LOST = (1 << 10), // Makes the peep feel lost (animation triggered) + PEEP_FLAGS_HUNGER = (1 << 11), // Makes the peep become hungry quicker + PEEP_FLAGS_BATHROOM = (1 << 12), // Makes the peep want to go to the bathroom + PEEP_FLAGS_CROWDED = (1 << 13), // The peep will start feeling crowded + PEEP_FLAGS_HAPPINESS = (1 << 14), // The peep will start increasing happiness + PEEP_FLAGS_NAUSEA = (1 << 15), // Makes the peep feel sick (e.g. after an extreme ride) + PEEP_FLAGS_PURPLE = (1 << 16), // Makes surrounding peeps purple + PEEP_FLAGS_PIZZA = (1 << 17), // Gives passing peeps pizza + PEEP_FLAGS_EXPLODE = (1 << 18), PEEP_FLAGS_RIDE_SHOULD_BE_MARKED_AS_FAVOURITE = (1 << 19), PEEP_FLAGS_PARK_ENTRANCE_CHOSEN = (1 << 20), // Set when the nearest park entrance has been chosen - PEEP_FLAGS_21 = (1 << 21), + PEEP_FLAGS_21 = (1 << 21), PEEP_FLAGS_CONTAGIOUS = (1 << 22), // Makes any peeps in surrounding tiles sick - PEEP_FLAGS_JOY = (1 << 23), // Makes the peep jump in joy - PEEP_FLAGS_ANGRY = (1 << 24), - PEEP_FLAGS_ICE_CREAM = (1 << 25), // Gives passing peeps ice cream and they wave back - PEEP_FLAGS_NICE_RIDE_DEPRECATED = - (1 << 26), // Used to make the peep think "Nice ride! But not as good as the Phoenix..." on exiting a ride - PEEP_FLAGS_INTAMIN_DEPRECATED = - (1 << 27), // Used to make the peep think "I'm so excited - It's an Intamin ride!" while riding on a Intamin ride. + PEEP_FLAGS_JOY = (1 << 23), // Makes the peep jump in joy + PEEP_FLAGS_ANGRY = (1 << 24), + PEEP_FLAGS_ICE_CREAM = (1 << 25), // Gives passing peeps ice cream and they wave back + PEEP_FLAGS_NICE_RIDE_DEPRECATED + = (1 << 26), // Used to make the peep think "Nice ride! But not as good as the Phoenix..." on exiting a ride + PEEP_FLAGS_INTAMIN_DEPRECATED + = (1 << 27), // Used to make the peep think "I'm so excited - It's an Intamin ride!" while riding on a Intamin ride. PEEP_FLAGS_HERE_WE_ARE = (1 << 28), // Makes the peep think "...and here we are on X!" while riding a ride - PEEP_FLAGS_TWITCH = (1u << 31) // Added for twitch integration + PEEP_FLAGS_TWITCH = (1u << 31) // Added for twitch integration }; enum PEEP_NEXT_FLAGS @@ -385,121 +385,121 @@ enum PEEP_NAUSEA_TOLERANCE enum PEEP_ITEM { // item_standard_flags - PEEP_ITEM_BALLOON = (1 << 0), - PEEP_ITEM_TOY = (1 << 1), - PEEP_ITEM_MAP = (1 << 2), - PEEP_ITEM_PHOTO = (1 << 3), - PEEP_ITEM_UMBRELLA = (1 << 4), - PEEP_ITEM_DRINK = (1 << 5), - PEEP_ITEM_BURGER = (1 << 6), - PEEP_ITEM_CHIPS = (1 << 7), - PEEP_ITEM_ICE_CREAM = (1 << 8), - PEEP_ITEM_CANDYFLOSS = (1 << 9), - PEEP_ITEM_EMPTY_CAN = (1 << 10), - PEEP_ITEM_RUBBISH = (1 << 11), + PEEP_ITEM_BALLOON = (1 << 0), + PEEP_ITEM_TOY = (1 << 1), + PEEP_ITEM_MAP = (1 << 2), + PEEP_ITEM_PHOTO = (1 << 3), + PEEP_ITEM_UMBRELLA = (1 << 4), + PEEP_ITEM_DRINK = (1 << 5), + PEEP_ITEM_BURGER = (1 << 6), + PEEP_ITEM_CHIPS = (1 << 7), + PEEP_ITEM_ICE_CREAM = (1 << 8), + PEEP_ITEM_CANDYFLOSS = (1 << 9), + PEEP_ITEM_EMPTY_CAN = (1 << 10), + PEEP_ITEM_RUBBISH = (1 << 11), PEEP_ITEM_EMPTY_BURGER_BOX = (1 << 12), - PEEP_ITEM_PIZZA = (1 << 13), - PEEP_ITEM_VOUCHER = (1 << 14), - PEEP_ITEM_POPCORN = (1 << 15), - PEEP_ITEM_HOT_DOG = (1 << 16), - PEEP_ITEM_TENTACLE = (1 << 17), - PEEP_ITEM_HAT = (1 << 18), - PEEP_ITEM_TOFFEE_APPLE = (1 << 19), - PEEP_ITEM_TSHIRT = (1 << 20), - PEEP_ITEM_DOUGHNUT = (1 << 21), - PEEP_ITEM_COFFEE = (1 << 22), - PEEP_ITEM_EMPTY_CUP = (1 << 23), - PEEP_ITEM_CHICKEN = (1 << 24), - PEEP_ITEM_LEMONADE = (1 << 25), - PEEP_ITEM_EMPTY_BOX = (1 << 26), - PEEP_ITEM_EMPTY_BOTTLE = (1 << 27), + PEEP_ITEM_PIZZA = (1 << 13), + PEEP_ITEM_VOUCHER = (1 << 14), + PEEP_ITEM_POPCORN = (1 << 15), + PEEP_ITEM_HOT_DOG = (1 << 16), + PEEP_ITEM_TENTACLE = (1 << 17), + PEEP_ITEM_HAT = (1 << 18), + PEEP_ITEM_TOFFEE_APPLE = (1 << 19), + PEEP_ITEM_TSHIRT = (1 << 20), + PEEP_ITEM_DOUGHNUT = (1 << 21), + PEEP_ITEM_COFFEE = (1 << 22), + PEEP_ITEM_EMPTY_CUP = (1 << 23), + PEEP_ITEM_CHICKEN = (1 << 24), + PEEP_ITEM_LEMONADE = (1 << 25), + PEEP_ITEM_EMPTY_BOX = (1 << 26), + PEEP_ITEM_EMPTY_BOTTLE = (1 << 27), // item_extra_flags - PEEP_ITEM_PHOTO2 = (1 << 0), - PEEP_ITEM_PHOTO3 = (1 << 1), - PEEP_ITEM_PHOTO4 = (1 << 2), - PEEP_ITEM_PRETZEL = (1 << 3), - PEEP_ITEM_CHOCOLATE = (1 << 4), - PEEP_ITEM_ICED_TEA = (1 << 5), - PEEP_ITEM_FUNNEL_CAKE = (1 << 6), - PEEP_ITEM_SUNGLASSES = (1 << 7), - PEEP_ITEM_BEEF_NOODLES = (1 << 8), + PEEP_ITEM_PHOTO2 = (1 << 0), + PEEP_ITEM_PHOTO3 = (1 << 1), + PEEP_ITEM_PHOTO4 = (1 << 2), + PEEP_ITEM_PRETZEL = (1 << 3), + PEEP_ITEM_CHOCOLATE = (1 << 4), + PEEP_ITEM_ICED_TEA = (1 << 5), + PEEP_ITEM_FUNNEL_CAKE = (1 << 6), + PEEP_ITEM_SUNGLASSES = (1 << 7), + PEEP_ITEM_BEEF_NOODLES = (1 << 8), PEEP_ITEM_FRIED_RICE_NOODLES = (1 << 9), - PEEP_ITEM_WONTON_SOUP = (1 << 10), - PEEP_ITEM_MEATBALL_SOUP = (1 << 11), - PEEP_ITEM_FRUIT_JUICE = (1 << 12), - PEEP_ITEM_SOYBEAN_MILK = (1 << 13), - PEEP_ITEM_SU_JONGKWA = (1 << 14), - PEEP_ITEM_SUB_SANDWICH = (1 << 15), - PEEP_ITEM_COOKIE = (1 << 16), - PEEP_ITEM_EMPTY_BOWL_RED = (1 << 17), + PEEP_ITEM_WONTON_SOUP = (1 << 10), + PEEP_ITEM_MEATBALL_SOUP = (1 << 11), + PEEP_ITEM_FRUIT_JUICE = (1 << 12), + PEEP_ITEM_SOYBEAN_MILK = (1 << 13), + PEEP_ITEM_SU_JONGKWA = (1 << 14), + PEEP_ITEM_SUB_SANDWICH = (1 << 15), + PEEP_ITEM_COOKIE = (1 << 16), + PEEP_ITEM_EMPTY_BOWL_RED = (1 << 17), PEEP_ITEM_EMPTY_DRINK_CARTON = (1 << 18), - PEEP_ITEM_EMPTY_JUICE_CUP = (1 << 19), - PEEP_ITEM_ROAST_SAUSAGE = (1 << 20), - PEEP_ITEM_EMPTY_BOWL_BLUE = (1 << 21) + PEEP_ITEM_EMPTY_JUICE_CUP = (1 << 19), + PEEP_ITEM_ROAST_SAUSAGE = (1 << 20), + PEEP_ITEM_EMPTY_BOWL_BLUE = (1 << 21) }; enum PEEP_SPRITE_TYPE { - PEEP_SPRITE_TYPE_NORMAL = 0, - PEEP_SPRITE_TYPE_HANDYMAN = 1, - PEEP_SPRITE_TYPE_MECHANIC = 2, - PEEP_SPRITE_TYPE_SECURITY = 3, - PEEP_SPRITE_TYPE_ENTERTAINER_PANDA = 4, - PEEP_SPRITE_TYPE_ENTERTAINER_TIGER = 5, - PEEP_SPRITE_TYPE_ENTERTAINER_ELEPHANT = 6, - PEEP_SPRITE_TYPE_ENTERTAINER_ROMAN = 7, - PEEP_SPRITE_TYPE_ENTERTAINER_GORILLA = 8, - PEEP_SPRITE_TYPE_ENTERTAINER_SNOWMAN = 9, - PEEP_SPRITE_TYPE_ENTERTAINER_KNIGHT = 10, + PEEP_SPRITE_TYPE_NORMAL = 0, + PEEP_SPRITE_TYPE_HANDYMAN = 1, + PEEP_SPRITE_TYPE_MECHANIC = 2, + PEEP_SPRITE_TYPE_SECURITY = 3, + PEEP_SPRITE_TYPE_ENTERTAINER_PANDA = 4, + PEEP_SPRITE_TYPE_ENTERTAINER_TIGER = 5, + PEEP_SPRITE_TYPE_ENTERTAINER_ELEPHANT = 6, + PEEP_SPRITE_TYPE_ENTERTAINER_ROMAN = 7, + PEEP_SPRITE_TYPE_ENTERTAINER_GORILLA = 8, + PEEP_SPRITE_TYPE_ENTERTAINER_SNOWMAN = 9, + PEEP_SPRITE_TYPE_ENTERTAINER_KNIGHT = 10, PEEP_SPRITE_TYPE_ENTERTAINER_ASTRONAUT = 11, - PEEP_SPRITE_TYPE_ENTERTAINER_BANDIT = 12, - PEEP_SPRITE_TYPE_ENTERTAINER_SHERIFF = 13, - PEEP_SPRITE_TYPE_ENTERTAINER_PIRATE = 14, - PEEP_SPRITE_TYPE_ICE_CREAM = 15, - PEEP_SPRITE_TYPE_CHIPS = 16, - PEEP_SPRITE_TYPE_BURGER = 17, - PEEP_SPRITE_TYPE_DRINK = 18, - PEEP_SPRITE_TYPE_BALLOON = 19, - PEEP_SPRITE_TYPE_CANDYFLOSS = 20, - PEEP_SPRITE_TYPE_UMBRELLA = 21, - PEEP_SPRITE_TYPE_PIZZA = 22, - PEEP_SPRITE_TYPE_SECURITY_ALT = 23, - PEEP_SPRITE_TYPE_POPCORN = 24, - PEEP_SPRITE_TYPE_ARMS_CROSSED = 25, - PEEP_SPRITE_TYPE_HEAD_DOWN = 26, - PEEP_SPRITE_TYPE_NAUSEOUS = 27, - PEEP_SPRITE_TYPE_VERY_NAUSEOUS = 28, - PEEP_SPRITE_TYPE_REQUIRE_BATHROOM = 29, - PEEP_SPRITE_TYPE_HAT = 30, - PEEP_SPRITE_TYPE_HOT_DOG = 31, - PEEP_SPRITE_TYPE_TENTACLE = 32, - PEEP_SPRITE_TYPE_TOFFEE_APPLE = 33, - PEEP_SPRITE_TYPE_DOUGHNUT = 34, - PEEP_SPRITE_TYPE_COFFEE = 35, - PEEP_SPRITE_TYPE_CHICKEN = 36, - PEEP_SPRITE_TYPE_LEMONADE = 37, - PEEP_SPRITE_TYPE_WATCHING = 38, - PEEP_SPRITE_TYPE_PRETZEL = 39, - PEEP_SPRITE_TYPE_SUNGLASSES = 40, - PEEP_SPRITE_TYPE_SU_JONGKWA = 41, - PEEP_SPRITE_TYPE_JUICE = 42, - PEEP_SPRITE_TYPE_FUNNEL_CAKE = 43, - PEEP_SPRITE_TYPE_NOODLES = 44, - PEEP_SPRITE_TYPE_SAUSAGE = 45, - PEEP_SPRITE_TYPE_SOUP = 46, - PEEP_SPRITE_TYPE_SANDWICH = 47, + PEEP_SPRITE_TYPE_ENTERTAINER_BANDIT = 12, + PEEP_SPRITE_TYPE_ENTERTAINER_SHERIFF = 13, + PEEP_SPRITE_TYPE_ENTERTAINER_PIRATE = 14, + PEEP_SPRITE_TYPE_ICE_CREAM = 15, + PEEP_SPRITE_TYPE_CHIPS = 16, + PEEP_SPRITE_TYPE_BURGER = 17, + PEEP_SPRITE_TYPE_DRINK = 18, + PEEP_SPRITE_TYPE_BALLOON = 19, + PEEP_SPRITE_TYPE_CANDYFLOSS = 20, + PEEP_SPRITE_TYPE_UMBRELLA = 21, + PEEP_SPRITE_TYPE_PIZZA = 22, + PEEP_SPRITE_TYPE_SECURITY_ALT = 23, + PEEP_SPRITE_TYPE_POPCORN = 24, + PEEP_SPRITE_TYPE_ARMS_CROSSED = 25, + PEEP_SPRITE_TYPE_HEAD_DOWN = 26, + PEEP_SPRITE_TYPE_NAUSEOUS = 27, + PEEP_SPRITE_TYPE_VERY_NAUSEOUS = 28, + PEEP_SPRITE_TYPE_REQUIRE_BATHROOM = 29, + PEEP_SPRITE_TYPE_HAT = 30, + PEEP_SPRITE_TYPE_HOT_DOG = 31, + PEEP_SPRITE_TYPE_TENTACLE = 32, + PEEP_SPRITE_TYPE_TOFFEE_APPLE = 33, + PEEP_SPRITE_TYPE_DOUGHNUT = 34, + PEEP_SPRITE_TYPE_COFFEE = 35, + PEEP_SPRITE_TYPE_CHICKEN = 36, + PEEP_SPRITE_TYPE_LEMONADE = 37, + PEEP_SPRITE_TYPE_WATCHING = 38, + PEEP_SPRITE_TYPE_PRETZEL = 39, + PEEP_SPRITE_TYPE_SUNGLASSES = 40, + PEEP_SPRITE_TYPE_SU_JONGKWA = 41, + PEEP_SPRITE_TYPE_JUICE = 42, + PEEP_SPRITE_TYPE_FUNNEL_CAKE = 43, + PEEP_SPRITE_TYPE_NOODLES = 44, + PEEP_SPRITE_TYPE_SAUSAGE = 45, + PEEP_SPRITE_TYPE_SOUP = 46, + PEEP_SPRITE_TYPE_SANDWICH = 47, PEEP_SPRITE_TYPE_COUNT }; // Flags used by peep->window_invalidate_flags enum PEEP_INVALIDATE { - PEEP_INVALIDATE_PEEP_THOUGHTS = 1, - PEEP_INVALIDATE_PEEP_STATS = 1 << 1, - PEEP_INVALIDATE_PEEP_2 = 1 << 2, + PEEP_INVALIDATE_PEEP_THOUGHTS = 1, + PEEP_INVALIDATE_PEEP_STATS = 1 << 1, + PEEP_INVALIDATE_PEEP_2 = 1 << 2, PEEP_INVALIDATE_PEEP_INVENTORY = 1 << 3, - PEEP_INVALIDATE_STAFF_STATS = 1 << 4, + PEEP_INVALIDATE_STAFF_STATS = 1 << 4, }; // Flags used by peep_should_go_on_ride() @@ -512,83 +512,85 @@ enum PEEP_RIDE_DECISION #pragma pack(push, 1) struct rct_peep_thought { - uint8_t type; // 0 - uint8_t item; // 1 - uint8_t freshness; // 2 larger is less fresh + uint8_t type; // 0 + uint8_t item; // 1 + uint8_t freshness; // 2 larger is less fresh uint8_t fresh_timeout; // 3 updates every tick }; assert_struct_size(rct_peep_thought, 4); struct rct_peep { - uint8_t sprite_identifier; // 0x00 - uint8_t misc_identifier; // 0x01 - uint16_t next_in_quadrant; // 0x02 - uint16_t next; // 0x04 - uint16_t previous; // 0x06 - uint8_t linked_list_type_offset; // 0x08 Valid values are SPRITE_LINKEDLIST_OFFSET_... + uint8_t sprite_identifier; // 0x00 + uint8_t misc_identifier; // 0x01 + uint16_t next_in_quadrant; // 0x02 + uint16_t next; // 0x04 + uint16_t previous; // 0x06 + uint8_t linked_list_type_offset; // 0x08 Valid values are SPRITE_LINKEDLIST_OFFSET_... // Height from centre of sprite to bottom - uint8_t sprite_height_negative; // 0x09 - uint16_t sprite_index; // 0x0A - uint16_t flags; // 0x0C + uint8_t sprite_height_negative; // 0x09 + uint16_t sprite_index; // 0x0A + uint16_t flags; // 0x0C int16_t x; // 0x0E int16_t y; // 0x10 int16_t z; // 0x12 // Width from centre of sprite to edge uint8_t sprite_width; // 0x14 // Height from centre of sprite to top - uint8_t sprite_height_positive; // 0x15 - int16_t sprite_left; // 0x16 - int16_t sprite_top; // 0x18 - int16_t sprite_right; // 0x1A - int16_t sprite_bottom; // 0x1C - uint8_t sprite_direction; // 0x1E - uint8_t pad_1F[3]; + uint8_t sprite_height_positive; // 0x15 + int16_t sprite_left; // 0x16 + int16_t sprite_top; // 0x18 + int16_t sprite_right; // 0x1A + int16_t sprite_bottom; // 0x1C + uint8_t sprite_direction; // 0x1E + uint8_t pad_1F[3]; rct_string_id name_string_idx; // 0x22 - uint16_t next_x; // 0x24 - uint16_t next_y; // 0x26 - uint8_t next_z; // 0x28 - uint8_t next_flags; // 0x29 - uint8_t outside_of_park; // 0x2A - uint8_t state; // 0x2B - uint8_t sub_state; // 0x2C - uint8_t sprite_type; // 0x2D - uint8_t type; // 0x2E - union { + uint16_t next_x; // 0x24 + uint16_t next_y; // 0x26 + uint8_t next_z; // 0x28 + uint8_t next_flags; // 0x29 + uint8_t outside_of_park; // 0x2A + uint8_t state; // 0x2B + uint8_t sub_state; // 0x2C + uint8_t sprite_type; // 0x2D + uint8_t type; // 0x2E + union + { uint8_t staff_type; // 0x2F uint8_t no_of_rides; // 0x2F }; - uint8_t tshirt_colour; // 0x30 - uint8_t trousers_colour; // 0x31 - uint16_t destination_x; // 0x32 Location that the peep is trying to get to - uint16_t destination_y; // 0x34 - uint8_t destination_tolerance; // 0x36 How close to destination before next action/state 0 = exact - uint8_t var_37; - uint8_t energy; // 0x38 - uint8_t energy_target; // 0x39 - uint8_t happiness; // 0x3A - uint8_t happiness_target; // 0x3B - uint8_t nausea; // 0x3C - uint8_t nausea_target; // 0x3D - uint8_t hunger; // 0x3E - uint8_t thirst; // 0x3F - uint8_t toilet; // 0x40 - uint8_t mass; // 0x41 - uint8_t time_to_consume; // 0x42 - uint8_t intensity; // 0x43 The max intensity is stored in the first 4 bits, and the min intensity in the second 4 bits - uint8_t nausea_tolerance; // 0x44 - uint8_t window_invalidate_flags; // 0x45 + uint8_t tshirt_colour; // 0x30 + uint8_t trousers_colour; // 0x31 + uint16_t destination_x; // 0x32 Location that the peep is trying to get to + uint16_t destination_y; // 0x34 + uint8_t destination_tolerance; // 0x36 How close to destination before next action/state 0 = exact + uint8_t var_37; + uint8_t energy; // 0x38 + uint8_t energy_target; // 0x39 + uint8_t happiness; // 0x3A + uint8_t happiness_target; // 0x3B + uint8_t nausea; // 0x3C + uint8_t nausea_target; // 0x3D + uint8_t hunger; // 0x3E + uint8_t thirst; // 0x3F + uint8_t toilet; // 0x40 + uint8_t mass; // 0x41 + uint8_t time_to_consume; // 0x42 + uint8_t intensity; // 0x43 The max intensity is stored in the first 4 bits, and the min intensity in the second 4 bits + uint8_t nausea_tolerance; // 0x44 + uint8_t window_invalidate_flags; // 0x45 money16 paid_on_drink; // 0x46 - uint8_t ride_types_been_on[16]; // 0x48 - uint32_t item_extra_flags; // 0x58 - uint8_t photo2_ride_ref; // 0x5C - uint8_t photo3_ride_ref; // 0x5D - uint8_t photo4_ride_ref; // 0x5E - uint8_t pad_5F[0x09]; // 0x5F - uint8_t current_ride; // 0x68 - uint8_t current_ride_station; // 0x69 - uint8_t current_train; // 0x6A - union { + uint8_t ride_types_been_on[16]; // 0x48 + uint32_t item_extra_flags; // 0x58 + uint8_t photo2_ride_ref; // 0x5C + uint8_t photo3_ride_ref; // 0x5D + uint8_t photo4_ride_ref; // 0x5E + uint8_t pad_5F[0x09]; // 0x5F + uint8_t current_ride; // 0x68 + uint8_t current_ride_station; // 0x69 + uint8_t current_train; // 0x6A + union + { struct { uint8_t current_car; // 0x6B @@ -611,90 +613,99 @@ struct rct_peep uint8_t action; // 0x71 uint8_t action_frame; // 0x72 uint8_t step_progress; // 0x73 - union { - uint16_t mechanic_time_since_call; // time getting to ride to fix - uint16_t next_in_queue; // 0x74 + union + { + uint16_t mechanic_time_since_call; // time getting to ride to fix + uint16_t next_in_queue; // 0x74 }; uint8_t pad_76; // Previously this was set to 0 but never used. uint8_t pad_77; - union { + union + { uint8_t maze_last_edge; // 0x78 uint8_t direction; // Direction ? }; - uint8_t interaction_ride_index; - uint16_t time_in_queue; // 0x7A - uint8_t rides_been_on[32]; // 0x7C + uint8_t interaction_ride_index; + uint16_t time_in_queue; // 0x7A + uint8_t rides_been_on[32]; // 0x7C // 255 bit bitmap of every ride the peep has been on see // window_peep_rides_update for how to use. - uint32_t id; // 0x9C - money32 cash_in_pocket; // 0xA0 - money32 cash_spent; // 0xA4 - int32_t time_in_park; // 0xA8 - int8_t rejoin_queue_timeout; // 0xAC whilst waiting for a free vehicle (or pair) in the entrance - uint8_t previous_ride; // 0xAD - uint16_t previous_ride_time_out; // 0xAE + uint32_t id; // 0x9C + money32 cash_in_pocket; // 0xA0 + money32 cash_spent; // 0xA4 + int32_t time_in_park; // 0xA8 + int8_t rejoin_queue_timeout; // 0xAC whilst waiting for a free vehicle (or pair) in the entrance + uint8_t previous_ride; // 0xAD + uint16_t previous_ride_time_out; // 0xAE rct_peep_thought thoughts[PEEP_MAX_THOUGHTS]; // 0xB0 - uint8_t path_check_optimisation; // 0xC4 see peep.checkForPath - union { + uint8_t path_check_optimisation; // 0xC4 see peep.checkForPath + union + { uint8_t staff_id; // 0xC5 uint8_t guest_heading_to_ride_id; // 0xC5 }; - union { + union + { uint8_t staff_orders; // 0xC6 uint8_t peep_is_lost_countdown; // 0xC6 }; - uint8_t photo1_ride_ref; // 0xC7 - uint32_t peep_flags; // 0xC8 + uint8_t photo1_ride_ref; // 0xC7 + uint32_t peep_flags; // 0xC8 rct12_xyzd8 pathfind_goal; // 0xCC rct12_xyzd8 pathfind_history[4]; // 0xD0 - uint8_t no_action_frame_num; // 0xE0 + uint8_t no_action_frame_num; // 0xE0 // 0x3F Litter Count split into lots of 3 with time, 0xC0 Time since last recalc uint8_t litter_count; // 0xE1 - union { - uint8_t time_on_ride; // 0xE2 - uint8_t staff_mowing_timeout; // 0xE2 + union + { + uint8_t time_on_ride; // 0xE2 + uint8_t staff_mowing_timeout; // 0xE2 }; // 0x3F Sick Count split into lots of 3 with time, 0xC0 Time since last recalc uint8_t disgusting_count; // 0xE3 - union { - money16 paid_to_enter; // 0xE4 - uint16_t staff_lawns_mown; // 0xE4 - uint16_t staff_rides_fixed; // 0xE4 + union + { + money16 paid_to_enter; // 0xE4 + uint16_t staff_lawns_mown; // 0xE4 + uint16_t staff_rides_fixed; // 0xE4 }; - union { - money16 paid_on_rides; // 0xE6 - uint16_t staff_gardens_watered; // 0xE6 - uint16_t staff_rides_inspected; // 0xE6 + union + { + money16 paid_on_rides; // 0xE6 + uint16_t staff_gardens_watered; // 0xE6 + uint16_t staff_rides_inspected; // 0xE6 }; - union { - money16 paid_on_food; // 0xE8 - uint16_t staff_litter_swept; // 0xE8 + union + { + money16 paid_on_food; // 0xE8 + uint16_t staff_litter_swept; // 0xE8 }; - union { - money16 paid_on_souvenirs; // 0xEA - uint16_t staff_bins_emptied; // 0xEA + union + { + money16 paid_on_souvenirs; // 0xEA + uint16_t staff_bins_emptied; // 0xEA }; - uint8_t no_of_food; // 0xEC - uint8_t no_of_drinks; // 0xED - uint8_t no_of_souvenirs; // 0xEE - uint8_t vandalism_seen; // 0xEF 0xC0 vandalism thought timeout, 0x3F vandalism tiles seen - uint8_t voucher_type; // 0xF0 - uint8_t voucher_arguments; // 0xF1 ride_id or string_offset_id - uint8_t surroundings_thought_timeout; // 0xF2 - uint8_t angriness; // 0xF3 - uint8_t time_lost; // 0xF4 the time the peep has been lost when it reaches 254 generates the lost thought - uint8_t days_in_queue; // 0xF5 - uint8_t balloon_colour; // 0xF6 - uint8_t umbrella_colour; // 0xF7 - uint8_t hat_colour; // 0xF8 - uint8_t favourite_ride; // 0xF9 - uint8_t favourite_ride_rating; // 0xFA - uint8_t pad_FB; + uint8_t no_of_food; // 0xEC + uint8_t no_of_drinks; // 0xED + uint8_t no_of_souvenirs; // 0xEE + uint8_t vandalism_seen; // 0xEF 0xC0 vandalism thought timeout, 0x3F vandalism tiles seen + uint8_t voucher_type; // 0xF0 + uint8_t voucher_arguments; // 0xF1 ride_id or string_offset_id + uint8_t surroundings_thought_timeout; // 0xF2 + uint8_t angriness; // 0xF3 + uint8_t time_lost; // 0xF4 the time the peep has been lost when it reaches 254 generates the lost thought + uint8_t days_in_queue; // 0xF5 + uint8_t balloon_colour; // 0xF6 + uint8_t umbrella_colour; // 0xF7 + uint8_t hat_colour; // 0xF8 + uint8_t favourite_ride; // 0xF9 + uint8_t favourite_ride_rating; // 0xFA + uint8_t pad_FB; uint32_t item_standard_flags; // 0xFC public: // Peep void Update(); - bool UpdateAction(int16_t * actionX, int16_t * actionY, int16_t * xy_distance); + bool UpdateAction(int16_t* actionX, int16_t* actionY, int16_t* xy_distance); bool UpdateAction(); void SetState(uint8_t new_state); void Remove(); @@ -710,6 +721,7 @@ public: // Peep void Pickup(); void PickupAbort(int32_t old_x); bool Place(TileCoordsXYZ location, bool apply); + public: // Guest void Tick128UpdateGuest(int32_t index); void RemoveFromQueue(); @@ -722,6 +734,7 @@ public: // Guest void RemoveFromRide(); void UpdateSpriteType(); bool HeadingForRideOrParkExit() const; + public: // Staff void Tick128UpdateStaff(); bool IsMechanic() const; @@ -730,9 +743,10 @@ private: // Peep update void UpdateFalling(); void Update1(); void UpdatePicked(); + private: // Guest update void UpdateRide(); - void UpdateOnRide() {}; // TODO + void UpdateOnRide(){}; // TODO void UpdateWalking(); void UpdateQueuing(); void UpdateSitting(); @@ -744,7 +758,7 @@ private: // Guest update void UpdateRideAtEntrance(); void UpdateRideAdvanceThroughEntrance(); void UpdateRideFreeVehicleCheck(); - void UpdateRideFreeVehicleEnterRide(Ride * ride); + void UpdateRideFreeVehicleEnterRide(Ride* ride); void UpdateRideApproachVehicle(); void UpdateRideEnterVehicle(); void UpdateRideLeaveVehicle(); @@ -760,6 +774,7 @@ private: // Guest update void UpdateRideShopApproach(); void UpdateRideShopInteract(); void UpdateRideShopLeave(); + private: // Staff update void UpdatePatrolling(); void UpdateMowing(); @@ -768,58 +783,58 @@ private: // Staff update void UpdateWatering(); void UpdateAnswering(); void UpdateFixing(int32_t steps); - bool UpdateFixingEnterStation(Ride * ride); - bool UpdateFixingMoveToBrokenDownVehicle(bool firstRun, Ride * ride); - bool UpdateFixingFixVehicle(bool firstRun, Ride * ride); - bool UpdateFixingFixVehicleMalfunction(bool firstRun, Ride * ride); - bool UpdateFixingMoveToStationEnd(bool firstRun, Ride * ride); + bool UpdateFixingEnterStation(Ride* ride); + bool UpdateFixingMoveToBrokenDownVehicle(bool firstRun, Ride* ride); + bool UpdateFixingFixVehicle(bool firstRun, Ride* ride); + bool UpdateFixingFixVehicleMalfunction(bool firstRun, Ride* ride); + bool UpdateFixingMoveToStationEnd(bool firstRun, Ride* ride); bool UpdateFixingFixStationEnd(bool firstRun); - bool UpdateFixingMoveToStationStart(bool firstRun, Ride * ride); - bool UpdateFixingFixStationStart(bool firstRun, Ride * ride); - bool UpdateFixingFixStationBrakes(bool firstRun, Ride * ride); - bool UpdateFixingMoveToStationExit(bool firstRun, Ride * ride); - bool UpdateFixingFinishFixOrInspect(bool firstRun, int32_t steps, Ride * ride); - bool UpdateFixingLeaveByEntranceExit(bool firstRun, Ride * ride); + bool UpdateFixingMoveToStationStart(bool firstRun, Ride* ride); + bool UpdateFixingFixStationStart(bool firstRun, Ride* ride); + bool UpdateFixingFixStationBrakes(bool firstRun, Ride* ride); + bool UpdateFixingMoveToStationExit(bool firstRun, Ride* ride); + bool UpdateFixingFinishFixOrInspect(bool firstRun, int32_t steps, Ride* ride); + bool UpdateFixingLeaveByEntranceExit(bool firstRun, Ride* ride); void UpdateRideInspected(int32_t rideIndex); void UpdateHeadingToInspect(); // TODO: Make these private again when done refactoring public: // Peep - bool CheckForPath(); - void PerformNextAction(uint8_t & pathing_result); - void PerformNextAction(uint8_t & pathing_result, rct_tile_element *& tile_result); + bool CheckForPath(); + void PerformNextAction(uint8_t& pathing_result); + void PerformNextAction(uint8_t& pathing_result, rct_tile_element*& tile_result); int32_t GetZOnSlope(int32_t tile_x, int32_t tile_y); - void SwitchNextActionSpriteType(); - uint8_t GetActionSpriteType(); + void SwitchNextActionSpriteType(); + uint8_t GetActionSpriteType(); public: // Guest - void StopPurchaseThought(uint8_t ride_type); - void TryGetUpFromSitting(); - void ChoseNotToGoOnRide(int32_t rideIndex, bool peepAtRide, bool updateLastRide); - void PickRideToGoOn(); - void ReadMap(); - bool ShouldGoOnRide(int32_t rideIndex, int32_t entranceNum, bool atQueue, bool thinking); - bool ShouldGoToShop(int32_t rideIndex, bool peepAtShop); - bool ShouldFindBench(); - bool UpdateWalkingFindBench(); - bool UpdateWalkingFindBin(); - void SpendMoney(money16 & peep_expend_type, money32 amount); - void SpendMoney(money32 amount); - void SetHasRidden(int32_t rideIndex); - bool HasRidden(int32_t rideIndex) const; - void SetHasRiddenRideType(int32_t rideType); - bool HasRiddenRideType(int32_t rideType) const; + void StopPurchaseThought(uint8_t ride_type); + void TryGetUpFromSitting(); + void ChoseNotToGoOnRide(int32_t rideIndex, bool peepAtRide, bool updateLastRide); + void PickRideToGoOn(); + void ReadMap(); + bool ShouldGoOnRide(int32_t rideIndex, int32_t entranceNum, bool atQueue, bool thinking); + bool ShouldGoToShop(int32_t rideIndex, bool peepAtShop); + bool ShouldFindBench(); + bool UpdateWalkingFindBench(); + bool UpdateWalkingFindBin(); + void SpendMoney(money16& peep_expend_type, money32 amount); + void SpendMoney(money32 amount); + void SetHasRidden(int32_t rideIndex); + bool HasRidden(int32_t rideIndex) const; + void SetHasRiddenRideType(int32_t rideType); + bool HasRiddenRideType(int32_t rideType) const; int32_t HasFoodStandardFlag() const; int32_t HasFoodExtraFlag() const; - bool HasDrinkStandardFlag() const; - bool HasDrinkExtraFlag() const; + bool HasDrinkStandardFlag() const; + bool HasDrinkExtraFlag() const; int32_t HasEmptyContainerStandardFlag() const; int32_t HasEmptyContainerExtraFlag() const; - void CheckIfLost(); - void CheckCantFindRide(); - void CheckCantFindExit(); - bool DecideAndBuyItem(uint8_t rideIndex, int32_t shopItem, money32 price); - void SetSpriteType(uint8_t new_sprite_type); + void CheckIfLost(); + void CheckCantFindRide(); + void CheckCantFindExit(); + bool DecideAndBuyItem(uint8_t rideIndex, int32_t shopItem, money32 price); + void SetSpriteType(uint8_t new_sprite_type); }; assert_struct_size(rct_peep, 0x100); #pragma pack(pop) @@ -833,15 +848,15 @@ struct rct_sprite_bounds struct rct_peep_animation { - uint32_t base_image; // 0x00 - size_t num_frames; - const uint8_t * frame_offsets; + uint32_t base_image; // 0x00 + size_t num_frames; + const uint8_t* frame_offsets; }; struct rct_peep_animation_entry { - const rct_peep_animation * sprite_animation; // 0x00 - const rct_sprite_bounds * sprite_bounds; // 0x04 + const rct_peep_animation* sprite_animation; // 0x00 + const rct_sprite_bounds* sprite_bounds; // 0x04 }; enum @@ -892,94 +907,95 @@ enum if (((peep) = GET_PEEP(sprite_index)) != nullptr || 1) #define FOR_ALL_GUESTS(sprite_index, peep) \ - FOR_ALL_PEEPS(sprite_index, peep) \ - if ((peep)->type == PEEP_TYPE_GUEST) + FOR_ALL_PEEPS (sprite_index, peep) \ + if ((peep)->type == PEEP_TYPE_GUEST) #define FOR_ALL_STAFF(sprite_index, peep) \ - FOR_ALL_PEEPS(sprite_index, peep) \ - if ((peep)->type == PEEP_TYPE_STAFF) + FOR_ALL_PEEPS (sprite_index, peep) \ + if ((peep)->type == PEEP_TYPE_STAFF) // rct2: 0x00982708 extern rct_peep_animation_entry g_peep_animation_entries[PEEP_SPRITE_TYPE_COUNT]; extern const bool gSpriteTypeToSlowWalkMap[48]; -extern uint8_t gGuestChangeModifier; +extern uint8_t gGuestChangeModifier; extern uint16_t gNumGuestsInPark; extern uint16_t gNumGuestsInParkLastWeek; extern uint16_t gNumGuestsHeadingForPark; extern money16 gGuestInitialCash; -extern uint8_t gGuestInitialHappiness; -extern uint8_t gGuestInitialHunger; -extern uint8_t gGuestInitialThirst; +extern uint8_t gGuestInitialHappiness; +extern uint8_t gGuestInitialHunger; +extern uint8_t gGuestInitialThirst; extern uint32_t gNextGuestNumber; extern uint8_t gPeepWarningThrottle[16]; extern TileCoordsXYZ gPeepPathFindGoalPosition; -extern bool gPeepPathFindIgnoreForeignQueues; -extern uint8_t gPeepPathFindQueueRideIndex; +extern bool gPeepPathFindIgnoreForeignQueues; +extern uint8_t gPeepPathFindQueueRideIndex; -rct_peep * try_get_guest(uint16_t spriteIndex); -int32_t peep_get_staff_count(); -bool peep_can_be_picked_up(rct_peep * peep); -void peep_update_all(); -void peep_problem_warnings_update(); -void peep_stop_crowd_noise(); -void peep_update_crowd_noise(); -void peep_update_days_in_queue(); -void peep_applause(); -rct_peep * peep_generate(int32_t x, int32_t y, int32_t z); -void get_arguments_from_action(rct_peep * peep, uint32_t * argument_1, uint32_t * argument_2); -void peep_thought_set_format_args(rct_peep_thought * thought); -int32_t get_peep_face_sprite_small(rct_peep * peep); -int32_t get_peep_face_sprite_large(rct_peep * peep); -int32_t peep_check_easteregg_name(int32_t index, rct_peep * peep); -int32_t peep_get_easteregg_name_id(rct_peep * peep); -bool peep_pickup_command(uint32_t peepnum, int32_t x, int32_t y, int32_t z, int32_t action, bool apply); -void game_command_pickup_guest(int32_t * eax, int32_t * ebx, int32_t * ecx, int32_t * edx, int32_t * esi, int32_t * edi, - int32_t * ebp); -void peep_sprite_remove(rct_peep * peep); +rct_peep* try_get_guest(uint16_t spriteIndex); +int32_t peep_get_staff_count(); +bool peep_can_be_picked_up(rct_peep* peep); +void peep_update_all(); +void peep_problem_warnings_update(); +void peep_stop_crowd_noise(); +void peep_update_crowd_noise(); +void peep_update_days_in_queue(); +void peep_applause(); +rct_peep* peep_generate(int32_t x, int32_t y, int32_t z); +void get_arguments_from_action(rct_peep* peep, uint32_t* argument_1, uint32_t* argument_2); +void peep_thought_set_format_args(rct_peep_thought* thought); +int32_t get_peep_face_sprite_small(rct_peep* peep); +int32_t get_peep_face_sprite_large(rct_peep* peep); +int32_t peep_check_easteregg_name(int32_t index, rct_peep* peep); +int32_t peep_get_easteregg_name_id(rct_peep* peep); +bool peep_pickup_command(uint32_t peepnum, int32_t x, int32_t y, int32_t z, int32_t action, bool apply); +void game_command_pickup_guest( + int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp); +void peep_sprite_remove(rct_peep* peep); -void peep_window_state_update(rct_peep * peep); -void peep_decrement_num_riders(rct_peep * peep); +void peep_window_state_update(rct_peep* peep); +void peep_decrement_num_riders(rct_peep* peep); /** * rct2: 0x699F5A * al:thought_type * ah:thought_arguments * esi: peep */ -void peep_insert_new_thought(rct_peep * peep, uint8_t thought_type, uint8_t thought_arguments); +void peep_insert_new_thought(rct_peep* peep, uint8_t thought_type, uint8_t thought_arguments); -void peep_set_map_tooltip(rct_peep * peep); +void peep_set_map_tooltip(rct_peep* peep); -void SwitchToSpecialSprite(rct_peep * peep, uint8_t special_sprite_id); -void peep_update_name_sort(rct_peep * peep); +void SwitchToSpecialSprite(rct_peep* peep, uint8_t special_sprite_id); +void peep_update_name_sort(rct_peep* peep); void peep_sort(); void peep_update_names(bool realNames); -void guest_set_name(uint16_t spriteIndex, const char * name); -void peep_handle_easteregg_name(rct_peep * peep); -void game_command_set_guest_name(int32_t * eax, int32_t * ebx, int32_t * ecx, int32_t * edx, int32_t * esi, int32_t * edi, - int32_t * ebp); +void guest_set_name(uint16_t spriteIndex, const char* name); +void peep_handle_easteregg_name(rct_peep* peep); +void game_command_set_guest_name( + int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp); -int32_t peep_pathfind_choose_direction(TileCoordsXYZ loc, rct_peep * peep); -void peep_reset_pathfind_goal(rct_peep * peep); +int32_t peep_pathfind_choose_direction(TileCoordsXYZ loc, rct_peep* peep); +void peep_reset_pathfind_goal(rct_peep* peep); -bool is_valid_path_z_and_direction(rct_tile_element * tileElement, int32_t currentZ, int32_t currentDirection); -int32_t guest_path_finding(rct_peep * peep); +bool is_valid_path_z_and_direction(rct_tile_element* tileElement, int32_t currentZ, int32_t currentDirection); +int32_t guest_path_finding(rct_peep* peep); #if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 -#define PATHFIND_DEBUG 0 // Set to 0 to disable pathfinding debugging; - // Set to 1 to enable pathfinding debugging. +#define PATHFIND_DEBUG \ + 0 // Set to 0 to disable pathfinding debugging; + // Set to 1 to enable pathfinding debugging. // Some variables used for the path finding debugging. extern bool gPathFindDebug; // Use to guard calls to log messages extern utf8 gPathFindDebugPeepName[256]; // Use to put the peep name in the log message // The following calls set the above two variables for a peep. // ... when PATHFIND_DEBUG is 1 (nonzero) -void pathfind_logging_enable(rct_peep * peep); +void pathfind_logging_enable(rct_peep* peep); void pathfind_logging_disable(); #endif // defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 diff --git a/src/openrct2/peep/Staff.cpp b/src/openrct2/peep/Staff.cpp index f88b22a49e..998684ecdc 100644 --- a/src/openrct2/peep/Staff.cpp +++ b/src/openrct2/peep/Staff.cpp @@ -7,13 +7,15 @@ * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ -#include "../audio/audio.h" -#include "../core/Math.hpp" -#include "../core/Util.hpp" +#include "Staff.h" + #include "../Context.h" -#include "../config/Config.h" #include "../Game.h" #include "../Input.h" +#include "../audio/audio.h" +#include "../config/Config.h" +#include "../core/Math.hpp" +#include "../core/Util.hpp" #include "../interface/Viewport.h" #include "../localisation/Date.h" #include "../localisation/Localisation.h" @@ -21,10 +23,10 @@ #include "../management/Finance.h" #include "../network/network.h" #include "../object/ObjectList.h" -#include "../ride/Station.h" -#include "../ride/RideData.h" -#include "../ride/Track.h" #include "../paint/tile_element/Paint.TileElement.h" +#include "../ride/RideData.h" +#include "../ride/Station.h" +#include "../ride/Track.h" #include "../scenario/Scenario.h" #include "../util/Util.h" #include "../world/Entrance.h" @@ -34,7 +36,6 @@ #include "../world/Sprite.h" #include "../world/Surface.h" #include "Peep.h" -#include "Staff.h" // clang-format off const rct_string_id StaffCostumeNames[] = { @@ -54,9 +55,9 @@ const rct_string_id StaffCostumeNames[] = { // Every staff member has STAFF_PATROL_AREA_SIZE elements assigned to in this array, indexed by their staff_id // Additionally there is a patrol area for each staff type, which is the union of the patrols of all staff members of that type -uint32_t gStaffPatrolAreas[(STAFF_MAX_COUNT + STAFF_TYPE_COUNT) * STAFF_PATROL_AREA_SIZE]; -uint8_t gStaffModes[STAFF_MAX_COUNT + STAFF_TYPE_COUNT]; -uint16_t gStaffDrawPatrolAreas; +uint32_t gStaffPatrolAreas[(STAFF_MAX_COUNT + STAFF_TYPE_COUNT) * STAFF_PATROL_AREA_SIZE]; +uint8_t gStaffModes[STAFF_MAX_COUNT + STAFF_TYPE_COUNT]; +uint16_t gStaffDrawPatrolAreas; colour_t gStaffHandymanColour; colour_t gStaffMechanicColour; colour_t gStaffSecurityColour; @@ -76,20 +77,20 @@ void staff_reset_modes() staff_update_greyed_patrol_areas(); } -static inline void staff_autoposition_new_staff_member(rct_peep * newPeep) +static inline void staff_autoposition_new_staff_member(rct_peep* newPeep) { // Find a location to place new staff member newPeep->state = PEEP_STATE_FALLING; - int16_t x, y, z; - uint32_t count = 0; - uint16_t sprite_index; - rct_peep * guest = nullptr; - rct_tile_element * guest_tile = nullptr; + int16_t x, y, z; + uint32_t count = 0; + uint16_t sprite_index; + rct_peep* guest = nullptr; + rct_tile_element* guest_tile = nullptr; // Count number of walking guests - FOR_ALL_GUESTS(sprite_index, guest) + FOR_ALL_GUESTS (sprite_index, guest) { if (guest->state == PEEP_STATE_WALKING) { @@ -104,7 +105,7 @@ static inline void staff_autoposition_new_staff_member(rct_peep * newPeep) { // Place staff at a random guest uint32_t rand = scenario_rand_max(count); - FOR_ALL_GUESTS(sprite_index, guest) + FOR_ALL_GUESTS (sprite_index, guest) { if (guest->state == PEEP_STATE_WALKING) { @@ -147,9 +148,9 @@ static inline void staff_autoposition_new_staff_member(rct_peep * newPeep) } uint8_t dir = gParkEntrances[i].direction; - x = gParkEntrances[i].x; - y = gParkEntrances[i].y; - z = gParkEntrances[i].z; + x = gParkEntrances[i].x; + y = gParkEntrances[i].y; + z = gParkEntrances[i].z; x += 16 + ((dir & 1) == 0 ? ((dir & 2) ? 32 : -32) : 0); y += 16 + ((dir & 1) == 1 ? ((dir & 2) ? -32 : 32) : 0); } @@ -157,23 +158,29 @@ static inline void staff_autoposition_new_staff_member(rct_peep * newPeep) { // No more options; user must pick a location newPeep->state = PEEP_STATE_PICKED; - x = newPeep->x; - y = newPeep->y; - z = newPeep->z; + x = newPeep->x; + y = newPeep->y; + z = newPeep->z; } } - sprite_move(x, y, z + 16, (rct_sprite *)newPeep); - invalidate_sprite_2((rct_sprite *)newPeep); + sprite_move(x, y, z + 16, (rct_sprite*)newPeep); + invalidate_sprite_2((rct_sprite*)newPeep); } -static money32 staff_hire_new_staff_member(uint8_t staff_type, uint8_t flags, int16_t command_x, int16_t command_y, int16_t command_z, - int32_t autoposition, int32_t * newPeep_sprite_index) +static money32 staff_hire_new_staff_member( + uint8_t staff_type, + uint8_t flags, + int16_t command_x, + int16_t command_y, + int16_t command_z, + int32_t autoposition, + int32_t* newPeep_sprite_index) { gCommandExpenditureType = RCT_EXPENDITURE_TYPE_WAGES; - gCommandPosition.x = command_x; - gCommandPosition.y = command_y; - gCommandPosition.z = command_z; + gCommandPosition.x = command_x; + gCommandPosition.y = command_y; + gCommandPosition.z = command_z; if (gSpriteListCount[SPRITE_LIST_NULL] < 400) { @@ -218,9 +225,9 @@ static money32 staff_hire_new_staff_member(uint8_t staff_type, uint8_t flags, in if (flags & GAME_COMMAND_FLAG_APPLY) { - int32_t newStaffId = i; - const rct_sprite_bounds * spriteBounds; - rct_peep * newPeep = &(create_sprite(flags)->peep); + int32_t newStaffId = i; + const rct_sprite_bounds* spriteBounds; + rct_peep* newPeep = &(create_sprite(flags)->peep); if (newPeep == nullptr) { @@ -230,27 +237,27 @@ static money32 staff_hire_new_staff_member(uint8_t staff_type, uint8_t flags, in if (flags == 0) { - sprite_remove((rct_sprite *)newPeep); + sprite_remove((rct_sprite*)newPeep); } else { - move_sprite_to_list((rct_sprite *)newPeep, SPRITE_LIST_PEEP * 2); + move_sprite_to_list((rct_sprite*)newPeep, SPRITE_LIST_PEEP * 2); - newPeep->sprite_identifier = 1; - newPeep->window_invalidate_flags = 0; - newPeep->action = PEEP_ACTION_NONE_2; - newPeep->special_sprite = 0; + newPeep->sprite_identifier = 1; + newPeep->window_invalidate_flags = 0; + newPeep->action = PEEP_ACTION_NONE_2; + newPeep->special_sprite = 0; newPeep->action_sprite_image_offset = 0; - newPeep->no_action_frame_num = 0; - newPeep->action_sprite_type = 0; - newPeep->path_check_optimisation = 0; - newPeep->type = PEEP_TYPE_STAFF; - newPeep->outside_of_park = 0; - newPeep->peep_flags = 0; - newPeep->paid_to_enter = 0; - newPeep->paid_on_rides = 0; - newPeep->paid_on_food = 0; - newPeep->paid_on_souvenirs = 0; + newPeep->no_action_frame_num = 0; + newPeep->action_sprite_type = 0; + newPeep->path_check_optimisation = 0; + newPeep->type = PEEP_TYPE_STAFF; + newPeep->outside_of_park = 0; + newPeep->peep_flags = 0; + newPeep->paid_to_enter = 0; + newPeep->paid_on_rides = 0; + newPeep->paid_on_food = 0; + newPeep->paid_on_souvenirs = 0; if (staff_type == STAFF_TYPE_HANDYMAN) newPeep->staff_orders = STAFF_ORDERS_SWEEPING | STAFF_ORDERS_WATER_FLOWERS | STAFF_ORDERS_EMPTY_BINS; @@ -259,8 +266,8 @@ static money32 staff_hire_new_staff_member(uint8_t staff_type, uint8_t flags, in else newPeep->staff_orders = 0; - uint16_t idSearchSpriteIndex; - rct_peep * idSearchPeep; + uint16_t idSearchSpriteIndex; + rct_peep* idSearchPeep; // We search for the first available id for a given staff type uint32_t newStaffIndex = 0; @@ -269,7 +276,7 @@ static money32 staff_hire_new_staff_member(uint8_t staff_type, uint8_t flags, in bool found = false; ++newStaffIndex; - FOR_ALL_STAFF(idSearchSpriteIndex, idSearchPeep) + FOR_ALL_STAFF (idSearchSpriteIndex, idSearchPeep) { if (idSearchPeep->staff_type != staff_type) continue; @@ -285,7 +292,7 @@ static money32 staff_hire_new_staff_member(uint8_t staff_type, uint8_t flags, in break; } - newPeep->id = newStaffIndex; + newPeep->id = newStaffIndex; newPeep->staff_type = staff_type; static constexpr const rct_string_id staffNames[] = { @@ -309,10 +316,10 @@ static money32 staff_hire_new_staff_member(uint8_t staff_type, uint8_t flags, in sprite_type = PEEP_SPRITE_TYPE_ENTERTAINER_PANDA + entertainerType; } newPeep->name_string_idx = staffNames[staff_type]; - newPeep->sprite_type = sprite_type; + newPeep->sprite_type = sprite_type; - spriteBounds = g_peep_animation_entries[sprite_type].sprite_bounds; - newPeep->sprite_width = spriteBounds->sprite_width; + spriteBounds = g_peep_animation_entries[sprite_type].sprite_bounds; + newPeep->sprite_width = spriteBounds->sprite_width; newPeep->sprite_height_negative = spriteBounds->sprite_height_negative; newPeep->sprite_height_positive = spriteBounds->sprite_height_positive; @@ -324,24 +331,24 @@ static money32 staff_hire_new_staff_member(uint8_t staff_type, uint8_t flags, in { newPeep->state = PEEP_STATE_PICKED; - sprite_move(newPeep->x, newPeep->y, newPeep->z, (rct_sprite *)newPeep); - invalidate_sprite_2((rct_sprite *)newPeep); + sprite_move(newPeep->x, newPeep->y, newPeep->z, (rct_sprite*)newPeep); + invalidate_sprite_2((rct_sprite*)newPeep); } - newPeep->time_in_park = gDateMonthsElapsed; - newPeep->pathfind_goal.x = 0xFF; - newPeep->pathfind_goal.y = 0xFF; - newPeep->pathfind_goal.z = 0xFF; + newPeep->time_in_park = gDateMonthsElapsed; + newPeep->pathfind_goal.x = 0xFF; + newPeep->pathfind_goal.y = 0xFF; + newPeep->pathfind_goal.z = 0xFF; newPeep->pathfind_goal.direction = 0xFF; - uint8_t colour = staff_get_colour(staff_type); - newPeep->tshirt_colour = colour; + uint8_t colour = staff_get_colour(staff_type); + newPeep->tshirt_colour = colour; newPeep->trousers_colour = colour; // Staff energy determines their walking speed - newPeep->energy = 0x60; + newPeep->energy = 0x60; newPeep->energy_target = 0x60; - newPeep->staff_mowing_timeout = 0; + newPeep->staff_mowing_timeout = 0; peep_update_name_sort(newPeep); @@ -365,10 +372,16 @@ static money32 staff_hire_new_staff_member(uint8_t staff_type, uint8_t flags, in * rct2: 0x006BEFA1 */ void game_command_hire_new_staff_member( - int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, [[maybe_unused]] int32_t* esi, int32_t* edi, [[maybe_unused]] int32_t* ebp) + int32_t* eax, + int32_t* ebx, + int32_t* ecx, + int32_t* edx, + [[maybe_unused]] int32_t* esi, + int32_t* edi, + [[maybe_unused]] int32_t* ebp) { - *ebx = staff_hire_new_staff_member((*ebx & 0xFF00) >> 8, *ebx & 0xFF, *eax & 0xFFFF, *ecx & 0xFFFF, *edx & 0xFFFF, - (*ebx & 0xFF0000) >> 16, edi); + *ebx = staff_hire_new_staff_member( + (*ebx & 0xFF00) >> 8, *ebx & 0xFF, *eax & 0xFFFF, *ecx & 0xFFFF, *edx & 0xFFFF, (*ebx & 0xFF0000) >> 16, edi); } /** rct2: 0x00982134 */ @@ -405,8 +418,8 @@ void game_command_set_staff_order( [[maybe_unused]] int32_t* ebp) { gCommandExpenditureType = RCT_EXPENDITURE_TYPE_WAGES; - uint8_t order_id = *ebx >> 8; - uint16_t sprite_id = *edx; + uint8_t order_id = *ebx >> 8; + uint16_t sprite_id = *edx; if (sprite_id >= MAX_SPRITES) { log_warning("Invalid game command, sprite_id = %u", sprite_id); @@ -415,7 +428,7 @@ void game_command_set_staff_order( } if (*ebx & GAME_COMMAND_FLAG_APPLY) { - rct_peep * peep = &get_sprite(sprite_id)->peep; + rct_peep* peep = &get_sprite(sprite_id)->peep; if (order_id & 0x80) { // change costume uint8_t sprite_type = order_id & ~0x80; @@ -463,8 +476,8 @@ void game_command_set_staff_patrol( { if (*ebx & GAME_COMMAND_FLAG_APPLY) { - int32_t x = *eax; - int32_t y = *ecx; + int32_t x = *eax; + int32_t y = *ecx; uint16_t sprite_id = *edx; if (sprite_id >= MAX_SPRITES) { @@ -472,15 +485,15 @@ void game_command_set_staff_patrol( log_warning("Invalid sprite id %u", sprite_id); return; } - rct_sprite * sprite = get_sprite(sprite_id); + rct_sprite* sprite = get_sprite(sprite_id); if (sprite->unknown.sprite_identifier != SPRITE_IDENTIFIER_PEEP || sprite->peep.type != PEEP_TYPE_STAFF) { *ebx = MONEY32_UNDEFINED; log_warning("Invalid type of sprite %u for game command", sprite_id); return; } - rct_peep * peep = &sprite->peep; - int32_t patrolOffset = peep->staff_id * STAFF_PATROL_AREA_SIZE; + rct_peep* peep = &sprite->peep; + int32_t patrolOffset = peep->staff_id * STAFF_PATROL_AREA_SIZE; staff_toggle_patrol_area(peep->staff_id, x, y); @@ -532,11 +545,11 @@ void game_command_fire_staff_member( *ebx = MONEY32_UNDEFINED; return; } - rct_peep * peep = &get_sprite(sprite_id)->peep; + rct_peep* peep = &get_sprite(sprite_id)->peep; if (peep->sprite_identifier != SPRITE_IDENTIFIER_PEEP || peep->type != PEEP_TYPE_STAFF) { - log_warning("Invalid game command, peep->sprite_identifier = %u, peep->type = %u", peep->sprite_identifier, - peep->type); + log_warning( + "Invalid game command, peep->sprite_identifier = %u, peep->type = %u", peep->sprite_identifier, peep->type); *ebx = MONEY32_UNDEFINED; return; } @@ -555,7 +568,7 @@ uint16_t hire_new_staff_member(uint8_t staffType) int32_t command_x, ebx, command_y, command_z, esi, new_sprite_index, ebp; command_y = command_z = esi = new_sprite_index = ebp = 0; - command_x = 0x8000; + command_x = 0x8000; int32_t autoposition = gConfigGeneral.auto_staff_placement; if (gInputPlaceObjectModifier & PLACE_OBJECT_MODIFIER_SHIFT_Z) @@ -566,18 +579,24 @@ uint16_t hire_new_staff_member(uint8_t staffType) ebx = autoposition << 16 | staffType << 8 | GAME_COMMAND_FLAG_APPLY; game_command_callback = game_command_callback_hire_new_staff_member; - int32_t result = game_do_command_p(GAME_COMMAND_HIRE_NEW_STAFF_MEMBER, &command_x, &ebx, &command_y, &command_z, &esi, - &new_sprite_index, &ebp); + int32_t result = game_do_command_p( + GAME_COMMAND_HIRE_NEW_STAFF_MEMBER, &command_x, &ebx, &command_y, &command_z, &esi, &new_sprite_index, &ebp); if (result == MONEY32_UNDEFINED) return SPRITE_INDEX_NULL; if ((staffType == STAFF_TYPE_HANDYMAN) && gConfigGeneral.handymen_mow_default) { - rct_peep * newPeep = GET_PEEP(new_sprite_index); - uint8_t new_orders = newPeep->staff_orders | STAFF_ORDERS_MOWING; - game_do_command(newPeep->x, ((int32_t)new_orders << 8) | GAME_COMMAND_FLAG_APPLY, newPeep->y, new_sprite_index, - GAME_COMMAND_SET_STAFF_ORDER, 0, 0); + rct_peep* newPeep = GET_PEEP(new_sprite_index); + uint8_t new_orders = newPeep->staff_orders | STAFF_ORDERS_MOWING; + game_do_command( + newPeep->x, + ((int32_t)new_orders << 8) | GAME_COMMAND_FLAG_APPLY, + newPeep->y, + new_sprite_index, + GAME_COMMAND_SET_STAFF_ORDER, + 0, + 0); } return new_sprite_index; @@ -589,7 +608,7 @@ uint16_t hire_new_staff_member(uint8_t staffType) */ void staff_update_greyed_patrol_areas() { - rct_peep * peep; + rct_peep* peep; for (int32_t staff_type = 0; staff_type < STAFF_TYPE_COUNT; ++staff_type) { @@ -600,7 +619,7 @@ void staff_update_greyed_patrol_areas() } for (uint16_t sprite_index = gSpriteListHead[SPRITE_LIST_PEEP]; sprite_index != SPRITE_INDEX_NULL; - sprite_index = peep->next) + sprite_index = peep->next) { peep = GET_PEEP(sprite_index); @@ -616,7 +635,7 @@ void staff_update_greyed_patrol_areas() } } -static bool staff_is_location_in_patrol_area(rct_peep * peep, int32_t x, int32_t y) +static bool staff_is_location_in_patrol_area(rct_peep* peep, int32_t x, int32_t y) { // Patrol quads are stored in a bit map (8 patrol quads per byte) // Each patrol quad is 4x4 @@ -628,7 +647,7 @@ static bool staff_is_location_in_patrol_area(rct_peep * peep, int32_t x, int32_t * * rct2: 0x006C0905 */ -bool staff_is_location_in_patrol(rct_peep * staff, int32_t x, int32_t y) +bool staff_is_location_in_patrol(rct_peep* staff, int32_t x, int32_t y) { // Check if location is in the park if (!map_is_location_owned_or_has_rights(x, y)) @@ -641,23 +660,23 @@ bool staff_is_location_in_patrol(rct_peep * staff, int32_t x, int32_t y) return staff_is_location_in_patrol_area(staff, x, y); } -bool staff_is_location_on_patrol_edge(rct_peep * mechanic, int32_t x, int32_t y) +bool staff_is_location_on_patrol_edge(rct_peep* mechanic, int32_t x, int32_t y) { // Check whether the location x,y is inside and on the edge of the // patrol zone for mechanic. - bool onZoneEdge = false; + bool onZoneEdge = false; int32_t neighbourDir = 0; while (!onZoneEdge && neighbourDir <= 7) { int32_t neighbourX = x + CoordsDirectionDelta[neighbourDir].x; int32_t neighbourY = y + CoordsDirectionDelta[neighbourDir].y; - onZoneEdge = !staff_is_location_in_patrol(mechanic, neighbourX, neighbourY); + onZoneEdge = !staff_is_location_in_patrol(mechanic, neighbourX, neighbourY); neighbourDir++; } return onZoneEdge; } -bool staff_can_ignore_wide_flag(rct_peep * staff, int32_t x, int32_t y, uint8_t z, rct_tile_element * path) +bool staff_can_ignore_wide_flag(rct_peep* staff, int32_t x, int32_t y, uint8_t z, rct_tile_element* path) { /* Wide flags can potentially wall off parts of a staff patrol zone * for the heuristic search. @@ -690,14 +709,14 @@ bool staff_can_ignore_wide_flag(rct_peep * staff, int32_t x, int32_t y, uint8_t /* Check the connected adjacent paths that are also inside the patrol * zone but are not on the patrol zone edge have the wide flag set. */ - uint8_t total = 0; + uint8_t total = 0; uint8_t pathcount = 0; uint8_t widecount = 0; for (int32_t adjac_dir = 0; adjac_dir <= 3; adjac_dir++) { int32_t adjac_x = x + CoordsDirectionDelta[adjac_dir].x; int32_t adjac_y = y + CoordsDirectionDelta[adjac_dir].y; - uint8_t adjac_z = z; + uint8_t adjac_z = z; /* Ignore adjacent tiles outside the patrol zone. */ if (!staff_is_location_in_patrol(staff, adjac_x, adjac_y)) @@ -726,9 +745,9 @@ bool staff_can_ignore_wide_flag(rct_peep * staff, int32_t x, int32_t y, uint8_t } /* Search through all adjacent map elements */ - rct_tile_element * test_element = map_get_first_element_at(adjac_x / 32, adjac_y / 32); - bool pathfound = false; - bool widefound = false; + rct_tile_element* test_element = map_get_first_element_at(adjac_x / 32, adjac_y / 32); + bool pathfound = false; + bool widefound = false; do { if (test_element->GetType() != TILE_ELEMENT_TYPE_PATH) @@ -760,14 +779,14 @@ bool staff_can_ignore_wide_flag(rct_peep * staff, int32_t x, int32_t y, uint8_t switch (total) { - case 0: /* Concave corner */ - return true; - case 1: /* Straight side */ - case 2: /* Convex corner */ - if (pathcount <= total - 1 || widecount == total) - { + case 0: /* Concave corner */ return true; - } + case 1: /* Straight side */ + case 2: /* Convex corner */ + if (pathcount <= total - 1 || widecount == total) + { + return true; + } } return false; @@ -778,7 +797,7 @@ bool staff_can_ignore_wide_flag(rct_peep * staff, int32_t x, int32_t y, uint8_t * rct2: 0x006C095B * returns 0xF if not in a valid patrol area */ -static uint8_t staff_get_valid_patrol_directions(rct_peep * peep, int16_t x, int16_t y) +static uint8_t staff_get_valid_patrol_directions(rct_peep* peep, int16_t x, int16_t y) { uint8_t directions = 0; @@ -816,18 +835,18 @@ static uint8_t staff_get_valid_patrol_directions(rct_peep * peep, int16_t x, int */ void staff_reset_stats() { - uint16_t spriteIndex; - rct_peep * peep; + uint16_t spriteIndex; + rct_peep* peep; - FOR_ALL_STAFF(spriteIndex, peep) + FOR_ALL_STAFF (spriteIndex, peep) { - peep->time_in_park = gDateMonthsElapsed; - peep->staff_lawns_mown = 0; - peep->staff_rides_fixed = 0; + peep->time_in_park = gDateMonthsElapsed; + peep->staff_lawns_mown = 0; + peep->staff_rides_fixed = 0; peep->staff_gardens_watered = 0; peep->staff_rides_inspected = 0; - peep->staff_litter_swept = 0; - peep->staff_bins_emptied = 0; + peep->staff_litter_swept = 0; + peep->staff_bins_emptied = 0; } } @@ -837,8 +856,8 @@ bool staff_is_patrol_area_set(int32_t staffIndex, int32_t x, int32_t y) y = (y & 0x1F80) >> 1; int32_t peepOffset = staffIndex * STAFF_PATROL_AREA_SIZE; - int32_t offset = (x | y) >> 5; - int32_t bitIndex = (x | y) & 0x1F; + int32_t offset = (x | y) >> 5; + int32_t bitIndex = (x | y) & 0x1F; return gStaffPatrolAreas[peepOffset + offset] & (((uint32_t)1) << bitIndex); } @@ -847,10 +866,10 @@ void staff_set_patrol_area(int32_t staffIndex, int32_t x, int32_t y, bool value) x = (x & 0x1F80) >> 7; y = (y & 0x1F80) >> 1; - int32_t peepOffset = staffIndex * STAFF_PATROL_AREA_SIZE; - int32_t offset = (x | y) >> 5; - int32_t bitIndex = (x | y) & 0x1F; - uint32_t * addr = &gStaffPatrolAreas[peepOffset + offset]; + int32_t peepOffset = staffIndex * STAFF_PATROL_AREA_SIZE; + int32_t offset = (x | y) >> 5; + int32_t bitIndex = (x | y) & 0x1F; + uint32_t* addr = &gStaffPatrolAreas[peepOffset + offset]; if (value) { *addr |= (1 << bitIndex); @@ -867,8 +886,8 @@ void staff_toggle_patrol_area(int32_t staffIndex, int32_t x, int32_t y) y = (y & 0x1F80) >> 1; int32_t peepOffset = staffIndex * STAFF_PATROL_AREA_SIZE; - int32_t offset = (x | y) >> 5; - int32_t bitIndex = (x | y) & 0x1F; + int32_t offset = (x | y) >> 5; + int32_t bitIndex = (x | y) & 0x1F; gStaffPatrolAreas[peepOffset + offset] ^= (1 << bitIndex); } @@ -878,11 +897,11 @@ void staff_toggle_patrol_area(int32_t staffIndex, int32_t x, int32_t y) * * Returns 0xFF when no nearby litter or unpathable litter */ -static uint8_t staff_handyman_direction_to_nearest_litter(rct_peep * peep) +static uint8_t staff_handyman_direction_to_nearest_litter(rct_peep* peep) { - uint16_t nearestLitterDist = (uint16_t)-1; - rct_litter * nearestLitter = nullptr; - rct_litter * litter = nullptr; + uint16_t nearestLitterDist = (uint16_t)-1; + rct_litter* nearestLitter = nullptr; + rct_litter* litter = nullptr; for (uint16_t litterIndex = gSpriteListHead[SPRITE_LIST_LITTER]; litterIndex != 0xFFFF; litterIndex = litter->next) { @@ -893,7 +912,7 @@ static uint8_t staff_handyman_direction_to_nearest_litter(rct_peep * peep) if (distance < nearestLitterDist) { nearestLitterDist = distance; - nearestLitter = litter; + nearestLitter = litter; } } @@ -902,7 +921,8 @@ static uint8_t staff_handyman_direction_to_nearest_litter(rct_peep * peep) return 0xFF; } - LocationXY16 litterTile = { static_cast(nearestLitter->x & 0xFFE0), static_cast(nearestLitter->y & 0xFFE0) }; + LocationXY16 litterTile + = { static_cast(nearestLitter->x & 0xFFE0), static_cast(nearestLitter->y & 0xFFE0) }; if (!staff_is_location_in_patrol(peep, litterTile.x, litterTile.y)) { @@ -931,14 +951,13 @@ static uint8_t staff_handyman_direction_to_nearest_litter(rct_peep * peep) int16_t nextZ = ((peep->z + 8) & 0xFFF0) / 8; - rct_tile_element * tileElement = map_get_first_element_at(nextTile.x / 32, nextTile.y / 32); + rct_tile_element* tileElement = map_get_first_element_at(nextTile.x / 32, nextTile.y / 32); do { if (tileElement->base_height != nextZ) continue; - if (tileElement->GetType() == TILE_ELEMENT_TYPE_ENTRANCE || - tileElement->GetType() == TILE_ELEMENT_TYPE_TRACK) + if (tileElement->GetType() == TILE_ELEMENT_TYPE_ENTRANCE || tileElement->GetType() == TILE_ELEMENT_TYPE_TRACK) { return 0xFF; } @@ -953,8 +972,7 @@ static uint8_t staff_handyman_direction_to_nearest_litter(rct_peep * peep) { if (tileElement->base_height != nextZ) continue; - if (tileElement->GetType() == TILE_ELEMENT_TYPE_ENTRANCE || - tileElement->GetType() == TILE_ELEMENT_TYPE_TRACK) + if (tileElement->GetType() == TILE_ELEMENT_TYPE_ENTRANCE || tileElement->GetType() == TILE_ELEMENT_TYPE_TRACK) { return 0xFF; } @@ -963,24 +981,23 @@ static uint8_t staff_handyman_direction_to_nearest_litter(rct_peep * peep) return nextDirection; } - /** * * rct2: 0x006BF931 */ -static uint8_t staff_handyman_direction_to_uncut_grass(rct_peep * peep, uint8_t valid_directions) +static uint8_t staff_handyman_direction_to_uncut_grass(rct_peep* peep, uint8_t valid_directions) { if (!(peep->GetNextIsSurface())) { - - rct_tile_element * tileElement = map_get_surface_element_at({peep->next_x, peep->next_y}); + rct_tile_element* tileElement = map_get_surface_element_at({ peep->next_x, peep->next_y }); if (peep->next_z != tileElement->base_height) return 0xFF; if (peep->GetNextIsSloped()) { - if ((tileElement->properties.surface.slope & TILE_ELEMENT_SURFACE_SLOPE_MASK) != byte_98D800[peep->GetNextDirection()]) + if ((tileElement->properties.surface.slope & TILE_ELEMENT_SURFACE_SLOPE_MASK) + != byte_98D800[peep->GetNextDirection()]) return 0xFF; } else if ((tileElement->properties.surface.slope & TILE_ELEMENT_SURFACE_SLOPE_MASK) != 0) @@ -1003,7 +1020,7 @@ static uint8_t staff_handyman_direction_to_uncut_grass(rct_peep * peep, uint8_t if (chosenTile.x > 0x1FFF || chosenTile.y > 0x1FFF) continue; - rct_tile_element * tileElement = map_get_surface_element_at(chosenTile); + rct_tile_element* tileElement = map_get_surface_element_at(chosenTile); if (surface_get_terrain(tileElement) != 0) continue; @@ -1023,7 +1040,7 @@ static uint8_t staff_handyman_direction_to_uncut_grass(rct_peep * peep, uint8_t * * rct2: 0x006BFD9C */ -static int32_t staff_handyman_direction_rand_surface(rct_peep * peep, uint8_t validDirections) +static int32_t staff_handyman_direction_rand_surface(rct_peep* peep, uint8_t validDirections) { uint8_t direction = scenario_rand() & 3; for (int32_t i = 0; i < 4; ++i, ++direction) @@ -1033,7 +1050,7 @@ static int32_t staff_handyman_direction_rand_surface(rct_peep * peep, uint8_t va continue; LocationXY16 chosenTile = { static_cast(peep->next_x + CoordsDirectionDelta[direction].x), - static_cast(peep->next_y + CoordsDirectionDelta[direction].y) }; + static_cast(peep->next_y + CoordsDirectionDelta[direction].y) }; if (map_surface_is_blocked(chosenTile.x, chosenTile.y)) continue; @@ -1051,7 +1068,7 @@ static int32_t staff_handyman_direction_rand_surface(rct_peep * peep, uint8_t va * * rct2: 0x006BFBA8 */ -static bool staff_path_finding_handyman(rct_peep * peep) +static bool staff_path_finding_handyman(rct_peep* peep) { peep->staff_mowing_timeout++; @@ -1077,7 +1094,7 @@ static bool staff_path_finding_handyman(rct_peep * peep) } else { - rct_tile_element * tileElement = map_get_path_element_at(peep->next_x / 32, peep->next_y / 32, peep->next_z); + rct_tile_element* tileElement = map_get_path_element_at(peep->next_x / 32, peep->next_y / 32, peep->next_z); if (tileElement == nullptr) return true; @@ -1095,7 +1112,7 @@ static bool staff_path_finding_handyman(rct_peep * peep) if ((scenario_rand() & 0xFFFF) >= 0x1999) { chooseRandom = false; - direction = litterDirection; + direction = litterDirection; } } else @@ -1122,18 +1139,18 @@ static bool staff_path_finding_handyman(rct_peep * peep) assert(direction < 8); LocationXY16 chosenTile = { static_cast(peep->next_x + CoordsDirectionDelta[direction].x), - static_cast(peep->next_y + CoordsDirectionDelta[direction].y) }; + static_cast(peep->next_y + CoordsDirectionDelta[direction].y) }; while (chosenTile.x > 0x1FFF || chosenTile.y > 0x1FFF) { - direction = staff_handyman_direction_rand_surface(peep, validDirections); + direction = staff_handyman_direction_rand_surface(peep, validDirections); chosenTile.x = peep->next_x + CoordsDirectionDelta[direction].x; chosenTile.y = peep->next_y + CoordsDirectionDelta[direction].y; } - peep->direction = direction; - peep->destination_x = chosenTile.x + 16; - peep->destination_y = chosenTile.y + 16; + peep->direction = direction; + peep->destination_x = chosenTile.x + 16; + peep->destination_y = chosenTile.y + 16; peep->destination_tolerance = 3; if (peep->state == PEEP_STATE_QUEUING) { @@ -1142,7 +1159,7 @@ static bool staff_path_finding_handyman(rct_peep * peep) return false; } -static uint8_t staff_direction_surface(rct_peep * peep, uint8_t initialDirection) +static uint8_t staff_direction_surface(rct_peep* peep, uint8_t initialDirection) { uint8_t direction = initialDirection; for (int32_t i = 0; i < 3; ++i) @@ -1150,16 +1167,16 @@ static uint8_t staff_direction_surface(rct_peep * peep, uint8_t initialDirection // Looks left and right from initial direction switch (i) { - case 1: - direction++; - if (scenario_rand() & 1) - { + case 1: + direction++; + if (scenario_rand() & 1) + { + direction -= 2; + } + break; + case 2: direction -= 2; - } - break; - case 2: - direction -= 2; - break; + break; } direction &= 3; @@ -1171,7 +1188,7 @@ static uint8_t staff_direction_surface(rct_peep * peep, uint8_t initialDirection continue; LocationXY16 chosenTile = { static_cast(peep->next_x + CoordsDirectionDelta[direction].x), - static_cast(peep->next_y + CoordsDirectionDelta[direction].y) }; + static_cast(peep->next_y + CoordsDirectionDelta[direction].y) }; if (map_surface_is_blocked(chosenTile.x, chosenTile.y) == false) { @@ -1185,7 +1202,7 @@ static uint8_t staff_direction_surface(rct_peep * peep, uint8_t initialDirection * * rct2: 0x006BFF45 */ -static uint8_t staff_mechanic_direction_surface(rct_peep * peep) +static uint8_t staff_mechanic_direction_surface(rct_peep* peep) { uint8_t direction = scenario_rand() & 3; @@ -1219,7 +1236,7 @@ static uint8_t staff_mechanic_direction_surface(rct_peep * peep) * * rct2: 0x006C02D1 */ -static uint8_t staff_mechanic_direction_path_rand(rct_peep * peep, uint8_t pathDirections) +static uint8_t staff_mechanic_direction_path_rand(rct_peep* peep, uint8_t pathDirections) { if (scenario_rand() & 1) { @@ -1243,10 +1260,9 @@ static uint8_t staff_mechanic_direction_path_rand(rct_peep * peep, uint8_t pathD * * rct2: 0x006C0121 */ -static uint8_t staff_mechanic_direction_path(rct_peep * peep, uint8_t validDirections, rct_tile_element * pathElement) +static uint8_t staff_mechanic_direction_path(rct_peep* peep, uint8_t validDirections, rct_tile_element* pathElement) { - - uint8_t direction = 0xFF; + uint8_t direction = 0xFF; uint8_t pathDirections = pathElement->properties.path.edges & 0xF; pathDirections &= validDirections; @@ -1302,13 +1318,14 @@ static uint8_t staff_mechanic_direction_path(rct_peep * peep, uint8_t validDirec gPeepPathFindGoalPosition.z = location.z; gPeepPathFindIgnoreForeignQueues = false; - gPeepPathFindQueueRideIndex = 255; + gPeepPathFindQueueRideIndex = 255; #if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 pathfind_logging_enable(peep); #endif // defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 - int32_t pathfindDirection = peep_pathfind_choose_direction({ peep->next_x / 32, peep->next_y / 32, peep->next_z }, peep); + int32_t pathfindDirection + = peep_pathfind_choose_direction({ peep->next_x / 32, peep->next_y / 32, peep->next_z }, peep); #if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 pathfind_logging_disable(); @@ -1335,17 +1352,17 @@ static uint8_t staff_mechanic_direction_path(rct_peep * peep, uint8_t validDirec * * rct2: 0x006BFF2C */ -static bool staff_path_finding_mechanic(rct_peep * peep) +static bool staff_path_finding_mechanic(rct_peep* peep) { uint8_t validDirections = staff_get_valid_patrol_directions(peep, peep->next_x, peep->next_y); - uint8_t direction = 0xFF; + uint8_t direction = 0xFF; if (peep->GetNextIsSurface()) { direction = staff_mechanic_direction_surface(peep); } else { - rct_tile_element * pathElement = map_get_path_element_at(peep->next_x / 32, peep->next_y / 32, peep->next_z); + rct_tile_element* pathElement = map_get_path_element_at(peep->next_x / 32, peep->next_y / 32, peep->next_z); if (pathElement == nullptr) return true; @@ -1356,18 +1373,18 @@ static bool staff_path_finding_mechanic(rct_peep * peep) assert(direction < 8); LocationXY16 chosenTile = { static_cast(peep->next_x + CoordsDirectionDelta[direction].x), - static_cast(peep->next_y + CoordsDirectionDelta[direction].y) }; + static_cast(peep->next_y + CoordsDirectionDelta[direction].y) }; while (chosenTile.x > 0x1FFF || chosenTile.y > 0x1FFF) { - direction = staff_mechanic_direction_surface(peep); + direction = staff_mechanic_direction_surface(peep); chosenTile.x = peep->next_x + CoordsDirectionDelta[direction].x; chosenTile.y = peep->next_y + CoordsDirectionDelta[direction].y; } - peep->direction = direction; - peep->destination_x = chosenTile.x + 16; - peep->destination_y = chosenTile.y + 16; + peep->direction = direction; + peep->destination_x = chosenTile.x + 16; + peep->destination_y = chosenTile.y + 16; peep->destination_tolerance = (scenario_rand() & 7) + 2; return false; @@ -1377,9 +1394,9 @@ static bool staff_path_finding_mechanic(rct_peep * peep) * * rct2: 0x006C050B */ -static uint8_t staff_direction_path(rct_peep * peep, uint8_t validDirections, rct_tile_element * pathElement) +static uint8_t staff_direction_path(rct_peep* peep, uint8_t validDirections, rct_tile_element* pathElement) { - uint8_t direction = 0xFF; + uint8_t direction = 0xFF; uint8_t pathDirections = pathElement->properties.path.edges & 0xF; if (peep->state != PEEP_STATE_ANSWERING && peep->state != PEEP_STATE_HEADING_TO_INSPECTION) { @@ -1422,7 +1439,7 @@ static uint8_t staff_direction_path(rct_peep * peep, uint8_t validDirections, rc * * rct2: 0x006C0351 */ -static bool staff_path_finding_misc(rct_peep * peep) +static bool staff_path_finding_misc(rct_peep* peep) { uint8_t validDirections = staff_get_valid_patrol_directions(peep, peep->next_x, peep->next_y); @@ -1433,7 +1450,7 @@ static bool staff_path_finding_misc(rct_peep * peep) } else { - rct_tile_element * pathElement = map_get_path_element_at(peep->next_x / 32, peep->next_y / 32, peep->next_z); + rct_tile_element* pathElement = map_get_path_element_at(peep->next_x / 32, peep->next_y / 32, peep->next_z); if (pathElement == nullptr) return true; @@ -1441,18 +1458,18 @@ static bool staff_path_finding_misc(rct_peep * peep) } LocationXY16 chosenTile = { static_cast(peep->next_x + CoordsDirectionDelta[direction].x), - static_cast(peep->next_y + CoordsDirectionDelta[direction].y) }; + static_cast(peep->next_y + CoordsDirectionDelta[direction].y) }; while (chosenTile.x > 0x1FFF || chosenTile.y > 0x1FFF) { - direction = staff_direction_surface(peep, scenario_rand() & 3); + direction = staff_direction_surface(peep, scenario_rand() & 3); chosenTile.x = peep->next_x + CoordsDirectionDelta[direction].x; chosenTile.y = peep->next_y + CoordsDirectionDelta[direction].y; } - peep->direction = direction; - peep->destination_x = chosenTile.x + 16; - peep->destination_y = chosenTile.y + 16; + peep->direction = direction; + peep->destination_x = chosenTile.x + 16; + peep->destination_y = chosenTile.y + 16; peep->destination_tolerance = (scenario_rand() & 7) + 2; return false; @@ -1462,12 +1479,12 @@ static bool staff_path_finding_misc(rct_peep * peep) * * rct2: 0x006C086D */ -static void staff_entertainer_update_nearby_peeps(rct_peep * peep) +static void staff_entertainer_update_nearby_peeps(rct_peep* peep) { - uint16_t spriteIndex; - rct_peep * guest; + uint16_t spriteIndex; + rct_peep* guest; - FOR_ALL_GUESTS(spriteIndex, guest) + FOR_ALL_GUESTS (spriteIndex, guest) { if (guest->x == LOCATION_NULL) continue; @@ -1508,16 +1525,14 @@ static void staff_entertainer_update_nearby_peeps(rct_peep * peep) * * rct2: 0x006C05AE */ -static int32_t staff_path_finding_entertainer(rct_peep * peep) +static int32_t staff_path_finding_entertainer(rct_peep* peep) { - if (((scenario_rand() & 0xFFFF) <= 0x4000) && (peep->action == PEEP_ACTION_NONE_1 || peep->action == PEEP_ACTION_NONE_2)) { - peep->Invalidate(); - peep->action = (scenario_rand() & 1) ? PEEP_ACTION_WAVE_2 : PEEP_ACTION_JOY; - peep->action_frame = 0; + peep->action = (scenario_rand() & 1) ? PEEP_ACTION_WAVE_2 : PEEP_ACTION_JOY; + peep->action_frame = 0; peep->action_sprite_image_offset = 0; peep->UpdateCurrentActionSpriteType(); @@ -1532,22 +1547,22 @@ static int32_t staff_path_finding_entertainer(rct_peep * peep) * * rct2: 0x006BF926 */ -int32_t staff_path_finding(rct_peep * peep) +int32_t staff_path_finding(rct_peep* peep) { switch (peep->staff_type) { - case STAFF_TYPE_HANDYMAN: - return staff_path_finding_handyman(peep); - case STAFF_TYPE_MECHANIC: - return staff_path_finding_mechanic(peep); - case STAFF_TYPE_SECURITY: - return staff_path_finding_misc(peep); - case STAFF_TYPE_ENTERTAINER: - return staff_path_finding_entertainer(peep); + case STAFF_TYPE_HANDYMAN: + return staff_path_finding_handyman(peep); + case STAFF_TYPE_MECHANIC: + return staff_path_finding_mechanic(peep); + case STAFF_TYPE_SECURITY: + return staff_path_finding_misc(peep); + case STAFF_TYPE_ENTERTAINER: + return staff_path_finding_entertainer(peep); - default: - assert(false); - return 0; + default: + assert(false); + return 0; } } @@ -1555,10 +1570,10 @@ void game_command_pickup_staff( int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, [[maybe_unused]] int32_t* esi, int32_t* edi, int32_t* ebp) { int32_t peepnum = *eax; - int32_t x = *edi; - int32_t y = *ebp; - int32_t z = *edx; - int32_t action = *ecx; + int32_t x = *edi; + int32_t y = *ebp; + int32_t z = *edx; + int32_t action = *ecx; if (peep_pickup_command(peepnum, x, y, z, action, *ebx & GAME_COMMAND_FLAG_APPLY)) { *ebx = 0; @@ -1573,17 +1588,17 @@ colour_t staff_get_colour(uint8_t staffType) { switch (staffType) { - case STAFF_TYPE_HANDYMAN: - return gStaffHandymanColour; - case STAFF_TYPE_MECHANIC: - return gStaffMechanicColour; - case STAFF_TYPE_SECURITY: - return gStaffSecurityColour; - case STAFF_TYPE_ENTERTAINER: - return 0; - default: - assert(false); - return 0; + case STAFF_TYPE_HANDYMAN: + return gStaffHandymanColour; + case STAFF_TYPE_MECHANIC: + return gStaffMechanicColour; + case STAFF_TYPE_SECURITY: + return gStaffSecurityColour; + case STAFF_TYPE_ENTERTAINER: + return 0; + default: + assert(false); + return 0; } } @@ -1591,17 +1606,17 @@ bool staff_set_colour(uint8_t staffType, colour_t value) { switch (staffType) { - case STAFF_TYPE_HANDYMAN: - gStaffHandymanColour = value; - break; - case STAFF_TYPE_MECHANIC: - gStaffMechanicColour = value; - break; - case STAFF_TYPE_SECURITY: - gStaffSecurityColour = value; - break; - default: - return false; + case STAFF_TYPE_HANDYMAN: + gStaffHandymanColour = value; + break; + case STAFF_TYPE_MECHANIC: + gStaffMechanicColour = value; + break; + case STAFF_TYPE_SECURITY: + gStaffSecurityColour = value; + break; + default: + return false; } return true; } @@ -1622,15 +1637,16 @@ uint32_t staff_get_available_entertainer_costumes() entertainerCostumes >>= 4; // Fix #6593: force enable the default costumes, which normally get enabled through the default scenery groups. - entertainerCostumes |= (1 << ENTERTAINER_COSTUME_PANDA) | (1 << ENTERTAINER_COSTUME_TIGER) | (1 << ENTERTAINER_COSTUME_ELEPHANT); + entertainerCostumes + |= (1 << ENTERTAINER_COSTUME_PANDA) | (1 << ENTERTAINER_COSTUME_TIGER) | (1 << ENTERTAINER_COSTUME_ELEPHANT); return entertainerCostumes; } -int32_t staff_get_available_entertainer_costume_list(uint8_t * costumeList) +int32_t staff_get_available_entertainer_costume_list(uint8_t* costumeList) { uint32_t availableCostumes = staff_get_available_entertainer_costumes(); - int32_t numCostumes = 0; + int32_t numCostumes = 0; for (uint8_t i = 0; i < ENTERTAINER_COSTUME_COUNT; i++) { if (availableCostumes & (1 << i)) @@ -1688,7 +1704,7 @@ void rct_peep::UpdateMowing() if (var_37 != 7) continue; - rct_tile_element * tile_element = map_get_first_element_at(next_x / 32, next_y / 32); + rct_tile_element* tile_element = map_get_first_element_at(next_x / 32, next_y / 32); for (; (tile_element->GetType() != TILE_ELEMENT_TYPE_SURFACE); tile_element++) ; @@ -1696,8 +1712,7 @@ void rct_peep::UpdateMowing() if ((tile_element->properties.surface.terrain & TILE_ELEMENT_SURFACE_TERRAIN_MASK) == (TERRAIN_GRASS << 5)) { tile_element->properties.surface.grass_length = GRASS_LENGTH_MOWED; - map_invalidate_tile_zoom0(next_x, next_y, tile_element->base_height * 8, - tile_element->base_height * 8 + 16); + map_invalidate_tile_zoom0(next_x, next_y, tile_element->base_height * 8, tile_element->base_height * 8 + 16); } staff_lawns_mown++; window_invalidate_flags |= PEEP_INVALIDATE_STAFF_STATS; @@ -1721,9 +1736,9 @@ void rct_peep::UpdateWatering() if (!(pathingResult & PATHING_DESTINATION_REACHED)) return; - sprite_direction = (var_37 & 3) << 3; - action = PEEP_ACTION_STAFF_WATERING; - action_frame = 0; + sprite_direction = (var_37 & 3) << 3; + action = PEEP_ACTION_STAFF_WATERING; + action_frame = 0; action_sprite_image_offset = 0; UpdateCurrentActionSpriteType(); Invalidate(); @@ -1742,7 +1757,7 @@ void rct_peep::UpdateWatering() int32_t actionX = next_x + CoordsDirectionDelta[var_37].x; int32_t actionY = next_y + CoordsDirectionDelta[var_37].y; - rct_tile_element * tile_element = map_get_first_element_at(actionX / 32, actionY / 32); + rct_tile_element* tile_element = map_get_first_element_at(actionX / 32, actionY / 32); do { @@ -1752,7 +1767,7 @@ void rct_peep::UpdateWatering() if (abs(((int32_t)next_z) - tile_element->base_height) > 4) continue; - rct_scenery_entry * scenery_entry = get_small_scenery_entry(tile_element->properties.scenery.type); + rct_scenery_entry* scenery_entry = get_small_scenery_entry(tile_element->properties.scenery.type); if (!scenery_small_entry_has_flag(scenery_entry, SMALL_SCENERY_FLAG_CAN_BE_WATERED)) continue; @@ -1784,9 +1799,9 @@ void rct_peep::UpdateEmptyingBin() if (!(pathingResult & PATHING_DESTINATION_REACHED)) return; - sprite_direction = (var_37 & 3) << 3; - action = PEEP_ACTION_STAFF_EMPTY_BIN; - action_frame = 0; + sprite_direction = (var_37 & 3) << 3; + action = PEEP_ACTION_STAFF_EMPTY_BIN; + action_frame = 0; action_sprite_image_offset = 0; UpdateCurrentActionSpriteType(); Invalidate(); @@ -1795,7 +1810,6 @@ void rct_peep::UpdateEmptyingBin() } else if (sub_state == 1) { - if (action == PEEP_ACTION_NONE_2) { StateReset(); @@ -1810,7 +1824,7 @@ void rct_peep::UpdateEmptyingBin() if (action_frame != 11) return; - rct_tile_element * tile_element = map_get_first_element_at(next_x / 32, next_y / 32); + rct_tile_element* tile_element = map_get_first_element_at(next_x / 32, next_y / 32); for (;; tile_element++) { @@ -1832,9 +1846,9 @@ void rct_peep::UpdateEmptyingBin() return; } - rct_scenery_entry * scenery_entry = get_footpath_item_entry(footpath_element_get_path_scenery_index(tile_element)); - if (!(scenery_entry->path_bit.flags & PATH_BIT_FLAG_IS_BIN) || tile_element->flags & (1 << 5) || - footpath_element_path_scenery_is_ghost(tile_element)) + rct_scenery_entry* scenery_entry = get_footpath_item_entry(footpath_element_get_path_scenery_index(tile_element)); + if (!(scenery_entry->path_bit.flags & PATH_BIT_FLAG_IS_BIN) || tile_element->flags & (1 << 5) + || footpath_element_path_scenery_is_ghost(tile_element)) { StateReset(); return; @@ -1882,8 +1896,8 @@ void rct_peep::UpdateSweeping() var_37++; if (var_37 != 2) { - action = PEEP_ACTION_STAFF_SWEEP; - action_frame = 0; + action = PEEP_ACTION_STAFF_SWEEP; + action_frame = 0; action_sprite_image_offset = 0; UpdateCurrentActionSpriteType(); Invalidate(); @@ -1898,7 +1912,7 @@ void rct_peep::UpdateSweeping() */ void rct_peep::UpdateHeadingToInspect() { - Ride * ride = get_ride(current_ride); + Ride* ride = get_ride(current_ride); if (ride->type == RIDE_TYPE_NULL) { @@ -1943,7 +1957,7 @@ void rct_peep::UpdateHeadingToInspect() return; uint8_t pathingResult; - rct_tile_element * rideEntranceExitElement; + rct_tile_element* rideEntranceExitElement; PerformNextAction(pathingResult, rideEntranceExitElement); if (!(pathingResult & PATHING_RIDE_EXIT) && !(pathingResult & PATHING_RIDE_ENTRANCE)) @@ -1972,12 +1986,12 @@ void rct_peep::UpdateHeadingToInspect() int32_t destX = next_x + 16 + word_981D6C[direction].x * 53; int32_t destY = next_y + 16 + word_981D6C[direction].y * 53; - destination_x = destX; - destination_y = destY; + destination_x = destX; + destination_y = destY; destination_tolerance = 2; - sprite_direction = direction << 3; + sprite_direction = direction << 3; - z = rideEntranceExitElement->base_height * 4; + z = rideEntranceExitElement->base_height * 4; sub_state = 4; // Falls through into sub_state 4 } @@ -2011,19 +2025,18 @@ void rct_peep::UpdateHeadingToInspect() */ void rct_peep::UpdateAnswering() { - Ride * ride = get_ride(current_ride); + Ride* ride = get_ride(current_ride); if (ride->type == RIDE_TYPE_NULL || ride->mechanic_status != RIDE_MECHANIC_STATUS_HEADING) { - SetState(PEEP_STATE_FALLING); return; } if (sub_state == 0) { - action = PEEP_ACTION_STAFF_ANSWER_CALL; - action_frame = 0; + action = PEEP_ACTION_STAFF_ANSWER_CALL; + action_frame = 0; action_sprite_image_offset = 0; UpdateCurrentActionSpriteType(); @@ -2062,7 +2075,7 @@ void rct_peep::UpdateAnswering() return; uint8_t pathingResult; - rct_tile_element * rideEntranceExitElement; + rct_tile_element* rideEntranceExitElement; PerformNextAction(pathingResult, rideEntranceExitElement); if (!(pathingResult & PATHING_RIDE_EXIT) && !(pathingResult & PATHING_RIDE_ENTRANCE)) @@ -2091,12 +2104,12 @@ void rct_peep::UpdateAnswering() int32_t destX = next_x + 16 + word_981D6C[direction].x * 53; int32_t destY = next_y + 16 + word_981D6C[direction].y * 53; - destination_x = destX; - destination_y = destY; + destination_x = destX; + destination_y = destY; destination_tolerance = 2; - sprite_direction = direction << 3; + sprite_direction = direction << 3; - z = rideEntranceExitElement->base_height * 4; + z = rideEntranceExitElement->base_height * 4; sub_state = 4; // Falls through into sub_state 4 } @@ -2133,7 +2146,7 @@ static constexpr const LocationXY16 _WateringUseOffsets[] = { * * rct2: 0x006BF483 */ -static int32_t peep_update_patrolling_find_watering(rct_peep * peep) +static int32_t peep_update_patrolling_find_watering(rct_peep* peep) { if (!(peep->staff_orders & STAFF_ORDERS_WATER_FLOWERS)) return 0; @@ -2146,7 +2159,7 @@ static int32_t peep_update_patrolling_find_watering(rct_peep * peep) int32_t x = peep->next_x + CoordsDirectionDelta[chosen_position].x; int32_t y = peep->next_y + CoordsDirectionDelta[chosen_position].y; - rct_tile_element * tile_element = map_get_first_element_at(x / 32, y / 32); + rct_tile_element* tile_element = map_get_first_element_at(x / 32, y / 32); // This seems to happen in some SV4 files. if (tile_element == nullptr) @@ -2168,7 +2181,7 @@ static int32_t peep_update_patrolling_find_watering(rct_peep * peep) continue; } - rct_scenery_entry * sceneryEntry = get_small_scenery_entry(tile_element->properties.scenery.type); + rct_scenery_entry* sceneryEntry = get_small_scenery_entry(tile_element->properties.scenery.type); if (sceneryEntry == nullptr || !scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_CAN_BE_WATERED)) { @@ -2191,9 +2204,9 @@ static int32_t peep_update_patrolling_find_watering(rct_peep * peep) peep->SetState(PEEP_STATE_WATERING); peep->var_37 = chosen_position; - peep->sub_state = 0; - peep->destination_x = (peep->x & 0xFFE0) + _WateringUseOffsets[chosen_position].x; - peep->destination_y = (peep->y & 0xFFE0) + _WateringUseOffsets[chosen_position].y; + peep->sub_state = 0; + peep->destination_x = (peep->x & 0xFFE0) + _WateringUseOffsets[chosen_position].x; + peep->destination_y = (peep->y & 0xFFE0) + _WateringUseOffsets[chosen_position].y; peep->destination_tolerance = 3; return 1; @@ -2206,7 +2219,7 @@ static int32_t peep_update_patrolling_find_watering(rct_peep * peep) * * rct2: 0x006BF3A1 */ -static int32_t peep_update_patrolling_find_bin(rct_peep * peep) +static int32_t peep_update_patrolling_find_bin(rct_peep* peep) { if (!(peep->staff_orders & STAFF_ORDERS_EMPTY_BINS)) return 0; @@ -2214,13 +2227,12 @@ static int32_t peep_update_patrolling_find_bin(rct_peep * peep) if (peep->GetNextIsSurface()) return 0; - rct_tile_element * tileElement = map_get_first_element_at(peep->next_x / 32, peep->next_y / 32); + rct_tile_element* tileElement = map_get_first_element_at(peep->next_x / 32, peep->next_y / 32); if (tileElement == nullptr) return 0; for (;; tileElement++) { - if (tileElement->GetType() == TILE_ELEMENT_TYPE_PATH && (tileElement->base_height == peep->next_z)) break; @@ -2230,7 +2242,7 @@ static int32_t peep_update_patrolling_find_bin(rct_peep * peep) if (!footpath_element_has_path_scenery(tileElement)) return 0; - rct_scenery_entry * sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(tileElement)); + rct_scenery_entry* sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(tileElement)); if (!(sceneryEntry->path_bit.flags & PATH_BIT_FLAG_IS_BIN)) return 0; @@ -2241,8 +2253,8 @@ static int32_t peep_update_patrolling_find_bin(rct_peep * peep) if (footpath_element_path_scenery_is_ghost(tileElement)) return 0; - uint8_t bin_positions = tileElement->properties.path.edges & 0xF; - uint8_t bin_quantity = tileElement->properties.path.addition_status; + uint8_t bin_positions = tileElement->properties.path.edges & 0xF; + uint8_t bin_quantity = tileElement->properties.path.addition_status; uint8_t chosen_position = 0; for (; chosen_position < 4; ++chosen_position) @@ -2259,9 +2271,9 @@ static int32_t peep_update_patrolling_find_bin(rct_peep * peep) peep->var_37 = chosen_position; peep->SetState(PEEP_STATE_EMPTYING_BIN); - peep->sub_state = 0; - peep->destination_x = (peep->x & 0xFFE0) + BinUseOffsets[chosen_position].x; - peep->destination_y = (peep->y & 0xFFE0) + BinUseOffsets[chosen_position].y; + peep->sub_state = 0; + peep->destination_x = (peep->x & 0xFFE0) + BinUseOffsets[chosen_position].x; + peep->destination_y = (peep->y & 0xFFE0) + BinUseOffsets[chosen_position].y; peep->destination_tolerance = 3; return 1; } @@ -2270,7 +2282,7 @@ static int32_t peep_update_patrolling_find_bin(rct_peep * peep) * * rct2: 0x006BF322 */ -static int32_t peep_update_patrolling_find_grass(rct_peep * peep) +static int32_t peep_update_patrolling_find_grass(rct_peep* peep) { if (!(peep->staff_orders & STAFF_ORDERS_MOWING)) return 0; @@ -2281,7 +2293,7 @@ static int32_t peep_update_patrolling_find_grass(rct_peep * peep) if (!(peep->GetNextIsSurface())) return 0; - rct_tile_element * tile_element = map_get_surface_element_at({peep->next_x, peep->next_y}); + rct_tile_element* tile_element = map_get_surface_element_at({ peep->next_x, peep->next_y }); if ((tile_element->properties.surface.terrain & TILE_ELEMENT_SURFACE_TERRAIN_MASK) != TERRAIN_GRASS) return 0; @@ -2292,8 +2304,8 @@ static int32_t peep_update_patrolling_find_grass(rct_peep * peep) peep->SetState(PEEP_STATE_MOWING); peep->var_37 = 0; // Original code used .y for both x and y. Changed to .x to make more sense (both x and y are 28) - peep->destination_x = peep->next_x + _MowingWaypoints[0].x; - peep->destination_y = peep->next_y + _MowingWaypoints[0].y; + peep->destination_x = peep->next_x + _MowingWaypoints[0].x; + peep->destination_y = peep->next_y + _MowingWaypoints[0].y; peep->destination_tolerance = 3; return 1; } @@ -2302,16 +2314,15 @@ static int32_t peep_update_patrolling_find_grass(rct_peep * peep) * * rct2: 0x006BF295 */ -static int32_t peep_update_patrolling_find_sweeping(rct_peep * peep) +static int32_t peep_update_patrolling_find_sweeping(rct_peep* peep) { if (!(peep->staff_orders & STAFF_ORDERS_SWEEPING)) return 0; uint16_t sprite_id = sprite_get_first_in_quadrant(peep->x, peep->y); - for (rct_sprite * sprite = nullptr; sprite_id != SPRITE_INDEX_NULL; sprite_id = sprite->unknown.next_in_quadrant) + for (rct_sprite* sprite = nullptr; sprite_id != SPRITE_INDEX_NULL; sprite_id = sprite->unknown.next_in_quadrant) { - sprite = get_sprite(sprite_id); if (sprite->unknown.linked_list_type_offset != SPRITE_LIST_LITTER * 2) @@ -2323,9 +2334,9 @@ static int32_t peep_update_patrolling_find_sweeping(rct_peep * peep) continue; peep->SetState(PEEP_STATE_SWEEPING); - peep->var_37 = 0; - peep->destination_x = sprite->litter.x; - peep->destination_y = sprite->litter.y; + peep->var_37 = 0; + peep->destination_x = sprite->litter.x; + peep->destination_y = sprite->litter.y; peep->destination_tolerance = 5; return 1; } @@ -2345,9 +2356,9 @@ void rct_peep::Tick128UpdateStaff() if (sprite_type == newSpriteType) return; - sprite_type = newSpriteType; + sprite_type = newSpriteType; action_sprite_image_offset = 0; - no_action_frame_num = 0; + no_action_frame_num = 0; if (action < PEEP_ACTION_NONE_1) action = PEEP_ACTION_NONE_2; @@ -2382,7 +2393,7 @@ void rct_peep::UpdatePatrolling() if (GetNextIsSurface()) { - rct_tile_element * tile_element = map_get_surface_element_at({next_x, next_y}); + rct_tile_element* tile_element = map_get_surface_element_at({ next_x, next_y }); if (tile_element != nullptr) { @@ -2417,21 +2428,21 @@ void rct_peep::UpdatePatrolling() enum { - PEEP_FIXING_ENTER_STATION = 0, - PEEP_FIXING_MOVE_TO_BROKEN_DOWN_VEHICLE = 1, + PEEP_FIXING_ENTER_STATION = 0, + PEEP_FIXING_MOVE_TO_BROKEN_DOWN_VEHICLE = 1, PEEP_FIXING_FIX_VEHICLE_CLOSED_RESTRAINTS = 2, - PEEP_FIXING_FIX_VEHICLE_CLOSED_DOORS = 3, - PEEP_FIXING_FIX_VEHICLE_OPEN_RESTRAINTS = 4, - PEEP_FIXING_FIX_VEHICLE_OPEN_DOORS = 5, - PEEP_FIXING_FIX_VEHICLE_MALFUNCTION = 6, - PEEP_FIXING_MOVE_TO_STATION_END = 7, - PEEP_FIXING_FIX_STATION_END = 8, - PEEP_FIXING_MOVE_TO_STATION_START = 9, - PEEP_FIXING_FIX_STATION_START = 10, - PEEP_FIXING_FIX_STATION_BRAKES = 11, - PEEP_FIXING_MOVE_TO_STATION_EXIT = 12, - PEEP_FIXING_FINISH_FIX_OR_INSPECT = 13, - PEEP_FIXING_LEAVE_BY_ENTRANCE_EXIT = 14, + PEEP_FIXING_FIX_VEHICLE_CLOSED_DOORS = 3, + PEEP_FIXING_FIX_VEHICLE_OPEN_RESTRAINTS = 4, + PEEP_FIXING_FIX_VEHICLE_OPEN_DOORS = 5, + PEEP_FIXING_FIX_VEHICLE_MALFUNCTION = 6, + PEEP_FIXING_MOVE_TO_STATION_END = 7, + PEEP_FIXING_FIX_STATION_END = 8, + PEEP_FIXING_MOVE_TO_STATION_START = 9, + PEEP_FIXING_FIX_STATION_START = 10, + PEEP_FIXING_FIX_STATION_BRAKES = 11, + PEEP_FIXING_MOVE_TO_STATION_EXIT = 12, + PEEP_FIXING_FINISH_FIX_OR_INSPECT = 13, + PEEP_FIXING_LEAVE_BY_ENTRANCE_EXIT = 14, }; /** @@ -2442,75 +2453,42 @@ enum * - index 8 is for inspecting a ride. */ static constexpr const uint32_t FixingSubstatesForBreakdown[9] = { - ( // BREAKDOWN_SAFETY_CUT_OUT - (1 << PEEP_FIXING_MOVE_TO_STATION_END) | - (1 << PEEP_FIXING_FIX_STATION_END) | - (1 << PEEP_FIXING_MOVE_TO_STATION_START) | - (1 << PEEP_FIXING_FIX_STATION_START) | - (1 << PEEP_FIXING_MOVE_TO_STATION_EXIT) | - (1 << PEEP_FIXING_FINISH_FIX_OR_INSPECT) | - (1 << PEEP_FIXING_LEAVE_BY_ENTRANCE_EXIT) - ), - ( // BREAKDOWN_RESTRAINTS_STUCK_CLOSED - (1 << PEEP_FIXING_MOVE_TO_BROKEN_DOWN_VEHICLE) | - (1 << PEEP_FIXING_FIX_VEHICLE_CLOSED_RESTRAINTS) | - (1 << PEEP_FIXING_MOVE_TO_STATION_EXIT) | - (1 << PEEP_FIXING_FINISH_FIX_OR_INSPECT) | - (1 << PEEP_FIXING_LEAVE_BY_ENTRANCE_EXIT) - ), - ( // BREAKDOWN_RESTRAINTS_STUCK_OPEN - (1 << PEEP_FIXING_MOVE_TO_BROKEN_DOWN_VEHICLE) | - (1 << PEEP_FIXING_FIX_VEHICLE_OPEN_RESTRAINTS) | - (1 << PEEP_FIXING_MOVE_TO_STATION_EXIT) | - (1 << PEEP_FIXING_FINISH_FIX_OR_INSPECT) | - (1 << PEEP_FIXING_LEAVE_BY_ENTRANCE_EXIT) - ), - ( // BREAKDOWN_DOORS_STUCK_CLOSED - (1 << PEEP_FIXING_MOVE_TO_BROKEN_DOWN_VEHICLE) | - (1 << PEEP_FIXING_FIX_VEHICLE_CLOSED_DOORS) | - (1 << PEEP_FIXING_MOVE_TO_STATION_EXIT) | - (1 << PEEP_FIXING_FINISH_FIX_OR_INSPECT) | - (1 << PEEP_FIXING_LEAVE_BY_ENTRANCE_EXIT) - ), - ( // BREAKDOWN_DOORS_STUCK_OPEN - (1 << PEEP_FIXING_MOVE_TO_BROKEN_DOWN_VEHICLE) | - (1 << PEEP_FIXING_FIX_VEHICLE_OPEN_DOORS) | - (1 << PEEP_FIXING_MOVE_TO_STATION_EXIT) | - (1 << PEEP_FIXING_FINISH_FIX_OR_INSPECT) | - (1 << PEEP_FIXING_LEAVE_BY_ENTRANCE_EXIT) - ), - ( // BREAKDOWN_VEHICLE_MALFUNCTION - (1 << PEEP_FIXING_MOVE_TO_BROKEN_DOWN_VEHICLE) | - (1 << PEEP_FIXING_FIX_VEHICLE_MALFUNCTION) | - (1 << PEEP_FIXING_MOVE_TO_STATION_EXIT) | - (1 << PEEP_FIXING_FINISH_FIX_OR_INSPECT) | - (1 << PEEP_FIXING_LEAVE_BY_ENTRANCE_EXIT) - ), - ( // BREAKDOWN_BRAKES_FAILURE - (1 << PEEP_FIXING_MOVE_TO_STATION_START) | - (1 << PEEP_FIXING_FIX_STATION_BRAKES) | - (1 << PEEP_FIXING_MOVE_TO_STATION_EXIT) | - (1 << PEEP_FIXING_FINISH_FIX_OR_INSPECT) | - (1 << PEEP_FIXING_LEAVE_BY_ENTRANCE_EXIT) - ), - ( // BREAKDOWN_CONTROL_FAILURE - (1 << PEEP_FIXING_MOVE_TO_STATION_END) | - (1 << PEEP_FIXING_FIX_STATION_END) | - (1 << PEEP_FIXING_MOVE_TO_STATION_START) | - (1 << PEEP_FIXING_FIX_STATION_START) | - (1 << PEEP_FIXING_MOVE_TO_STATION_EXIT) | - (1 << PEEP_FIXING_FINISH_FIX_OR_INSPECT) | - (1 << PEEP_FIXING_LEAVE_BY_ENTRANCE_EXIT) - ), - ( // INSPECTION - (1 << PEEP_FIXING_MOVE_TO_STATION_END) | - (1 << PEEP_FIXING_FIX_STATION_END) | - (1 << PEEP_FIXING_MOVE_TO_STATION_START) | - (1 << PEEP_FIXING_FIX_STATION_START) | - (1 << PEEP_FIXING_MOVE_TO_STATION_EXIT) | - (1 << PEEP_FIXING_FINISH_FIX_OR_INSPECT) | - (1 << PEEP_FIXING_LEAVE_BY_ENTRANCE_EXIT) - ) + ( // BREAKDOWN_SAFETY_CUT_OUT + (1 << PEEP_FIXING_MOVE_TO_STATION_END) | (1 << PEEP_FIXING_FIX_STATION_END) | (1 << PEEP_FIXING_MOVE_TO_STATION_START) + | (1 << PEEP_FIXING_FIX_STATION_START) | (1 << PEEP_FIXING_MOVE_TO_STATION_EXIT) + | (1 << PEEP_FIXING_FINISH_FIX_OR_INSPECT) | (1 << PEEP_FIXING_LEAVE_BY_ENTRANCE_EXIT)), + ( // BREAKDOWN_RESTRAINTS_STUCK_CLOSED + (1 << PEEP_FIXING_MOVE_TO_BROKEN_DOWN_VEHICLE) | (1 << PEEP_FIXING_FIX_VEHICLE_CLOSED_RESTRAINTS) + | (1 << PEEP_FIXING_MOVE_TO_STATION_EXIT) | (1 << PEEP_FIXING_FINISH_FIX_OR_INSPECT) + | (1 << PEEP_FIXING_LEAVE_BY_ENTRANCE_EXIT)), + ( // BREAKDOWN_RESTRAINTS_STUCK_OPEN + (1 << PEEP_FIXING_MOVE_TO_BROKEN_DOWN_VEHICLE) | (1 << PEEP_FIXING_FIX_VEHICLE_OPEN_RESTRAINTS) + | (1 << PEEP_FIXING_MOVE_TO_STATION_EXIT) | (1 << PEEP_FIXING_FINISH_FIX_OR_INSPECT) + | (1 << PEEP_FIXING_LEAVE_BY_ENTRANCE_EXIT)), + ( // BREAKDOWN_DOORS_STUCK_CLOSED + (1 << PEEP_FIXING_MOVE_TO_BROKEN_DOWN_VEHICLE) | (1 << PEEP_FIXING_FIX_VEHICLE_CLOSED_DOORS) + | (1 << PEEP_FIXING_MOVE_TO_STATION_EXIT) | (1 << PEEP_FIXING_FINISH_FIX_OR_INSPECT) + | (1 << PEEP_FIXING_LEAVE_BY_ENTRANCE_EXIT)), + ( // BREAKDOWN_DOORS_STUCK_OPEN + (1 << PEEP_FIXING_MOVE_TO_BROKEN_DOWN_VEHICLE) | (1 << PEEP_FIXING_FIX_VEHICLE_OPEN_DOORS) + | (1 << PEEP_FIXING_MOVE_TO_STATION_EXIT) | (1 << PEEP_FIXING_FINISH_FIX_OR_INSPECT) + | (1 << PEEP_FIXING_LEAVE_BY_ENTRANCE_EXIT)), + ( // BREAKDOWN_VEHICLE_MALFUNCTION + (1 << PEEP_FIXING_MOVE_TO_BROKEN_DOWN_VEHICLE) | (1 << PEEP_FIXING_FIX_VEHICLE_MALFUNCTION) + | (1 << PEEP_FIXING_MOVE_TO_STATION_EXIT) | (1 << PEEP_FIXING_FINISH_FIX_OR_INSPECT) + | (1 << PEEP_FIXING_LEAVE_BY_ENTRANCE_EXIT)), + ( // BREAKDOWN_BRAKES_FAILURE + (1 << PEEP_FIXING_MOVE_TO_STATION_START) | (1 << PEEP_FIXING_FIX_STATION_BRAKES) + | (1 << PEEP_FIXING_MOVE_TO_STATION_EXIT) | (1 << PEEP_FIXING_FINISH_FIX_OR_INSPECT) + | (1 << PEEP_FIXING_LEAVE_BY_ENTRANCE_EXIT)), + ( // BREAKDOWN_CONTROL_FAILURE + (1 << PEEP_FIXING_MOVE_TO_STATION_END) | (1 << PEEP_FIXING_FIX_STATION_END) | (1 << PEEP_FIXING_MOVE_TO_STATION_START) + | (1 << PEEP_FIXING_FIX_STATION_START) | (1 << PEEP_FIXING_MOVE_TO_STATION_EXIT) + | (1 << PEEP_FIXING_FINISH_FIX_OR_INSPECT) | (1 << PEEP_FIXING_LEAVE_BY_ENTRANCE_EXIT)), + ( // INSPECTION + (1 << PEEP_FIXING_MOVE_TO_STATION_END) | (1 << PEEP_FIXING_FIX_STATION_END) | (1 << PEEP_FIXING_MOVE_TO_STATION_START) + | (1 << PEEP_FIXING_FIX_STATION_START) | (1 << PEEP_FIXING_MOVE_TO_STATION_EXIT) + | (1 << PEEP_FIXING_FINISH_FIX_OR_INSPECT) | (1 << PEEP_FIXING_LEAVE_BY_ENTRANCE_EXIT)) }; /** @@ -2520,7 +2498,7 @@ static constexpr const uint32_t FixingSubstatesForBreakdown[9] = { */ void rct_peep::UpdateFixing(int32_t steps) { - Ride * ride = get_ride(current_ride); + Ride* ride = get_ride(current_ride); if (ride->type == RIDE_TYPE_NULL) { @@ -2529,10 +2507,10 @@ void rct_peep::UpdateFixing(int32_t steps) } bool progressToNextSubstate = true; - bool firstRun = true; + bool firstRun = true; - if ((state == PEEP_STATE_INSPECTING) && - (ride->lifecycle_flags & ( RIDE_LIFECYCLE_BREAKDOWN_PENDING | RIDE_LIFECYCLE_BROKEN_DOWN))) + if ((state == PEEP_STATE_INSPECTING) + && (ride->lifecycle_flags & (RIDE_LIFECYCLE_BREAKDOWN_PENDING | RIDE_LIFECYCLE_BROKEN_DOWN))) { // Ride has broken down since Mechanic was called to inspect it. // Mechanic identifies the breakdown and switches to fixing it. @@ -2543,61 +2521,61 @@ void rct_peep::UpdateFixing(int32_t steps) { switch (sub_state) { - case PEEP_FIXING_ENTER_STATION: - next_flags &= ~PEEP_NEXT_FLAG_IS_SLOPED; - progressToNextSubstate = UpdateFixingEnterStation(ride); - break; + case PEEP_FIXING_ENTER_STATION: + next_flags &= ~PEEP_NEXT_FLAG_IS_SLOPED; + progressToNextSubstate = UpdateFixingEnterStation(ride); + break; - case PEEP_FIXING_MOVE_TO_BROKEN_DOWN_VEHICLE: - progressToNextSubstate = UpdateFixingMoveToBrokenDownVehicle(firstRun, ride); - break; + case PEEP_FIXING_MOVE_TO_BROKEN_DOWN_VEHICLE: + progressToNextSubstate = UpdateFixingMoveToBrokenDownVehicle(firstRun, ride); + break; - case PEEP_FIXING_FIX_VEHICLE_CLOSED_RESTRAINTS: - case PEEP_FIXING_FIX_VEHICLE_CLOSED_DOORS: - case PEEP_FIXING_FIX_VEHICLE_OPEN_RESTRAINTS: - case PEEP_FIXING_FIX_VEHICLE_OPEN_DOORS: - progressToNextSubstate = UpdateFixingFixVehicle(firstRun, ride); - break; + case PEEP_FIXING_FIX_VEHICLE_CLOSED_RESTRAINTS: + case PEEP_FIXING_FIX_VEHICLE_CLOSED_DOORS: + case PEEP_FIXING_FIX_VEHICLE_OPEN_RESTRAINTS: + case PEEP_FIXING_FIX_VEHICLE_OPEN_DOORS: + progressToNextSubstate = UpdateFixingFixVehicle(firstRun, ride); + break; - case PEEP_FIXING_FIX_VEHICLE_MALFUNCTION: - progressToNextSubstate = UpdateFixingFixVehicleMalfunction(firstRun, ride); - break; + case PEEP_FIXING_FIX_VEHICLE_MALFUNCTION: + progressToNextSubstate = UpdateFixingFixVehicleMalfunction(firstRun, ride); + break; - case PEEP_FIXING_MOVE_TO_STATION_END: - progressToNextSubstate = UpdateFixingMoveToStationEnd(firstRun, ride); - break; + case PEEP_FIXING_MOVE_TO_STATION_END: + progressToNextSubstate = UpdateFixingMoveToStationEnd(firstRun, ride); + break; - case PEEP_FIXING_FIX_STATION_END: - progressToNextSubstate = UpdateFixingFixStationEnd(firstRun); - break; + case PEEP_FIXING_FIX_STATION_END: + progressToNextSubstate = UpdateFixingFixStationEnd(firstRun); + break; - case PEEP_FIXING_MOVE_TO_STATION_START: - progressToNextSubstate = UpdateFixingMoveToStationStart(firstRun, ride); - break; + case PEEP_FIXING_MOVE_TO_STATION_START: + progressToNextSubstate = UpdateFixingMoveToStationStart(firstRun, ride); + break; - case PEEP_FIXING_FIX_STATION_START: - progressToNextSubstate = UpdateFixingFixStationStart(firstRun, ride); - break; + case PEEP_FIXING_FIX_STATION_START: + progressToNextSubstate = UpdateFixingFixStationStart(firstRun, ride); + break; - case PEEP_FIXING_FIX_STATION_BRAKES: - progressToNextSubstate = UpdateFixingFixStationBrakes(firstRun, ride); - break; + case PEEP_FIXING_FIX_STATION_BRAKES: + progressToNextSubstate = UpdateFixingFixStationBrakes(firstRun, ride); + break; - case PEEP_FIXING_MOVE_TO_STATION_EXIT: - progressToNextSubstate = UpdateFixingMoveToStationExit(firstRun, ride); - break; + case PEEP_FIXING_MOVE_TO_STATION_EXIT: + progressToNextSubstate = UpdateFixingMoveToStationExit(firstRun, ride); + break; - case PEEP_FIXING_FINISH_FIX_OR_INSPECT: - progressToNextSubstate = UpdateFixingFinishFixOrInspect(firstRun, steps, ride); - break; + case PEEP_FIXING_FINISH_FIX_OR_INSPECT: + progressToNextSubstate = UpdateFixingFinishFixOrInspect(firstRun, steps, ride); + break; - case PEEP_FIXING_LEAVE_BY_ENTRANCE_EXIT: - progressToNextSubstate = UpdateFixingLeaveByEntranceExit(firstRun, ride); - break; + case PEEP_FIXING_LEAVE_BY_ENTRANCE_EXIT: + progressToNextSubstate = UpdateFixingLeaveByEntranceExit(firstRun, ride); + break; - default: - log_error("Invalid substate"); - progressToNextSubstate = false; + default: + log_error("Invalid substate"); + progressToNextSubstate = false; } firstRun = false; @@ -2607,7 +2585,7 @@ void rct_peep::UpdateFixing(int32_t steps) break; } - int32_t subState = sub_state; + int32_t subState = sub_state; uint32_t sub_state_sequence_mask = FixingSubstatesForBreakdown[8]; if (state != PEEP_STATE_INSPECTING) @@ -2628,7 +2606,7 @@ void rct_peep::UpdateFixing(int32_t steps) * rct2: 0x006C0EEC * fixing sub_state: enter_station - applies to fixing all break down reasons and ride inspections. */ -bool rct_peep::UpdateFixingEnterStation(Ride * ride) +bool rct_peep::UpdateFixingEnterStation(Ride* ride) { ride->mechanic_status = RIDE_MECHANIC_STATUS_FIXING; ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_MAINTENANCE; @@ -2641,11 +2619,11 @@ bool rct_peep::UpdateFixingEnterStation(Ride * ride) * fixing sub_state: move_to_broken_down_vehicle - applies to fixing all vehicle specific breakdown reasons * - see FixingSubstatesForBreakdown[] */ -bool rct_peep::UpdateFixingMoveToBrokenDownVehicle(bool firstRun, Ride * ride) +bool rct_peep::UpdateFixingMoveToBrokenDownVehicle(bool firstRun, Ride* ride) { if (!firstRun) { - rct_vehicle * vehicle = ride_get_broken_vehicle(ride); + rct_vehicle* vehicle = ride_get_broken_vehicle(ride); if (vehicle == nullptr) { return true; @@ -2677,9 +2655,9 @@ bool rct_peep::UpdateFixingMoveToBrokenDownVehicle(bool firstRun, Ride * ride) vehicle = GET_VEHICLE(vehicle->prev_vehicle_on_ride); } - LocationXY16 offset = word_981D6C[direction]; - destination_x = (offset.x * -12) + vehicle->x; - destination_y = (offset.y * -12) + vehicle->y; + LocationXY16 offset = word_981D6C[direction]; + destination_x = (offset.x * -12) + vehicle->x; + destination_y = (offset.y * -12) + vehicle->y; destination_tolerance = 2; } @@ -2687,7 +2665,7 @@ bool rct_peep::UpdateFixingMoveToBrokenDownVehicle(bool firstRun, Ride * ride) int16_t actionX, actionY, tmp_xy_distance; if (UpdateAction(&actionX, &actionY, &tmp_xy_distance)) { - sprite_move(actionX, actionY, z, (rct_sprite *)this); + sprite_move(actionX, actionY, z, (rct_sprite*)this); Invalidate(); return false; } @@ -2704,15 +2682,15 @@ bool rct_peep::UpdateFixingMoveToBrokenDownVehicle(bool firstRun, Ride * ride) * 4. doors stuck open. * - see FixingSubstatesForBreakdown[] */ -bool rct_peep::UpdateFixingFixVehicle(bool firstRun, Ride * ride) +bool rct_peep::UpdateFixingFixVehicle(bool firstRun, Ride* ride) { if (!firstRun) { sprite_direction = direction << 3; - action = (scenario_rand() & 1) ? PEEP_ACTION_STAFF_FIX_2 : PEEP_ACTION_STAFF_FIX; + action = (scenario_rand() & 1) ? PEEP_ACTION_STAFF_FIX_2 : PEEP_ACTION_STAFF_FIX; action_sprite_image_offset = 0; - action_frame = 0; + action_frame = 0; UpdateCurrentActionSpriteType(); Invalidate(); } @@ -2730,7 +2708,7 @@ bool rct_peep::UpdateFixingFixVehicle(bool firstRun, Ride * ride) return false; } - rct_vehicle * vehicle = ride_get_broken_vehicle(ride); + rct_vehicle* vehicle = ride_get_broken_vehicle(ride); if (vehicle == nullptr) { return true; @@ -2746,14 +2724,14 @@ bool rct_peep::UpdateFixingFixVehicle(bool firstRun, Ride * ride) * fixing sub_state: fix_vehicle_malfunction - applies fixing to vehicle malfunction. * - see FixingSubstatesForBreakdown[] */ -bool rct_peep::UpdateFixingFixVehicleMalfunction(bool firstRun, Ride * ride) +bool rct_peep::UpdateFixingFixVehicleMalfunction(bool firstRun, Ride* ride) { if (!firstRun) { - sprite_direction = direction << 3; - action = PEEP_ACTION_STAFF_FIX_3; + sprite_direction = direction << 3; + action = PEEP_ACTION_STAFF_FIX_3; action_sprite_image_offset = 0; - action_frame = 0; + action_frame = 0; UpdateCurrentActionSpriteType(); Invalidate(); @@ -2770,7 +2748,7 @@ bool rct_peep::UpdateFixingFixVehicleMalfunction(bool firstRun, Ride * ride) return false; } - rct_vehicle * vehicle = ride_get_broken_vehicle(ride); + rct_vehicle* vehicle = ride_get_broken_vehicle(ride); if (vehicle == nullptr) { return true; @@ -2791,10 +2769,11 @@ static constexpr const CoordsXY _StationFixingOffsets[] = { /** * rct2: 0x006C1114 - * fixing sub_state: move_to_station_end - applies to fixing station specific breakdowns: safety cut-out, control failure, inspection. + * fixing sub_state: move_to_station_end - applies to fixing station specific breakdowns: safety cut-out, control failure, + * inspection. * - see FixingSubstatesForBreakdown[] */ -bool rct_peep::UpdateFixingMoveToStationEnd(bool firstRun, Ride * ride) +bool rct_peep::UpdateFixingMoveToStationEnd(bool firstRun, Ride* ride) { if (!firstRun) { @@ -2809,19 +2788,19 @@ bool rct_peep::UpdateFixingMoveToStationEnd(bool firstRun, Ride * ride) return true; } - uint8_t stationZ = ride->station_heights[current_ride_station]; + uint8_t stationZ = ride->station_heights[current_ride_station]; uint16_t stationX = stationPosition.x * 32; uint16_t stationY = stationPosition.y * 32; - rct_tile_element * tileElement = map_get_track_element_at(stationX, stationY, stationZ); + rct_tile_element* tileElement = map_get_track_element_at(stationX, stationY, stationZ); if (tileElement == nullptr) { log_error("Couldn't find tile_element"); return false; } - int32_t trackDirection = tile_element_get_direction(tileElement); - CoordsXY offset = _StationFixingOffsets[trackDirection]; + int32_t trackDirection = tile_element_get_direction(tileElement); + CoordsXY offset = _StationFixingOffsets[trackDirection]; stationX += 16 + offset.x; if (offset.x == 0) @@ -2835,8 +2814,8 @@ bool rct_peep::UpdateFixingMoveToStationEnd(bool firstRun, Ride * ride) stationY = destination_y; } - destination_x = stationX; - destination_y = stationY; + destination_x = stationX; + destination_y = stationY; destination_tolerance = 2; } @@ -2847,7 +2826,7 @@ bool rct_peep::UpdateFixingMoveToStationEnd(bool firstRun, Ride * ride) return true; } - sprite_move(actionX, actionY, z, (rct_sprite *)this); + sprite_move(actionX, actionY, z, (rct_sprite*)this); Invalidate(); return false; @@ -2855,16 +2834,17 @@ bool rct_peep::UpdateFixingMoveToStationEnd(bool firstRun, Ride * ride) /** * rct2: 0x006C11F5 - * fixing sub_state: fix_station_end - applies to fixing station specific breakdowns: safety cut-out, control failure, inspection. + * fixing sub_state: fix_station_end - applies to fixing station specific breakdowns: safety cut-out, control failure, + * inspection. * - see FixingSubstatesForBreakdown[] */ bool rct_peep::UpdateFixingFixStationEnd(bool firstRun) { if (!firstRun) { - sprite_direction = direction << 3; - action = PEEP_ACTION_STAFF_CHECKBOARD; - action_frame = 0; + sprite_direction = direction << 3; + action = PEEP_ACTION_STAFF_CHECKBOARD; + action_frame = 0; action_sprite_image_offset = 0; UpdateCurrentActionSpriteType(); @@ -2889,7 +2869,7 @@ bool rct_peep::UpdateFixingFixStationEnd(bool firstRun) * 3. applies to inspection. * - see FixingSubstatesForBreakdown[] */ -bool rct_peep::UpdateFixingMoveToStationStart(bool firstRun, Ride * ride) +bool rct_peep::UpdateFixingMoveToStationStart(bool firstRun, Ride* ride) { if (!firstRun) { @@ -2907,22 +2887,22 @@ bool rct_peep::UpdateFixingMoveToStationStart(bool firstRun, Ride * ride) uint8_t stationZ = ride->station_heights[current_ride_station]; CoordsXYE input; - input.x = stationPosition.x * 32; - input.y = stationPosition.y * 32; + input.x = stationPosition.x * 32; + input.y = stationPosition.y * 32; input.element = map_get_track_element_at_from_ride(input.x, input.y, stationZ, current_ride); if (input.element == nullptr) { return true; } - uint8_t stationDirection = 0; + uint8_t stationDirection = 0; track_begin_end trackBeginEnd; while (track_block_get_previous(input.x, input.y, input.element, &trackBeginEnd)) { if (track_element_is_station(trackBeginEnd.begin_element)) { - input.x = trackBeginEnd.begin_x; - input.y = trackBeginEnd.begin_y; + input.x = trackBeginEnd.begin_x; + input.y = trackBeginEnd.begin_y; input.element = trackBeginEnd.begin_element; stationDirection = tile_element_get_direction(trackBeginEnd.begin_element); @@ -2950,8 +2930,8 @@ bool rct_peep::UpdateFixingMoveToStationStart(bool firstRun, Ride * ride) destinationY = destination_y; } - destination_x = destinationX; - destination_y = destinationY; + destination_x = destinationX; + destination_y = destinationY; destination_tolerance = 2; } @@ -2962,7 +2942,7 @@ bool rct_peep::UpdateFixingMoveToStationStart(bool firstRun, Ride * ride) return true; } - sprite_move(actionX, actionY, z, (rct_sprite *)this); + sprite_move(actionX, actionY, z, (rct_sprite*)this); Invalidate(); return false; @@ -2975,7 +2955,7 @@ bool rct_peep::UpdateFixingMoveToStationStart(bool firstRun, Ride * ride) * 2. applies to inspection. * - see FixingSubstatesForBreakdown[] */ -bool rct_peep::UpdateFixingFixStationStart(bool firstRun, Ride * ride) +bool rct_peep::UpdateFixingFixStationStart(bool firstRun, Ride* ride) { if (!firstRun) { @@ -2986,8 +2966,8 @@ bool rct_peep::UpdateFixingFixStationStart(bool firstRun, Ride * ride) sprite_direction = direction << 3; - action = PEEP_ACTION_STAFF_FIX; - action_frame = 0; + action = PEEP_ACTION_STAFF_FIX; + action_frame = 0; action_sprite_image_offset = 0; UpdateCurrentActionSpriteType(); @@ -3009,14 +2989,14 @@ bool rct_peep::UpdateFixingFixStationStart(bool firstRun, Ride * ride) * fixing sub_state: fix_station_brakes - applies to fixing brake failure * - see FixingSubstatesForBreakdown[] */ -bool rct_peep::UpdateFixingFixStationBrakes(bool firstRun, Ride * ride) +bool rct_peep::UpdateFixingFixStationBrakes(bool firstRun, Ride* ride) { if (!firstRun) { sprite_direction = direction << 3; - action = PEEP_ACTION_STAFF_FIX_GROUND; - action_frame = 0; + action = PEEP_ACTION_STAFF_FIX_GROUND; + action_frame = 0; action_sprite_image_offset = 0; UpdateCurrentActionSpriteType(); @@ -3035,8 +3015,7 @@ bool rct_peep::UpdateFixingFixStationBrakes(bool firstRun, Ride * ride) ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_MAINTENANCE; } - if (action_frame == 0x13 || action_frame == 0x19 || action_frame == 0x1F || action_frame == 0x25 || - action_frame == 0x2B) + if (action_frame == 0x13 || action_frame == 0x19 || action_frame == 0x1F || action_frame == 0x25 || action_frame == 0x2B) { audio_play_sound_at_location(SOUND_MECHANIC_FIX, x, y, z); } @@ -3049,7 +3028,7 @@ bool rct_peep::UpdateFixingFixStationBrakes(bool firstRun, Ride * ride) * fixing sub_state: move_to_station_exit - applies to fixing all failures & inspections * - see FixingSubstatesForBreakdown[] */ -bool rct_peep::UpdateFixingMoveToStationExit(bool firstRun, Ride * ride) +bool rct_peep::UpdateFixingMoveToStationExit(bool firstRun, Ride* ride) { if (!firstRun) { @@ -3074,8 +3053,8 @@ bool rct_peep::UpdateFixingMoveToStationExit(bool firstRun, Ride * ride) stationX += stationPlatformDirection.x * 20; stationY += stationPlatformDirection.y * 20; - destination_x = stationX; - destination_y = stationY; + destination_x = stationX; + destination_y = stationY; destination_tolerance = 2; } @@ -3087,7 +3066,7 @@ bool rct_peep::UpdateFixingMoveToStationExit(bool firstRun, Ride * ride) } else { - sprite_move(actionX, actionY, z, (rct_sprite *)this); + sprite_move(actionX, actionY, z, (rct_sprite*)this); Invalidate(); } @@ -3099,7 +3078,7 @@ bool rct_peep::UpdateFixingMoveToStationExit(bool firstRun, Ride * ride) * fixing sub_state: finish_fix_or_inspect - applies to fixing all failures & inspections * - see FixingSubstatesForBreakdown[] */ -bool rct_peep::UpdateFixingFinishFixOrInspect(bool firstRun, int32_t steps, Ride * ride) +bool rct_peep::UpdateFixingFinishFixOrInspect(bool firstRun, int32_t steps, Ride* ride) { if (!firstRun) { @@ -3118,9 +3097,9 @@ bool rct_peep::UpdateFixingFinishFixOrInspect(bool firstRun, int32_t steps, Ride staff_rides_fixed++; window_invalidate_flags |= RIDE_INVALIDATE_RIDE_INCOME | RIDE_INVALIDATE_RIDE_LIST; - sprite_direction = direction << 3; - action = PEEP_ACTION_STAFF_ANSWER_CALL_2; - action_frame = 0; + sprite_direction = direction << 3; + action = PEEP_ACTION_STAFF_ANSWER_CALL_2; + action_frame = 0; action_sprite_image_offset = 0; UpdateCurrentActionSpriteType(); @@ -3143,7 +3122,7 @@ bool rct_peep::UpdateFixingFinishFixOrInspect(bool firstRun, int32_t steps, Ride * fixing sub_state: leave_by_entrance_exit - applies to fixing all failures & inspections * - see FixingSubstatesForBreakdown[] */ -bool rct_peep::UpdateFixingLeaveByEntranceExit(bool firstRun, Ride * ride) +bool rct_peep::UpdateFixingLeaveByEntranceExit(bool firstRun, Ride* ride) { if (!firstRun) { @@ -3169,8 +3148,8 @@ bool rct_peep::UpdateFixingLeaveByEntranceExit(bool firstRun, Ride * ride) exitX -= ebx_direction.x * 19; exitY -= ebx_direction.y * 19; - destination_x = exitX; - destination_y = exitY; + destination_x = exitX; + destination_y = exitY; destination_tolerance = 2; } @@ -3189,7 +3168,7 @@ bool rct_peep::UpdateFixingLeaveByEntranceExit(bool firstRun, Ride * ride) stationHeight += RideData5[ride->type].z; } - sprite_move(actionX, actionY, stationHeight, (rct_sprite *)this); + sprite_move(actionX, actionY, stationHeight, (rct_sprite*)this); Invalidate(); return false; @@ -3200,7 +3179,7 @@ bool rct_peep::UpdateFixingLeaveByEntranceExit(bool firstRun, Ride * ride) */ void rct_peep::UpdateRideInspected(int32_t rideIndex) { - Ride * ride = get_ride(rideIndex); + Ride* ride = get_ride(rideIndex); ride->lifecycle_flags &= ~RIDE_LIFECYCLE_DUE_INSPECTION; ride->reliability += ((100 - ride->reliability_percentage) / 4) * (scenario_rand() & 0xFF); diff --git a/src/openrct2/peep/Staff.h b/src/openrct2/peep/Staff.h index 458fd742c6..4c9854f13a 100644 --- a/src/openrct2/peep/Staff.h +++ b/src/openrct2/peep/Staff.h @@ -37,12 +37,12 @@ enum STAFF_TYPE enum STAFF_ORDERS { - STAFF_ORDERS_SWEEPING = (1 << 0), + STAFF_ORDERS_SWEEPING = (1 << 0), STAFF_ORDERS_WATER_FLOWERS = (1 << 1), - STAFF_ORDERS_EMPTY_BINS = (1 << 2), - STAFF_ORDERS_MOWING = (1 << 3), + STAFF_ORDERS_EMPTY_BINS = (1 << 2), + STAFF_ORDERS_MOWING = (1 << 3), STAFF_ORDERS_INSPECT_RIDES = (1 << 0), - STAFF_ORDERS_FIX_RIDES = (1 << 1) + STAFF_ORDERS_FIX_RIDES = (1 << 1) }; enum ENTERTAINER_COSTUME @@ -64,43 +64,43 @@ enum ENTERTAINER_COSTUME extern const rct_string_id StaffCostumeNames[ENTERTAINER_COSTUME_COUNT]; -extern uint32_t gStaffPatrolAreas[(STAFF_MAX_COUNT + STAFF_TYPE_COUNT) * STAFF_PATROL_AREA_SIZE]; -extern uint8_t gStaffModes[STAFF_MAX_COUNT + STAFF_TYPE_COUNT]; -extern uint16_t gStaffDrawPatrolAreas; +extern uint32_t gStaffPatrolAreas[(STAFF_MAX_COUNT + STAFF_TYPE_COUNT) * STAFF_PATROL_AREA_SIZE]; +extern uint8_t gStaffModes[STAFF_MAX_COUNT + STAFF_TYPE_COUNT]; +extern uint16_t gStaffDrawPatrolAreas; extern colour_t gStaffHandymanColour; extern colour_t gStaffMechanicColour; extern colour_t gStaffSecurityColour; -void game_command_hire_new_staff_member(int32_t * eax, int32_t * ebx, int32_t * ecx, int32_t * edx, int32_t * esi, int32_t * edi, - int32_t * ebp); -void game_command_callback_hire_new_staff_member(int32_t eax, int32_t ebx, int32_t ecx, int32_t edx, int32_t esi, int32_t edi, - int32_t ebp); -void game_command_set_staff_order(int32_t * eax, int32_t * ebx, int32_t * ecx, int32_t * edx, int32_t * esi, int32_t * edi, - int32_t * ebp); -void game_command_set_staff_patrol(int32_t * eax, int32_t * ebx, int32_t * ecx, int32_t * edx, int32_t * esi, int32_t * edi, - int32_t * ebp); -void game_command_fire_staff_member(int32_t * eax, int32_t * ebx, int32_t * ecx, int32_t * edx, int32_t * esi, int32_t * edi, - int32_t * ebp); -void game_command_set_staff_name(int32_t * eax, int32_t * ebx, int32_t * ecx, int32_t * edx, int32_t * esi, int32_t * edi, - int32_t * ebp); -void game_command_pickup_staff(int32_t * eax, int32_t * ebx, int32_t * ecx, int32_t * edx, int32_t * esi, int32_t * edi, - int32_t * ebp); +void game_command_hire_new_staff_member( + int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp); +void game_command_callback_hire_new_staff_member( + int32_t eax, int32_t ebx, int32_t ecx, int32_t edx, int32_t esi, int32_t edi, int32_t ebp); +void game_command_set_staff_order( + int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp); +void game_command_set_staff_patrol( + int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp); +void game_command_fire_staff_member( + int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp); +void game_command_set_staff_name( + int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp); +void game_command_pickup_staff( + int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp); -void staff_reset_modes(); -void staff_set_name(uint16_t spriteIndex, const char * name); -uint16_t hire_new_staff_member(uint8_t staffType); -void staff_update_greyed_patrol_areas(); -bool staff_is_location_in_patrol(rct_peep * mechanic, int32_t x, int32_t y); -bool staff_is_location_on_patrol_edge(rct_peep * mechanic, int32_t x, int32_t y); -bool staff_can_ignore_wide_flag(rct_peep * mechanic, int32_t x, int32_t y, uint8_t z, rct_tile_element * path); -int32_t staff_path_finding(rct_peep * peep); -void staff_reset_stats(); -bool staff_is_patrol_area_set(int32_t staffIndex, int32_t x, int32_t y); -void staff_set_patrol_area(int32_t staffIndex, int32_t x, int32_t y, bool value); -void staff_toggle_patrol_area(int32_t staffIndex, int32_t x, int32_t y); +void staff_reset_modes(); +void staff_set_name(uint16_t spriteIndex, const char* name); +uint16_t hire_new_staff_member(uint8_t staffType); +void staff_update_greyed_patrol_areas(); +bool staff_is_location_in_patrol(rct_peep* mechanic, int32_t x, int32_t y); +bool staff_is_location_on_patrol_edge(rct_peep* mechanic, int32_t x, int32_t y); +bool staff_can_ignore_wide_flag(rct_peep* mechanic, int32_t x, int32_t y, uint8_t z, rct_tile_element* path); +int32_t staff_path_finding(rct_peep* peep); +void staff_reset_stats(); +bool staff_is_patrol_area_set(int32_t staffIndex, int32_t x, int32_t y); +void staff_set_patrol_area(int32_t staffIndex, int32_t x, int32_t y, bool value); +void staff_toggle_patrol_area(int32_t staffIndex, int32_t x, int32_t y); colour_t staff_get_colour(uint8_t staffType); -bool staff_set_colour(uint8_t staffType, colour_t value); -uint32_t staff_get_available_entertainer_costumes(); -int32_t staff_get_available_entertainer_costume_list(uint8_t * costumeList); +bool staff_set_colour(uint8_t staffType, colour_t value); +uint32_t staff_get_available_entertainer_costumes(); +int32_t staff_get_available_entertainer_costume_list(uint8_t* costumeList); #endif