From 1d3fc842e301f9858e0864ffadeca58c7ef0d198 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Sat, 1 Nov 2014 03:32:57 +0000 Subject: [PATCH] fix bugs and refactor ride update --- src/audio/audio.c | 53 +++-- src/audio/audio.h | 2 +- src/ride/ride.c | 520 ++++++++++++++++++++++++++-------------------- src/ride/ride.h | 6 +- 4 files changed, 334 insertions(+), 247 deletions(-) diff --git a/src/audio/audio.c b/src/audio/audio.c index 4a0f5fd2de..54bdd956d2 100644 --- a/src/audio/audio.c +++ b/src/audio/audio.c @@ -1874,17 +1874,32 @@ void sub_6BC348() * @param x (ax) * @param y (cx) * @param z (dx) - * @param bx - * @param ebp - * @param di - * @returns ebp register + * @param sampleRate (di) + * @param rideIndex (bl) + * @param position (ebp) + * @param tuneId (bh) + * @returns new position (ebp) */ -int sub_6BC3AC(sint16 x, sint16 y, sint16 z, uint16 bx, uint32 ebp, uint16 di) +int sub_6BC3AC(sint16 x, sint16 y, sint16 z, uint8 rideIndex, uint16 sampleRate, uint32 position, uint8 *tuneId) { - uint8 bl = LOBYTE(bx); - uint8 bh = HIBYTE(bx); + { + int a_eax, a_ebx, a_ecx, a_edx, a_esi, a_edi, a_ebp; + + a_eax = x; + a_ebx = (*tuneId << 8) | rideIndex; + a_ecx = y; + a_edx = z; + a_edi = sampleRate; + a_ebp = position; + RCT2_CALLFUNC_X(0x006BC3AC, &a_eax, &a_ebx, &a_ecx, &a_edx, &a_esi, &a_edi, &a_ebp); + + *tuneId = (a_ebx >> 8) & 0xFF; + return a_ebp; + } + + // TODO fix / bh needs returning too! if(!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) && !RCT2_GLOBAL(0x009AF59C, uint8) && RCT2_GLOBAL(0x00F438A4, rct_viewport*) != (rct_viewport*)-1) { - RCT2_GLOBAL(0x009AF47C, uint16) = di; + RCT2_GLOBAL(0x009AF47C, uint16) = sampleRate; sint16 v11; sint16 v12; switch (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)) { @@ -1988,12 +2003,12 @@ int sub_6BC3AC(sint16 x, sint16 y, sint16 z, uint16 bx, uint32 ebp, uint16 di) rct_music_info2* music_info2 = &RCT2_GLOBAL(0x009AF46C, rct_music_info2); int channel = 0; uint32 a1; - while (music_info2->id != bl && music_info2->var_1 != bh) { + while (music_info2->id != rideIndex && music_info2->var_1 != *tuneId) { music_info2++; channel++; if (channel >= 2) { - rct_music_info3* music_info3 = &RCT2_GLOBAL(0x009AF1C8, rct_music_info3*)[bh]; - a1 = ebp + music_info3->var_4; + rct_music_info3* music_info3 = &RCT2_GLOBAL(0x009AF1C8, rct_music_info3*)[*tuneId]; + a1 = position + music_info3->var_4; goto label51; } } @@ -2007,11 +2022,11 @@ int sub_6BC3AC(sint16 x, sint16 y, sint16 z, uint16 bx, uint32 ebp, uint16 di) a1 = sub_401B46(channel); RCT2_GLOBAL(0x014241BC, uint32) = 0; label51: - if (a1 < RCT2_GLOBAL(0x009AF1C8, rct_music_info3*)[bh].var_0) { + if (a1 < RCT2_GLOBAL(0x009AF1C8, rct_music_info3*)[*tuneId].var_0) { rct_music_info* music_info = RCT2_GLOBAL(0x009AF42C, rct_music_info*); if (music_info < (rct_music_info*)0x009AF46C/*music_info list end*/) { - music_info->id = bl; - music_info->var_1 = bh; + music_info->id = rideIndex; + music_info->var_1 = *tuneId; music_info->offset = a1; music_info->volume = v32; music_info->pan = panx; @@ -2022,16 +2037,16 @@ int sub_6BC3AC(sint16 x, sint16 y, sint16 z, uint16 bx, uint32 ebp, uint16 di) } else { uint32 eax; label58: - eax = ebp; - ebp = bh; - rct_music_info3* music_info3 = &RCT2_GLOBAL(0x009AF1C8, rct_music_info3*)[bh]; + eax = position; + position = *tuneId; + rct_music_info3* music_info3 = &RCT2_GLOBAL(0x009AF1C8, rct_music_info3*)[*tuneId]; eax += music_info3->var_4; if (eax < music_info3->var_0) { - ebp = eax; + position = eax; } } } - return ebp; + return position; } /** diff --git a/src/audio/audio.h b/src/audio/audio.h index eaa1797413..5821ce051f 100644 --- a/src/audio/audio.h +++ b/src/audio/audio.h @@ -215,7 +215,7 @@ void unpause_sounds(); void stop_vehicle_sounds(); void sub_6BC348(); void sub_6BC6D8(); -int sub_6BC3AC(sint16 x, sint16 y, sint16 z, uint16 bx, uint32 ebp, uint16 di); +int sub_6BC3AC(sint16 x, sint16 y, sint16 z, uint8 rideIndex, uint16 sampleRate, uint32 position, uint8 *tuneId); // 0x009AF59C probably does the same job // once it's confirmed and calls in pause_sounds() are reversed, it can be used instead of this diff --git a/src/ride/ride.c b/src/ride/ride.c index c09e59d85a..e976e89d42 100644 --- a/src/ride/ride.c +++ b/src/ride/ride.c @@ -23,6 +23,7 @@ #include "../audio/audio.h" #include "../game.h" #include "../interface/window.h" +#include "../localisation/date.h" #include "../localisation/localisation.h" #include "../management/news_item.h" #include "../peep/peep.h" @@ -261,7 +262,7 @@ money32 ride_calculate_income_per_hour(rct_ride *ride) */ void ride_play_music() { - + RCT2_CALLPROC_EBPSAFE(0x006BC6D8); } rct_map_element *ride_get_station_start_track_element(rct_ride *ride, int stationIndex) @@ -523,84 +524,299 @@ int sub_6B7294(rct_ride *ride) return ebx; } +/** + * + * rct2: 0x006B75C8 + */ +void sub_6B75C8(int rideIndex) +{ + RCT2_CALLPROC_X(0x006B75C8, 0, 0, 0, rideIndex, 0, 0, 0); +} + +/** + * + * rct2: 0x006AC622 + */ +void ride_breakdown_update(int rideIndex) +{ + int agePenalty, years, ax; + rct_ride *ride = GET_RIDE(rideIndex); + + if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) & 255) + return; + if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_DESIGNER) + return; + + if (ride->lifecycle_flags & (RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED)) + ride->var_19C++; + + if (!(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) & 8191)) { + int ax = + ride->var_19C + + ride->var_19D + + ride->var_19E + + ride->var_1A0 + + ride->var_1A2 + + ride->var_1A3; + ride->var_199 = min(ax / 2, 100); + + ride->var_1A3 = ride->var_1A2; + ride->var_1A2 = ride->var_1A1; + ride->var_1A1 = ride->var_1A0; + ride->var_1A0 = ride->var_19F; + ride->var_19F = ride->var_19E; + ride->var_19E = ride->var_19D; + ride->var_19D = ride->var_19C; + ride->var_19C = 0; + ride->var_14D |= 32; + } + + if (ride->lifecycle_flags & (RIDE_LIFECYCLE_6 | RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED)) + return; + if (ride->status == RIDE_STATUS_CLOSED) + return; + + // Calculate breakdown probability? + ax = ride->var_198; + agePenalty; + years = date_get_year(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint16) - ride->build_date); + switch (years) { + case 0: + agePenalty = 0; + break; + case 1: + agePenalty = ax >> 3; + break; + case 2: + agePenalty = ax >> 2; + break; + case 3: + agePenalty = ax >> 1; + break; + case 4: + case 5: + case 6: + agePenalty = ax >> 0; + break; + default: + agePenalty = ax << 1; + break; + } + ax += agePenalty; + ride->var_196 = max(0, ride->var_196 - ax); + ride->var_14D |= 32; + + // Break down based on probability? + if (ride->var_196 == 0 || (scenario_rand() & 0x2FFFFF) <= 25856 - ride->var_196) + if (sub_6B7294(ride) != -1) + sub_6B75C8(rideIndex); +} + +/** + * + * rct2: 0x006AC7C2 + */ +void ride_inspection_update(rct_ride *ride) +{ + int i; + + if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) & 2047) + return; + if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_DESIGNER) + return; + + ride->last_inspection++; + if (ride->last_inspection == 0) + ride->last_inspection--; + + int inspectionIntervalMinutes = RideInspectionInterval[ride->inspection_interval]; + if (inspectionIntervalMinutes == 0) + return; + + if (RCT2_ADDRESS(0x0097C740, uint32)[ride->type] == 0) + return; + + if (inspectionIntervalMinutes > ride->last_inspection) + return; + + if (ride->lifecycle_flags & (RIDE_LIFECYCLE_6 | RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_DUE_INSPECTION | RIDE_LIFECYCLE_CRASHED)) + return; + + // Inspect the first station that has an exit + ride->lifecycle_flags |= RIDE_LIFECYCLE_DUE_INSPECTION; + ride->inspection_station = 0; + for (i = 0; i < 4; i++) { + if (ride->exits[i] != 0xFFFF) { + ride->inspection_station = i; + break; + } + } +} + +/** + * + * rct2: 0x006AC489 + */ +void ride_chairlift_update(rct_ride *ride) +{ + int x, y, z, ax, bx, cx; + + if (!(ride->lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK)) + return; + if (!(ride->lifecycle_flags & (RIDE_LIFECYCLE_6 | RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED))) + return; + if (ride->var_18C == 0) + return; + + ax = ride->var_0D0 * 2048; + bx = ride->var_148; + cx = bx + ax; + ride->var_148 = cx; + if (bx >> 14 == cx >> 14) + return; + + x = (ride->var_13A & 0xFF) * 32; + y = (ride->var_13A >> 8) * 32; + z = ride->var_13E * 8; + map_invalidate_tile(x, y, z, z + (4 * 8)); + + x = (ride->var_13C & 0xFF) * 32; + y = (ride->var_13C >> 8) * 32; + z = ride->var_13F * 8; + map_invalidate_tile(x, y, z, z + (4 * 8)); +} + +/** + * + * rct2: 0x006AC545 + */ +void ride_spiral_slide_update(rct_ride *ride) +{ + int i, x, y, z; + rct_map_element *mapElement; + + if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) & 3) + return; + if (ride->var_15D == 0) + return; + + ride->var_176++; + if (ride->var_176 >= 48) { + ride->var_15D--; + + // TODO find out what type of sprite is stored here + rct_sprite *sprite = &g_sprite_list[ride->maze_tiles]; + RCT2_GLOBAL((int)sprite + 0x32, uint16)++; + } + + // Invalidate something related to station start + for (i = 0; i < 4; i++) { + if (ride->station_starts[i] == 0xFFFF) + continue; + + x = ride->station_starts[i] & 0xFF; + y = ride->station_starts[i] >> 8; + z = ride->station_heights[i]; + + mapElement = ride_get_station_start_track_element(ride, i); + int rotation = ((mapElement->type & 3) << 2) | RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8); + x += RCT2_GLOBAL(0x0098DDB8 + (rotation * 4), uint16); + y += RCT2_GLOBAL(0x0098DDBA + (rotation * 4), uint16); + + map_invalidate_tile(x, y, mapElement->base_height * 8, mapElement->clearance_height * 8); + } +} + +/** + * + * rct2: 0x006ABE85 + */ +void ride_music_update(int rideIndex) +{ + int x, y, z; + rct_vehicle *vehicle; + rct_ride *ride = GET_RIDE(rideIndex); + + if (!(RCT2_GLOBAL(0x0097D4F2 + (ride->type * 8), uint16) & 6)) + return; + + if (ride->status != RIDE_STATUS_OPEN || !(ride->lifecycle_flags & RIDE_LIFECYCLE_MUSIC)) { + ride->music_tune_id = 255; + return; + } + + if (ride->type == RIDE_TYPE_CIRCUS_SHOW) { + vehicle = &(g_sprite_list[ride->vehicles[0]].vehicle); + if (vehicle->status != VEHICLE_STATUS_DOING_CIRCUS_SHOW) { + ride->music_tune_id = 255; + return; + } + } + + // Oscillate parameters for a power cut effect when breaking down + if (ride->lifecycle_flags & (RIDE_LIFECYCLE_6 | RIDE_LIFECYCLE_BROKEN_DOWN)) { + if (ride->var_18C == 7) { + if (!(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) & 7)) + if (ride->var_1AC != 255) + ride->var_1AC++; + } else { + if ((ride->lifecycle_flags & RIDE_LIFECYCLE_BROKEN_DOWN) || ride->var_18C == 6 || ride->var_18C == 7) + if (ride->var_1AC != 255) + ride->var_1AC++; + + if (ride->var_1AC == 255) { + ride->music_tune_id = 255; + return; + } + } + } + + // Select random tune from available tunes for a music style (of course only merry-go-rounds have more than one tune) + if (ride->music_tune_id == 255) { + uint8 *musicStyleTunes = RCT2_ADDRESS(0x009AEF28, uint8*)[ride->music]; + uint8 numTunes = *musicStyleTunes++; + ride->music_tune_id = musicStyleTunes[scenario_rand() % numTunes]; + ride->music_position = 0; + return; + } + + x = (ride->station_starts[0] & 0xFF) * 32 + 16; + y = (ride->station_starts[0] >> 8) * 32 + 16; + z = ride->station_heights[0] * 8; + + int sampleRate = 22050; + + // Alter sample rate for a power cut effect + if (ride->lifecycle_flags & (RIDE_LIFECYCLE_6 | RIDE_LIFECYCLE_BROKEN_DOWN)) { + sampleRate = ride->var_1AC * 70; + if (ride->var_18C != 7) + sampleRate *= -1; + sampleRate += 22050; + } + + ride->music_position = sub_6BC3AC(x, y, z, rideIndex, sampleRate, ride->music_position, &ride->music_tune_id); +} + /** * * rct2: 0x006ABE73 */ -void ride_update(int index) +void ride_update(int rideIndex) { - rct_vehicle *vehicle; - int j, x, y, z; - rct_map_element *mapElement; - rct_ride *ride = GET_RIDE(index); + int i; + rct_ride *ride = GET_RIDE(rideIndex); if (ride->var_1CA != 0) ride->var_1CA--; - if (!(RCT2_GLOBAL(0x0097D4F2 + (ride->type * 8), uint16) & 6)) { - if (ride->status == RIDE_STATUS_OPEN && !(ride->lifecycle_flags & RIDE_LIFECYCLE_MUSIC)) { - if (ride->type == RIDE_TYPE_CIRCUS_SHOW) { - vehicle = &(g_sprite_list[ride->vehicles[0]].vehicle); - if (vehicle->status != VEHICLE_STATUS_DOING_CIRCUS_SHOW) { - ride->var_15C = 255; - goto loc_6ABF76; - } - } - - if (!(ride->lifecycle_flags & (RIDE_LIFECYCLE_6 | RIDE_LIFECYCLE_BROKEN_DOWN))) { - if (ride->var_18C == 7) { - if (!(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) & 7)) - if (ride->var_1AC != 255) - ride->var_1AC++; - } else { - if ((ride->lifecycle_flags & RIDE_LIFECYCLE_BROKEN_DOWN) || ride->var_18C == 6 || ride->var_18C != 7) - if (ride->var_1AC != 255) - ride->var_1AC++; - - if (ride->var_1AC == 255) { - ride->var_15C = 255; - goto loc_6ABF76; - } - } - } - - if (ride->var_15C == 255) { - uint8 *someKindOfMusicInfo = RCT2_ADDRESS(0x009AEF28, uint8*)[ride->music]; - uint8 someKindOfMusicInfoCount = *someKindOfMusicInfo++; - ride->var_15C = someKindOfMusicInfo[scenario_rand() % someKindOfMusicInfoCount]; - ride->var_188 = 0; - } - goto loc_6ABF76; - } - ride->var_15C = 255; - - loc_6ABF76: - if (ride->var_15C != 255) { - // Ride music of some sort, possibly break down power cut effect - x = (ride->station_starts[0] & 0xFF) * 32 + 16; - y = (ride->station_starts[0] >> 8) * 32 + 16; - z = ride->station_heights[0] * 8; - - uint8 bh = ride->var_15C; - int sampleRate = 22050; - if (!(ride->lifecycle_flags & (RIDE_LIFECYCLE_6 | RIDE_LIFECYCLE_BROKEN_DOWN))) { - sampleRate = ride->var_1AC * 70; - if (ride->var_18C != 7) - sampleRate *= -1; - sampleRate += 22050; - } - - ride->var_188 = sub_6BC3AC(x, y, z, (ride->var_15C << 8) | index, ride->var_188, sampleRate); - ride->var_15C = bh; - } - } + ride_music_update(rideIndex); // Update stations if (ride->type != RIDE_TYPE_MAZE) - for (j = 0; j < 4; j++) - ride_update_station(ride, j); + for (i = 0; i < 4; i++) + ride_update_station(ride, i); - // + // Update financial statistics ride->var_122++; if (ride->var_122 >= 960) { ride->var_122 = 0; @@ -620,170 +836,24 @@ void ride_update(int index) ride->income_per_hour = ride_calculate_income_per_hour(ride); ride->var_14D |= 2; - if (ride->upkeep_cost != (money16)0xFFFF) { - ride->upkeep_cost *= -16; - ride->upkeep_cost += (money16)ride->income_per_hour; - } + if (ride->upkeep_cost != (money16)0xFFFF) + ride->upkeep_cost = (money16)ride->income_per_hour - (ride->upkeep_cost * 16); } - if (ride->type == RIDE_TYPE_CHAIRLIFT && (ride->lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK)) { - if ( - (ride->lifecycle_flags & (RIDE_LIFECYCLE_6 | RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED)) || - ride->var_18C != 0 - ) { - int ax = ride->var_0D0 * 2048; - int bx = ride->var_148; - int cx = bx + ax; - ride->var_148 = cx; - if (bx >> 14 != cx >> 14) { - x = (ride->var_13A & 0xFF) * 32; - y = (ride->var_13A >> 8) * 32; - z = ride->var_13E * 8; - map_invalidate_tile(x, y, z, z + (4 * 8)); + // Ride specific updates + if (ride->type == RIDE_TYPE_CHAIRLIFT) + ride_chairlift_update(ride); + else if (ride->type == RIDE_TYPE_SPIRAL_SLIDE) + ride_spiral_slide_update(ride); - x = (ride->var_13C & 0xFF) * 32; - y = (ride->var_13C >> 8) * 32; - z = ride->var_13F * 8; - map_invalidate_tile(x, y, z, z + (4 * 8)); - } - } - } + ride_breakdown_update(rideIndex); - if ( - !(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) & 3) && - ride->type == RIDE_TYPE_SPIRAL_SLIDE && - ride->var_15D != 0 - ) { - ride->var_176++; - if (ride->var_176 >= 48) { - ride->var_15D--; - - // TODO find out what type of sprite is stored here - rct_sprite *sprite = &g_sprite_list[ride->maze_tiles]; - RCT2_GLOBAL((int)sprite + 0x32, uint16)++; - } - - // Invalidate something related to station start - for (j = 0; j < 4; j++) { - if (ride->station_starts[j] == 0xFFFF) - continue; - - x = ride->station_starts[j] & 0xFF; - y = ride->station_starts[j] >> 8; - z = ride->station_heights[j]; - - mapElement = ride_get_station_start_track_element(ride, j); - int rotation = ((mapElement->type & 3) << 2) | RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8); - x += RCT2_GLOBAL(0x0098DDB8 + (rotation * 4), uint16); - y += RCT2_GLOBAL(0x0098DDBA + (rotation * 4), uint16); - - map_invalidate_tile(x, y, mapElement->base_height * 8, mapElement->clearance_height * 8); - } - } - - if ( - !(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) & 255) && - !(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_DESIGNER) - ) { - if (ride->lifecycle_flags & (RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED)) - ride->var_19C++; - - if (!(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) & 8191)) { - int ax = - ride->var_19C + - ride->var_19D + - ride->var_19E + - ride->var_1A0 + - ride->var_1A2 + - ride->var_1A3; - ride->var_199 = min(ax / 2, 100); - - ride->var_1A3 = ride->var_1A2; - ride->var_1A2 = ride->var_1A1; - ride->var_1A1 = ride->var_1A0; - ride->var_1A0 = ride->var_19F; - ride->var_19F = ride->var_19E; - ride->var_19E = ride->var_19D; - ride->var_19D = ride->var_19C; - ride->var_19C = 0; - ride->var_14D |= 32; - } - - if ( - !(ride->lifecycle_flags & (RIDE_LIFECYCLE_6 | RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED)) && - ride->status != RIDE_STATUS_CLOSED - ) { - int ax = ride->var_198; - int dx = 0; - int cx = (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint16) - ride->build_date) >> 3; - if (cx != 0) { - dx = ax >> 3; - if (cx != 1) { - dx = ax >> 2; - if (cx != 2) { - dx = ax >> 1; - if (cx > 4) { - dx = ax; - if (cx > 7) { - dx = ax << 1; - } - } - } - } - } - ax += dx; - ride->var_196 = max(0, ride->var_196 - ax); - ride->var_14D |= 32; - - int ebx = ride->var_196; - if (ebx == 0) { - goto loc_6AC787; - } else { - ebx *= -1; - ebx += 25856; - if ((scenario_rand() & 0x2FFFFF) <= ebx) { - loc_6AC787: - if (sub_6B7294(ride) != -1) { - // Possibly do breakdown function - RCT2_CALLPROC_X(0x006B75C8, 0, 0, 0, index, 0, 0, 0); - } - } - } - } - } - - // ? + // Various things include news messages if (ride->lifecycle_flags & (RIDE_LIFECYCLE_6 | RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_DUE_INSPECTION)) - if (((RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) >> 1) & 255) == index) - RCT2_CALLPROC_X(0x006B75C8, 0, 0, 0, index, 0, 0, 0); + if (((RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) >> 1) & 255) == rideIndex) + sub_6B75C8(rideIndex); - // Inspection - if (!(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) & 2047)) { - if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_DESIGNER)) { - ride->last_inspection++; - if (ride->last_inspection == 0) - ride->last_inspection--; - - int inspectionIntervalMinutes = RideInspectionInterval[ride->inspection_interval]; - if (inspectionIntervalMinutes != 0) { - if (RCT2_ADDRESS(0x0097C740, uint32)[ride->type] != 0) { - if (inspectionIntervalMinutes <= ride->last_inspection) { - if (!(ride->lifecycle_flags & (RIDE_LIFECYCLE_6 | RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_DUE_INSPECTION | RIDE_LIFECYCLE_CRASHED))) { - ride->lifecycle_flags |= RIDE_LIFECYCLE_DUE_INSPECTION; - - ride->var_190 = 0; - for (j = 0; j < 4; j++) { - if (ride->exits[j] != 0xFFFF) { - ride->var_190 = j; - break; - } - } - } - } - } - } - } - } + ride_inspection_update(ride); } /** @@ -796,6 +866,8 @@ void ride_update_all() rct_ride *ride; int i; + // RCT2_CALLPROC_EBPSAFE(0x006ABE4C); return; + // Remove all rides if certain flags are set (possible scenario editor?) int *esi = (int*)0x9DCE9E; if (esi[0x1BCA] & 2) { diff --git a/src/ride/ride.h b/src/ride/ride.h index 5a214f1f4d..9d25f00d1d 100644 --- a/src/ride/ride.h +++ b/src/ride/ride.h @@ -178,7 +178,7 @@ typedef struct { uint16 var_158; uint8 pad_15A; uint8 num_riders; // 0x15B - uint8 var_15C; + uint8 music_tune_id; // 0x15C uint8 var_15D; uint16 maze_tiles; // 0x15E uint8 pad_160[0x16]; @@ -188,11 +188,11 @@ typedef struct { money16 upkeep_cost; // 0x182 uint16 race_winner; // 0x184 uint8 pad_186[0x02]; - uint32 var_188; + uint32 music_position; // 0x188 uint8 var_18C; uint8 mechanic_status; // 0x18D uint16 mechanic; // 0x18E - uint8 var_190; + uint8 inspection_station; // 0x190 uint8 pad_191[0x02]; uint8 breakdown_reason; // 0x193 money16 price_secondary; // 0x194