mirror of https://github.com/OpenRCT2/OpenRCT2.git
Make sure null ride type gets handled properly
This commit is contained in:
parent
eb645cd4f3
commit
d19fe0e334
|
@ -4068,6 +4068,8 @@ STR_5760 :Hong Kong Dollars (HK$)
|
|||
STR_5761 :New Taiwan Dollar (NT$)
|
||||
STR_5762 :Chinese Yuan (CN{YEN})
|
||||
STR_5763 :All files
|
||||
STR_5764 :Invalid ride type
|
||||
STR_5765 :Cannot edit rides of invalid type
|
||||
|
||||
#############
|
||||
# Scenarios #
|
||||
|
|
|
@ -2372,6 +2372,9 @@ enum {
|
|||
|
||||
STR_ALL_FILES = 5763,
|
||||
|
||||
STR_INVALID_RIDE_TYPE = 5764,
|
||||
STR_CANT_EDIT_INVALID_RIDE_TYPE = 5765,
|
||||
|
||||
// Have to include resource strings (from scenarios and objects) for the time being now that language is partially working
|
||||
STR_COUNT = 32768
|
||||
};
|
||||
|
|
|
@ -841,6 +841,11 @@ void reset_all_ride_build_dates()
|
|||
|
||||
static int ride_check_if_construction_allowed(rct_ride *ride)
|
||||
{
|
||||
rct_ride_type *rideType = get_ride_entry_by_ride(ride);
|
||||
if (rideType == NULL) {
|
||||
window_error_open(STR_INVALID_RIDE_TYPE, STR_CANT_EDIT_INVALID_RIDE_TYPE);
|
||||
return 0;
|
||||
}
|
||||
if (ride->lifecycle_flags & RIDE_LIFECYCLE_BROKEN_DOWN) {
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 6, uint16) = ride->name;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 8, uint32) = ride->name_arguments;
|
||||
|
@ -1684,13 +1689,15 @@ int ride_modify(rct_xy_element *input)
|
|||
int rideIndex, x, y, z, direction, type;
|
||||
rct_xy_element mapElement, endOfTrackElement;
|
||||
rct_ride *ride;
|
||||
rct_ride_type *rideType;
|
||||
rct_window *constructionWindow;
|
||||
|
||||
mapElement = *input;
|
||||
rideIndex = mapElement.element->properties.track.ride_index;
|
||||
ride = get_ride(rideIndex);
|
||||
rideType = get_ride_entry(rideIndex);
|
||||
|
||||
if (!ride_check_if_construction_allowed(ride))
|
||||
if ((ride == NULL) || (rideType == NULL) || !ride_check_if_construction_allowed(ride))
|
||||
return 0;
|
||||
|
||||
if (ride->lifecycle_flags & RIDE_LIFECYCLE_INDESTRUCTIBLE) {
|
||||
|
@ -4940,7 +4947,10 @@ void loc_6B51C0(int rideIndex)
|
|||
|
||||
ride_try_get_origin_element(rideIndex, &trackElement);
|
||||
ride_find_track_gap(&trackElement, &trackElement);
|
||||
ride_modify(&trackElement);
|
||||
int ok = ride_modify(&trackElement);
|
||||
if (ok == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
w = window_find_by_class(WC_RIDE_CONSTRUCTION);
|
||||
if (w != NULL)
|
||||
|
|
|
@ -4384,7 +4384,7 @@ static money32 track_place(int rideIndex, int type, int originX, int originY, in
|
|||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
rct_ride_type *rideEntry = get_ride_entry(ride->subtype);
|
||||
if (rideEntry == (rct_ride_type *)0xFFFFFFFF)
|
||||
if (rideEntry == (rct_ride_type *)0xFFFFFFFF || rideEntry == NULL)
|
||||
{
|
||||
log_warning("Invalid ride type for track placement, rideIndex = %d", rideIndex);
|
||||
return MONEY32_UNDEFINED;
|
||||
|
|
|
@ -1159,7 +1159,10 @@ void window_ride_disable_tabs(rct_window *w)
|
|||
|
||||
rct_ride_type *type = get_ride_entry(ride->subtype);
|
||||
|
||||
if ((type->flags & RIDE_ENTRY_FLAG_19) != 0)
|
||||
if (type == NULL) {
|
||||
disabled_tabs |= 1 << WIDX_TAB_2 | 1 << WIDX_TAB_3 | 1 << WIDX_TAB_4 | 1 << WIDX_TAB_5 | 1 << WIDX_TAB_6
|
||||
| 1 << WIDX_TAB_7 | 1 << WIDX_TAB_8 | 1 << WIDX_TAB_9 | 1 << WIDX_TAB_10;
|
||||
} else if ((type->flags & RIDE_ENTRY_FLAG_19) != 0)
|
||||
disabled_tabs |= (1 << WIDX_TAB_5); // 0x100
|
||||
|
||||
w->disabled_widgets = disabled_tabs;
|
||||
|
@ -3360,6 +3363,9 @@ static void window_ride_maintenance_mousedown(int widgetIndex, rct_window *w, rc
|
|||
|
||||
ride = get_ride(w->number);
|
||||
ride_type = get_ride_entry(ride->subtype);
|
||||
if (ride_type == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (widgetIndex) {
|
||||
case WIDX_INSPECTION_INTERVAL_DROPDOWN:
|
||||
|
|
|
@ -2693,6 +2693,9 @@ static void window_ride_construction_update_enabled_track_pieces()
|
|||
rct_ride *ride = get_ride(_currentRideIndex);
|
||||
rct_ride_type *rideEntry = get_ride_entry_by_ride(ride);
|
||||
|
||||
if (rideEntry == NULL)
|
||||
return;
|
||||
|
||||
int rideType = _currentTrackCovered & 2 ? RCT2_ADDRESS(0x0097D4F5, uint8)[ride->type * 8] : ride->type;
|
||||
_enabledRidePiecesA = rideEntry->enabledTrackPiecesA & RCT2_ADDRESS(0x01357444, uint32)[rideType];
|
||||
_enabledRidePiecesB = rideEntry->enabledTrackPiecesB & RCT2_ADDRESS(0x01357644, uint32)[rideType];
|
||||
|
|
Loading…
Reference in New Issue