Fix #20361: Crash when using random map generation (#20400)

* Fix #20361: Crash using map generation

* Update changelog.txt
This commit is contained in:
Matthias Moninger 2023-06-15 22:27:00 +03:00 committed by GitHub
parent 1b612b5a99
commit d9a565dd21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View File

@ -12,6 +12,7 @@
- Fix: [#20155] Fairground organ style 2 shows up as regular music, rather than for the merry-go-round.
- Fix: [#20260] Ride locks up when inspecting/fixing staff member is fired.
- Fix: [#20262] Title screen music missing when “random” title music is selected and RCT1 is no longer linked.
- Fix: [#20361] Crash when using random map generation.
0.4.5 (2023-05-08)
------------------------------------------------------------------------

View File

@ -370,7 +370,7 @@ static void MapGenPlaceTrees()
neighbourPos.y = std::clamp(neighbourPos.y, COORDS_XY_STEP, COORDS_XY_STEP * (gMapSize.y - 1));
const auto neighboutSurface = MapGetSurfaceElementAt(neighbourPos);
if (neighboutSurface->GetWaterHeight() > 0)
if (neighboutSurface != nullptr && neighboutSurface->GetWaterHeight() > 0)
{
float distance = std::sqrt(offsetX * offsetX + offsetY * offsetY);
oasisScore += 0.5f / (maxOasisDistance * distance);