diff --git a/distribution/changelog.txt b/distribution/changelog.txt index ba845825b4..fb68f9c27c 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -28,6 +28,7 @@ - Fix: [#14710] Ride/Track Design preview does not show if it costs more money than available. - Fix: [#14774] Incorrect import of scenery research caused all scenery to be unlocked. - Fix: [#14806] Incorrect function call in WallPlaceAction plugin code. +- Fix: [#14871] Crash when trying to place track when there are no free tile elements. - Improved: [#14511] “Unlock operating limits” cheat now also unlocks all music. - Improved: [#14712, #14716]: Improve startup times. diff --git a/src/openrct2/actions/TrackPlaceAction.cpp b/src/openrct2/actions/TrackPlaceAction.cpp index 7f5f8b3d8c..4858dff29e 100644 --- a/src/openrct2/actions/TrackPlaceAction.cpp +++ b/src/openrct2/actions/TrackPlaceAction.cpp @@ -547,7 +547,11 @@ GameActions::Result::Ptr TrackPlaceAction::Execute() const } auto* trackElement = TileElementInsert(mapLoc, quarterTile.GetBaseQuarterOccupied()); - Guard::Assert(trackElement != nullptr); + if (trackElement == nullptr) + { + log_warning("Cannot create track element for ride = %d", static_cast(_rideIndex)); + return std::make_unique(GameActions::Status::NoFreeElements); + } trackElement->SetClearanceZ(clearanceZ); trackElement->SetDirection(_origin.direction);