From 4a24aa6cf370f969d1eaa00974c3b8b1bf23e56b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Fri, 26 Feb 2016 22:58:06 +0100 Subject: [PATCH] Don't crash if mapElement is null This allows for loading parks such as "Cocopa Bay" --- src/ride/station.c | 4 ++-- src/windows/ride.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ride/station.c b/src/ride/station.c index 641d96b000..2b584b214a 100644 --- a/src/ride/station.c +++ b/src/ride/station.c @@ -66,7 +66,7 @@ static void ride_update_station_blocksection(rct_ride *ride, int stationIndex) mapElement = ride_get_station_start_track_element(ride, stationIndex); - if ((ride->status == RIDE_STATUS_CLOSED && ride->num_riders == 0) || mapElement->flags & 0x20) { + if ((ride->status == RIDE_STATUS_CLOSED && ride->num_riders == 0) || (mapElement != NULL && mapElement->flags & 0x20)) { ride->station_depart[stationIndex] &= ~STATION_DEPART_FLAG; if ((ride->station_depart[stationIndex] & STATION_DEPART_FLAG) || (mapElement->properties.track.sequence & 0x80)) @@ -75,7 +75,7 @@ static void ride_update_station_blocksection(rct_ride *ride, int stationIndex) if (!(ride->station_depart[stationIndex] & STATION_DEPART_FLAG)) { ride->station_depart[stationIndex] |= STATION_DEPART_FLAG; ride_invalidate_station_start(ride, stationIndex, 1); - } else if (mapElement->properties.track.sequence & 0x80) { + } else if (mapElement != NULL && mapElement->properties.track.sequence & 0x80) { ride_invalidate_station_start(ride, stationIndex, 1); } } diff --git a/src/windows/ride.c b/src/windows/ride.c index c8d211561b..ae7d2d7aeb 100644 --- a/src/windows/ride.c +++ b/src/windows/ride.c @@ -3359,8 +3359,8 @@ static void window_ride_locate_mechanic(rct_window *w) static void window_ride_maintenance_draw_bar(rct_window *w, rct_drawpixelinfo *dpi, int x, int y, int value, int unk) { gfx_fill_rect_inset(dpi, x, y, x + 149, y + 8, w->colours[1], 0x30); - if (unk & (1 << 31)) { - unk &= ~(1 << 31); + if (unk & (1u << 31)) { + unk &= ~(1u << 31); if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) == 0 && (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) & 8)) return; }