mirror of https://github.com/OpenRCT2/OpenRCT2.git
Fix #8873: null dereference when trying to place footpath.
This commit is contained in:
parent
1d9b17a66e
commit
126ffd104e
|
@ -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());
|
||||
|
|
Loading…
Reference in New Issue