mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-27 00:34:46 +01:00
* Refactor to result GameActions::Result as copy instead of unique_ptr * Remove alias GameActions::Result::Ptr * Remove MakeResult wrapper * Remove type forwarder in TileInspector
This commit is contained in:
@@ -43,40 +43,42 @@ void FootpathRemoveAction::Serialise(DataSerialiser& stream)
|
||||
stream << DS_TAG(_loc);
|
||||
}
|
||||
|
||||
GameActions::Result::Ptr FootpathRemoveAction::Query() const
|
||||
GameActions::Result FootpathRemoveAction::Query() const
|
||||
{
|
||||
GameActions::Result::Ptr res = std::make_unique<GameActions::Result>();
|
||||
res->Cost = 0;
|
||||
res->Expenditure = ExpenditureType::Landscaping;
|
||||
res->Position = { _loc.x + 16, _loc.y + 16, _loc.z };
|
||||
auto res = GameActions::Result();
|
||||
res.Cost = 0;
|
||||
res.Expenditure = ExpenditureType::Landscaping;
|
||||
res.Position = { _loc.x + 16, _loc.y + 16, _loc.z };
|
||||
|
||||
if (!LocationValid(_loc))
|
||||
{
|
||||
return MakeResult(GameActions::Status::NotOwned, STR_CANT_REMOVE_FOOTPATH_FROM_HERE, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
return GameActions::Result(
|
||||
GameActions::Status::NotOwned, STR_CANT_REMOVE_FOOTPATH_FROM_HERE, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
}
|
||||
|
||||
if (!((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gCheatsSandboxMode) && !map_is_location_owned(_loc))
|
||||
{
|
||||
return MakeResult(GameActions::Status::NotOwned, STR_CANT_REMOVE_FOOTPATH_FROM_HERE, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
return GameActions::Result(
|
||||
GameActions::Status::NotOwned, STR_CANT_REMOVE_FOOTPATH_FROM_HERE, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
}
|
||||
|
||||
TileElement* footpathElement = GetFootpathElement();
|
||||
if (footpathElement == nullptr)
|
||||
{
|
||||
return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_FOOTPATH_FROM_HERE, STR_NONE);
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_FOOTPATH_FROM_HERE, STR_NONE);
|
||||
}
|
||||
|
||||
res->Cost = GetRefundPrice(footpathElement);
|
||||
res.Cost = GetRefundPrice(footpathElement);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
GameActions::Result::Ptr FootpathRemoveAction::Execute() const
|
||||
GameActions::Result FootpathRemoveAction::Execute() const
|
||||
{
|
||||
GameActions::Result::Ptr res = std::make_unique<GameActions::Result>();
|
||||
res->Cost = 0;
|
||||
res->Expenditure = ExpenditureType::Landscaping;
|
||||
res->Position = { _loc.x + 16, _loc.y + 16, _loc.z };
|
||||
auto res = GameActions::Result();
|
||||
res.Cost = 0;
|
||||
res.Expenditure = ExpenditureType::Landscaping;
|
||||
res.Position = { _loc.x + 16, _loc.y + 16, _loc.z };
|
||||
|
||||
if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST))
|
||||
{
|
||||
@@ -89,9 +91,9 @@ GameActions::Result::Ptr FootpathRemoveAction::Execute() const
|
||||
{
|
||||
footpath_queue_chain_reset();
|
||||
auto bannerRes = RemoveBannersAtElement(_loc, footpathElement);
|
||||
if (bannerRes->Error == GameActions::Status::Ok)
|
||||
if (bannerRes.Error == GameActions::Status::Ok)
|
||||
{
|
||||
res->Cost += bannerRes->Cost;
|
||||
res.Cost += bannerRes.Cost;
|
||||
}
|
||||
footpath_remove_edges_at(_loc, footpathElement);
|
||||
map_invalidate_tile_full(_loc);
|
||||
@@ -111,10 +113,10 @@ GameActions::Result::Ptr FootpathRemoveAction::Execute() const
|
||||
}
|
||||
else
|
||||
{
|
||||
return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_FOOTPATH_FROM_HERE, STR_NONE);
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_FOOTPATH_FROM_HERE, STR_NONE);
|
||||
}
|
||||
|
||||
res->Cost += GetRefundPrice(footpathElement);
|
||||
res.Cost += GetRefundPrice(footpathElement);
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -158,9 +160,9 @@ money32 FootpathRemoveAction::GetRefundPrice(TileElement* footpathElement) const
|
||||
*
|
||||
* rct2: 0x006BA23E
|
||||
*/
|
||||
GameActions::Result::Ptr FootpathRemoveAction::RemoveBannersAtElement(const CoordsXY& loc, TileElement* tileElement) const
|
||||
GameActions::Result FootpathRemoveAction::RemoveBannersAtElement(const CoordsXY& loc, TileElement* tileElement) const
|
||||
{
|
||||
auto result = MakeResult();
|
||||
auto result = GameActions::Result();
|
||||
while (!(tileElement++)->IsLastForTile())
|
||||
{
|
||||
if (tileElement->GetType() == TILE_ELEMENT_TYPE_PATH)
|
||||
@@ -175,9 +177,9 @@ GameActions::Result::Ptr FootpathRemoveAction::RemoveBannersAtElement(const Coor
|
||||
bannerRemoveAction.SetFlags(bannerFlags);
|
||||
auto res = GameActions::ExecuteNested(&bannerRemoveAction);
|
||||
// Ghost removal is free
|
||||
if (res->Error == GameActions::Status::Ok && !isGhost)
|
||||
if (res.Error == GameActions::Status::Ok && !isGhost)
|
||||
{
|
||||
result->Cost += res->Cost;
|
||||
result.Cost += res.Cost;
|
||||
}
|
||||
tileElement--;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user