From 4f247c16b2b19d38dde38dd3812442efa60b2017 Mon Sep 17 00:00:00 2001 From: Ted John Date: Wed, 5 Oct 2016 21:34:21 +0100 Subject: [PATCH] Fix #4525: Track Designs Manager Crashing Handle tracks that use a vehicle object that can not be found, fall-back if possible to another object of the same ride type. --- src/ride/ride.c | 5 ++++- src/windows/track_list.c | 15 +++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/ride/ride.c b/src/ride/ride.c index 5996037adb..0ec9c7fa3f 100644 --- a/src/ride/ride.c +++ b/src/ride/ride.c @@ -5954,6 +5954,9 @@ static money32 ride_create(int type, int subType, int flags, int *outRideIndex, } } subType = availableRideEntries[0]; + if (subType == 255) { + return MONEY32_UNDEFINED; + } } foundRideEntry: @@ -5961,7 +5964,7 @@ foundRideEntry: rideIndex = ride_get_empty_slot(); if (subType >= 128) { - log_warning("Invalid request for ride type %u", subType); + log_warning("Invalid request for ride entry %u", subType); return MONEY32_UNDEFINED; } if (rideIndex == -1) { diff --git a/src/windows/track_list.c b/src/windows/track_list.c index 092bfaeea6..1547bed634 100644 --- a/src/windows/track_list.c +++ b/src/windows/track_list.c @@ -332,16 +332,15 @@ static void window_track_list_update(rct_window *w) */ static void window_track_list_invalidate(rct_window *w) { - rct_ride_entry *entry; - rct_string_id stringId; - colour_scheme_update(w); - entry = get_ride_entry(_window_track_list_item.entry_index); - - stringId = entry->name; - if (!(entry->flags & RIDE_ENTRY_FLAG_SEPARATE_RIDE_NAME) || rideTypeShouldLoseSeparateFlag(entry)) - stringId = _window_track_list_item.type + 2; + rct_string_id stringId = STR_NONE; + rct_ride_entry *entry = get_ride_entry(_window_track_list_item.entry_index); + if (entry != NULL && entry != (rct_ride_entry*)-1) { + stringId = entry->name; + if (!(entry->flags & RIDE_ENTRY_FLAG_SEPARATE_RIDE_NAME) || rideTypeShouldLoseSeparateFlag(entry)) + stringId = _window_track_list_item.type + 2; + } set_format_arg(0, rct_string_id, stringId); if (gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER) {