Fix #15612: Crash in WallCheckObstruction()

This commit is contained in:
Michael Steenbeek 2021-10-20 16:15:35 +02:00 committed by GitHub
parent 27939c2417
commit 578d8ce247
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 14 deletions

View File

@ -43,6 +43,7 @@
- Fix: [#15567] Litter not being counted correctly during Park rating calculation (original bug).
- Fix: [#15582] [Plugin] Litter properties return incorrect values.
- Fix: [#15584] Ride income underflows when on-ride photos are making losses.
- Fix: [#15612] Crash when placing walls beside certain scenery objects.
- Improved: [#3417] Crash dumps are now placed in their own folder.
- Improved: [#13524] macOS arm64 native (universal) app
- Improved: [#15538] Software rendering can now draw in parallel when Multithreading is enabled.

View File

@ -486,9 +486,6 @@ bool WallPlaceAction::WallCheckObstructionWithTrack(
GameActions::Result::Ptr WallPlaceAction::WallCheckObstruction(
WallSceneryEntry* wall, int32_t z0, int32_t z1, bool* wallAcrossTrack) const
{
int32_t entryType, sequence;
rct_large_scenery_tile* tile;
*wallAcrossTrack = false;
if (map_is_location_at_edge(_loc))
{
@ -537,24 +534,28 @@ GameActions::Result::Ptr WallPlaceAction::WallCheckObstruction(
break;
case TILE_ELEMENT_TYPE_LARGE_SCENERY:
{
entryType = tileElement->AsLargeScenery()->GetEntryIndex();
sequence = tileElement->AsLargeScenery()->GetSequenceIndex();
auto* sceneryEntry = get_large_scenery_entry(entryType);
tile = &sceneryEntry->tiles[sequence];
const auto* largeSceneryElement = tileElement->AsLargeScenery();
const auto* sceneryEntry = largeSceneryElement->GetEntry();
// If there is no entry, assume the object is not in the way.
if (sceneryEntry == nullptr)
break;
auto sequence = largeSceneryElement->GetSequenceIndex();
const rct_large_scenery_tile& tile = sceneryEntry->tiles[sequence];
int32_t direction = ((_edge - tileElement->GetDirection()) & TILE_ELEMENT_DIRECTION_MASK) + 8;
if (!(tile.flags & (1 << direction)))
{
int32_t direction = ((_edge - tileElement->GetDirection()) & TILE_ELEMENT_DIRECTION_MASK) + 8;
if (!(tile->flags & (1 << direction)))
{
map_obstruction_set_error_text(tileElement, *res);
return res;
}
map_obstruction_set_error_text(tileElement, *res);
return res;
}
break;
}
case TILE_ELEMENT_TYPE_SMALL_SCENERY:
{
auto sceneryEntry = tileElement->AsSmallScenery()->GetEntry();
if (sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_NO_WALLS))
if (sceneryEntry != nullptr && sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_NO_WALLS))
{
map_obstruction_set_error_text(tileElement, *res);
return res;