From 38e6b174bd554dde7b287e40b4c00f20d8984a64 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Tue, 1 Aug 2017 19:34:42 +0200 Subject: [PATCH] Replace memmove calls for downtime and customer history with loops --- src/openrct2/ride/ride.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/openrct2/ride/ride.c b/src/openrct2/ride/ride.c index 5de82ab61d..e8b7cf10cf 100644 --- a/src/openrct2/ride/ride.c +++ b/src/openrct2/ride/ride.c @@ -2030,7 +2030,10 @@ static void ride_update(sint32 rideIndex) ride->num_customers_timeout = 0; // Shift number of customers history, start of the array is the most recent one - memmove(ride->num_customers + 1, ride->num_customers, sizeof(ride->num_customers) - 1); + for (sint32 i = CUSTOMER_HISTORY_SIZE - 1; i > 0; i--) + { + ride->num_customers[i] = ride->num_customers[i - 1]; + } ride->num_customers[0] = ride->cur_num_customers; ride->cur_num_customers = 0; @@ -2305,9 +2308,12 @@ static void ride_breakdown_update(sint32 rideIndex) ride->downtime = min(totalDowntime / 2, 100); - memmove(&ride->downtime_history[1], ride->downtime_history, sizeof(ride->downtime_history) - 1); - + for (sint32 i = DOWNTIME_HISTORY_SIZE - 1; i > 0; i--) + { + ride->downtime_history[i] = ride->downtime_history[i - 1]; + } ride->downtime_history[0] = 0; + ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_MAINTENANCE; }