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; } } 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; diff --git a/src/world/map_animation.c b/src/world/map_animation.c index 9ac1eee941..b481cb0029 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; } @@ -82,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++;