mirror of https://github.com/OpenRCT2/OpenRCT2.git
refactor wallRemoveAction
This commit is contained in:
parent
7730b35d82
commit
0320f195e3
|
@ -574,7 +574,7 @@ static void viewport_interaction_remove_park_wall(TileElement* tileElement, int3
|
|||
}
|
||||
else
|
||||
{
|
||||
TileCoordsXYZD wallLocation = { x >> 5, y >> 5, tileElement->base_height, tileElement->GetDirection() };
|
||||
CoordsXYZD wallLocation = { x , y , tileElement->base_height , tileElement->GetDirection() };
|
||||
auto wallRemoveAction = WallRemoveAction(wallLocation);
|
||||
GameActions::Execute(&wallRemoveAction);
|
||||
}
|
||||
|
|
|
@ -474,7 +474,7 @@ static void window_sign_small_mouseup(rct_window* w, rct_widgetindex widgetIndex
|
|||
}
|
||||
tile_element++;
|
||||
}
|
||||
TileCoordsXYZD wallLocation = { x >> 5, y >> 5, tile_element->base_height, tile_element->GetDirection() };
|
||||
CoordsXYZD wallLocation = { x , y , tile_element->base_height, tile_element->GetDirection() };
|
||||
auto wallRemoveAction = WallRemoveAction(wallLocation);
|
||||
GameActions::Execute(&wallRemoveAction);
|
||||
break;
|
||||
|
|
|
@ -186,7 +186,7 @@ private:
|
|||
case TILE_ELEMENT_TYPE_WALL:
|
||||
if (_itemsToClear & CLEARABLE_ITEMS::SCENERY_SMALL)
|
||||
{
|
||||
TileCoordsXYZD wallLocation = { x, y, tileElement->base_height, tileElement->GetDirection() };
|
||||
CoordsXYZD wallLocation = { x<<5, y<<5, tileElement->base_height, tileElement->GetDirection() };
|
||||
auto wallRemoveAction = WallRemoveAction(wallLocation);
|
||||
wallRemoveAction.SetFlags(GetFlags());
|
||||
|
||||
|
|
|
@ -22,12 +22,12 @@
|
|||
DEFINE_GAME_ACTION(WallRemoveAction, GAME_COMMAND_REMOVE_WALL, GameActionResult)
|
||||
{
|
||||
private:
|
||||
TileCoordsXYZD _location;
|
||||
CoordsXYZD _loc;
|
||||
|
||||
public:
|
||||
WallRemoveAction() = default;
|
||||
WallRemoveAction(const TileCoordsXYZD& location)
|
||||
: _location(location)
|
||||
WallRemoveAction(const CoordsXYZD& loc)
|
||||
: _loc(loc)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ public:
|
|||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_location.x) << DS_TAG(_location.y) << DS_TAG(_location.z) << DS_TAG(_location.direction);
|
||||
stream << DS_TAG(_loc);
|
||||
}
|
||||
|
||||
GameActionResult::Ptr Query() const override
|
||||
|
@ -44,7 +44,7 @@ public:
|
|||
res->Cost = 0;
|
||||
res->ExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING;
|
||||
|
||||
if (!map_is_location_valid({ _location.x << 5, _location.y << 5 }))
|
||||
if (!map_is_location_valid({ _loc.x , _loc.y }))
|
||||
{
|
||||
return std::make_unique<GameActionResult>(
|
||||
GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS);
|
||||
|
@ -52,12 +52,12 @@ public:
|
|||
|
||||
const bool isGhost = GetFlags() & GAME_COMMAND_FLAG_GHOST;
|
||||
if (!isGhost && !(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode
|
||||
&& !map_is_location_owned(_location.x << 5, _location.y << 5, _location.z << 3))
|
||||
&& !map_is_location_owned(_loc.x , _loc.y , _loc.z ))
|
||||
{
|
||||
return std::make_unique<GameActionResult>(GA_ERROR::NOT_OWNED, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
}
|
||||
|
||||
TileElement* wallElement = GetFirstWallElementAt(_location, isGhost);
|
||||
TileElement* wallElement = GetFirstWallElementAt(_loc, isGhost);
|
||||
if (wallElement == nullptr)
|
||||
{
|
||||
return std::make_unique<GameActionResult>(
|
||||
|
@ -76,29 +76,29 @@ public:
|
|||
|
||||
const bool isGhost = GetFlags() & GAME_COMMAND_FLAG_GHOST;
|
||||
|
||||
TileElement* wallElement = GetFirstWallElementAt(_location, isGhost);
|
||||
TileElement* wallElement = GetFirstWallElementAt(_loc, isGhost);
|
||||
if (wallElement == nullptr)
|
||||
{
|
||||
return std::make_unique<GameActionResult>(
|
||||
GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS);
|
||||
}
|
||||
|
||||
res->Position.x = (_location.x << 5) + 16;
|
||||
res->Position.y = (_location.y << 5) + 16;
|
||||
res->Position.x = _loc.x + 16;
|
||||
res->Position.y = _loc.y + 16;
|
||||
res->Position.z = tile_element_height(res->Position.x, res->Position.y);
|
||||
|
||||
tile_element_remove_banner_entry(wallElement);
|
||||
map_invalidate_tile_zoom1(
|
||||
_location.x << 5, _location.y << 5, wallElement->base_height * 8, (wallElement->base_height * 8) + 72);
|
||||
_loc.x, _loc.y , wallElement->base_height , wallElement->base_height + 72);
|
||||
tile_element_remove(wallElement);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
private:
|
||||
TileElement* GetFirstWallElementAt(const TileCoordsXYZD& location, bool isGhost) const
|
||||
TileElement* GetFirstWallElementAt(const CoordsXYZD& location, bool isGhost) const
|
||||
{
|
||||
TileElement* tileElement = map_get_first_element_at(location.x, location.y);
|
||||
TileElement* tileElement = map_get_first_element_at(location.x >> 5 , location.y >> 5 );
|
||||
if (!tileElement)
|
||||
return nullptr;
|
||||
|
||||
|
|
|
@ -783,7 +783,7 @@ static bool TrackDesignPlaceSceneryElementRemoveGhost(
|
|||
ga = std::make_unique<LargeSceneryRemoveAction>(mapCoord.x, mapCoord.y, z, sceneryRotation, 0);
|
||||
break;
|
||||
case OBJECT_TYPE_WALLS:
|
||||
ga = std::make_unique<WallRemoveAction>(TileCoordsXYZD{ mapCoord.x / 32, mapCoord.y / 32, z, sceneryRotation });
|
||||
ga = std::make_unique<WallRemoveAction>(CoordsXYZD{ mapCoord.x , mapCoord.y , z, sceneryRotation });
|
||||
break;
|
||||
case OBJECT_TYPE_PATHS:
|
||||
ga = std::make_unique<FootpathRemoveAction>(mapCoord.x, mapCoord.y, z);
|
||||
|
|
|
@ -1755,7 +1755,7 @@ static void clear_element_at(int32_t x, int32_t y, TileElement** elementPtr)
|
|||
}
|
||||
case TILE_ELEMENT_TYPE_WALL:
|
||||
{
|
||||
TileCoordsXYZD wallLocation = { x >> 5, y >> 5, element->base_height, element->GetDirection() };
|
||||
CoordsXYZD wallLocation = { x, y, element->base_height, element->GetDirection() };
|
||||
auto wallRemoveAction = WallRemoveAction(wallLocation);
|
||||
GameActions::Execute(&wallRemoveAction);
|
||||
}
|
||||
|
|
|
@ -216,7 +216,7 @@ void scenery_remove_ghost_tool_placement()
|
|||
{
|
||||
gSceneryGhostType &= ~SCENERY_GHOST_FLAG_2;
|
||||
|
||||
TileCoordsXYZD wallLocation = { x >> 5, y >> 5, z, gSceneryGhostWallRotation };
|
||||
CoordsXYZD wallLocation = { x , y , z, gSceneryGhostWallRotation };
|
||||
auto wallRemoveAction = WallRemoveAction(wallLocation);
|
||||
wallRemoveAction.SetFlags(GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_PATH_SCENERY);
|
||||
wallRemoveAction.Execute();
|
||||
|
|
Loading…
Reference in New Issue