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:
@@ -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)
|
||||
------------------------------------------------------------------------
|
||||
|
||||
@@ -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()))
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user