From a66966a4d9608a6344ab49342b39abbea5853a35 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Mon, 8 Jun 2015 19:07:30 +0100 Subject: [PATCH] fix rating bugs and merge mistakes --- src/rct1.c | 2 +- src/ride/ride.c | 30 ++++++++++++----- src/ride/ride.h | 52 +--------------------------- src/ride/ride_data.c | 6 ++-- src/ride/ride_ratings.c | 75 +++++++++++++++++++---------------------- src/ride/track.c | 2 +- src/ride/vehicle.c | 31 ++++++----------- src/ride/vehicle.h | 26 +++----------- 8 files changed, 77 insertions(+), 147 deletions(-) diff --git a/src/rct1.c b/src/rct1.c index 90fe58171d..2134b67d5c 100644 --- a/src/rct1.c +++ b/src/rct1.c @@ -712,7 +712,7 @@ static void rct1_fix_z() for (int i = 0; i < 4; i++) { ride->station_heights[i] /= 2; } - ride->var_116 /= 2; + ride->start_drop_height /= 2; ride->highest_drop_height = 1; if (ride->var_11F != 255) { ride->var_11F /= 2; diff --git a/src/ride/ride.c b/src/ride/ride.c index a663f54d5e..46839e1958 100644 --- a/src/ride/ride.c +++ b/src/ride/ride.c @@ -2261,10 +2261,6 @@ void ride_prepare_breakdown(int rideIndex, int breakdownReason) } if (vehicle != NULL) vehicle->update_flags |= VEHICLE_UPDATE_FLAG_BROKEN_CAR; - vehicle = &(g_sprite_list[ride->vehicles[ride->broken_vehicle]].vehicle); - for (i = ride->broken_car; i > 0; i--) - vehicle = &(g_sprite_list[vehicle->next_vehicle_on_train].vehicle); - vehicle->update_flags |= VEHICLE_UPDATE_FLAG_BROKEN_CAR; break; case BREAKDOWN_VEHICLE_MALFUNCTION: // Choose a random train @@ -5339,7 +5335,7 @@ foundRideEntry: ride->station_starts[i] = 0xFFFF; ride->entrances[i] = 0xFFFF; ride->exits[i] = 0xFFFF; - ride->var_066[i] = 255; + ride->train_at_station[i] = 255; ride->queue_time[i] = 0; } @@ -5909,6 +5905,8 @@ void increment_turn_count_1_element(rct_ride* ride, uint8 type){ case 2: turn_count = &ride->turn_count_sloped; break; + default: + return; } uint16 value = (*turn_count & TURN_MASK_1_ELEMENT) + 1; *turn_count &= ~TURN_MASK_1_ELEMENT; @@ -5930,6 +5928,8 @@ void increment_turn_count_2_elements(rct_ride* ride, uint8 type){ case 2: turn_count = &ride->turn_count_sloped; break; + default: + return; } uint16 value = (*turn_count & TURN_MASK_2_ELEMENTS) + 0x20; *turn_count &= ~TURN_MASK_2_ELEMENTS; @@ -5951,6 +5951,8 @@ void increment_turn_count_3_elements(rct_ride* ride, uint8 type){ case 2: turn_count = &ride->turn_count_sloped; break; + default: + return; } uint16 value = (*turn_count & TURN_MASK_3_ELEMENTS) + 0x100; *turn_count &= ~TURN_MASK_3_ELEMENTS; @@ -5971,6 +5973,8 @@ void increment_turn_count_4_plus_elements(rct_ride* ride, uint8 type){ case 2: turn_count = &ride->turn_count_sloped; break; + default: + return; } uint16 value = (*turn_count & TURN_MASK_4_PLUS_ELEMENTS) + 0x800; *turn_count &= ~TURN_MASK_4_PLUS_ELEMENTS; @@ -5992,6 +5996,8 @@ int get_turn_count_1_element(rct_ride* ride, uint8 type) { case 2: turn_count = &ride->turn_count_sloped; break; + default: + return 0; } return (*turn_count) & TURN_MASK_1_ELEMENT; @@ -6009,9 +6015,11 @@ int get_turn_count_2_elements(rct_ride* ride, uint8 type) { case 2: turn_count = &ride->turn_count_sloped; break; + default: + return 0; } - return (*turn_count >> 5) & TURN_MASK_2_ELEMENTS; + return ((*turn_count) & TURN_MASK_2_ELEMENTS) >> 5; } int get_turn_count_3_elements(rct_ride* ride, uint8 type) { @@ -6026,9 +6034,11 @@ int get_turn_count_3_elements(rct_ride* ride, uint8 type) { case 2: turn_count = &ride->turn_count_sloped; break; + default: + return 0; } - return (*turn_count >> 8) & TURN_MASK_3_ELEMENTS; + return ((*turn_count) & TURN_MASK_3_ELEMENTS) >> 8; } int get_turn_count_4_plus_elements(rct_ride* ride, uint8 type) { @@ -6040,9 +6050,11 @@ int get_turn_count_4_plus_elements(rct_ride* ride, uint8 type) { case 2: turn_count = &ride->turn_count_sloped; break; + default: + return 0; } - return (*turn_count >> 11) & TURN_MASK_4_PLUS_ELEMENTS; + return ((*turn_count) & TURN_MASK_4_PLUS_ELEMENTS) >> 11; } bool ride_has_spinning_tunnel(rct_ride *ride) { @@ -6720,7 +6732,7 @@ void ride_update_max_vehicles(int rideIndex) for (int i = 0; i < numCars; i++) { vehicleEntry = &rideEntry->vehicles[trainLayout[i]]; trainLength += vehicleEntry->spacing; - totalFriction += vehicleEntry->friction; + totalFriction += vehicleEntry->car_friction; } if (trainLength <= stationLength && totalFriction <= maxFriction) { diff --git a/src/ride/ride.h b/src/ride/ride.h index 15c2073702..0cbc944584 100644 --- a/src/ride/ride.h +++ b/src/ride/ride.h @@ -70,56 +70,6 @@ typedef struct { vehicle_colour list[256]; } vehicle_colour_preset_list; -/** - * Ride type vehicle structure. - * size: 0x65 - */ -typedef struct{ - uint16 var_00; // 0x00 , 0x1A - uint8 var_02; // 0x02 , 0x1C - uint8 var_03; // 0x03 , 0x1D - uint32 spacing; // 0x04 , 0x1E - uint16 friction; // 0x08 , 0x22 - sint8 var_0A; // 0x0A , 0x24 - uint8 pad_0B; - uint16 available_sprites; // 0x0C , 0x26 - uint8 var_0E; // 0x0E , 0x28 - uint8 var_0F; // 0x0F , 0x29 - uint8 var_10; // 0x10 , 0x2A - uint8 var_11; // 0x11 , 0x2B - uint16 var_12; // 0x12 , 0x2C - uint16 var_14; // 0x14 , 0x2E - uint16 var_16; // 0x16 , 0x30 - uint32 base_image_id; // 0x18 , 0x32 - uint32 var_1C; // 0x1C , 0x36 - uint32 var_20; // 0x20 , 0x3A - uint32 var_24; // 0x24 , 0x3E - uint32 var_28; // 0x28 , 0x42 - uint32 var_2C; // 0x2C , 0x46 - uint32 var_30; // 0x30 , 0x4A - uint32 var_34; // 0x34 , 0x4E - uint32 var_38; // 0x38 , 0x52 - uint32 var_3C; // 0x3C , 0x56 - uint32 var_40; // 0x40 , 0x5A - uint32 var_44; // 0x44 , 0x5E - uint32 var_48; // 0x48 , 0x62 - uint32 var_4C; // 0x4C , 0x66 - uint32 no_vehicle_images; // 0x50 , 0x6A - uint8 no_seating_rows; // 0x54 , 0x6E - uint8 spinning_inertia; // 0x55 , 0x6F - uint8 spinning_friction; // 0x56 , 0x70 - uint8 var_57; // 0x57 , 0x71 - uint8 pad_58; - uint8 sound_range; // 0x59 , 0x73 - uint8 var_5A; // 0x5A , 0x74 - uint8 pad_5B; // 0x5B , 0x75 - uint8 var_5C; // 0x5C , 0x76 - uint8 var_5D; // 0x5D , 0x77 - uint8 pad_5E[0x2]; - uint8 var_60; // 0x60 , 0x7A - sint8* peep_loading_positions; // 0x61 , 0x7B -} rct_ride_type_vehicle; - /** * Ride type structure. * size: unknown @@ -147,7 +97,7 @@ typedef struct { uint8 third_vehicle; // 0x018 uint8 pad_019; rct_ride_type_vehicle vehicles[4]; // 0x1A - uint32 var_1AE; + vehicle_colour_preset_list *vehicle_preset_list; // 0x1AE sint8 excitement_multipler; // 0x1B2 sint8 intensity_multipler; // 0x1B3 sint8 nausea_multipler; // 0x1B4 diff --git a/src/ride/ride_data.c b/src/ride/ride_data.c index c7cc940212..3f48607a17 100644 --- a/src/ride/ride_data.c +++ b/src/ride/ride_data.c @@ -1256,7 +1256,7 @@ const rct_ride_type_vehicle CableLiftVehicle = { .rotation_frame_mask = 31, .var_02 = 0, .var_03 = 0, - .var_04 = 0, + .spacing = 0, .car_friction = 0, .tab_height = 0, .num_seats = 0, @@ -1286,7 +1286,9 @@ const rct_ride_type_vehicle CableLiftVehicle = { .no_seating_rows = 0, .spinning_inertia = 0, .spinning_friction = 255, - .pad_57 = { 0,0,0 }, + .var_57 = 0, + .pad_58 = 0, + .sound_range = 0, .var_5A = 0, .powered_acceleration = 0, .powered_max_speed = 0, diff --git a/src/ride/ride_ratings.c b/src/ride/ride_ratings.c index 0f99ce8052..ebebef733b 100644 --- a/src/ride/ride_ratings.c +++ b/src/ride/ride_ratings.c @@ -931,23 +931,24 @@ static int sub_65E72D(rct_ride *ride) } static rating_tuple get_flat_turns_rating(rct_ride* ride) { + rating_tuple rating; + int no_3_plus_turns = get_turn_count_3_elements(ride, 0); int no_2_turns = get_turn_count_2_elements(ride, 0); int no_1_turns = get_turn_count_1_element(ride, 0); - int excitement = (no_3_plus_turns * 0x28000) >> 16; - excitement += no_2_turns * 3; - excitement += (no_1_turns * 63421) >> 16; + rating.excitement = (no_3_plus_turns * 0x28000) >> 16; + rating.excitement += (no_2_turns * 0x30000) >> 16; + rating.excitement += (no_1_turns * 63421) >> 16; - int intensity = (no_3_plus_turns * 81920) >> 16; - intensity += (no_2_turns * 49152) >> 16; - intensity += (no_1_turns * 21140) >> 16; + rating.intensity = (no_3_plus_turns * 81920) >> 16; + rating.intensity += (no_2_turns * 49152) >> 16; + rating.intensity += (no_1_turns * 21140) >> 16; - int nausea = no_3_plus_turns * 5; - nausea += (no_2_turns * 0x3200) >> 16; - nausea += (no_1_turns * 42281) >> 16; + rating.nausea = (no_3_plus_turns * 0x50000) >> 16; + rating.nausea += (no_2_turns * 0x32000) >> 16; + rating.nausea += (no_1_turns * 42281) >> 16; - rating_tuple rating = { excitement, intensity, nausea }; return rating; } @@ -955,23 +956,24 @@ static rating_tuple get_flat_turns_rating(rct_ride* ride) { * rct2: 0x0065DF72 */ static rating_tuple get_banked_turns_rating(rct_ride* ride) { + rating_tuple rating; + int no_3_plus_turns = get_turn_count_3_elements(ride, 1); int no_2_turns = get_turn_count_2_elements(ride, 1); int no_1_turns = get_turn_count_1_element(ride, 1); - int excitement = (no_3_plus_turns * 0x3c000) >> 16; - excitement += (no_2_turns * 0x3c000) >> 16; - excitement += (no_1_turns * 73992) >> 16; + rating.excitement = (no_3_plus_turns * 0x3C000) >> 16; + rating.excitement += (no_2_turns * 0x3C000) >> 16; + rating.excitement += (no_1_turns * 73992) >> 16; - int intensity = (no_3_plus_turns * 0x14000) >> 16; - intensity += (no_2_turns * 49152) >> 16; - intensity += (no_1_turns * 21140) >> 16; + rating.intensity = (no_3_plus_turns * 0x14000) >> 16; + rating.intensity += (no_2_turns * 49152) >> 16; + rating.intensity += (no_1_turns * 21140) >> 16; - int nausea = no_3_plus_turns * 5; - nausea += (no_2_turns * 0x32000) >> 16; - nausea += (no_1_turns * 48623) >> 16; + rating.nausea = (no_3_plus_turns * 0x50000) >> 16; + rating.nausea += (no_2_turns * 0x32000) >> 16; + rating.nausea += (no_1_turns * 48623) >> 16; - rating_tuple rating = { excitement, intensity, nausea }; return rating; } @@ -979,28 +981,20 @@ static rating_tuple get_banked_turns_rating(rct_ride* ride) { * rct2: 0x0065E047 */ static rating_tuple get_sloped_turns_rating(rct_ride* ride) { + rating_tuple rating; + int no_4_plus_turns = get_turn_count_4_plus_elements(ride, 2); int no_3_turns = get_turn_count_3_elements(ride, 2); int no_2_turns = get_turn_count_2_elements(ride, 2); int no_1_turns = get_turn_count_1_element(ride, 2); - int al; - al = min(no_4_plus_turns, 4); - int excitement = (al * 0x78000) >> 16; + rating.excitement = (min(no_4_plus_turns, 4) * 0x78000) >> 16; + rating.excitement += (min(no_3_turns, 6) * 273066) >> 16; + rating.excitement += (min(no_2_turns, 6) * 0x3AAAA) >> 16; + rating.excitement += (min(no_1_turns, 7) * 187245) >> 16; + rating.intensity = 0; + rating.nausea = (min(no_4_plus_turns, 8) * 0x78000) >> 16; - al = min(no_4_plus_turns, 8); - int nausea = (al * 0x78000) >> 16; - - al = min(no_3_turns, 6); - excitement += (al * 273066) >> 16; - - al = min(no_2_turns, 6); - excitement += (al * 0x3aaaa) >> 16; - - al = min(no_1_turns, 7); - excitement += (al * 187245) >> 16; - - rating_tuple rating = { excitement, 0, nausea }; return rating; } @@ -1008,11 +1002,12 @@ static rating_tuple get_sloped_turns_rating(rct_ride* ride) { * rct2: 0x0065E0F2 */ static rating_tuple get_inversions_ratings(uint8 inversions) { - int excitement = (min(inversions, 6) * 0x1AAAAA) >> 16; - int intensity = (inversions * 0x320000) >> 16; - int nausea = (inversions * 0x15AAAA) >> 16; + rating_tuple rating; + + rating.excitement = (min(inversions, 6) * 0x1AAAAA) >> 16; + rating.intensity = (inversions * 0x320000) >> 16; + rating.nausea = (inversions * 0x15AAAA) >> 16; - rating_tuple rating = { excitement, intensity, nausea }; return rating; } diff --git a/src/ride/track.c b/src/ride/track.c index ff7bf11948..a66b0fc42c 100644 --- a/src/ride/track.c +++ b/src/ride/track.c @@ -4241,7 +4241,7 @@ static money32 track_place(int rideIndex, int type, int originX, int originY, in if (!gCheatsDisableSupportLimits){ int ride_height = clearanceZ - mapElement->base_height; if (ride_height >= 0) { - int maxHeight = rideEntry->max_height; + int maxHeight = rideEntry->additional_max_height; if (maxHeight == 0) { maxHeight = RCT2_GLOBAL(0x0097D218 + (ride->type * 8), uint8); } diff --git a/src/ride/vehicle.c b/src/ride/vehicle.c index e322639ee4..930dde1fe0 100644 --- a/src/ride/vehicle.c +++ b/src/ride/vehicle.c @@ -517,7 +517,7 @@ static int vehicle_close_restraints(rct_vehicle* vehicle){ } vehicle->var_B5 -= 20; } - invalidate_sprite((rct_sprite*)vehicle); + invalidate_sprite_2((rct_sprite*)vehicle); ebp++; } while ((vehicle_id = vehicle->next_vehicle_on_train) != 0xFFFF); @@ -563,7 +563,7 @@ static int vehicle_open_restraints(rct_vehicle* vehicle){ vehicle->var_BA += value; vehicle->var_B6 -= value; - invalidate_sprite((rct_sprite*)vehicle); + invalidate_sprite_2((rct_sprite*)vehicle); continue; } @@ -574,7 +574,7 @@ static int vehicle_open_restraints(rct_vehicle* vehicle){ vehicle->var_C8 = vehicle->var_C8 + 0x3333 - 0xFFFF; vehicle->var_C5++; vehicle->var_C5 &= 7; - invalidate_sprite((rct_sprite*)vehicle); + invalidate_sprite_2((rct_sprite*)vehicle); } else{ vehicle->var_C8 += 0x3333; @@ -616,7 +616,7 @@ static int vehicle_open_restraints(rct_vehicle* vehicle){ continue; } vehicle->var_B5 += 20; - invalidate_sprite((rct_sprite*)vehicle); + invalidate_sprite_2((rct_sprite*)vehicle); ebp++; } @@ -696,9 +696,9 @@ static void vehicle_update_measurements(rct_vehicle *vehicle) } } - uint16 map_location = (vehicle->var_38 / 32) | ((vehicle->var_3A / 32) << 8); - if (vehicle->var_3C / 8 != ride->var_11F || map_location != ride->var_10C){ - ride->var_11F = vehicle->var_3C / 8; + uint16 map_location = (vehicle->track_x / 32) | ((vehicle->track_y / 32) << 8); + if (vehicle->track_z / 8 != ride->var_11F || map_location != ride->var_10C){ + ride->var_11F = vehicle->track_z / 8; ride->var_10C = map_location; if (ride->entrances[ride->var_1F6] == 0xFFFF) @@ -1089,15 +1089,6 @@ static void vehicle_ride_null_update_arriving(rct_vehicle *vehicle) vehicle->status = VEHICLE_STATUS_MOVING_TO_END_OF_STATION; } -static void sub_6DAB4C(rct_vehicle* vehicle, int* eax, int* ebx){ - int eax_, ebx_, ecx, edx, esi, ebp, edi; - esi = (int)vehicle; - RCT2_CALLFUNC_X(0x006DAB4C, &eax_, &ebx_, &ecx, &edx, &esi, &edi, &ebp); - - *eax = eax_; - *ebx = ebx_; -} - /** * * rct2: 0x006D7BCC @@ -1119,7 +1110,7 @@ static void vehicle_update_moving_to_end_of_station(rct_vehicle *vehicle){ vehicle->var_2C = 0; } - sub_6DAB4C(vehicle, &eax, &ebx); + eax = sub_6DAB4C(vehicle, &ebx); if (!(eax&(1 << 5))) break; //Fall through to next case @@ -1163,7 +1154,7 @@ static void vehicle_update_moving_to_end_of_station(rct_vehicle *vehicle){ } int station; - sub_6DAB4C(vehicle, &eax, &station); + eax = sub_6DAB4C(vehicle, &station); if (eax & (1 << 1)){ vehicle->velocity = 0; @@ -1276,7 +1267,7 @@ static void vehicle_update_waiting_for_passengers(rct_vehicle* vehicle){ vehicle->var_51 = 1; vehicle->var_C0 = 0; - invalidate_sprite((rct_sprite*)vehicle); + invalidate_sprite_2((rct_sprite*)vehicle); return; } else if (vehicle->var_51 == 1){ @@ -1552,9 +1543,7 @@ static void vehicle_update_sound(rct_vehicle *vehicle) } /** -<<<<<<< 0bfcf9391dbd97ecf76b3e6440e443ad52442517 * -======= * * rct2: 0x006D796B */ diff --git a/src/ride/vehicle.h b/src/ride/vehicle.h index 0577334ad0..025a8ee7b6 100644 --- a/src/ride/vehicle.h +++ b/src/ride/vehicle.h @@ -37,7 +37,7 @@ typedef struct { uint16 rotation_frame_mask; // 0x00 , 0x1A uint8 var_02; // 0x02 , 0x1C uint8 var_03; // 0x03 , 0x1D - uint32 var_04; // 0x04 , 0x1E + uint32 spacing; // 0x04 , 0x1E uint16 car_friction; // 0x08 , 0x22 sint8 tab_height; // 0x0A , 0x24 uint8 num_seats; // 0x0B , 0x25 @@ -67,7 +67,9 @@ typedef struct { uint8 no_seating_rows; // 0x54 , 0x6E uint8 spinning_inertia; // 0x55 , 0x6F uint8 spinning_friction; // 0x56 , 0x70 - uint8 pad_57[0x3]; + uint8 var_57; // 0x57 , 0x71 + uint8 pad_58; + uint8 sound_range; // 0x59 , 0x73 uint8 var_5A; // 0x5A , 0x74 uint8 powered_acceleration; // 0x5B , 0x75 uint8 powered_max_speed; // 0x5C , 0x76 @@ -105,7 +107,6 @@ typedef struct { uint8 var_20; uint8 pad_21[3]; uint32 var_24; - uint8 pad_21[0x07]; sint32 velocity; // 0x28 sint32 var_2C; uint8 ride; // 0x30 @@ -267,25 +268,6 @@ enum { VEHICLE_VISUAL_SUBMARINE }; -enum{ - VEHICLE_UPDATE_FLAG_0 = (1 << 0), - VEHICLE_UPDATE_FLAG_1 = (1 << 1), - VEHICLE_UPDATE_FLAG_WAIT_ON_ADJACENT = (1 << 2), - VEHICLE_UPDATE_FLAG_3 = (1 << 3), - VEHICLE_UPDATE_FLAG_TRAIN_READY_DEPART = (1 << 4), - VEHICLE_UPDATE_FLAG_TESTING = (1 << 5), - VEHICLE_UPDATE_FLAG_6 = (1 << 6), - VEHICLE_UPDATE_FLAG_7 = (1 << 7), - VEHICLE_UPDATE_FLAG_BROKEN_CAR = (1 << 8), - VEHICLE_UPDATE_FLAG_BROKEN_TRAIN = (1 << 9), - VEHICLE_UPDATE_FLAG_10 = (1 << 10), - VEHICLE_UPDATE_FLAG_11 = (1 << 11), - VEHICLE_UPDATE_FLAG_12 = (1 << 12), - VEHICLE_UPDATE_FLAG_13 = (1 << 13), - VEHICLE_UPDATE_FLAG_14 = (1 << 14), - VEHICLE_UPDATE_FLAG_15 = (1 << 15) -}; - #define VEHICLE_SEAT_PAIR_FLAG 0x80 #define VEHICLE_SEAT_NUM_MASK 0x7F