diff --git a/distribution/changelog.txt b/distribution/changelog.txt index d59d354111..2c189fc68a 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -1,6 +1,9 @@ 0.1.1 (in development) ------------------------------------------------------------------------ +- Fix: [#3589] Crash due to invalid footpathEntry in path_paint +- Fix: [#4931] Crash in path_paint - footpathentry was null + 0.1.0 (2017-07-12) ------------------------------------------------------------------------ - Feature: [#1399 (partial), #5177] Add window that displays any missing/corrupt objects when loading a park diff --git a/src/openrct2/paint/map_element/entrance.c b/src/openrct2/paint/map_element/entrance.c index ea9edbd551..6aa17a8bad 100644 --- a/src/openrct2/paint/map_element/entrance.c +++ b/src/openrct2/paint/map_element/entrance.c @@ -214,8 +214,10 @@ static void park_entrance_paint(uint8 direction, sint32 height, rct_map_element* switch (part_index){ case 0: - image_id = (path_entry->image + 5 * (1 + (direction & 1))) | ghost_id; - sub_98197C(image_id, 0, 0, 32, 0x1C, 0, height, 0, 2, height, get_current_rotation()); + if (path_entry != (void*)-1) { + image_id = (path_entry->image + 5 * (1 + (direction & 1))) | ghost_id; + sub_98197C(image_id, 0, 0, 32, 0x1C, 0, height, 0, 2, height, get_current_rotation()); + } entrance = (rct_entrance_type*)object_entry_groups[OBJECT_TYPE_PARK_ENTRANCE].chunks[0]; image_id = (entrance->image_id + direction * 3) | ghost_id; diff --git a/src/openrct2/paint/map_element/path.c b/src/openrct2/paint/map_element/path.c index 9772b4a514..edf7825664 100644 --- a/src/openrct2/paint/map_element/path.c +++ b/src/openrct2/paint/map_element/path.c @@ -765,12 +765,15 @@ void path_paint(uint8 direction, uint16 height, rct_map_element * map_element) } uint8 pathType = (map_element->properties.path.type & 0xF0) >> 4; - rct_footpath_entry * footpathEntry = gFootpathEntries[pathType]; + rct_footpath_entry * footpathEntry = get_footpath_entry(pathType); - if (footpathEntry->support_type == FOOTPATH_ENTRY_SUPPORT_TYPE_POLE) { - path_paint_pole_support(map_element, height, footpathEntry, word_F3F038, imageFlags, sceneryImageFlags); - } else { - path_paint_box_support(map_element, height, footpathEntry, word_F3F038, imageFlags, sceneryImageFlags); + if (footpathEntry != (void*)-1) { + if (footpathEntry->support_type == FOOTPATH_ENTRY_SUPPORT_TYPE_POLE) { + path_paint_pole_support(map_element, height, footpathEntry, word_F3F038, imageFlags, sceneryImageFlags); + } + else { + path_paint_box_support(map_element, height, footpathEntry, word_F3F038, imageFlags, sceneryImageFlags); + } } #ifdef __ENABLE_LIGHTFX__ diff --git a/src/openrct2/paint/map_element/scenery_multiple.c b/src/openrct2/paint/map_element/scenery_multiple.c index d32338c6a0..549ebb04d8 100644 --- a/src/openrct2/paint/map_element/scenery_multiple.c +++ b/src/openrct2/paint/map_element/scenery_multiple.c @@ -188,6 +188,9 @@ void scenery_multiple_paint(uint8 direction, uint16 height, rct_map_element *map gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_LARGE_SCENERY; uint32 ebp = mapElement->properties.scenerymultiple.type >> 10; rct_scenery_entry *entry = get_large_scenery_entry(mapElement->properties.scenerymultiple.type & 0x3FF); + if (entry == (void*)-1) + return; + uint32 image_id = (ebp << 2) + entry->image + 4 + direction; rct_large_scenery_tile *tile = &entry->large_scenery.tiles[ebp]; uint32 dword_F4387C = 0; diff --git a/src/openrct2/world/Fountain.cpp b/src/openrct2/world/Fountain.cpp index fc1b2cf6dd..42ea2f028a 100644 --- a/src/openrct2/world/Fountain.cpp +++ b/src/openrct2/world/Fountain.cpp @@ -315,7 +315,7 @@ static bool is_jumping_fountain(sint32 type, sint32 x, sint32 y, sint32 z) uint8 additionIndex = footpath_element_get_path_scenery_index(mapElement); rct_scenery_entry * sceneryEntry = get_footpath_item_entry(additionIndex); - if (sceneryEntry->path_bit.flags & pathBitFlagMask) + if (sceneryEntry != reinterpret_cast(-1) && sceneryEntry->path_bit.flags & pathBitFlagMask) { return true; } diff --git a/src/openrct2/world/scenery.c b/src/openrct2/world/scenery.c index cdf9bde5b1..3210f814ec 100644 --- a/src/openrct2/world/scenery.c +++ b/src/openrct2/world/scenery.c @@ -93,12 +93,14 @@ void scenery_update_tile(sint32 x, sint32 y) scenery_update_age(x, y, mapElement); } else if (map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_PATH) { if (footpath_element_has_path_scenery(mapElement) && !footpath_element_path_scenery_is_ghost(mapElement)) { - rct_scenery_entry *sceneryEntry; - sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(mapElement)); - if (sceneryEntry->path_bit.flags & PATH_BIT_FLAG_JUMPING_FOUNTAIN_WATER) { - jumping_fountain_begin(JUMPING_FOUNTAIN_TYPE_WATER, x, y, mapElement); - } else if (sceneryEntry->path_bit.flags & PATH_BIT_FLAG_JUMPING_FOUNTAIN_SNOW) { - jumping_fountain_begin(JUMPING_FOUNTAIN_TYPE_SNOW, x, y, mapElement); + rct_scenery_entry *sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(mapElement)); + if (sceneryEntry != (void*)-1) { + if (sceneryEntry->path_bit.flags & PATH_BIT_FLAG_JUMPING_FOUNTAIN_WATER) { + jumping_fountain_begin(JUMPING_FOUNTAIN_TYPE_WATER, x, y, mapElement); + } + else if (sceneryEntry->path_bit.flags & PATH_BIT_FLAG_JUMPING_FOUNTAIN_SNOW) { + jumping_fountain_begin(JUMPING_FOUNTAIN_TYPE_SNOW, x, y, mapElement); + } } } }