From 3e6a16ef4cde541431c441a699562cb80de2c60f Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Thu, 26 Mar 2015 20:48:42 +0000 Subject: [PATCH 1/4] Label known values --- src/ride/vehicle.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ride/vehicle.c b/src/ride/vehicle.c index 7d3070fe8b..4e8b969717 100644 --- a/src/ride/vehicle.c +++ b/src/ride/vehicle.c @@ -35,7 +35,7 @@ static void vehicle_update(rct_vehicle *vehicle); */ void vehicle_update_sound_params(rct_vehicle* vehicle) { - if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) && (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 4) || RCT2_GLOBAL(0x0141F570, uint8) == 6)) { + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) && (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_DESIGNER) || RCT2_GLOBAL(0x0141F570, uint8) == 6)) { if (vehicle->sound1_id != (uint8)-1 || vehicle->sound2_id != (uint8)-1) { if (vehicle->sprite_left != 0x8000) { RCT2_GLOBAL(0x009AF5A0, sint16) = vehicle->sprite_left; @@ -549,10 +549,10 @@ void vehicle_update_all() uint16 sprite_index; rct_vehicle *vehicle; - if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) + if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) return; - if ((RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 4) && RCT2_GLOBAL(0x0141F570, uint8) != 6) + if ((RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_DESIGNER) && RCT2_GLOBAL(0x0141F570, uint8) != 6) return; From 112290ca0c19fbcc8716f70884c03933c5ce3be9 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Thu, 26 Mar 2015 21:37:45 +0000 Subject: [PATCH 2/4] Fix station lights for races and normal operation rides --- src/ride/station.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/ride/station.c b/src/ride/station.c index 33cf3e9d75..a35e050c26 100644 --- a/src/ride/station.c +++ b/src/ride/station.c @@ -89,7 +89,8 @@ static void ride_update_station_bumpercar(rct_ride *ride, int stationIndex) { int i, dx, dl, dh; rct_vehicle *vehicle; - + // Change of station depart flag should really call invalidate_station_start + // but since bumpercars do not have station lights there is no point. if ( ride->status == RIDE_STATUS_CLOSED || (ride->lifecycle_flags & (RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED)) @@ -142,21 +143,24 @@ static void ride_update_station_normal(rct_ride *ride, int stationIndex) time = ride->station_depart[stationIndex] & STATION_DEPART_MASK; if ( - (ride->lifecycle_flags & (RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED)) && + (ride->lifecycle_flags & (RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED)) || (ride->status == RIDE_STATUS_CLOSED && ride->num_riders == 0) ) { if (time != 0 && time != 127 && !(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) & 7)) time--; ride->station_depart[stationIndex] = time; + ride_invalidate_station_start(ride, stationIndex, 0); } else { if (time == 0) { ride->station_depart[stationIndex] |= STATION_DEPART_FLAG; + ride_invalidate_station_start(ride, stationIndex, 1); } else { if (time != 127 && !(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) & 31)) time--; ride->station_depart[stationIndex] = time; + ride_invalidate_station_start(ride, stationIndex, 0); } } } @@ -175,7 +179,10 @@ static void ride_update_station_race(rct_ride *ride, int stationIndex) ride->status == RIDE_STATUS_CLOSED || (ride->lifecycle_flags & (RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED)) ) { - ride->station_depart[stationIndex] &= ~STATION_DEPART_FLAG; + if (ride->station_depart[stationIndex] & STATION_DEPART_FLAG){ + ride->station_depart[stationIndex] &= ~STATION_DEPART_FLAG; + ride_invalidate_station_start(ride, stationIndex, 0); + } return; } @@ -193,7 +200,10 @@ static void ride_update_station_race(rct_ride *ride, int stationIndex) // Race is over ride->lifecycle_flags &= ~RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING; - ride->station_depart[stationIndex] &= ~STATION_DEPART_FLAG; + if (ride->station_depart[stationIndex] & STATION_DEPART_FLAG){ + ride->station_depart[stationIndex] &= ~STATION_DEPART_FLAG; + ride_invalidate_station_start(ride, stationIndex, 0); + } return; } } @@ -205,7 +215,10 @@ static void ride_update_station_race(rct_ride *ride, int stationIndex) for (i = 0; i < ride->num_vehicles; i++) { vehicle = &(g_sprite_list[ride->vehicles[i]].vehicle); if (vehicle->status != VEHICLE_STATUS_WAITING_TO_DEPART && vehicle->status != VEHICLE_STATUS_DEPARTING) { - ride->station_depart[stationIndex] &= ~STATION_DEPART_FLAG; + if (ride->station_depart[stationIndex] & STATION_DEPART_FLAG){ + ride->station_depart[stationIndex] &= ~STATION_DEPART_FLAG; + ride_invalidate_station_start(ride, stationIndex, 0); + } return; } } @@ -213,7 +226,10 @@ static void ride_update_station_race(rct_ride *ride, int stationIndex) // Begin the race ride_race_init_vehicle_speeds(ride); ride->lifecycle_flags |= RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING; - ride->station_depart[stationIndex] |= STATION_DEPART_FLAG; + if (!(ride->station_depart[stationIndex] & STATION_DEPART_FLAG)){ + ride->station_depart[stationIndex] |= STATION_DEPART_FLAG; + ride_invalidate_station_start(ride, stationIndex, 1); + } ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_MAIN | RIDE_INVALIDATE_RIDE_LIST; } } From 0e041899512cb5f50061a858425d46cc56021279 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Thu, 26 Mar 2015 22:08:56 +0000 Subject: [PATCH 3/4] Fix potential future bug --- src/world/map_animation.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/world/map_animation.c b/src/world/map_animation.c index 9ac1eee941..282cad529c 100644 --- a/src/world/map_animation.c +++ b/src/world/map_animation.c @@ -55,7 +55,8 @@ void map_animation_create(int type, int x, int y, int z) continue; if (aobj->baseZ != z) continue; - + if (aobj->type != type) + continue; // Animation already exists return; } From bba61bd8911772394d5a73dd106dc03be9b275aa Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Fri, 27 Mar 2015 08:47:47 +0000 Subject: [PATCH 4/4] Fix on ride photos staying flashed --- src/world/map_animation.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/world/map_animation.c b/src/world/map_animation.c index 282cad529c..b481cb0029 100644 --- a/src/world/map_animation.c +++ b/src/world/map_animation.c @@ -83,7 +83,7 @@ void map_animation_invalidate_all() RCT2_GLOBAL(0x0138B580, uint16)--; numAnimatedObjects--; if (numAnimatedObjects > 0) - memmove(aobj, aobj + 1, numAnimatedObjects); + memmove(aobj, aobj + 1, numAnimatedObjects * sizeof(rct_map_animation)); } else { numAnimatedObjects--; aobj++;