From ac32e7dd084fa80fa1ff945420c2dc51ab172680 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Mon, 26 Dec 2016 15:53:11 +0100 Subject: [PATCH] Fix #4920: Crash in peep pathfinding --- src/world/footpath.c | 2 ++ src/world/map.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/world/footpath.c b/src/world/footpath.c index ed168d31b4..aac224c94a 100644 --- a/src/world/footpath.c +++ b/src/world/footpath.c @@ -851,6 +851,8 @@ bool fence_in_the_way(int x, int y, int z0, int z1, int direction) rct_map_element *mapElement; mapElement = map_get_first_element_at(x >> 5, y >> 5); + if (mapElement == NULL) + return false; do { if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_FENCE) continue; diff --git a/src/world/map.c b/src/world/map.c index 874d6b06a2..8c0874bd11 100644 --- a/src/world/map.c +++ b/src/world/map.c @@ -5146,6 +5146,10 @@ bool map_surface_is_blocked(sint16 x, sint16 y){ mapElement = map_get_surface_element_at(x / 32, y / 32); + if (mapElement == NULL) { + return true; + } + sint16 water_height = mapElement->properties.surface.terrain & MAP_ELEMENT_WATER_HEIGHT_MASK; water_height *= 2; if (water_height > mapElement->base_height)