From 94e47be3e34f97ce6e6f8a8b9debb53e29155c8c Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Fri, 15 Jan 2016 00:04:17 +0100 Subject: [PATCH] Use `ride_type_has_flag` for checking ride type flags --- src/peep/peep.c | 32 +++++++++++++-------------- src/ride/vehicle.c | 11 +++++---- src/windows/editor_object_selection.c | 3 +-- src/windows/guest_list.c | 2 +- src/windows/ride.c | 8 +++---- 5 files changed, 27 insertions(+), 29 deletions(-) diff --git a/src/peep/peep.c b/src/peep/peep.c index 7e8a5b043d..99172db151 100644 --- a/src/peep/peep.c +++ b/src/peep/peep.c @@ -1594,7 +1594,7 @@ void remove_peep_from_queue(rct_peep* peep) */ static rct_vehicle* peep_choose_car_from_ride(rct_peep* peep, rct_ride* ride, uint8* car_array, uint8 car_array_size){ uint8 chosen_car = scenario_rand(); - if (RCT2_ADDRESS(RCT2_ADDRESS_RIDE_FLAGS, uint32)[ride->type * 2] & RIDE_TYPE_FLAG_HAS_G_FORCES + if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_HAS_G_FORCES) && ((chosen_car & 0xC) != 0xC)){ chosen_car = (scenario_rand() & 1) ? 0 : car_array_size - 1; } @@ -1713,7 +1713,7 @@ static void peep_update_ride_sub_state_0(rct_peep* peep){ uint8 car_array_size = 0xFF; uint8* car_array = RCT2_ADDRESS(0xF1AD78, uint8); - if (RCT2_ADDRESS(RCT2_ADDRESS_RIDE_FLAGS, uint32)[ride->type * 2] & RIDE_TYPE_FLAG_13){ + if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_13)){ if (ride->num_riders >= ride->operation_option) return; } @@ -1842,7 +1842,7 @@ static void peep_update_ride_sub_state_0(rct_peep* peep){ } } - if (!(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_FLAGS, uint32)[ride->type * 2] & RIDE_TYPE_FLAG_13)){ + if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_13)){ rct_vehicle* vehicle = peep_choose_car_from_ride(peep, ride, car_array, car_array_size); peep_choose_seat_from_car(peep, ride, vehicle); } @@ -1888,7 +1888,7 @@ void peep_update_ride_sub_state_1(rct_peep* peep){ return; } - if (RCT2_ADDRESS(RCT2_ADDRESS_RIDE_FLAGS, uint32)[ride->type * 2] &RIDE_TYPE_FLAG_13) + if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_13)) { sint16 x, y, z; x = ride->entrances[peep->current_ride_station] & 0xFF; @@ -2133,7 +2133,7 @@ static void peep_update_ride_sub_state_2_enter_ride(rct_peep* peep, rct_ride* ri RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 8, uint32) = ride->name_arguments; rct_string_id msg_string; - if (RCT2_ADDRESS(RCT2_ADDRESS_RIDE_FLAGS, uint32)[ride->type * 2] & RIDE_TYPE_FLAG_IN_RIDE) + if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_IN_RIDE)) msg_string = STR_PEEP_TRACKING_PEEP_IS_IN_X; else msg_string = STR_PEEP_TRACKING_PEEP_IS_ON_X; @@ -2207,7 +2207,7 @@ static void peep_update_ride_sub_state_2_rejoin_queue(rct_peep* peep, rct_ride* static void peep_update_ride_sub_state_2(rct_peep* peep){ rct_ride* ride = GET_RIDE(peep->current_ride); - if (RCT2_ADDRESS(RCT2_ADDRESS_RIDE_FLAGS, uint32)[ride->type * 2] & RIDE_TYPE_FLAG_13){ + if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_13)){ if (ride->status != RIDE_STATUS_OPEN || ride->var_1CA != 0 || (++peep->var_AC) == 0){ @@ -2389,7 +2389,7 @@ void peep_update_ride_sub_state_7(rct_peep* peep){ uint8 exit_direction = (map_element == NULL ? 0 : map_element->type & MAP_ELEMENT_DIRECTION_MASK); exit_direction ^= (1 << 1); - if (!(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_FLAGS, uint32)[ride->type * 2] & RIDE_TYPE_FLAG_16)){ + if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_16)){ for (; vehicle->is_child; vehicle = GET_VEHICLE(vehicle->prev_vehicle_on_ride)){ uint16 trackType = vehicle->track_type >> 2; @@ -6101,13 +6101,13 @@ static void peep_stop_purchase_thought(rct_peep* peep, uint8 ride_type){ uint8 thought_type = PEEP_THOUGHT_TYPE_HUNGRY; - if (!(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_FLAGS, uint32)[ride_type * 2] & 0x800000)){ + if (!ride_type_has_flag(ride_type, RIDE_TYPE_FLAG_SELLS_FOOD)){ thought_type = PEEP_THOUGHT_TYPE_THIRSTY; - if (!(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_FLAGS, uint32)[ride_type * 2] & 0x1000000)){ + if (!ride_type_has_flag(ride_type, RIDE_TYPE_FLAG_SELLS_DRINKS)){ thought_type = PEEP_THOUGHT_RUNNING_OUT; if (ride_type != RIDE_TYPE_CASH_MACHINE){ thought_type = PEEP_THOUGHT_TYPE_BATHROOM; - if (!(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_FLAGS, uint32)[ride_type * 2] & 0x2000000)){ + if (!ride_type_has_flag(ride_type, RIDE_TYPE_FLAG_IS_BATHROOM)){ return; } } @@ -7001,7 +7001,7 @@ static uint8 loc_6949B9( if (z != mapElement->base_height) continue; int rideIndex = inputMapElement->properties.path.ride_index; rct_ride *ride = GET_RIDE(rideIndex); - if (RCT2_GLOBAL(RCT2_ADDRESS_RIDE_FLAGS + (ride->type * 8), uint32) & 0x20000) { + if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_IS_SHOP)) { *outRideIndex = rideIndex; return PATH_SEARCH_RIDE_ENTRANCE; } @@ -8060,7 +8060,7 @@ static void peep_update_ride_nausea_growth(rct_peep *peep, rct_ride *ride) static bool peep_should_go_on_ride_again(rct_peep *peep, rct_ride *ride) { - if (!(RCT2_GLOBAL(RCT2_ADDRESS_RIDE_FLAGS + (ride->type * 8), uint32) & 0x100000)) return false; + if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_20)) return false; if (ride->excitement == (ride_rating)0xFFFF) return false; if (ride->intensity > RIDE_RATING(10,00) && !gConfigCheat.ignore_ride_intensity) return false; if (peep->happiness < 180) return false; @@ -8541,7 +8541,7 @@ static bool peep_should_go_on_ride(rct_peep *peep, int rideIndex, int entranceNu } } - if (RCT2_ADDRESS(RCT2_ADDRESS_RIDE_FLAGS, uint32)[ride->type * 2] & RIDE_TYPE_FLAG_IS_SHOP) { + if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_IS_SHOP)) { return peep_should_go_to_shop(peep, rideIndex, peepAtRide); } @@ -9105,7 +9105,7 @@ static void peep_head_for_nearest_ride_with_flags(rct_peep *peep, int rideTypeFl if (peep->x == (sint16)0x8000) return; if (peep->guest_heading_to_ride_id != 255) { ride = GET_RIDE(peep->guest_heading_to_ride_id); - if (RCT2_ADDRESS(RCT2_ADDRESS_RIDE_FLAGS, uint32)[ride->type * 2] & (RIDE_TYPE_FLAG_IS_BATHROOM | RIDE_TYPE_FLAG_SELLS_DRINKS | RIDE_TYPE_FLAG_SELLS_FOOD)) { + if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_IS_BATHROOM | RIDE_TYPE_FLAG_SELLS_DRINKS | RIDE_TYPE_FLAG_SELLS_FOOD)) { return; } } @@ -9128,7 +9128,7 @@ static void peep_head_for_nearest_ride_with_flags(rct_peep *peep, int rideTypeFl // Consider all rides in the park int i; FOR_ALL_RIDES(i, ride) { - if (RCT2_ADDRESS(RCT2_ADDRESS_RIDE_FLAGS, uint32)[ride->type * 2] & rideTypeFlags) { + if (ride_type_has_flag(ride->type, rideTypeFlags)) { RCT2_ADDRESS(0x00F1AD98, uint32)[i >> 5] |= (1u << (i & 0x1F)); } } @@ -9145,7 +9145,7 @@ static void peep_head_for_nearest_ride_with_flags(rct_peep *peep, int rideTypeFl int rideIndex = mapElement->properties.track.ride_index; ride = GET_RIDE(rideIndex); - if (RCT2_ADDRESS(RCT2_ADDRESS_RIDE_FLAGS, uint32)[ride->type * 2] & rideTypeFlags) { + if (ride_type_has_flag(ride->type, rideTypeFlags)) { RCT2_ADDRESS(0x00F1AD98, uint32)[rideIndex >> 5] |= (1u << (rideIndex & 0x1F)); } } while (!map_element_is_last_for_tile(mapElement++)); diff --git a/src/ride/vehicle.c b/src/ride/vehicle.c index 6b607d9c27..f88f14bb85 100644 --- a/src/ride/vehicle.c +++ b/src/ride/vehicle.c @@ -770,7 +770,7 @@ static void vehicle_update_measurements(rct_vehicle *vehicle) ride->length[test_segment] += distance; } - if (RCT2_ADDRESS(RCT2_ADDRESS_RIDE_FLAGS, uint32)[ride->type * 2] & RIDE_TYPE_FLAG_HAS_G_FORCES){ + if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_HAS_G_FORCES)){ int vertical_g, lateral_g; vehicle_get_g_forces(vehicle, &vertical_g, &lateral_g); @@ -1396,7 +1396,7 @@ static void vehicle_update_waiting_for_passengers(rct_vehicle* vehicle){ num_seats_on_train &= 0x7F; - if (!(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_FLAGS, uint32)[ride->type * 2] & RIDE_TYPE_FLAG_NO_TEST_MODE)){ + if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_NO_TEST_MODE)){ if (vehicle->var_C0 < 20){ train_ready_to_depart(vehicle, num_peeps_on_train, num_used_seats_on_train); return; @@ -1409,7 +1409,7 @@ static void vehicle_update_waiting_for_passengers(rct_vehicle* vehicle){ } } - if (RCT2_ADDRESS(RCT2_ADDRESS_RIDE_FLAGS, uint32)[ride->type * 2] & RIDE_TYPE_FLAG_HAS_LOAD_OPTIONS){ + if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_HAS_LOAD_OPTIONS)){ if (ride->depart_flags & RIDE_DEPART_WAIT_FOR_MINIMUM_LENGTH){ if (ride->min_waiting_time * 32 > vehicle->var_C0){ train_ready_to_depart(vehicle, num_peeps_on_train, num_used_seats_on_train); @@ -1448,7 +1448,7 @@ static void vehicle_update_waiting_for_passengers(rct_vehicle* vehicle){ } } - if (RCT2_ADDRESS(RCT2_ADDRESS_RIDE_FLAGS, uint32)[ride->type * 2] & RIDE_TYPE_FLAG_HAS_LOAD_OPTIONS && + if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_HAS_LOAD_OPTIONS) && ride->depart_flags & RIDE_DEPART_WAIT_FOR_LOAD){ if (num_peeps_on_train == num_seats_on_train){ @@ -1619,8 +1619,7 @@ static void vehicle_update_waiting_to_depart(rct_vehicle* vehicle) { return; } - if (RCT2_ADDRESS(RCT2_ADDRESS_RIDE_FLAGS, uint32)[ride->type * 2] - & RIDE_TYPE_FLAG_CAN_SYNCHRONISE_ADJACENT_STATIONS) { + if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_CAN_SYNCHRONISE_ADJACENT_STATIONS)) { if (ride->depart_flags & RIDE_DEPART_SYNCHRONISE_WITH_ADJACENT_STATIONS) { if (vehicle->update_flags & VEHICLE_UPDATE_FLAG_WAIT_ON_ADJACENT) { if (vehicle_can_depart_synchronised(vehicle)) { diff --git a/src/windows/editor_object_selection.c b/src/windows/editor_object_selection.c index 56e8316b2f..1a0ec6402c 100644 --- a/src/windows/editor_object_selection.c +++ b/src/windows/editor_object_selection.c @@ -470,8 +470,7 @@ static void setup_track_manager_objects(){ if (ride_type == 0xFF) continue; - if (!(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_FLAGS, uint32)[ride_type * 2] & - RIDE_TYPE_FLAG_HAS_TRACK)) + if (!ride_type_has_flag(ride_type, RIDE_TYPE_FLAG_HAS_TRACK)) continue; if (pos[3] & (1 << 0)){ diff --git a/src/windows/guest_list.c b/src/windows/guest_list.c index fb7e0b2af9..bcba76768b 100644 --- a/src/windows/guest_list.c +++ b/src/windows/guest_list.c @@ -217,7 +217,7 @@ void window_guest_list_open_with_filter(int type, int index) eax = (eax << 16) + 1435; - if ((RCT2_GLOBAL(RCT2_ADDRESS_RIDE_FLAGS + ride->type * 8, uint32) & 0x400000) != 0) + if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_IN_RIDE)) eax++; RCT2_GLOBAL(0x00F1EDF6, uint32) = eax; diff --git a/src/windows/ride.c b/src/windows/ride.c index 969d0cd616..380e065607 100644 --- a/src/windows/ride.c +++ b/src/windows/ride.c @@ -1123,23 +1123,23 @@ void window_ride_disable_tabs(rct_window *w) uint8 ride_type = ride->type; // ecx - if ((RCT2_GLOBAL(RCT2_ADDRESS_RIDE_FLAGS + ride_type * 8, uint32) & 0x200) == 0) + if (!ride_type_has_flag(ride_type, RIDE_TYPE_FLAG_HAS_DATA_LOGGING)) disabled_tabs |= (1 << WIDX_TAB_8); // 0x800 if (ride_type == RIDE_TYPE_MINI_GOLF) disabled_tabs |= (1 << WIDX_TAB_2 | 1 << WIDX_TAB_3 | 1 << WIDX_TAB_4); // 0xE0 - if ((RCT2_GLOBAL(RCT2_ADDRESS_RIDE_FLAGS + ride_type * 8, uint32) & 0x2000) != 0) + if (ride_type_has_flag(ride_type, RIDE_TYPE_FLAG_13)) disabled_tabs |= (1 << WIDX_TAB_2); // 0x20 if ( - !(RCT2_GLOBAL(RCT2_ADDRESS_RIDE_FLAGS + ride_type * 8, uint32) & 0x4000007) && + ride_type_has_flag(ride_type, RIDE_TYPE_FLAG_HAS_TRACK_COLOUR_MAIN | RIDE_TYPE_FLAG_HAS_TRACK_COLOUR_ADDITIONAL | RIDE_TYPE_FLAG_HAS_TRACK_COLOUR_SUPPORTS | RIDE_TYPE_FLAG_26) && !(RideData4[ride->type].flags & RIDE_TYPE_FLAG4_HAS_ENTRANCE_EXIT) ) { disabled_tabs |= (1 << WIDX_TAB_5); // 0x100 } - if ((RCT2_GLOBAL(RCT2_ADDRESS_RIDE_FLAGS + ride_type * 8, uint32) & 0x20000) != 0) + if (ride_type_has_flag(ride_type, RIDE_TYPE_FLAG_IS_SHOP)) disabled_tabs |= (1 << WIDX_TAB_3 | 1 << WIDX_TAB_4 | 1 << WIDX_TAB_7); // 0x4C0 if (!(RideData4[ride->type].flags & RIDE_TYPE_FLAG4_ALLOW_MUSIC)) {