Skip to content

Commit

Permalink
Fix OpenRCT2#9324: crash trying to remove invalid footpath scenery.
Browse files Browse the repository at this point in the history
  • Loading branch information
ZehMatt committed Jun 15, 2019
1 parent 84e7376 commit d57065b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/openrct2/actions/FootpathSceneryRemoveAction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,22 @@ DEFINE_GAME_ACTION(FootpathSceneryRemoveAction, GAME_COMMAND_REMOVE_FOOTPATH_SCE
}

auto tileElement = map_get_footpath_element(_loc.x / 32, _loc.y / 32, _loc.z / 8);
auto pathElement = tileElement->AsPath();
if (tileElement == nullptr)
{
log_warning("Could not find path element.");
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS);
}

auto pathElement = tileElement->AsPath();
if (pathElement == nullptr)
{
log_error("Could not find path element.");
log_warning("Could not find path element.");
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS);
}

if (!pathElement->AdditionIsGhost() && (GetFlags() & GAME_COMMAND_FLAG_GHOST))
{
log_error("Tried to remove non ghost during ghost removal.");
log_warning("Tried to remove non ghost during ghost removal.");
return MakeResult(GA_ERROR::DISALLOWED, STR_CANT_REMOVE_THIS);
}
auto res = MakeResult();
Expand Down

0 comments on commit d57065b

Please sign in to comment.