1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-11 10:02:27 +01:00

Merge pull request #8874 from ZehMatt/fix-8873

Fix #8873: null dereference when trying to place footpath.
This commit is contained in:
Duncan
2019-03-16 07:40:48 +00:00
committed by GitHub
3 changed files with 7 additions and 6 deletions

View File

@@ -1,6 +1,7 @@
0.2.2+ (in development)
------------------------------------------------------------------------
- Fix: [#5579] Network desync immediately after connecting.
- Fix: [#8873] Potential crash when placing footpaths.
0.2.2 (2019-03-13)
------------------------------------------------------------------------

View File

@@ -75,14 +75,14 @@ public:
}
auto tileElement = map_get_footpath_element(_loc.x / 32, _loc.y / 32, _loc.z / 8);
auto pathElement = tileElement->AsPath();
if (pathElement == nullptr)
if (tileElement == nullptr)
{
log_error("Could not find path element.");
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_POSITION_THIS_HERE);
}
auto pathElement = tileElement->AsPath();
// No change
if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST) && pathElement->GetAddition() == _pathItemType
&& !(pathElement->IsBroken()))

View File

@@ -112,11 +112,11 @@ static bool entrance_has_direction(TileElement* tileElement, int32_t direction)
TileElement* map_get_footpath_element(int32_t x, int32_t y, int32_t z)
{
TileElement* tileElement;
tileElement = map_get_first_element_at(x, y);
TileElement* tileElement = map_get_first_element_at(x, y);
do
{
if (tileElement == nullptr)
break;
if (tileElement->GetType() == TILE_ELEMENT_TYPE_PATH && tileElement->base_height == z)
return tileElement;
} while (!(tileElement++)->IsLastForTile());