From ac30e35dfa5bb8f32437b6902b0e6593070de0e2 Mon Sep 17 00:00:00 2001 From: Matt Date: Tue, 15 Oct 2019 17:32:44 +0200 Subject: [PATCH] Fix crash when ducks try to navigate out of bounds --- src/openrct2/world/Duck.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openrct2/world/Duck.cpp b/src/openrct2/world/Duck.cpp index b45c3ca16f..f7a9758a77 100644 --- a/src/openrct2/world/Duck.cpp +++ b/src/openrct2/world/Duck.cpp @@ -124,7 +124,7 @@ void rct_duck::UpdateFlyToWater() int32_t manhattanDistanceN = abs(target_x - newX) + abs(target_y - newY); auto surfaceElement = map_get_surface_element_at({ target_x, target_y }); - int32_t waterHeight = surfaceElement->GetWaterHeight(); + int32_t waterHeight = surfaceElement != nullptr ? surfaceElement->GetWaterHeight() : 0; if (waterHeight == 0) { state = DUCK_STATE::FLY_AWAY;