Merge pull request #5073 from IntelOrca/refactor/name-ride-entry-flags

Refactor/name ride entry flags
This commit is contained in:
Ted John 2017-01-14 18:29:34 +00:00 committed by GitHub
commit c418836a87
6 changed files with 60 additions and 66 deletions

View file

@ -82,7 +82,7 @@ typedef struct rct1_ride {
uint8 max_waiting_time;
uint8 operation_option;
uint8 boat_hire_return_direction;
uint16 boat_hire_return_position;
rct_xy8 boat_hire_return_position;
uint8 data_logging_index;
uint8 special_track_elements;
uint16 unk_86;

View file

@ -4341,7 +4341,8 @@ static void ride_set_boat_hire_return_point(rct_ride *ride, rct_xy_element *star
trackType = returnTrackElement->properties.track.type;
int elementReturnDirection = TrackCoordinates[trackType].rotation_begin;
ride->boat_hire_return_direction = (returnTrackElement->type + elementReturnDirection) & 3;
ride->boat_hire_return_position = (returnX >> 5) | ((returnY >> 5) << 8);
ride->boat_hire_return_position.x = returnX >> 5;
ride->boat_hire_return_position.y = returnY >> 5;
}
/**

View file

@ -183,8 +183,9 @@ typedef struct rct_ride {
uint8 speed; // 0x0D0
uint8 rotations; // 0x0D0
};
uint8 boat_hire_return_direction; // 0x0D1
uint16 boat_hire_return_position; // 0x0D2
rct_xy8 boat_hire_return_position; // 0x0D2
uint8 measurement_index; // 0x0D4
// bits 0 through 4 are the number of helix sections
// bit 5: spinning tunnel, water splash, or rapids
@ -412,41 +413,30 @@ enum {
// Constants used by the ride_type->flags property at 0x008
enum {
RIDE_ENTRY_FLAG_0 = 1 << 0, // 0x1
RIDE_ENTRY_FLAG_NO_INVERSIONS = 1 << 1, // 0x2
RIDE_ENTRY_FLAG_NO_BANKED_TRACK = 1 << 2, // 0x4
RIDE_ENTRY_FLAG_3 = 1 << 3, // 0x8
RIDE_ENTRY_FLAG_ALTERNATIVE_SWING_MODE_1 = 1 << 4, // 0x10
RIDE_ENTRY_FLAG_VEHICLE_TAB_SCALE_HALF = 1 << 0,
RIDE_ENTRY_FLAG_NO_INVERSIONS = 1 << 1,
RIDE_ENTRY_FLAG_NO_BANKED_TRACK = 1 << 2,
RIDE_ENTRY_FLAG_PLAY_DEPART_SOUND = 1 << 3,
RIDE_ENTRY_FLAG_ALTERNATIVE_SWING_MODE_1 = 1 << 4,
// Twist type rotation ride
RIDE_ENTRY_FLAG_ALTERNATIVE_ROTATION_MODE_1 = 1 << 5, // 0x20
RIDE_ENTRY_FLAG_ALTERNATIVE_ROTATION_MODE_1 = 1 << 5,
// Lifting arm rotation ride (enterprise)
RIDE_ENTRY_FLAG_ALTERNATIVE_ROTATION_MODE_2 = 1 << 6, // 0x40
RIDE_ENTRY_FLAG_7 = 1 << 7, // 0x80
RIDE_ENTRY_FLAG_8 = 1 << 8, // 0x100
RIDE_ENTRY_FLAG_9 = 1 << 9, // 0x200
RIDE_ENTRY_FLAG_COVERED_RIDE = 1 << 10, // 0x400
RIDE_ENTRY_FLAG_11 = 1 << 11, // 0x800
RIDE_ENTRY_FLAG_SEPARATE_RIDE_NAME = 1 << 12, // 0x1000
RIDE_ENTRY_FLAG_SEPARATE_RIDE = 1 << 13, // 0x2000
RIDE_ENTRY_FLAG_CANNOT_BREAK_DOWN = 1 << 14, // 0x4000
RIDE_ENTRY_DISABLE_LAST_OPERATING_MODE = 1 << 15, // 0x8000
RIDE_ENTRY_FLAG_16 = 1 << 16, // 0x10000
RIDE_ENTRY_DISABLE_FIRST_TWO_OPERATING_MODES = 1 << 17, // 0x20000
RIDE_ENTRY_FLAG_18 = 1 << 18, // 0x40000
RIDE_ENTRY_FLAG_19 = 1 << 19, // 0x80000
RIDE_ENTRY_FLAG_ALTERNATIVE_ROTATION_MODE_2 = 1 << 6,
RIDE_ENTRY_FLAG_7 = 1 << 7,
RIDE_ENTRY_FLAG_PLAY_SPLASH_SOUND = 1 << 8,
RIDE_ENTRY_FLAG_PLAY_SPLASH_SOUND_SLIDE = 1 << 9,
RIDE_ENTRY_FLAG_COVERED_RIDE = 1 << 10,
RIDE_ENTRY_FLAG_LIMIT_AIRTIME_BONUS = 1 << 11,
RIDE_ENTRY_FLAG_SEPARATE_RIDE_NAME = 1 << 12,
RIDE_ENTRY_FLAG_SEPARATE_RIDE = 1 << 13,
RIDE_ENTRY_FLAG_CANNOT_BREAK_DOWN = 1 << 14,
RIDE_ENTRY_DISABLE_LAST_OPERATING_MODE = 1 << 15,
RIDE_ENTRY_FLAG_16 = 1 << 16,
RIDE_ENTRY_DISABLE_FIRST_TWO_OPERATING_MODES = 1 << 17,
RIDE_ENTRY_FLAG_18 = 1 << 18,
RIDE_ENTRY_FLAG_DISABLE_COLOUR_TAB = 1 << 19,
// Must be set with swing mode 1 as well.
RIDE_ENTRY_FLAG_ALTERNATIVE_SWING_MODE_2 = 1 << 20, // 0x100000
RIDE_ENTRY_FLAG_21 = 1 << 21, // 0x200000
RIDE_ENTRY_FLAG_22 = 1 << 22, // 0x400000
RIDE_ENTRY_FLAG_23 = 1 << 23, // 0x800000
RIDE_ENTRY_FLAG_24 = 1 << 24, // 0x1000000
RIDE_ENTRY_FLAG_25 = 1 << 25, // 0x2000000
RIDE_ENTRY_FLAG_26 = 1 << 26, // 0x4000000
RIDE_ENTRY_FLAG_27 = 1 << 27, // 0x8000000
RIDE_ENTRY_FLAG_28 = 1 << 28, // 0x10000000
RIDE_ENTRY_FLAG_29 = 1 << 29, // 0x20000000
RIDE_ENTRY_FLAG_30 = 1 << 30, // 0x40000000
RIDE_ENTRY_FLAG_31 = 1u << 31, // 0x80000000
RIDE_ENTRY_FLAG_ALTERNATIVE_SWING_MODE_2 = 1 << 20,
};
enum{

View file

@ -754,7 +754,7 @@ static void ride_ratings_apply_adjustments(rct_ride *ride, rating_tuple *ratings
#ifdef ORIGINAL_RATINGS
if (RideData4[ride->type].flags & RIDE_TYPE_FLAG4_HAS_AIR_TIME) {
uint16 totalAirTime = ride->total_air_time;
if (rideEntry->flags & RIDE_ENTRY_FLAG_11) {
if (rideEntry->flags & RIDE_ENTRY_FLAG_LIMIT_AIRTIME_BONUS) {
if (totalAirTime >= 96) {
totalAirTime -= 96;
ratings->excitement -= totalAirTime / 8;
@ -767,7 +767,7 @@ static void ride_ratings_apply_adjustments(rct_ride *ride, rating_tuple *ratings
}
#else
if (RideData4[ride->type].flags & RIDE_TYPE_FLAG4_HAS_AIR_TIME) {
if (rideEntry->flags & RIDE_ENTRY_FLAG_11) {
if (rideEntry->flags & RIDE_ENTRY_FLAG_LIMIT_AIRTIME_BONUS) {
// Limit airtime bonus for heartline twister coaster (see issues #2031 and #2064)
ratings->excitement += min(ride->total_air_time, 96) / 8;
} else {

View file

@ -58,7 +58,7 @@ static void vehicle_update_top_spin_operating(rct_vehicle* vehicle);
static void vehicle_update_crash(rct_vehicle *vehicle);
static void vehicle_update_travelling_boat(rct_vehicle* vehicle);
static void vehicle_update_motion_boat_hire(rct_vehicle *vehicle);
static void sub_6DA280(rct_vehicle *vehicle);
static void vehicle_update_boat_location(rct_vehicle *vehicle);
static bool vehicle_is_boat_on_water(rct_vehicle *vehicle, int x, int y);
static void vehicle_update_arriving(rct_vehicle* vehicle);
static void vehicle_update_unloading_passengers(rct_vehicle* vehicle);
@ -2709,7 +2709,7 @@ static void vehicle_update_departing(rct_vehicle* vehicle) {
vehicle->sub_state = 1;
vehicle_peep_easteregg_here_we_are(vehicle);
if (rideEntry->flags & RIDE_ENTRY_FLAG_3) {
if (rideEntry->flags & RIDE_ENTRY_FLAG_PLAY_DEPART_SOUND) {
uint8 soundId = (rideEntry->vehicles[0].sound_range == 4) ?
SOUND_TRAM :
SOUND_TRAIN_CHUGGING;
@ -3832,7 +3832,7 @@ static void vehicle_update_motion_boat_hire(rct_vehicle *vehicle)
vehicle->var_34 = bl;
x += y;
if (x <= 12) {
sub_6DA280(vehicle);
vehicle_update_boat_location(vehicle);
}
if (!(vehicle->var_35 & (1 << 0))) {
@ -3863,7 +3863,7 @@ static void vehicle_update_motion_boat_hire(rct_vehicle *vehicle)
vehicle->remaining_distance = 0;
if (vehicle->sprite_direction == vehicle->var_34) {
vehicle->sprite_direction ^= (1 << 4);
sub_6DA280(vehicle);
vehicle_update_boat_location(vehicle);
vehicle->sprite_direction ^= (1 << 4);
}
break;
@ -3881,7 +3881,7 @@ static void vehicle_update_motion_boat_hire(rct_vehicle *vehicle)
do_loc_6DAA97 = true;
} else {
uint16 xy = (((dx >> 5) << 8) | (bx >> 5));
if (xy != ride->boat_hire_return_position) {
if (xy != ride->boat_hire_return_position.xy) {
do_loc_6DAA97 = true;
}
}
@ -3890,7 +3890,7 @@ static void vehicle_update_motion_boat_hire(rct_vehicle *vehicle)
if (do_loc_6DAA97) {
vehicle->remaining_distance = 0;
if (vehicle->sprite_direction == vehicle->var_34) {
sub_6DA280(vehicle);
vehicle_update_boat_location(vehicle);
}
break;
}
@ -3988,16 +3988,18 @@ static void vehicle_update_motion_boat_hire(rct_vehicle *vehicle)
*
* rct2: 0x006DA280
*/
static void sub_6DA280(rct_vehicle *vehicle)
static void vehicle_update_boat_location(rct_vehicle *vehicle)
{
rct_ride* ride = get_ride(vehicle->ride);
rct_ride *ride = get_ride(vehicle->ride);
rct_xy8 returnPosition = ride->boat_hire_return_position;
uint8 returnDirection = ride->boat_hire_return_direction & 3;
rct_xy8 location = {
.x = (vehicle->x + TileDirectionDelta[ride->boat_hire_return_direction & 3].x) / 32,
.y = (vehicle->y + TileDirectionDelta[ride->boat_hire_return_direction & 3].y) / 32
.x = (vehicle->x + TileDirectionDelta[returnDirection].x) / 32,
.y = (vehicle->y + TileDirectionDelta[returnDirection].y) / 32
};
if (*((uint16*)&location) == ride->boat_hire_return_position) {
if (location.xy == returnPosition.xy) {
vehicle->sub_state = 1;
vehicle->boat_location = location;
return;
@ -4007,21 +4009,22 @@ static void sub_6DA280(rct_vehicle *vehicle)
uint8 curDirection = ((vehicle->sprite_direction + 19) >> 3) & 3;
uint8 randDirection = scenario_rand() & 3;
rct_ride_entry* rideEntry = get_ride_entry(vehicle->ride_subtype);
if (scenario_rand() & 1 && (!(rideEntry->flags & RIDE_ENTRY_FLAG_7) || vehicle->lost_time_out > 1920)) {
location = *((rct_xy8*)&ride->boat_hire_return_position);
rct_xy16 destLocation = {
.x = location.x * 32 - TileDirectionDelta[ride->boat_hire_return_direction & 3].x + 16,
.y = location.y * 32 - TileDirectionDelta[ride->boat_hire_return_direction & 3].y + 16
};
rct_ride_entry *rideEntry = get_ride_entry(vehicle->ride_subtype);
if (!(rideEntry->flags & RIDE_ENTRY_FLAG_7) || vehicle->lost_time_out > 1920) {
if (scenario_rand() & 1) {
rct_xy16 destLocation = {
.x = returnPosition.x * 32 - TileDirectionDelta[returnDirection].x + 16,
.y = returnPosition.y * 32 - TileDirectionDelta[returnDirection].y + 16
};
destLocation.x -= vehicle->x;
destLocation.y -= vehicle->y;
destLocation.x -= vehicle->x;
destLocation.y -= vehicle->y;
if (abs(destLocation.x) <= abs(destLocation.y)) {
randDirection = destLocation.y < 0 ? 3 : 1;
} else {
randDirection = destLocation.x < 0 ? 0 : 2;
if (abs(destLocation.x) <= abs(destLocation.y)) {
randDirection = destLocation.y < 0 ? 3 : 1;
} else {
randDirection = destLocation.x < 0 ? 0 : 2;
}
}
}
@ -6965,8 +6968,8 @@ static void vehicle_update_handle_water_splash(rct_vehicle *vehicle)
rct_ride_entry *rideEntry = get_ride_entry(vehicle->ride_subtype);
int trackType = vehicle->track_type >> 2;
if (!(rideEntry->flags & RIDE_ENTRY_FLAG_8)) {
if (rideEntry->flags & RIDE_ENTRY_FLAG_9) {
if (!(rideEntry->flags & RIDE_ENTRY_FLAG_PLAY_SPLASH_SOUND)) {
if (rideEntry->flags & RIDE_ENTRY_FLAG_PLAY_SPLASH_SOUND_SLIDE) {
if (!vehicle->is_child) {
if (track_element_is_covered(trackType)) {
rct_vehicle *nextVehicle = GET_VEHICLE(vehicle->next_vehicle_on_ride);
@ -8896,7 +8899,7 @@ loc_6DC316:
}
}
if (rideEntry->flags & RIDE_ENTRY_FLAG_9) {
if (rideEntry->flags & RIDE_ENTRY_FLAG_PLAY_SPLASH_SOUND_SLIDE) {
if (!vehicle->is_child) {
regs.bx = vehicle->track_type >> 2;
if (track_element_is_covered(regs.bx)) {

View file

@ -1350,7 +1350,7 @@ static void window_ride_draw_tab_vehicle(rct_drawpixelinfo *dpi, rct_window *w)
rct_ride *ride = get_ride(w->number);
rct_ride_entry *rideEntry = get_ride_entry_by_ride(ride);
if (rideEntry->flags & RIDE_ENTRY_FLAG_0) {
if (rideEntry->flags & RIDE_ENTRY_FLAG_VEHICLE_TAB_SCALE_HALF) {
clipDPI.zoom_level = 1;
clipDPI.width *= 2;
clipDPI.height *= 2;
@ -1468,7 +1468,7 @@ static void window_ride_disable_tabs(rct_window *w)
if (type == NULL) {
disabled_tabs |= 1 << WIDX_TAB_2 | 1 << WIDX_TAB_3 | 1 << WIDX_TAB_4 | 1 << WIDX_TAB_5 | 1 << WIDX_TAB_6
| 1 << WIDX_TAB_7 | 1 << WIDX_TAB_8 | 1 << WIDX_TAB_9 | 1 << WIDX_TAB_10;
} else if ((type->flags & RIDE_ENTRY_FLAG_19) != 0)
} else if ((type->flags & RIDE_ENTRY_FLAG_DISABLE_COLOUR_TAB) != 0)
disabled_tabs |= (1 << WIDX_TAB_5); // 0x100
w->disabled_widgets = disabled_tabs;