mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-18 13:32:32 +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)
|
0.2.2+ (in development)
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
- Fix: [#5579] Network desync immediately after connecting.
|
- Fix: [#5579] Network desync immediately after connecting.
|
||||||
|
- Fix: [#8873] Potential crash when placing footpaths.
|
||||||
|
|
||||||
0.2.2 (2019-03-13)
|
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 tileElement = map_get_footpath_element(_loc.x / 32, _loc.y / 32, _loc.z / 8);
|
||||||
auto pathElement = tileElement->AsPath();
|
if (tileElement == nullptr)
|
||||||
|
|
||||||
if (pathElement == nullptr)
|
|
||||||
{
|
{
|
||||||
log_error("Could not find path element.");
|
log_error("Could not find path element.");
|
||||||
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_POSITION_THIS_HERE);
|
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_POSITION_THIS_HERE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto pathElement = tileElement->AsPath();
|
||||||
|
|
||||||
// No change
|
// No change
|
||||||
if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST) && pathElement->GetAddition() == _pathItemType
|
if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST) && pathElement->GetAddition() == _pathItemType
|
||||||
&& !(pathElement->IsBroken()))
|
&& !(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* map_get_footpath_element(int32_t x, int32_t y, int32_t z)
|
||||||
{
|
{
|
||||||
TileElement* tileElement;
|
TileElement* tileElement = map_get_first_element_at(x, y);
|
||||||
|
|
||||||
tileElement = map_get_first_element_at(x, y);
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
if (tileElement == nullptr)
|
||||||
|
break;
|
||||||
if (tileElement->GetType() == TILE_ELEMENT_TYPE_PATH && tileElement->base_height == z)
|
if (tileElement->GetType() == TILE_ELEMENT_TYPE_PATH && tileElement->base_height == z)
|
||||||
return tileElement;
|
return tileElement;
|
||||||
} while (!(tileElement++)->IsLastForTile());
|
} while (!(tileElement++)->IsLastForTile());
|
||||||
|
|||||||
Reference in New Issue
Block a user