forked from rosebudai/OpenRCT2-Web
Merge pull request #25036 from AaronVanGeffen/actions
Move game actions into GameActions namespace
This commit is contained in:
229 files changed
+14498
-14283
No files matched your search
@@ -429,7 +429,7 @@ static void ShortcutLoadGame()
|
||||
{
|
||||
if (!(isInTrackDesignerOrManager()))
|
||||
{
|
||||
auto loadOrQuitAction = LoadOrQuitAction(LoadOrQuitModes::OpenSavePrompt);
|
||||
auto loadOrQuitAction = GameActions::LoadOrQuitAction(GameActions::LoadOrQuitModes::OpenSavePrompt);
|
||||
GameActions::Execute(&loadOrQuitAction);
|
||||
}
|
||||
}
|
||||
@@ -522,8 +522,9 @@ static void ShortcutToggleWallSlope()
|
||||
int32_t newSlopeValue = (currSlopeValue + 1) % 3;
|
||||
|
||||
extern TileCoordsXY windowTileInspectorTile;
|
||||
auto modifyTile = TileModifyAction(
|
||||
windowTileInspectorTile.ToCoordsXY(), TileModifyType::WallSetSlope, windowTileInspectorSelectedIndex, newSlopeValue);
|
||||
auto modifyTile = GameActions::TileModifyAction(
|
||||
windowTileInspectorTile.ToCoordsXY(), GameActions::TileModifyType::WallSetSlope, windowTileInspectorSelectedIndex,
|
||||
newSlopeValue);
|
||||
GameActions::Execute(&modifyTile);
|
||||
}
|
||||
|
||||
@@ -609,7 +610,7 @@ static void ShortcutDecreaseElementHeight()
|
||||
|
||||
static void ShortcutToggleClearanceChecks()
|
||||
{
|
||||
auto cheatSetAction = CheatSetAction(
|
||||
auto cheatSetAction = GameActions::CheatSetAction(
|
||||
CheatType::DisableClearanceChecks, getGameState().cheats.disableClearanceChecks ? 0 : 1);
|
||||
GameActions::Execute(&cheatSetAction);
|
||||
}
|
||||
@@ -782,7 +783,7 @@ void ShortcutManager::RegisterDefaultShortcuts()
|
||||
RegisterShortcut(ShortcutId::kInterfacePause, STR_SHORTCUT_PAUSE_GAME, "PAUSE", []() {
|
||||
if (gLegacyScene != LegacyScene::titleSequence && gLegacyScene != LegacyScene::scenarioEditor && gLegacyScene != LegacyScene::trackDesignsManager)
|
||||
{
|
||||
auto pauseToggleAction = PauseToggleAction();
|
||||
auto pauseToggleAction = GameActions::PauseToggleAction();
|
||||
GameActions::Execute(&pauseToggleAction);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -222,7 +222,7 @@ namespace OpenRCT2::Ui
|
||||
{
|
||||
if (GameIsNotPaused())
|
||||
{
|
||||
auto balloonPress = BalloonPressAction(entity->Id);
|
||||
auto balloonPress = GameActions::BalloonPressAction(entity->Id);
|
||||
GameActions::Execute(&balloonPress);
|
||||
}
|
||||
}
|
||||
@@ -622,7 +622,7 @@ namespace OpenRCT2::Ui
|
||||
*/
|
||||
static void ViewportInteractionRemoveScenery(const SmallSceneryElement& smallSceneryElement, const CoordsXY& mapCoords)
|
||||
{
|
||||
auto removeSceneryAction = SmallSceneryRemoveAction(
|
||||
auto removeSceneryAction = GameActions::SmallSceneryRemoveAction(
|
||||
{ mapCoords.x, mapCoords.y, smallSceneryElement.GetBaseZ() }, smallSceneryElement.GetSceneryQuadrant(),
|
||||
smallSceneryElement.GetEntryIndex());
|
||||
|
||||
@@ -649,7 +649,7 @@ namespace OpenRCT2::Ui
|
||||
{
|
||||
if (tileElement2->GetType() == TileElementType::Path && tileElement2->GetBaseZ() == z)
|
||||
{
|
||||
auto action = FootpathRemoveAction({ mapCoords, z });
|
||||
auto action = GameActions::FootpathRemoveAction({ mapCoords, z });
|
||||
GameActions::Execute(&action);
|
||||
break;
|
||||
}
|
||||
@@ -662,7 +662,8 @@ namespace OpenRCT2::Ui
|
||||
*/
|
||||
static void ViewportInteractionRemovePathAddition(const PathElement& pathElement, const CoordsXY& mapCoords)
|
||||
{
|
||||
auto footpathAdditionRemoveAction = FootpathAdditionRemoveAction({ mapCoords.x, mapCoords.y, pathElement.GetBaseZ() });
|
||||
auto footpathAdditionRemoveAction = GameActions::FootpathAdditionRemoveAction(
|
||||
{ mapCoords.x, mapCoords.y, pathElement.GetBaseZ() });
|
||||
GameActions::Execute(&footpathAdditionRemoveAction);
|
||||
}
|
||||
|
||||
@@ -682,7 +683,8 @@ namespace OpenRCT2::Ui
|
||||
mapCoords -= CoordsDirectionDelta[rotation];
|
||||
break;
|
||||
}
|
||||
auto parkEntranceRemoveAction = ParkEntranceRemoveAction({ mapCoords.x, mapCoords.y, entranceElement.GetBaseZ() });
|
||||
auto parkEntranceRemoveAction = GameActions::ParkEntranceRemoveAction(
|
||||
{ mapCoords.x, mapCoords.y, entranceElement.GetBaseZ() });
|
||||
GameActions::Execute(&parkEntranceRemoveAction);
|
||||
}
|
||||
|
||||
@@ -700,7 +702,7 @@ namespace OpenRCT2::Ui
|
||||
else
|
||||
{
|
||||
CoordsXYZD wallLocation = { mapCoords.x, mapCoords.y, wallElement.GetBaseZ(), wallElement.GetDirection() };
|
||||
auto wallRemoveAction = WallRemoveAction(wallLocation);
|
||||
auto wallRemoveAction = GameActions::WallRemoveAction(wallLocation);
|
||||
GameActions::Execute(&wallRemoveAction);
|
||||
}
|
||||
}
|
||||
@@ -720,7 +722,7 @@ namespace OpenRCT2::Ui
|
||||
}
|
||||
else
|
||||
{
|
||||
auto removeSceneryAction = LargeSceneryRemoveAction(
|
||||
auto removeSceneryAction = GameActions::LargeSceneryRemoveAction(
|
||||
{ mapCoords.x, mapCoords.y, largeSceneryElement.GetBaseZ(), largeSceneryElement.GetDirection() },
|
||||
largeSceneryElement.GetSequenceIndex());
|
||||
GameActions::Execute(&removeSceneryAction);
|
||||
|
||||
@@ -229,7 +229,7 @@ namespace OpenRCT2
|
||||
int32_t colour1 = RideGetRandomColourPresetIndex(listItem.Type);
|
||||
int32_t colour2 = RideGetUnusedPresetVehicleColour(rideEntryIndex);
|
||||
|
||||
auto gameAction = RideCreateAction(
|
||||
auto gameAction = GameActions::RideCreateAction(
|
||||
listItem.Type, listItem.EntryIndex, colour1, colour2, getGameState().lastEntranceStyle);
|
||||
|
||||
gameAction.SetCallback([](const GameAction* ga, const GameActions::Result* result) {
|
||||
|
||||
@@ -202,7 +202,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
if (bannerElement == nullptr)
|
||||
break;
|
||||
|
||||
auto bannerRemoveAction = BannerRemoveAction(
|
||||
auto bannerRemoveAction = GameActions::BannerRemoveAction(
|
||||
{ banner->position.ToCoordsXY(), bannerElement->GetBaseZ(), bannerElement->GetPosition() });
|
||||
GameActions::Execute(&bannerRemoveAction);
|
||||
break;
|
||||
@@ -214,8 +214,8 @@ namespace OpenRCT2::Ui::Windows
|
||||
case WIDX_BANNER_NO_ENTRY:
|
||||
{
|
||||
TextinputCancel();
|
||||
auto bannerSetStyle = BannerSetStyleAction(
|
||||
BannerSetStyleType::NoEntry, GetBannerIndex(), !banner->flags.has(BannerFlag::noEntry));
|
||||
auto bannerSetStyle = GameActions::BannerSetStyleAction(
|
||||
GameActions::BannerSetStyleType::NoEntry, GetBannerIndex(), !banner->flags.has(BannerFlag::noEntry));
|
||||
GameActions::Execute(&bannerSetStyle);
|
||||
break;
|
||||
}
|
||||
@@ -231,8 +231,9 @@ namespace OpenRCT2::Ui::Windows
|
||||
if (dropdownIndex == -1)
|
||||
break;
|
||||
|
||||
auto bannerSetStyle = BannerSetStyleAction(
|
||||
BannerSetStyleType::PrimaryColour, GetBannerIndex(), ColourDropDownIndexToColour(dropdownIndex));
|
||||
auto bannerSetStyle = GameActions::BannerSetStyleAction(
|
||||
GameActions::BannerSetStyleType::PrimaryColour, GetBannerIndex(),
|
||||
ColourDropDownIndexToColour(dropdownIndex));
|
||||
GameActions::Execute(&bannerSetStyle);
|
||||
break;
|
||||
}
|
||||
@@ -240,8 +241,8 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
if (dropdownIndex == -1)
|
||||
break;
|
||||
auto bannerSetStyle = BannerSetStyleAction(
|
||||
BannerSetStyleType::TextColour, GetBannerIndex(), dropdownIndex + 1);
|
||||
auto bannerSetStyle = GameActions::BannerSetStyleAction(
|
||||
GameActions::BannerSetStyleType::TextColour, GetBannerIndex(), dropdownIndex + 1);
|
||||
GameActions::Execute(&bannerSetStyle);
|
||||
break;
|
||||
}
|
||||
@@ -252,7 +253,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
if (widgetIndex == WIDX_BANNER_TEXT)
|
||||
{
|
||||
auto bannerSetNameAction = BannerSetNameAction(GetBannerIndex(), std::string(text));
|
||||
auto bannerSetNameAction = GameActions::BannerSetNameAction(GetBannerIndex(), std::string(text));
|
||||
GameActions::Execute(&bannerSetNameAction);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -916,14 +916,15 @@ static StringId window_cheats_page_titles[] = {
|
||||
break;
|
||||
case WIDX_DATE_SET:
|
||||
{
|
||||
auto setDateAction = ParkSetDateAction(_yearSpinnerValue - 1, _monthSpinnerValue - 1, _daySpinnerValue - 1);
|
||||
auto setDateAction = GameActions::ParkSetDateAction(
|
||||
_yearSpinnerValue - 1, _monthSpinnerValue - 1, _daySpinnerValue - 1);
|
||||
GameActions::Execute(&setDateAction);
|
||||
windowMgr->InvalidateByClass(WindowClass::BottomToolbar);
|
||||
break;
|
||||
}
|
||||
case WIDX_DATE_RESET:
|
||||
{
|
||||
auto setDateAction = ParkSetDateAction(0, 0, 0);
|
||||
auto setDateAction = GameActions::ParkSetDateAction(0, 0, 0);
|
||||
GameActions::Execute(&setDateAction);
|
||||
windowMgr->InvalidateByClass(WindowClass::BottomToolbar);
|
||||
InvalidateWidget(WIDX_YEAR_BOX);
|
||||
@@ -965,7 +966,8 @@ static StringId window_cheats_page_titles[] = {
|
||||
InvalidateWidget(WIDX_PARK_RATING_SPINNER);
|
||||
if (Park::GetForcedRating() >= 0)
|
||||
{
|
||||
auto cheatSetAction = CheatSetAction(CheatType::SetForcedParkRating, _parkRatingSpinnerValue);
|
||||
auto cheatSetAction = GameActions::CheatSetAction(
|
||||
CheatType::SetForcedParkRating, _parkRatingSpinnerValue);
|
||||
GameActions::Execute(&cheatSetAction);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
case WIDX_DEMOLISH:
|
||||
{
|
||||
auto gameAction = RideDemolishAction(rideId, RideModifyType::demolish);
|
||||
auto gameAction = GameActions::RideDemolishAction(rideId, GameActions::RideModifyType::demolish);
|
||||
GameActions::Execute(&gameAction);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -194,7 +194,8 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
ParkEntranceRemoveGhost();
|
||||
|
||||
auto gameAction = ParkEntrancePlaceAction(parkEntrancePosition, gFootpathSelectedId, _selectedEntranceType);
|
||||
auto gameAction = GameActions::ParkEntrancePlaceAction(
|
||||
parkEntrancePosition, gFootpathSelectedId, _selectedEntranceType);
|
||||
gameAction.SetFlags(GAME_COMMAND_FLAG_GHOST);
|
||||
|
||||
auto result = GameActions::Execute(&gameAction);
|
||||
@@ -212,7 +213,8 @@ namespace OpenRCT2::Ui::Windows
|
||||
CoordsXYZD parkEntrancePosition = PlaceParkEntranceGetMapPosition(screenCoords);
|
||||
if (!parkEntrancePosition.IsNull())
|
||||
{
|
||||
auto gameAction = ParkEntrancePlaceAction(parkEntrancePosition, gFootpathSelectedId, _selectedEntranceType);
|
||||
auto gameAction = GameActions::ParkEntrancePlaceAction(
|
||||
parkEntrancePosition, gFootpathSelectedId, _selectedEntranceType);
|
||||
auto result = GameActions::Execute(&gameAction);
|
||||
if (result.Error == GameActions::Status::Ok)
|
||||
{
|
||||
|
||||
@@ -1345,7 +1345,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
case WIDX_PARK_NAME:
|
||||
{
|
||||
auto action = ParkSetNameAction(std::string(text));
|
||||
auto action = GameActions::ParkSetNameAction(std::string(text));
|
||||
GameActions::Execute(&action);
|
||||
|
||||
if (scenarioOptions.name.empty())
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#include <openrct2/GameState.h>
|
||||
#include <openrct2/SpriteIds.h>
|
||||
#include <openrct2/actions/ParkSetLoanAction.h>
|
||||
#include <openrct2/actions/ParkSetResearchFundingAction.h>
|
||||
#include <openrct2/localisation/Formatter.h>
|
||||
#include <openrct2/localisation/Formatting.h>
|
||||
#include <openrct2/localisation/Localisation.Date.h>
|
||||
@@ -548,7 +547,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
newLoan = std::min(gameState.park.maxBankLoan, newLoan);
|
||||
}
|
||||
auto gameAction = ParkSetLoanAction(newLoan);
|
||||
auto gameAction = GameActions::ParkSetLoanAction(newLoan);
|
||||
GameActions::Execute(&gameAction);
|
||||
break;
|
||||
}
|
||||
@@ -564,7 +563,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
newLoan = std::max(static_cast<money64>(0LL), newLoan);
|
||||
}
|
||||
auto gameAction = ParkSetLoanAction(newLoan);
|
||||
auto gameAction = GameActions::ParkSetLoanAction(newLoan);
|
||||
GameActions::Execute(&gameAction);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1145,7 +1145,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
auto selectedType = gFootpathSelection.GetSelectedSurface();
|
||||
PathConstructFlags constructFlags = FootpathCreateConstructFlags(selectedType);
|
||||
|
||||
auto footpathPlaceAction = FootpathPlaceAction(
|
||||
auto footpathPlaceAction = GameActions::FootpathPlaceAction(
|
||||
{ *mapPos, baseZ }, slope, selectedType, gFootpathSelection.Railings, kInvalidDirection, constructFlags);
|
||||
footpathPlaceAction.SetCallback([this](const GameAction* ga, const GameActions::Result* result) {
|
||||
if (result->Error == GameActions::Status::Ok)
|
||||
@@ -1237,7 +1237,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
PathConstructFlags constructFlags = FootpathCreateConstructFlags(type);
|
||||
|
||||
auto footpathPlaceAction = FootpathPlaceAction(
|
||||
auto footpathPlaceAction = GameActions::FootpathPlaceAction(
|
||||
footpathLoc, slope, type, gFootpathSelection.Railings, _footpathConstructDirection, constructFlags);
|
||||
|
||||
footpathPlaceAction.SetCallback([footpathLoc](const GameAction* ga, const GameActions::Result* result) {
|
||||
@@ -1320,7 +1320,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
|
||||
gFootpathConstructFromPosition.z = tileElement->GetBaseZ();
|
||||
auto action = FootpathRemoveAction(gFootpathConstructFromPosition);
|
||||
auto action = GameActions::FootpathRemoveAction(gFootpathConstructFromPosition);
|
||||
GameActions::Execute(&action);
|
||||
|
||||
// Move selection
|
||||
@@ -1756,7 +1756,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
FootpathRemoveProvisional();
|
||||
|
||||
auto footpathPlaceAction = FootpathPlaceAction(
|
||||
auto footpathPlaceAction = GameActions::FootpathPlaceAction(
|
||||
footpathLoc, slope, type, railingsType, kInvalidDirection, constructFlags);
|
||||
footpathPlaceAction.SetFlags(GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED);
|
||||
auto res = GameActions::Execute(&footpathPlaceAction);
|
||||
@@ -1814,7 +1814,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
_provisionalFootpath.flags.unset(ProvisionalPathFlag::placed);
|
||||
|
||||
auto action = FootpathRemoveAction(_provisionalFootpath.position);
|
||||
auto action = GameActions::FootpathRemoveAction(_provisionalFootpath.position);
|
||||
action.SetFlags(GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND | GAME_COMMAND_FLAG_GHOST);
|
||||
GameActions::Execute(&action);
|
||||
}
|
||||
|
||||
@@ -651,8 +651,9 @@ namespace OpenRCT2::Ui::Windows
|
||||
_pickedPeepX = peep->x;
|
||||
CoordsXYZ nullLoc{};
|
||||
nullLoc.SetNull();
|
||||
PeepPickupAction pickupAction{ PeepPickupType::Pickup, EntityId::FromUnderlying(number), nullLoc,
|
||||
NetworkGetCurrentPlayerId() };
|
||||
GameActions::PeepPickupAction pickupAction{ GameActions::PeepPickupType::Pickup,
|
||||
EntityId::FromUnderlying(number), nullLoc,
|
||||
NetworkGetCurrentPlayerId() };
|
||||
pickupAction.SetCallback([peepnum = number](const GameAction* ga, const GameActions::Result* result) {
|
||||
if (result->Error != GameActions::Status::Ok)
|
||||
return;
|
||||
@@ -677,7 +678,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
uint32_t guestFlags = peep->PeepFlags ^ PEEP_FLAGS_TRACKING;
|
||||
|
||||
auto guestSetFlagsAction = GuestSetFlagsAction(EntityId::FromUnderlying(number), guestFlags);
|
||||
auto guestSetFlagsAction = GameActions::GuestSetFlagsAction(EntityId::FromUnderlying(number), guestFlags);
|
||||
GameActions::Execute(&guestSetFlagsAction);
|
||||
}
|
||||
break;
|
||||
@@ -961,7 +962,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
if (text.empty())
|
||||
return;
|
||||
std::string sText(text);
|
||||
auto gameAction = GuestSetNameAction(EntityId::FromUnderlying(number), sText);
|
||||
auto gameAction = GameActions::GuestSetNameAction(EntityId::FromUnderlying(number), sText);
|
||||
GameActions::Execute(&gameAction);
|
||||
}
|
||||
|
||||
@@ -1018,10 +1019,10 @@ namespace OpenRCT2::Ui::Windows
|
||||
if (destCoords.IsNull())
|
||||
return;
|
||||
|
||||
PeepPickupAction pickupAction{ PeepPickupType::Place,
|
||||
EntityId::FromUnderlying(number),
|
||||
{ destCoords, tileElement->GetBaseZ() },
|
||||
NetworkGetCurrentPlayerId() };
|
||||
GameActions::PeepPickupAction pickupAction{ GameActions::PeepPickupType::Place,
|
||||
EntityId::FromUnderlying(number),
|
||||
{ destCoords, tileElement->GetBaseZ() },
|
||||
NetworkGetCurrentPlayerId() };
|
||||
pickupAction.SetCallback([](const GameAction* ga, const GameActions::Result* result) {
|
||||
if (result->Error != GameActions::Status::Ok)
|
||||
return;
|
||||
@@ -1036,9 +1037,10 @@ namespace OpenRCT2::Ui::Windows
|
||||
if (widgetIndex != WIDX_PICKUP)
|
||||
return;
|
||||
|
||||
PeepPickupAction pickupAction{
|
||||
PeepPickupType::Cancel, EntityId::FromUnderlying(number), { _pickedPeepX, 0, 0 }, NetworkGetCurrentPlayerId()
|
||||
};
|
||||
GameActions::PeepPickupAction pickupAction{ GameActions::PeepPickupType::Cancel,
|
||||
EntityId::FromUnderlying(number),
|
||||
{ _pickedPeepX, 0, 0 },
|
||||
NetworkGetCurrentPlayerId() };
|
||||
GameActions::Execute(&pickupAction);
|
||||
}
|
||||
|
||||
|
||||
@@ -339,7 +339,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
if (_landToolMountainMode)
|
||||
{
|
||||
auto landSmoothAction = LandSmoothAction(
|
||||
auto landSmoothAction = GameActions::LandSmoothAction(
|
||||
{ centreX, centreY },
|
||||
{ gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y },
|
||||
gMapSelectType, false);
|
||||
@@ -348,7 +348,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
return res.Error == GameActions::Status::Ok ? res.Cost : kMoney64Undefined;
|
||||
}
|
||||
|
||||
auto landRaiseAction = LandRaiseAction(
|
||||
auto landRaiseAction = GameActions::LandRaiseAction(
|
||||
{ centreX, centreY },
|
||||
{ gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y }, gMapSelectType);
|
||||
auto res = (flag & GAME_COMMAND_FLAG_APPLY) ? GameActions::Execute(&landRaiseAction)
|
||||
@@ -370,7 +370,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
if (_landToolMountainMode)
|
||||
{
|
||||
auto landSmoothAction = LandSmoothAction(
|
||||
auto landSmoothAction = GameActions::LandSmoothAction(
|
||||
{ centreX, centreY },
|
||||
{ gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y },
|
||||
gMapSelectType, true);
|
||||
@@ -379,7 +379,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
return res.Error == GameActions::Status::Ok ? res.Cost : kMoney64Undefined;
|
||||
}
|
||||
|
||||
auto landLowerAction = LandLowerAction(
|
||||
auto landLowerAction = GameActions::LandLowerAction(
|
||||
{ centreX, centreY },
|
||||
{ gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y }, gMapSelectType);
|
||||
auto res = (flag & GAME_COMMAND_FLAG_APPLY) ? GameActions::Execute(&landLowerAction)
|
||||
@@ -521,7 +521,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
case WIDX_BACKGROUND:
|
||||
if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)
|
||||
{
|
||||
auto surfaceSetStyleAction = SurfaceSetStyleAction(
|
||||
auto surfaceSetStyleAction = GameActions::SurfaceSetStyleAction(
|
||||
{ gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y },
|
||||
gLandToolTerrainSurface, gLandToolTerrainEdge);
|
||||
|
||||
@@ -548,7 +548,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)
|
||||
{
|
||||
auto surfaceSetStyleAction = SurfaceSetStyleAction(
|
||||
auto surfaceSetStyleAction = GameActions::SurfaceSetStyleAction(
|
||||
{ gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y },
|
||||
gLandToolTerrainSurface, gLandToolTerrainEdge);
|
||||
|
||||
|
||||
@@ -421,12 +421,12 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
}
|
||||
|
||||
LandBuyRightsAction GetLandBuyAction()
|
||||
GameActions::LandBuyRightsAction GetLandBuyAction()
|
||||
{
|
||||
auto mode = (_landRightsMode == LandRightsMode::BuyLand) ? LandBuyRightSetting::BuyLand
|
||||
: LandBuyRightSetting::BuyConstructionRights;
|
||||
auto mode = (_landRightsMode == LandRightsMode::BuyLand) ? GameActions::LandBuyRightSetting::BuyLand
|
||||
: GameActions::LandBuyRightSetting::BuyConstructionRights;
|
||||
|
||||
return LandBuyRightsAction(
|
||||
return GameActions::LandBuyRightsAction(
|
||||
{ gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y }, mode);
|
||||
}
|
||||
|
||||
@@ -448,11 +448,11 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
}
|
||||
|
||||
LandSetRightsAction GetLandSetAction()
|
||||
GameActions::LandSetRightsAction GetLandSetAction()
|
||||
{
|
||||
return LandSetRightsAction(
|
||||
return GameActions::LandSetRightsAction(
|
||||
{ gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y },
|
||||
LandSetRightSetting::SetOwnershipWithChecks, GetDesiredOwnership());
|
||||
GameActions::LandSetRightSetting::SetOwnershipWithChecks, GetDesiredOwnership());
|
||||
}
|
||||
|
||||
void OnToolUpdate(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords) override
|
||||
|
||||
@@ -481,7 +481,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
int32_t mapZ = tileElement->GetBaseZ();
|
||||
|
||||
auto gameAction = PeepSpawnPlaceAction({ mapCoords, mapZ, static_cast<Direction>(direction) });
|
||||
auto gameAction = GameActions::PeepSpawnPlaceAction({ mapCoords, mapZ, static_cast<Direction>(direction) });
|
||||
auto result = GameActions::Execute(&gameAction);
|
||||
if (result.Error == GameActions::Status::Ok)
|
||||
{
|
||||
@@ -515,7 +515,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
if (_resizeDirection != ResizeDirection::Y)
|
||||
newMapSize.x = size;
|
||||
|
||||
auto mapChangeSizeAction = MapChangeSizeAction(newMapSize);
|
||||
auto mapChangeSizeAction = GameActions::MapChangeSizeAction(newMapSize);
|
||||
GameActions::Execute(&mapChangeSizeAction);
|
||||
Invalidate();
|
||||
}
|
||||
@@ -763,7 +763,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
if (IsWidgetPressed(WIDX_MAP_SIZE_LINK) || _resizeDirection == ResizeDirection::X)
|
||||
newMapSize.x++;
|
||||
|
||||
auto increaseMapSizeAction = MapChangeSizeAction(newMapSize);
|
||||
auto increaseMapSizeAction = GameActions::MapChangeSizeAction(newMapSize);
|
||||
GameActions::Execute(&increaseMapSizeAction);
|
||||
}
|
||||
|
||||
@@ -775,7 +775,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
if (IsWidgetPressed(WIDX_MAP_SIZE_LINK) || _resizeDirection == ResizeDirection::X)
|
||||
newMapSize.x--;
|
||||
|
||||
auto decreaseMapSizeAction = MapChangeSizeAction(newMapSize);
|
||||
auto decreaseMapSizeAction = GameActions::MapChangeSizeAction(newMapSize);
|
||||
GameActions::Execute(&decreaseMapSizeAction);
|
||||
}
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
if (currentRide->overallView.IsNull())
|
||||
{
|
||||
auto gameAction = RideDemolishAction(currentRide->id, RideModifyType::demolish);
|
||||
auto gameAction = GameActions::RideDemolishAction(currentRide->id, GameActions::RideModifyType::demolish);
|
||||
gameAction.SetFlags(GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED);
|
||||
GameActions::Execute(&gameAction);
|
||||
}
|
||||
@@ -355,7 +355,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
RideId rideIndex = gRideEntranceExitPlaceRideIndex;
|
||||
|
||||
auto rideEntranceExitPlaceAction = RideEntranceExitPlaceAction(
|
||||
auto rideEntranceExitPlaceAction = GameActions::RideEntranceExitPlaceAction(
|
||||
entranceOrExitCoords, DirectionReverse(entranceOrExitCoords.direction), rideIndex,
|
||||
gRideEntranceExitPlaceStationIndex, gRideEntranceExitPlaceType == ENTRANCE_TYPE_RIDE_EXIT);
|
||||
|
||||
@@ -421,7 +421,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
|
||||
const auto loc = CoordsXYZD{ x, y, z, static_cast<uint8_t>(direction) };
|
||||
auto action = MazeSetTrackAction(loc, false, _currentRideIndex, mode);
|
||||
auto action = GameActions::MazeSetTrackAction(loc, false, _currentRideIndex, mode);
|
||||
action.SetFlags(actionFlags);
|
||||
const auto res = GameActions::Execute(&action);
|
||||
if (res.Error != GameActions::Status::Ok)
|
||||
@@ -433,7 +433,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
_currentTrackBegin.y = y;
|
||||
if (_rideConstructionState != RideConstructionState::MazeMove)
|
||||
{
|
||||
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::PlaceItem, { x, y, z });
|
||||
Audio::Play3D(Audio::SoundId::PlaceItem, { x, y, z });
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -250,13 +250,14 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
case WIDX_ADD_GROUP:
|
||||
{
|
||||
auto networkModifyGroup = NetworkModifyGroupAction(ModifyGroupType::AddGroup);
|
||||
auto networkModifyGroup = GameActions::NetworkModifyGroupAction(GameActions::ModifyGroupType::AddGroup);
|
||||
GameActions::Execute(&networkModifyGroup);
|
||||
break;
|
||||
}
|
||||
case WIDX_REMOVE_GROUP:
|
||||
{
|
||||
auto networkModifyGroup = NetworkModifyGroupAction(ModifyGroupType::RemoveGroup, _selectedGroup);
|
||||
auto networkModifyGroup = GameActions::NetworkModifyGroupAction(
|
||||
GameActions::ModifyGroupType::RemoveGroup, _selectedGroup);
|
||||
GameActions::Execute(&networkModifyGroup);
|
||||
break;
|
||||
}
|
||||
@@ -480,8 +481,8 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
case WIDX_DEFAULT_GROUP_DROPDOWN:
|
||||
{
|
||||
auto networkModifyGroup = NetworkModifyGroupAction(
|
||||
ModifyGroupType::SetDefault, NetworkGetGroupID(selectedIndex));
|
||||
auto networkModifyGroup = GameActions::NetworkModifyGroupAction(
|
||||
GameActions::ModifyGroupType::SetDefault, NetworkGetGroupID(selectedIndex));
|
||||
GameActions::Execute(&networkModifyGroup);
|
||||
break;
|
||||
}
|
||||
@@ -509,7 +510,8 @@ namespace OpenRCT2::Ui::Windows
|
||||
if (text.empty())
|
||||
return;
|
||||
|
||||
auto networkModifyGroup = NetworkModifyGroupAction(ModifyGroupType::SetName, _selectedGroup, std::string(text));
|
||||
auto networkModifyGroup = GameActions::NetworkModifyGroupAction(
|
||||
GameActions::ModifyGroupType::SetName, _selectedGroup, std::string(text));
|
||||
GameActions::Execute(&networkModifyGroup);
|
||||
break;
|
||||
}
|
||||
@@ -634,8 +636,9 @@ namespace OpenRCT2::Ui::Windows
|
||||
selected_list_item = index;
|
||||
Invalidate();
|
||||
|
||||
auto networkModifyGroup = NetworkModifyGroupAction(
|
||||
ModifyGroupType::SetPermissions, _selectedGroup, "", index, PermissionState::Toggle);
|
||||
auto networkModifyGroup = GameActions::NetworkModifyGroupAction(
|
||||
GameActions::ModifyGroupType::SetPermissions, _selectedGroup, "", index,
|
||||
GameActions::PermissionState::Toggle);
|
||||
GameActions::Execute(&networkModifyGroup);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -273,7 +273,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
break;
|
||||
case WIDX_START_BUTTON:
|
||||
{
|
||||
auto gameAction = ParkMarketingAction(
|
||||
auto gameAction = GameActions::ParkMarketingAction(
|
||||
Campaign.campaign_type, Campaign.RideId.ToUnderlying(), Campaign.no_weeks);
|
||||
gameAction.SetCallback([](const GameAction* ga, const GameActions::Result* result) {
|
||||
if (result->Error == GameActions::Status::Ok)
|
||||
|
||||
@@ -493,7 +493,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
if (widgetIndex == WIDX_RENAME && !text.empty())
|
||||
{
|
||||
auto action = ParkSetNameAction(std::string(text));
|
||||
auto action = GameActions::ParkSetNameAction(std::string(text));
|
||||
GameActions::Execute(&action);
|
||||
}
|
||||
}
|
||||
@@ -818,14 +818,14 @@ namespace OpenRCT2::Ui::Windows
|
||||
case WIDX_INCREASE_PRICE:
|
||||
{
|
||||
const auto newFee = std::min(kMaxEntranceFee, gameState.park.entranceFee + 1.00_GBP);
|
||||
auto gameAction = ParkSetEntranceFeeAction(newFee);
|
||||
auto gameAction = GameActions::ParkSetEntranceFeeAction(newFee);
|
||||
GameActions::Execute(&gameAction);
|
||||
break;
|
||||
}
|
||||
case WIDX_DECREASE_PRICE:
|
||||
{
|
||||
const auto newFee = std::max(0.00_GBP, gameState.park.entranceFee - 1.00_GBP);
|
||||
auto gameAction = ParkSetEntranceFeeAction(newFee);
|
||||
auto gameAction = GameActions::ParkSetEntranceFeeAction(newFee);
|
||||
GameActions::Execute(&gameAction);
|
||||
break;
|
||||
}
|
||||
@@ -1040,7 +1040,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
|
||||
money = std::clamp(money, 0.00_GBP, kMaxEntranceFee);
|
||||
auto gameAction = ParkSetEntranceFeeAction(money);
|
||||
auto gameAction = GameActions::ParkSetEntranceFeeAction(money);
|
||||
GameActions::Execute(&gameAction);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,7 +206,8 @@ namespace OpenRCT2::Ui::Windows
|
||||
auto staff = GetEntity<Staff>(_staffId);
|
||||
if (staff != nullptr)
|
||||
{
|
||||
_mode = staff->IsPatrolAreaSet(*mapTile) ? StaffSetPatrolAreaMode::Unset : StaffSetPatrolAreaMode::Set;
|
||||
_mode = staff->IsPatrolAreaSet(*mapTile) ? GameActions::StaffSetPatrolAreaMode::Unset
|
||||
: GameActions::StaffSetPatrolAreaMode::Set;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,7 +220,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
if (staff != nullptr)
|
||||
{
|
||||
MapRange range(gMapSelectPositionA, gMapSelectPositionB);
|
||||
auto staffSetPatrolAreaAction = StaffSetPatrolAreaAction(_staffId, range, _mode);
|
||||
auto staffSetPatrolAreaAction = GameActions::StaffSetPatrolAreaAction(_staffId, range, _mode);
|
||||
GameActions::Execute(&staffSetPatrolAreaAction);
|
||||
}
|
||||
}
|
||||
@@ -237,7 +238,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
private:
|
||||
EntityId _staffId;
|
||||
StaffSetPatrolAreaMode _mode;
|
||||
GameActions::StaffSetPatrolAreaMode _mode;
|
||||
|
||||
void EnableTool()
|
||||
{
|
||||
|
||||
@@ -507,7 +507,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
break;
|
||||
case WIDX_KICK:
|
||||
{
|
||||
auto kickPlayerAction = PlayerKickAction(number);
|
||||
auto kickPlayerAction = GameActions::PlayerKickAction(number);
|
||||
GameActions::Execute(&kickPlayerAction);
|
||||
}
|
||||
break;
|
||||
@@ -528,7 +528,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
const auto groupId = NetworkGetGroupID(dropdownIndex);
|
||||
const auto windowHandle = std::make_pair(classification, number);
|
||||
auto playerSetGroupAction = PlayerSetGroupAction(playerId, groupId);
|
||||
auto playerSetGroupAction = GameActions::PlayerSetGroupAction(playerId, groupId);
|
||||
playerSetGroupAction.SetCallback([windowHandle](const GameAction* ga, const GameActions::Result* result) {
|
||||
if (result->Error == GameActions::Status::Ok)
|
||||
{
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
case WIDX_REFURBISH:
|
||||
{
|
||||
auto gameAction = RideDemolishAction(rideId, RideModifyType::renew);
|
||||
auto gameAction = GameActions::RideDemolishAction(rideId, GameActions::RideModifyType::renew);
|
||||
GameActions::Execute(&gameAction);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -506,7 +506,8 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
auto activeResearchTypes = gameState.researchPriorities;
|
||||
activeResearchTypes ^= 1uLL << (widgetIndex - (WIDX_TRANSPORT_RIDES + widgetOffset));
|
||||
auto gameAction = ParkSetResearchFundingAction(activeResearchTypes, gameState.researchFundingLevel);
|
||||
auto gameAction = GameActions::ParkSetResearchFundingAction(
|
||||
activeResearchTypes, gameState.researchFundingLevel);
|
||||
GameActions::Execute(&gameAction);
|
||||
break;
|
||||
}
|
||||
@@ -521,7 +522,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
if (widgetIndex != (WIDX_RESEARCH_FUNDING_DROPDOWN_BUTTON + widgetOffset) || selectedIndex == -1)
|
||||
return;
|
||||
|
||||
auto gameAction = ParkSetResearchFundingAction(gameState.researchPriorities, selectedIndex);
|
||||
auto gameAction = GameActions::ParkSetResearchFundingAction(gameState.researchPriorities, selectedIndex);
|
||||
GameActions::Execute(&gameAction);
|
||||
}
|
||||
|
||||
|
||||
@@ -1671,7 +1671,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
status = RideStatus::open;
|
||||
break;
|
||||
}
|
||||
auto gameAction = RideSetStatusAction(ride->id, status);
|
||||
auto gameAction = GameActions::RideSetStatusAction(ride->id, status);
|
||||
GameActions::Execute(&gameAction);
|
||||
}
|
||||
break;
|
||||
@@ -2220,7 +2220,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
break;
|
||||
}
|
||||
}
|
||||
auto gameAction = RideSetStatusAction(ride->id, status);
|
||||
auto gameAction = GameActions::RideSetStatusAction(ride->id, status);
|
||||
GameActions::Execute(&gameAction);
|
||||
}
|
||||
break;
|
||||
@@ -2232,7 +2232,8 @@ namespace OpenRCT2::Ui::Windows
|
||||
auto rideType = _rideDropdownData[rideLabelId].RideTypeId;
|
||||
if (rideType < RIDE_TYPE_COUNT)
|
||||
{
|
||||
auto rideSetSetting = RideSetSettingAction(rideId, RideSetSetting::RideType, rideType);
|
||||
auto rideSetSetting = GameActions::RideSetSettingAction(
|
||||
rideId, GameActions::RideSetSetting::RideType, rideType);
|
||||
rideSetSetting.SetCallback([](const GameAction* ga, const GameActions::Result* result) {
|
||||
// Reset ghost track if ride construction window is open, prevents a crash
|
||||
// Will get set to the correct Alternative variable during set_default_next_piece.
|
||||
@@ -2302,7 +2303,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
if (ride != nullptr)
|
||||
{
|
||||
auto strText = std::string(text);
|
||||
auto gameAction = RideSetNameAction(ride->id, strText);
|
||||
auto gameAction = GameActions::RideSetNameAction(ride->id, strText);
|
||||
GameActions::Execute(&gameAction);
|
||||
}
|
||||
}
|
||||
@@ -3070,7 +3071,8 @@ namespace OpenRCT2::Ui::Windows
|
||||
uint8_t increment = ride->mode == RideMode::dodgems ? 10 : 1;
|
||||
|
||||
SetOperatingSetting(
|
||||
rideId, RideSetSetting::Operation, std::clamp<int16_t>(ride->operationOption + increment, minValue, maxValue));
|
||||
rideId, GameActions::RideSetSetting::Operation,
|
||||
std::clamp<int16_t>(ride->operationOption + increment, minValue, maxValue));
|
||||
}
|
||||
|
||||
void ModeTweakDecrease()
|
||||
@@ -3091,7 +3093,8 @@ namespace OpenRCT2::Ui::Windows
|
||||
uint8_t decrement = ride->mode == RideMode::dodgems ? 10 : 1;
|
||||
|
||||
SetOperatingSetting(
|
||||
rideId, RideSetSetting::Operation, std::clamp<int16_t>(ride->operationOption - decrement, minValue, maxValue));
|
||||
rideId, GameActions::RideSetSetting::Operation,
|
||||
std::clamp<int16_t>(ride->operationOption - decrement, minValue, maxValue));
|
||||
}
|
||||
|
||||
void ModeDropdown(Widget* widget)
|
||||
@@ -3175,23 +3178,28 @@ namespace OpenRCT2::Ui::Windows
|
||||
SetPage(widgetIndex - WIDX_TAB_1);
|
||||
break;
|
||||
case WIDX_LOAD_CHECKBOX:
|
||||
SetOperatingSetting(rideId, RideSetSetting::Departure, ride->departFlags ^ RIDE_DEPART_WAIT_FOR_LOAD);
|
||||
SetOperatingSetting(
|
||||
rideId, GameActions::RideSetSetting::Departure, ride->departFlags ^ RIDE_DEPART_WAIT_FOR_LOAD);
|
||||
break;
|
||||
case WIDX_LEAVE_WHEN_ANOTHER_ARRIVES_CHECKBOX:
|
||||
SetOperatingSetting(
|
||||
rideId, RideSetSetting::Departure, ride->departFlags ^ RIDE_DEPART_LEAVE_WHEN_ANOTHER_ARRIVES);
|
||||
rideId, GameActions::RideSetSetting::Departure,
|
||||
ride->departFlags ^ RIDE_DEPART_LEAVE_WHEN_ANOTHER_ARRIVES);
|
||||
break;
|
||||
case WIDX_MINIMUM_LENGTH_CHECKBOX:
|
||||
SetOperatingSetting(
|
||||
rideId, RideSetSetting::Departure, ride->departFlags ^ RIDE_DEPART_WAIT_FOR_MINIMUM_LENGTH);
|
||||
rideId, GameActions::RideSetSetting::Departure,
|
||||
ride->departFlags ^ RIDE_DEPART_WAIT_FOR_MINIMUM_LENGTH);
|
||||
break;
|
||||
case WIDX_MAXIMUM_LENGTH_CHECKBOX:
|
||||
SetOperatingSetting(
|
||||
rideId, RideSetSetting::Departure, ride->departFlags ^ RIDE_DEPART_WAIT_FOR_MAXIMUM_LENGTH);
|
||||
rideId, GameActions::RideSetSetting::Departure,
|
||||
ride->departFlags ^ RIDE_DEPART_WAIT_FOR_MAXIMUM_LENGTH);
|
||||
break;
|
||||
case WIDX_SYNCHRONISE_WITH_ADJACENT_STATIONS_CHECKBOX:
|
||||
SetOperatingSetting(
|
||||
rideId, RideSetSetting::Departure, ride->departFlags ^ RIDE_DEPART_SYNCHRONISE_WITH_ADJACENT_STATIONS);
|
||||
rideId, GameActions::RideSetSetting::Departure,
|
||||
ride->departFlags ^ RIDE_DEPART_SYNCHRONISE_WITH_ADJACENT_STATIONS);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -3228,7 +3236,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
? 0
|
||||
: ride->getRideTypeDescriptor().LiftData.minimum_speed;
|
||||
SetOperatingSetting(
|
||||
rideId, RideSetSetting::LiftHillSpeed,
|
||||
rideId, GameActions::RideSetSetting::LiftHillSpeed,
|
||||
std::clamp<int16_t>(ride->liftHillSpeed + 1, lowerBound, upperBound));
|
||||
break;
|
||||
case WIDX_LIFT_HILL_SPEED_DECREASE:
|
||||
@@ -3239,7 +3247,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
? 0
|
||||
: ride->getRideTypeDescriptor().LiftData.minimum_speed;
|
||||
SetOperatingSetting(
|
||||
rideId, RideSetSetting::LiftHillSpeed,
|
||||
rideId, GameActions::RideSetSetting::LiftHillSpeed,
|
||||
std::clamp<int16_t>(ride->liftHillSpeed - 1, lowerBound, upperBound));
|
||||
break;
|
||||
case WIDX_MINIMUM_LENGTH:
|
||||
@@ -3252,28 +3260,28 @@ namespace OpenRCT2::Ui::Windows
|
||||
upperBound = OpenRCT2::Limits::kMaxWaitingTime;
|
||||
lowerBound = 0;
|
||||
SetOperatingSetting(
|
||||
rideId, RideSetSetting::MinWaitingTime,
|
||||
rideId, GameActions::RideSetSetting::MinWaitingTime,
|
||||
std::clamp<int16_t>(ride->minWaitingTime + 1, lowerBound, upperBound));
|
||||
break;
|
||||
case WIDX_MINIMUM_LENGTH_DECREASE:
|
||||
upperBound = OpenRCT2::Limits::kMaxWaitingTime;
|
||||
lowerBound = 0;
|
||||
SetOperatingSetting(
|
||||
rideId, RideSetSetting::MinWaitingTime,
|
||||
rideId, GameActions::RideSetSetting::MinWaitingTime,
|
||||
std::clamp<int16_t>(ride->minWaitingTime - 1, lowerBound, upperBound));
|
||||
break;
|
||||
case WIDX_MAXIMUM_LENGTH_INCREASE:
|
||||
upperBound = OpenRCT2::Limits::kMaxWaitingTime;
|
||||
lowerBound = 0;
|
||||
SetOperatingSetting(
|
||||
rideId, RideSetSetting::MaxWaitingTime,
|
||||
rideId, GameActions::RideSetSetting::MaxWaitingTime,
|
||||
std::clamp<int16_t>(ride->maxWaitingTime + 1, lowerBound, upperBound));
|
||||
break;
|
||||
case WIDX_MAXIMUM_LENGTH_DECREASE:
|
||||
upperBound = OpenRCT2::Limits::kMaxWaitingTime;
|
||||
lowerBound = 0;
|
||||
SetOperatingSetting(
|
||||
rideId, RideSetSetting::MaxWaitingTime,
|
||||
rideId, GameActions::RideSetSetting::MaxWaitingTime,
|
||||
std::clamp<int16_t>(ride->maxWaitingTime - 1, lowerBound, upperBound));
|
||||
break;
|
||||
case WIDX_MODE_DROPDOWN:
|
||||
@@ -3287,7 +3295,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
: OpenRCT2::Limits::kMaxCircuitsPerRide;
|
||||
lowerBound = 1;
|
||||
SetOperatingSetting(
|
||||
rideId, RideSetSetting::NumCircuits,
|
||||
rideId, GameActions::RideSetSetting::NumCircuits,
|
||||
std::clamp<int16_t>(ride->numCircuits + 1, lowerBound, upperBound));
|
||||
break;
|
||||
case WIDX_OPERATE_NUMBER_OF_CIRCUITS_DECREASE:
|
||||
@@ -3295,7 +3303,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
: OpenRCT2::Limits::kMaxCircuitsPerRide;
|
||||
lowerBound = 1;
|
||||
SetOperatingSetting(
|
||||
rideId, RideSetSetting::NumCircuits,
|
||||
rideId, GameActions::RideSetSetting::NumCircuits,
|
||||
std::clamp<int16_t>(ride->numCircuits - 1, lowerBound, upperBound));
|
||||
break;
|
||||
}
|
||||
@@ -3381,12 +3389,12 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
}
|
||||
if (rideMode != RideMode::nullMode)
|
||||
SetOperatingSetting(rideId, RideSetSetting::Mode, static_cast<uint8_t>(rideMode));
|
||||
SetOperatingSetting(rideId, GameActions::RideSetSetting::Mode, static_cast<uint8_t>(rideMode));
|
||||
break;
|
||||
}
|
||||
case WIDX_LOAD_DROPDOWN:
|
||||
SetOperatingSetting(
|
||||
rideId, RideSetSetting::Departure,
|
||||
rideId, GameActions::RideSetSetting::Departure,
|
||||
(ride->departFlags & ~RIDE_DEPART_WAIT_FOR_LOAD_MASK) | dropdownIndex);
|
||||
break;
|
||||
}
|
||||
@@ -3428,7 +3436,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
uint32_t origSize = std::stol(std::string(text)) / multiplier;
|
||||
uint8_t size = static_cast<uint8_t>(std::clamp(origSize, minValue, maxValue));
|
||||
SetOperatingSetting(ride->id, RideSetSetting::Operation, size);
|
||||
SetOperatingSetting(ride->id, GameActions::RideSetSetting::Operation, size);
|
||||
}
|
||||
catch (const std::logic_error&)
|
||||
{
|
||||
@@ -3439,8 +3447,8 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
try
|
||||
{
|
||||
auto rideSetSetting = widgetIndex == WIDX_MINIMUM_LENGTH ? RideSetSetting::MinWaitingTime
|
||||
: RideSetSetting::MaxWaitingTime;
|
||||
auto rideSetSetting = widgetIndex == WIDX_MINIMUM_LENGTH ? GameActions::RideSetSetting::MinWaitingTime
|
||||
: GameActions::RideSetSetting::MaxWaitingTime;
|
||||
|
||||
uint16_t upperBound = OpenRCT2::Limits::kMaxWaitingTime;
|
||||
uint16_t lowerBound = 0;
|
||||
@@ -3886,7 +3894,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
switch (widgetIndex)
|
||||
{
|
||||
case WIDX_INSPECTION_INTERVAL_DROPDOWN:
|
||||
SetOperatingSetting(rideId, RideSetSetting::InspectionInterval, dropdownIndex);
|
||||
SetOperatingSetting(rideId, GameActions::RideSetSetting::InspectionInterval, dropdownIndex);
|
||||
break;
|
||||
|
||||
case WIDX_FORCE_BREAKDOWN:
|
||||
@@ -4188,7 +4196,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
auto z = info.Element->GetBaseZ();
|
||||
auto direction = info.Element->GetDirection();
|
||||
auto gameAction = RideSetColourSchemeAction(
|
||||
auto gameAction = GameActions::RideSetColourSchemeAction(
|
||||
CoordsXYZD{ info.Loc, z, static_cast<Direction>(direction) }, info.Element->AsTrack()->GetTrackType(),
|
||||
newColourScheme);
|
||||
GameActions::Execute(&gameAction);
|
||||
@@ -4228,8 +4236,8 @@ namespace OpenRCT2::Ui::Windows
|
||||
if (ride != nullptr)
|
||||
{
|
||||
const bool currentlyEnabled = ride->hasLifecycleFlag(RIDE_LIFECYCLE_RANDOM_SHOP_COLOURS);
|
||||
auto rideSetAppearanceAction = RideSetAppearanceAction(
|
||||
rideId, RideSetAppearanceType::SellingItemColourIsRandom, currentlyEnabled ? 0 : 1, 0);
|
||||
auto rideSetAppearanceAction = GameActions::RideSetAppearanceAction(
|
||||
rideId, GameActions::RideSetAppearanceType::SellingItemColourIsRandom, currentlyEnabled ? 0 : 1, 0);
|
||||
GameActions::Execute(&rideSetAppearanceAction);
|
||||
}
|
||||
break;
|
||||
@@ -4270,24 +4278,24 @@ namespace OpenRCT2::Ui::Windows
|
||||
if (allowChangingBodyColour)
|
||||
{
|
||||
colour_t colour = UtilRand() % kColourNumNormal;
|
||||
auto vehicleSetBodyColourAction = RideSetAppearanceAction(
|
||||
rideId, RideSetAppearanceType::VehicleColourBody, colour, i);
|
||||
auto vehicleSetBodyColourAction = GameActions::RideSetAppearanceAction(
|
||||
rideId, GameActions::RideSetAppearanceType::VehicleColourBody, colour, i);
|
||||
GameActions::Execute(&vehicleSetBodyColourAction);
|
||||
}
|
||||
|
||||
if (allowChangingTrimColour)
|
||||
{
|
||||
colour_t colour = UtilRand() % kColourNumNormal;
|
||||
auto vehicleSetTrimColourAction = RideSetAppearanceAction(
|
||||
rideId, RideSetAppearanceType::VehicleColourTrim, colour, i);
|
||||
auto vehicleSetTrimColourAction = GameActions::RideSetAppearanceAction(
|
||||
rideId, GameActions::RideSetAppearanceType::VehicleColourTrim, colour, i);
|
||||
GameActions::Execute(&vehicleSetTrimColourAction);
|
||||
}
|
||||
|
||||
if (allowChangingTertiaryColour)
|
||||
{
|
||||
colour_t colour = UtilRand() % kColourNumNormal;
|
||||
auto vehicleSetTertiaryColourAction = RideSetAppearanceAction(
|
||||
rideId, RideSetAppearanceType::VehicleColourTertiary, colour, i);
|
||||
auto vehicleSetTertiaryColourAction = GameActions::RideSetAppearanceAction(
|
||||
rideId, GameActions::RideSetAppearanceType::VehicleColourTertiary, colour, i);
|
||||
GameActions::Execute(&vehicleSetTertiaryColourAction);
|
||||
}
|
||||
}
|
||||
@@ -4457,32 +4465,32 @@ namespace OpenRCT2::Ui::Windows
|
||||
break;
|
||||
case WIDX_TRACK_MAIN_COLOUR:
|
||||
{
|
||||
auto rideSetAppearanceAction = RideSetAppearanceAction(
|
||||
rideId, RideSetAppearanceType::TrackColourMain, ColourDropDownIndexToColour(dropdownIndex),
|
||||
auto rideSetAppearanceAction = GameActions::RideSetAppearanceAction(
|
||||
rideId, GameActions::RideSetAppearanceType::TrackColourMain, ColourDropDownIndexToColour(dropdownIndex),
|
||||
_rideColour);
|
||||
GameActions::Execute(&rideSetAppearanceAction);
|
||||
}
|
||||
break;
|
||||
case WIDX_TRACK_ADDITIONAL_COLOUR:
|
||||
{
|
||||
auto rideSetAppearanceAction = RideSetAppearanceAction(
|
||||
rideId, RideSetAppearanceType::TrackColourAdditional, ColourDropDownIndexToColour(dropdownIndex),
|
||||
_rideColour);
|
||||
auto rideSetAppearanceAction = GameActions::RideSetAppearanceAction(
|
||||
rideId, GameActions::RideSetAppearanceType::TrackColourAdditional,
|
||||
ColourDropDownIndexToColour(dropdownIndex), _rideColour);
|
||||
GameActions::Execute(&rideSetAppearanceAction);
|
||||
}
|
||||
break;
|
||||
case WIDX_TRACK_SUPPORT_COLOUR:
|
||||
{
|
||||
auto rideSetAppearanceAction = RideSetAppearanceAction(
|
||||
rideId, RideSetAppearanceType::TrackColourSupports, ColourDropDownIndexToColour(dropdownIndex),
|
||||
_rideColour);
|
||||
auto rideSetAppearanceAction = GameActions::RideSetAppearanceAction(
|
||||
rideId, GameActions::RideSetAppearanceType::TrackColourSupports,
|
||||
ColourDropDownIndexToColour(dropdownIndex), _rideColour);
|
||||
GameActions::Execute(&rideSetAppearanceAction);
|
||||
}
|
||||
break;
|
||||
case WIDX_MAZE_STYLE_DROPDOWN:
|
||||
{
|
||||
auto rideSetAppearanceAction = RideSetAppearanceAction(
|
||||
rideId, RideSetAppearanceType::MazeStyle, dropdownIndex, _rideColour);
|
||||
auto rideSetAppearanceAction = GameActions::RideSetAppearanceAction(
|
||||
rideId, GameActions::RideSetAppearanceType::MazeStyle, dropdownIndex, _rideColour);
|
||||
GameActions::Execute(&rideSetAppearanceAction);
|
||||
}
|
||||
break;
|
||||
@@ -4493,8 +4501,8 @@ namespace OpenRCT2::Ui::Windows
|
||||
break;
|
||||
}
|
||||
auto objIndex = _entranceDropdownData[dropdownIndex].EntranceTypeId;
|
||||
auto rideSetAppearanceAction = RideSetAppearanceAction(
|
||||
rideId, RideSetAppearanceType::EntranceStyle, objIndex, 0);
|
||||
auto rideSetAppearanceAction = GameActions::RideSetAppearanceAction(
|
||||
rideId, GameActions::RideSetAppearanceType::EntranceStyle, objIndex, 0);
|
||||
rideSetAppearanceAction.SetCallback([objIndex](const GameAction*, const GameActions::Result* res) {
|
||||
if (res->Error != GameActions::Status::Ok)
|
||||
return;
|
||||
@@ -4505,8 +4513,8 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
case WIDX_VEHICLE_COLOUR_SCHEME_DROPDOWN:
|
||||
{
|
||||
auto rideSetAppearanceAction = RideSetAppearanceAction(
|
||||
rideId, RideSetAppearanceType::VehicleColourScheme, dropdownIndex, 0);
|
||||
auto rideSetAppearanceAction = GameActions::RideSetAppearanceAction(
|
||||
rideId, GameActions::RideSetAppearanceType::VehicleColourScheme, dropdownIndex, 0);
|
||||
rideSetAppearanceAction.SetCallback([this](const GameAction* ga, const GameActions::Result* result) {
|
||||
if (result->Error == GameActions::Status::Ok)
|
||||
{
|
||||
@@ -4522,25 +4530,25 @@ namespace OpenRCT2::Ui::Windows
|
||||
break;
|
||||
case WIDX_VEHICLE_BODY_COLOUR:
|
||||
{
|
||||
auto rideSetAppearanceAction = RideSetAppearanceAction(
|
||||
rideId, RideSetAppearanceType::VehicleColourBody, ColourDropDownIndexToColour(dropdownIndex),
|
||||
_vehicleIndex);
|
||||
auto rideSetAppearanceAction = GameActions::RideSetAppearanceAction(
|
||||
rideId, GameActions::RideSetAppearanceType::VehicleColourBody,
|
||||
ColourDropDownIndexToColour(dropdownIndex), _vehicleIndex);
|
||||
GameActions::Execute(&rideSetAppearanceAction);
|
||||
}
|
||||
break;
|
||||
case WIDX_VEHICLE_TRIM_COLOUR:
|
||||
{
|
||||
auto rideSetAppearanceAction = RideSetAppearanceAction(
|
||||
rideId, RideSetAppearanceType::VehicleColourTrim, ColourDropDownIndexToColour(dropdownIndex),
|
||||
_vehicleIndex);
|
||||
auto rideSetAppearanceAction = GameActions::RideSetAppearanceAction(
|
||||
rideId, GameActions::RideSetAppearanceType::VehicleColourTrim,
|
||||
ColourDropDownIndexToColour(dropdownIndex), _vehicleIndex);
|
||||
GameActions::Execute(&rideSetAppearanceAction);
|
||||
}
|
||||
break;
|
||||
case WIDX_VEHICLE_TERTIARY_COLOUR:
|
||||
{
|
||||
auto rideSetAppearanceAction = RideSetAppearanceAction(
|
||||
rideId, RideSetAppearanceType::VehicleColourTertiary, ColourDropDownIndexToColour(dropdownIndex),
|
||||
_vehicleIndex);
|
||||
auto rideSetAppearanceAction = GameActions::RideSetAppearanceAction(
|
||||
rideId, GameActions::RideSetAppearanceType::VehicleColourTertiary,
|
||||
ColourDropDownIndexToColour(dropdownIndex), _vehicleIndex);
|
||||
GameActions::Execute(&rideSetAppearanceAction);
|
||||
}
|
||||
break;
|
||||
@@ -4969,7 +4977,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
if (ride != nullptr)
|
||||
{
|
||||
int32_t activateMusic = (ride->lifecycleFlags & RIDE_LIFECYCLE_MUSIC) ? 0 : 1;
|
||||
SetOperatingSetting(rideId, RideSetSetting::Music, activateMusic);
|
||||
SetOperatingSetting(rideId, GameActions::RideSetSetting::Music, activateMusic);
|
||||
ride->windowInvalidateFlags |= RIDE_INVALIDATE_RIDE_MUSIC;
|
||||
}
|
||||
}
|
||||
@@ -5109,7 +5117,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
&& static_cast<size_t>(dropdownIndex) < window_ride_current_music_style_order.size())
|
||||
{
|
||||
auto musicStyle = window_ride_current_music_style_order[dropdownIndex];
|
||||
SetOperatingSetting(rideId, RideSetSetting::MusicType, musicStyle);
|
||||
SetOperatingSetting(rideId, GameActions::RideSetSetting::MusicType, musicStyle);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6250,7 +6258,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
newFlags ^= EnumToFlag(shop_item);
|
||||
}
|
||||
|
||||
auto parkSetParameter = ParkSetParameterAction(ParkParameter::SamePriceInPark, newFlags);
|
||||
auto parkSetParameter = GameActions::ParkSetParameterAction(GameActions::ParkParameter::SamePriceInPark, newFlags);
|
||||
GameActions::Execute(&parkSetParameter);
|
||||
}
|
||||
|
||||
@@ -6283,7 +6291,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
UpdateSamePriceThroughoutFlags(shopItem);
|
||||
|
||||
auto rideSetPriceAction = RideSetPriceAction(rideId, ride->price[0], true);
|
||||
auto rideSetPriceAction = GameActions::RideSetPriceAction(rideId, ride->price[0], true);
|
||||
GameActions::Execute(&rideSetPriceAction);
|
||||
}
|
||||
|
||||
@@ -6303,13 +6311,13 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
UpdateSamePriceThroughoutFlags(shop_item);
|
||||
|
||||
auto rideSetPriceAction = RideSetPriceAction(rideId, ride->price[1], false);
|
||||
auto rideSetPriceAction = GameActions::RideSetPriceAction(rideId, ride->price[1], false);
|
||||
GameActions::Execute(&rideSetPriceAction);
|
||||
}
|
||||
|
||||
void IncomeSetPrimaryPrice(money64 price)
|
||||
{
|
||||
auto rideSetPriceAction = RideSetPriceAction(rideId, price, true);
|
||||
auto rideSetPriceAction = GameActions::RideSetPriceAction(rideId, price, true);
|
||||
GameActions::Execute(&rideSetPriceAction);
|
||||
}
|
||||
|
||||
@@ -6356,7 +6364,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
void IncomeSetSecondaryPrice(money64 price)
|
||||
{
|
||||
auto rideSetPriceAction = RideSetPriceAction(rideId, price, false);
|
||||
auto rideSetPriceAction = GameActions::RideSetPriceAction(rideId, price, false);
|
||||
GameActions::Execute(&rideSetPriceAction);
|
||||
}
|
||||
|
||||
|
||||
@@ -312,7 +312,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
if (!_autoOpeningShop)
|
||||
{
|
||||
_autoOpeningShop = true;
|
||||
auto gameAction = RideSetStatusAction(currentRide->id, RideStatus::open);
|
||||
auto gameAction = GameActions::RideSetStatusAction(currentRide->id, RideStatus::open);
|
||||
GameActions::Execute(&gameAction);
|
||||
_autoOpeningShop = false;
|
||||
}
|
||||
@@ -325,7 +325,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
else
|
||||
{
|
||||
auto gameAction = RideDemolishAction(currentRide->id, RideModifyType::demolish);
|
||||
auto gameAction = GameActions::RideDemolishAction(currentRide->id, GameActions::RideModifyType::demolish);
|
||||
gameAction.SetFlags(GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED);
|
||||
GameActions::Execute(&gameAction);
|
||||
}
|
||||
@@ -1099,7 +1099,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
auto status = currentRide->status == RideStatus::simulating ? RideStatus::closed
|
||||
: RideStatus::simulating;
|
||||
auto gameAction = RideSetStatusAction(currentRide->id, status);
|
||||
auto gameAction = GameActions::RideSetStatusAction(currentRide->id, status);
|
||||
GameActions::Execute(&gameAction);
|
||||
}
|
||||
break;
|
||||
@@ -2318,7 +2318,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
return;
|
||||
}
|
||||
|
||||
auto trackPlaceAction = TrackPlaceAction(
|
||||
auto trackPlaceAction = GameActions::TrackPlaceAction(
|
||||
rideIndex, trackType, currentRide->type, { trackPos, static_cast<uint8_t>(trackDirection) }, properties & 0xFF,
|
||||
(properties >> 8) & 0x0F, (properties >> 12) & 0x0F, liftHillAndAlternativeState, false);
|
||||
if (_rideConstructionState == RideConstructionState::Back)
|
||||
@@ -2353,7 +2353,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
_currentTrackSelectionFlags.set(TrackSelectionFlag::trackPlaceActionQueued);
|
||||
}
|
||||
|
||||
const auto resultData = res.GetData<TrackPlaceActionResult>();
|
||||
const auto resultData = res.GetData<GameActions::TrackPlaceActionResult>();
|
||||
if (resultData.GroundFlags & ELEMENT_IS_UNDERGROUND)
|
||||
{
|
||||
ViewportSetVisibility(ViewportVisibility::UndergroundViewOn);
|
||||
@@ -2448,7 +2448,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
_gotoStartPlacementMode = true;
|
||||
}
|
||||
|
||||
auto trackRemoveAction = TrackRemoveAction(
|
||||
auto trackRemoveAction = GameActions::TrackRemoveAction(
|
||||
_currentTrackPieceType, 0,
|
||||
{ _currentTrackBegin.x, _currentTrackBegin.y, _currentTrackBegin.z, currentDirection });
|
||||
|
||||
@@ -2567,7 +2567,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
&tileElement, {})
|
||||
!= std::nullopt)
|
||||
{
|
||||
auto trackSetBrakeSpeed = TrackSetBrakeSpeedAction(
|
||||
auto trackSetBrakeSpeed = GameActions::TrackSetBrakeSpeedAction(
|
||||
_currentTrackBegin, tileElement->AsTrack()->GetTrackType(), brakesSpeed);
|
||||
trackSetBrakeSpeed.SetCallback([](const GameAction* ga, const GameActions::Result* result) {
|
||||
WindowRideConstructionUpdateActiveElements();
|
||||
@@ -2653,7 +2653,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
if (gRideEntranceExitPlaceDirection == kInvalidDirection)
|
||||
return;
|
||||
|
||||
auto rideEntranceExitPlaceAction = RideEntranceExitPlaceAction(
|
||||
auto rideEntranceExitPlaceAction = GameActions::RideEntranceExitPlaceAction(
|
||||
entranceOrExitCoords, DirectionReverse(gRideEntranceExitPlaceDirection), gRideEntranceExitPlaceRideIndex,
|
||||
gRideEntranceExitPlaceStationIndex, gRideEntranceExitPlaceType == ENTRANCE_TYPE_RIDE_EXIT);
|
||||
|
||||
@@ -3700,7 +3700,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
gDisableErrorWindowSound = true;
|
||||
|
||||
auto gameAction = MazeSetTrackAction(
|
||||
auto gameAction = GameActions::MazeSetTrackAction(
|
||||
CoordsXYZD{ _currentTrackBegin, 0 }, true, _currentRideIndex, GC_SET_MAZE_TRACK_BUILD);
|
||||
auto mazeSetTrackResult = GameActions::Execute(&gameAction);
|
||||
if (mazeSetTrackResult.Error == GameActions::Status::Ok)
|
||||
@@ -4760,7 +4760,8 @@ namespace OpenRCT2::Ui::Windows
|
||||
if (rtd.specialType == RtdSpecialType::maze)
|
||||
{
|
||||
int32_t flags = GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND | GAME_COMMAND_FLAG_GHOST;
|
||||
auto gameAction = MazeSetTrackAction(CoordsXYZD{ trackPos, 0 }, true, rideIndex, GC_SET_MAZE_TRACK_BUILD);
|
||||
auto gameAction = GameActions::MazeSetTrackAction(
|
||||
CoordsXYZD{ trackPos, 0 }, true, rideIndex, GC_SET_MAZE_TRACK_BUILD);
|
||||
gameAction.SetFlags(flags);
|
||||
auto result = GameActions::Execute(&gameAction);
|
||||
|
||||
@@ -4776,7 +4777,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
return result.Cost;
|
||||
}
|
||||
|
||||
auto trackPlaceAction = TrackPlaceAction(
|
||||
auto trackPlaceAction = GameActions::TrackPlaceAction(
|
||||
rideIndex, trackType, ride->type, { trackPos, static_cast<uint8_t>(trackDirection) }, 0, 0, 0,
|
||||
liftHillAndAlternativeState, false);
|
||||
trackPlaceAction.SetFlags(GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND | GAME_COMMAND_FLAG_GHOST);
|
||||
@@ -4801,7 +4802,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
_unkF440C5 = { trackPos.x, trackPos.y, trackPos.z + zBegin, static_cast<Direction>(trackDirection) };
|
||||
_currentTrackSelectionFlags.set(TrackSelectionFlag::track);
|
||||
|
||||
const auto resultData = res.GetData<TrackPlaceActionResult>();
|
||||
const auto resultData = res.GetData<GameActions::TrackPlaceActionResult>();
|
||||
const auto visiblity = (resultData.GroundFlags & ELEMENT_IS_UNDERGROUND) ? ViewportVisibility::UndergroundViewOn
|
||||
: ViewportVisibility::UndergroundViewOff;
|
||||
ViewportSetVisibility(visiblity);
|
||||
@@ -5148,7 +5149,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
};
|
||||
for (const auto& quadrant : quadrants)
|
||||
{
|
||||
auto gameAction = MazeSetTrackAction(quadrant, false, rideIndex, GC_SET_MAZE_TRACK_FILL);
|
||||
auto gameAction = GameActions::MazeSetTrackAction(quadrant, false, rideIndex, GC_SET_MAZE_TRACK_FILL);
|
||||
gameAction.SetFlags(flags);
|
||||
auto res = GameActions::Execute(&gameAction);
|
||||
}
|
||||
@@ -5166,7 +5167,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
auto trackType = next_track.element->AsTrack()->GetTrackType();
|
||||
int32_t trackSequence = next_track.element->AsTrack()->GetSequenceIndex();
|
||||
auto trackRemoveAction = TrackRemoveAction{
|
||||
auto trackRemoveAction = GameActions::TrackRemoveAction{
|
||||
trackType, trackSequence, { next_track.x, next_track.y, z, static_cast<Direction>(direction) }
|
||||
};
|
||||
trackRemoveAction.SetFlags(
|
||||
|
||||
@@ -473,7 +473,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
const auto selectedRideId = _rideList[index].Id;
|
||||
if (_quickDemolishMode && NetworkGetMode() != NETWORK_MODE_CLIENT)
|
||||
{
|
||||
auto gameAction = RideDemolishAction(selectedRideId, RideModifyType::demolish);
|
||||
auto gameAction = GameActions::RideDemolishAction(selectedRideId, GameActions::RideModifyType::demolish);
|
||||
GameActions::Execute(&gameAction);
|
||||
RefreshList();
|
||||
}
|
||||
@@ -1110,7 +1110,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
if (rideRef.status != RideStatus::closed
|
||||
&& rideRef.getClassification() == static_cast<RideClassification>(page))
|
||||
{
|
||||
auto gameAction = RideSetStatusAction(rideRef.id, RideStatus::closed);
|
||||
auto gameAction = GameActions::RideSetStatusAction(rideRef.id, RideStatus::closed);
|
||||
GameActions::Execute(&gameAction);
|
||||
}
|
||||
}
|
||||
@@ -1123,7 +1123,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
if (rideRef.status != RideStatus::open && rideRef.getClassification() == static_cast<RideClassification>(page))
|
||||
{
|
||||
auto gameAction = RideSetStatusAction(rideRef.id, RideStatus::open);
|
||||
auto gameAction = GameActions::RideSetStatusAction(rideRef.id, RideStatus::open);
|
||||
GameActions::Execute(&gameAction);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
#include <openrct2/world/tile_element/SurfaceElement.h>
|
||||
#include <openrct2/world/tile_element/WallElement.h>
|
||||
|
||||
using namespace OpenRCT2::Numerics;
|
||||
using namespace Numerics;
|
||||
|
||||
namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
@@ -199,7 +199,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
const SceneryGroupEntry* GetSceneryGroupEntry() const
|
||||
{
|
||||
return OpenRCT2::ObjectManager::GetObjectEntry<SceneryGroupEntry>(SceneryGroupIndex);
|
||||
return ObjectManager::GetObjectEntry<SceneryGroupEntry>(SceneryGroupIndex);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -329,7 +329,8 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
const auto newStatus = !IsSceneryItemRestricted(tabSelectedScenery);
|
||||
const auto objectType = GetObjectTypeFromSceneryType(tabSelectedScenery.SceneryType);
|
||||
auto action = ScenerySetRestrictedAction(objectType, tabSelectedScenery.EntryIndex, newStatus);
|
||||
auto action = GameActions::ScenerySetRestrictedAction(
|
||||
objectType, tabSelectedScenery.EntryIndex, newStatus);
|
||||
GameActions::Execute(&action);
|
||||
}
|
||||
break;
|
||||
@@ -554,22 +555,22 @@ namespace OpenRCT2::Ui::Windows
|
||||
else if (tabSelectedScenery.SceneryType == SCENERY_TYPE_LARGE)
|
||||
{
|
||||
gCurrentToolId = static_cast<Tool>(
|
||||
OpenRCT2::ObjectManager::GetObjectEntry<LargeSceneryEntry>(tabSelectedScenery.EntryIndex)->tool_id);
|
||||
ObjectManager::GetObjectEntry<LargeSceneryEntry>(tabSelectedScenery.EntryIndex)->tool_id);
|
||||
}
|
||||
else if (tabSelectedScenery.SceneryType == SCENERY_TYPE_WALL)
|
||||
{
|
||||
gCurrentToolId = static_cast<Tool>(
|
||||
OpenRCT2::ObjectManager::GetObjectEntry<WallSceneryEntry>(tabSelectedScenery.EntryIndex)->tool_id);
|
||||
ObjectManager::GetObjectEntry<WallSceneryEntry>(tabSelectedScenery.EntryIndex)->tool_id);
|
||||
}
|
||||
else if (tabSelectedScenery.SceneryType == SCENERY_TYPE_PATH_ITEM)
|
||||
{
|
||||
gCurrentToolId = static_cast<Tool>(
|
||||
OpenRCT2::ObjectManager::GetObjectEntry<PathAdditionEntry>(tabSelectedScenery.EntryIndex)->tool_id);
|
||||
ObjectManager::GetObjectEntry<PathAdditionEntry>(tabSelectedScenery.EntryIndex)->tool_id);
|
||||
}
|
||||
else
|
||||
{ // small scenery
|
||||
gCurrentToolId = static_cast<Tool>(
|
||||
OpenRCT2::ObjectManager::GetObjectEntry<SmallSceneryEntry>(tabSelectedScenery.EntryIndex)->tool_id);
|
||||
ObjectManager::GetObjectEntry<SmallSceneryEntry>(tabSelectedScenery.EntryIndex)->tool_id);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -699,8 +700,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
widgets[WIDX_SCENERY_BUILD_CLUSTER_BUTTON].type = WidgetType::flatBtn;
|
||||
|
||||
auto* sceneryEntry = OpenRCT2::ObjectManager::GetObjectEntry<SmallSceneryEntry>(
|
||||
tabSelectedScenery.EntryIndex);
|
||||
auto* sceneryEntry = ObjectManager::GetObjectEntry<SmallSceneryEntry>(tabSelectedScenery.EntryIndex);
|
||||
if (sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_ROTATABLE))
|
||||
{
|
||||
widgets[WIDX_SCENERY_ROTATE_OBJECTS_BUTTON].type = WidgetType::flatBtn;
|
||||
@@ -739,8 +739,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
if (tabSelectedScenery.SceneryType == SCENERY_TYPE_BANNER)
|
||||
{
|
||||
auto* bannerEntry = OpenRCT2::ObjectManager::GetObjectEntry<BannerSceneryEntry>(
|
||||
tabSelectedScenery.EntryIndex);
|
||||
auto* bannerEntry = ObjectManager::GetObjectEntry<BannerSceneryEntry>(tabSelectedScenery.EntryIndex);
|
||||
if (bannerEntry->flags & BANNER_ENTRY_FLAG_HAS_PRIMARY_COLOUR)
|
||||
{
|
||||
widgets[WIDX_SCENERY_PRIMARY_COLOUR_BUTTON].type = WidgetType::colourBtn;
|
||||
@@ -748,8 +747,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
else if (tabSelectedScenery.SceneryType == SCENERY_TYPE_LARGE)
|
||||
{
|
||||
auto* sceneryEntry = OpenRCT2::ObjectManager::GetObjectEntry<LargeSceneryEntry>(
|
||||
tabSelectedScenery.EntryIndex);
|
||||
auto* sceneryEntry = ObjectManager::GetObjectEntry<LargeSceneryEntry>(tabSelectedScenery.EntryIndex);
|
||||
|
||||
if (sceneryEntry->flags & LARGE_SCENERY_FLAG_HAS_PRIMARY_COLOUR
|
||||
&& !(sceneryEntry->flags & LARGE_SCENERY_FLAG_HIDE_PRIMARY_REMAP_BUTTON))
|
||||
@@ -762,7 +760,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
else if (tabSelectedScenery.SceneryType == SCENERY_TYPE_WALL)
|
||||
{
|
||||
auto* wallEntry = OpenRCT2::ObjectManager::GetObjectEntry<WallSceneryEntry>(tabSelectedScenery.EntryIndex);
|
||||
auto* wallEntry = ObjectManager::GetObjectEntry<WallSceneryEntry>(tabSelectedScenery.EntryIndex);
|
||||
if (wallEntry->flags & (WALL_SCENERY_HAS_PRIMARY_COLOUR | WALL_SCENERY_HAS_GLASS))
|
||||
{
|
||||
widgets[WIDX_SCENERY_PRIMARY_COLOUR_BUTTON].type = WidgetType::colourBtn;
|
||||
@@ -780,8 +778,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
else if (tabSelectedScenery.SceneryType == SCENERY_TYPE_SMALL)
|
||||
{
|
||||
auto* sceneryEntry = OpenRCT2::ObjectManager::GetObjectEntry<SmallSceneryEntry>(
|
||||
tabSelectedScenery.EntryIndex);
|
||||
auto* sceneryEntry = ObjectManager::GetObjectEntry<SmallSceneryEntry>(tabSelectedScenery.EntryIndex);
|
||||
|
||||
if (sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_HAS_PRIMARY_COLOUR | SMALL_SCENERY_FLAG_HAS_GLASS))
|
||||
{
|
||||
@@ -978,7 +975,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
gWindowSceneryRotation = rotation.value();
|
||||
}
|
||||
gWindowSceneryEyedropperEnabled = false;
|
||||
OpenRCT2::Audio::Play(OpenRCT2::Audio::SoundId::Click1, 0, ContextGetWidth() / 2);
|
||||
Audio::Play(Audio::SoundId::Click1, 0, ContextGetWidth() / 2);
|
||||
_hoverCounter = -16;
|
||||
gSceneryPlaceCost = kMoney64Undefined;
|
||||
Invalidate();
|
||||
@@ -1007,7 +1004,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
for (ObjectEntryIndex scenerySetIndex = 0; scenerySetIndex < kMaxTabs - kReservedTabCount; scenerySetIndex++)
|
||||
{
|
||||
const auto* sceneryGroupEntry = OpenRCT2::ObjectManager::GetObjectEntry<SceneryGroupEntry>(scenerySetIndex);
|
||||
const auto* sceneryGroupEntry = ObjectManager::GetObjectEntry<SceneryGroupEntry>(scenerySetIndex);
|
||||
if (sceneryGroupEntry != nullptr && SceneryGroupIsInvented(scenerySetIndex))
|
||||
{
|
||||
SceneryTabInfo tabInfo;
|
||||
@@ -1036,7 +1033,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
// small scenery
|
||||
for (ObjectEntryIndex sceneryId = 0; sceneryId < kMaxSmallSceneryObjects; sceneryId++)
|
||||
{
|
||||
const auto* sceneryEntry = OpenRCT2::ObjectManager::GetObjectEntry<SmallSceneryEntry>(sceneryId);
|
||||
const auto* sceneryEntry = ObjectManager::GetObjectEntry<SmallSceneryEntry>(sceneryId);
|
||||
if (sceneryEntry != nullptr)
|
||||
{
|
||||
InitSceneryEntry({ SCENERY_TYPE_SMALL, sceneryId }, sceneryEntry->scenery_tab_id);
|
||||
@@ -1046,7 +1043,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
// large scenery
|
||||
for (ObjectEntryIndex sceneryId = 0; sceneryId < kMaxLargeSceneryObjects; sceneryId++)
|
||||
{
|
||||
const auto* sceneryEntry = OpenRCT2::ObjectManager::GetObjectEntry<LargeSceneryEntry>(sceneryId);
|
||||
const auto* sceneryEntry = ObjectManager::GetObjectEntry<LargeSceneryEntry>(sceneryId);
|
||||
if (sceneryEntry != nullptr)
|
||||
{
|
||||
InitSceneryEntry({ SCENERY_TYPE_LARGE, sceneryId }, sceneryEntry->scenery_tab_id);
|
||||
@@ -1056,7 +1053,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
// walls
|
||||
for (ObjectEntryIndex sceneryId = 0; sceneryId < kMaxWallSceneryObjects; sceneryId++)
|
||||
{
|
||||
const auto* sceneryEntry = OpenRCT2::ObjectManager::GetObjectEntry<WallSceneryEntry>(sceneryId);
|
||||
const auto* sceneryEntry = ObjectManager::GetObjectEntry<WallSceneryEntry>(sceneryId);
|
||||
if (sceneryEntry != nullptr)
|
||||
{
|
||||
InitSceneryEntry({ SCENERY_TYPE_WALL, sceneryId }, sceneryEntry->scenery_tab_id);
|
||||
@@ -1066,7 +1063,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
// banners
|
||||
for (ObjectEntryIndex sceneryId = 0; sceneryId < kMaxBannerObjects; sceneryId++)
|
||||
{
|
||||
const auto* sceneryEntry = OpenRCT2::ObjectManager::GetObjectEntry<BannerSceneryEntry>(sceneryId);
|
||||
const auto* sceneryEntry = ObjectManager::GetObjectEntry<BannerSceneryEntry>(sceneryId);
|
||||
if (sceneryEntry != nullptr)
|
||||
{
|
||||
InitSceneryEntry({ SCENERY_TYPE_BANNER, sceneryId }, sceneryEntry->scenery_tab_id);
|
||||
@@ -1075,7 +1072,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
for (ObjectEntryIndex sceneryId = 0; sceneryId < kMaxPathAdditionObjects; sceneryId++)
|
||||
{
|
||||
const auto* sceneryEntry = OpenRCT2::ObjectManager::GetObjectEntry<PathAdditionEntry>(sceneryId);
|
||||
const auto* sceneryEntry = ObjectManager::GetObjectEntry<PathAdditionEntry>(sceneryId);
|
||||
if (sceneryEntry != nullptr)
|
||||
{
|
||||
InitSceneryEntry({ SCENERY_TYPE_PATH_ITEM, sceneryId }, sceneryEntry->scenery_tab_id);
|
||||
@@ -1514,7 +1511,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
_sceneryPaintEnabled = false;
|
||||
gWindowSceneryEyedropperEnabled = false;
|
||||
|
||||
OpenRCT2::Audio::Play(OpenRCT2::Audio::SoundId::Click1, 0, windowPos.x + (width / 2));
|
||||
Audio::Play(Audio::SoundId::Click1, 0, windowPos.x + (width / 2));
|
||||
_hoverCounter = -16;
|
||||
gSceneryPlaceCost = kMoney64Undefined;
|
||||
Invalidate();
|
||||
@@ -1544,8 +1541,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
case SCENERY_TYPE_SMALL:
|
||||
{
|
||||
auto* sceneryEntry = OpenRCT2::ObjectManager::GetObjectEntry<SmallSceneryEntry>(
|
||||
selectedScenery.EntryIndex);
|
||||
auto* sceneryEntry = ObjectManager::GetObjectEntry<SmallSceneryEntry>(selectedScenery.EntryIndex);
|
||||
if (sceneryEntry != nullptr)
|
||||
{
|
||||
price = sceneryEntry->price;
|
||||
@@ -1555,8 +1551,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
case SCENERY_TYPE_PATH_ITEM:
|
||||
{
|
||||
auto* sceneryEntry = OpenRCT2::ObjectManager::GetObjectEntry<PathAdditionEntry>(
|
||||
selectedScenery.EntryIndex);
|
||||
auto* sceneryEntry = ObjectManager::GetObjectEntry<PathAdditionEntry>(selectedScenery.EntryIndex);
|
||||
if (sceneryEntry != nullptr)
|
||||
{
|
||||
price = sceneryEntry->price;
|
||||
@@ -1566,8 +1561,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
case SCENERY_TYPE_WALL:
|
||||
{
|
||||
auto* sceneryEntry = OpenRCT2::ObjectManager::GetObjectEntry<WallSceneryEntry>(
|
||||
selectedScenery.EntryIndex);
|
||||
auto* sceneryEntry = ObjectManager::GetObjectEntry<WallSceneryEntry>(selectedScenery.EntryIndex);
|
||||
if (sceneryEntry != nullptr)
|
||||
{
|
||||
price = sceneryEntry->price;
|
||||
@@ -1577,8 +1571,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
case SCENERY_TYPE_LARGE:
|
||||
{
|
||||
auto* sceneryEntry = OpenRCT2::ObjectManager::GetObjectEntry<LargeSceneryEntry>(
|
||||
selectedScenery.EntryIndex);
|
||||
auto* sceneryEntry = ObjectManager::GetObjectEntry<LargeSceneryEntry>(selectedScenery.EntryIndex);
|
||||
if (sceneryEntry != nullptr)
|
||||
{
|
||||
price = sceneryEntry->price;
|
||||
@@ -1588,8 +1581,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
case SCENERY_TYPE_BANNER:
|
||||
{
|
||||
auto* sceneryEntry = OpenRCT2::ObjectManager::GetObjectEntry<BannerSceneryEntry>(
|
||||
selectedScenery.EntryIndex);
|
||||
auto* sceneryEntry = ObjectManager::GetObjectEntry<BannerSceneryEntry>(selectedScenery.EntryIndex);
|
||||
if (sceneryEntry != nullptr)
|
||||
{
|
||||
price = sceneryEntry->price;
|
||||
@@ -1621,14 +1613,14 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
if (scenerySelection.SceneryType == SCENERY_TYPE_BANNER)
|
||||
{
|
||||
auto bannerEntry = OpenRCT2::ObjectManager::GetObjectEntry<BannerSceneryEntry>(scenerySelection.EntryIndex);
|
||||
auto bannerEntry = ObjectManager::GetObjectEntry<BannerSceneryEntry>(scenerySelection.EntryIndex);
|
||||
auto imageId = ImageId(bannerEntry->image + gWindowSceneryRotation * 2, _sceneryPrimaryColour);
|
||||
GfxDrawSprite(rt, imageId, { 33, 40 });
|
||||
GfxDrawSprite(rt, imageId.WithIndexOffset(1), { 33, 40 });
|
||||
}
|
||||
else if (scenerySelection.SceneryType == SCENERY_TYPE_LARGE)
|
||||
{
|
||||
auto sceneryEntry = OpenRCT2::ObjectManager::GetObjectEntry<LargeSceneryEntry>(scenerySelection.EntryIndex);
|
||||
auto sceneryEntry = ObjectManager::GetObjectEntry<LargeSceneryEntry>(scenerySelection.EntryIndex);
|
||||
auto imageId = ImageId(sceneryEntry->image + gWindowSceneryRotation);
|
||||
if (sceneryEntry->flags & LARGE_SCENERY_FLAG_HAS_PRIMARY_COLOUR)
|
||||
imageId = imageId.WithPrimary(_sceneryPrimaryColour);
|
||||
@@ -1640,7 +1632,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
else if (scenerySelection.SceneryType == SCENERY_TYPE_WALL)
|
||||
{
|
||||
auto wallEntry = OpenRCT2::ObjectManager::GetObjectEntry<WallSceneryEntry>(scenerySelection.EntryIndex);
|
||||
auto wallEntry = ObjectManager::GetObjectEntry<WallSceneryEntry>(scenerySelection.EntryIndex);
|
||||
auto imageId = ImageId(wallEntry->image);
|
||||
auto spriteTop = (wallEntry->height * 2) + 0x32;
|
||||
if (wallEntry->flags & WALL_SCENERY_HAS_GLASS)
|
||||
@@ -1676,14 +1668,13 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
else if (scenerySelection.SceneryType == SCENERY_TYPE_PATH_ITEM)
|
||||
{
|
||||
auto* pathAdditionEntry = OpenRCT2::ObjectManager::GetObjectEntry<PathAdditionEntry>(
|
||||
scenerySelection.EntryIndex);
|
||||
auto* pathAdditionEntry = ObjectManager::GetObjectEntry<PathAdditionEntry>(scenerySelection.EntryIndex);
|
||||
auto imageId = ImageId(pathAdditionEntry->image);
|
||||
GfxDrawSprite(rt, imageId, { 11, 16 });
|
||||
}
|
||||
else
|
||||
{
|
||||
auto sceneryEntry = OpenRCT2::ObjectManager::GetObjectEntry<SmallSceneryEntry>(scenerySelection.EntryIndex);
|
||||
auto sceneryEntry = ObjectManager::GetObjectEntry<SmallSceneryEntry>(scenerySelection.EntryIndex);
|
||||
auto imageId = ImageId(sceneryEntry->image + gWindowSceneryRotation);
|
||||
if (sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_HAS_PRIMARY_COLOUR))
|
||||
{
|
||||
@@ -1844,7 +1835,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
gMapSelectPositionB.y = mapTile.y;
|
||||
}
|
||||
|
||||
auto* sceneryEntry = OpenRCT2::ObjectManager::GetObjectEntry<SmallSceneryEntry>(selection.EntryIndex);
|
||||
auto* sceneryEntry = ObjectManager::GetObjectEntry<SmallSceneryEntry>(selection.EntryIndex);
|
||||
|
||||
gMapSelectType = MAP_SELECT_TYPE_FULL;
|
||||
if (!sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_FULL_TILE) && !gWindowSceneryScatterEnabled)
|
||||
@@ -1991,7 +1982,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
return;
|
||||
}
|
||||
|
||||
auto* sceneryEntry = OpenRCT2::ObjectManager::GetObjectEntry<LargeSceneryEntry>(selection.EntryIndex);
|
||||
auto* sceneryEntry = ObjectManager::GetObjectEntry<LargeSceneryEntry>(selection.EntryIndex);
|
||||
gMapSelectionTiles.clear();
|
||||
|
||||
for (auto& tile : sceneryEntry->tiles)
|
||||
@@ -2096,14 +2087,14 @@ namespace OpenRCT2::Ui::Windows
|
||||
SceneryRemoveGhostToolPlacement();
|
||||
|
||||
// 6e252b
|
||||
auto smallSceneryPlaceAction = SmallSceneryPlaceAction(
|
||||
auto smallSceneryPlaceAction = GameActions::SmallSceneryPlaceAction(
|
||||
loc, quadrant, entryIndex, primaryColour, secondaryColour, tertiaryColour);
|
||||
smallSceneryPlaceAction.SetFlags(GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED);
|
||||
auto res = GameActions::Execute(&smallSceneryPlaceAction);
|
||||
if (res.Error != GameActions::Status::Ok)
|
||||
return kMoney64Undefined;
|
||||
|
||||
const auto placementData = res.GetData<SmallSceneryPlaceActionResult>();
|
||||
const auto placementData = res.GetData<GameActions::SmallSceneryPlaceActionResult>();
|
||||
|
||||
gSceneryPlaceRotation = loc.direction;
|
||||
gSceneryPlaceObject.SceneryType = SCENERY_TYPE_SMALL;
|
||||
@@ -2131,7 +2122,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
SceneryRemoveGhostToolPlacement();
|
||||
|
||||
// 6e265b
|
||||
auto footpathAdditionPlaceAction = FootpathAdditionPlaceAction(loc, entryIndex);
|
||||
auto footpathAdditionPlaceAction = GameActions::FootpathAdditionPlaceAction(loc, entryIndex);
|
||||
footpathAdditionPlaceAction.SetFlags(GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED);
|
||||
footpathAdditionPlaceAction.SetCallback([=](const GameAction* ga, const GameActions::Result* result) {
|
||||
if (result->Error != GameActions::Status::Ok)
|
||||
@@ -2155,14 +2146,15 @@ namespace OpenRCT2::Ui::Windows
|
||||
SceneryRemoveGhostToolPlacement();
|
||||
|
||||
// 6e26b0
|
||||
auto wallPlaceAction = WallPlaceAction(entryIndex, loc, edge, primaryColour, secondaryColour, tertiaryColour);
|
||||
auto wallPlaceAction = GameActions::WallPlaceAction(
|
||||
entryIndex, loc, edge, primaryColour, secondaryColour, tertiaryColour);
|
||||
wallPlaceAction.SetFlags(
|
||||
GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND);
|
||||
wallPlaceAction.SetCallback([=](const GameAction* ga, const GameActions::Result* result) {
|
||||
if (result->Error != GameActions::Status::Ok)
|
||||
return;
|
||||
|
||||
const auto placementData = result->GetData<WallPlaceActionResult>();
|
||||
const auto placementData = result->GetData<GameActions::WallPlaceActionResult>();
|
||||
gSceneryGhostPosition = { loc, placementData.BaseHeight };
|
||||
gSceneryGhostWallRotation = edge;
|
||||
|
||||
@@ -2183,14 +2175,15 @@ namespace OpenRCT2::Ui::Windows
|
||||
SceneryRemoveGhostToolPlacement();
|
||||
|
||||
// 6e25a7
|
||||
auto sceneryPlaceAction = LargeSceneryPlaceAction(loc, entryIndex, primaryColour, secondaryColour, tertiaryColour);
|
||||
auto sceneryPlaceAction = GameActions::LargeSceneryPlaceAction(
|
||||
loc, entryIndex, primaryColour, secondaryColour, tertiaryColour);
|
||||
sceneryPlaceAction.SetFlags(
|
||||
GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND);
|
||||
auto res = GameActions::Execute(&sceneryPlaceAction);
|
||||
if (res.Error != GameActions::Status::Ok)
|
||||
return kMoney64Undefined;
|
||||
|
||||
const auto placementData = res.GetData<LargeSceneryPlaceActionResult>();
|
||||
const auto placementData = res.GetData<GameActions::LargeSceneryPlaceActionResult>();
|
||||
|
||||
gSceneryPlaceRotation = loc.direction;
|
||||
|
||||
@@ -2216,7 +2209,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
// 6e2612
|
||||
auto primaryColour = _sceneryPrimaryColour;
|
||||
auto bannerPlaceAction = BannerPlaceAction(loc, entryIndex, primaryColour);
|
||||
auto bannerPlaceAction = GameActions::BannerPlaceAction(loc, entryIndex, primaryColour);
|
||||
bannerPlaceAction.SetFlags(
|
||||
GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND);
|
||||
auto res = GameActions::Execute(&bannerPlaceAction);
|
||||
@@ -2251,7 +2244,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
return;
|
||||
|
||||
uint8_t quadrant = info.Element->AsSmallScenery()->GetSceneryQuadrant();
|
||||
auto repaintScenery = SmallScenerySetColourAction(
|
||||
auto repaintScenery = GameActions::SmallScenerySetColourAction(
|
||||
{ info.Loc, info.Element->GetBaseZ() }, quadrant, info.Element->AsSmallScenery()->GetEntryIndex(),
|
||||
_sceneryPrimaryColour, _scenerySecondaryColour, _sceneryTertiaryColour);
|
||||
|
||||
@@ -2266,7 +2259,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
if (!(scenery_entry->flags & (WALL_SCENERY_HAS_PRIMARY_COLOUR | WALL_SCENERY_HAS_GLASS)))
|
||||
return;
|
||||
|
||||
auto repaintScenery = WallSetColourAction(
|
||||
auto repaintScenery = GameActions::WallSetColourAction(
|
||||
{ info.Loc, info.Element->GetBaseZ(), info.Element->GetDirection() }, _sceneryPrimaryColour,
|
||||
_scenerySecondaryColour, _sceneryTertiaryColour);
|
||||
|
||||
@@ -2281,7 +2274,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
if (!(sceneryEntry->flags & LARGE_SCENERY_FLAG_HAS_PRIMARY_COLOUR))
|
||||
return;
|
||||
|
||||
auto repaintScenery = LargeScenerySetColourAction(
|
||||
auto repaintScenery = GameActions::LargeScenerySetColourAction(
|
||||
{ info.Loc, info.Element->GetBaseZ(), info.Element->GetDirection() },
|
||||
info.Element->AsLargeScenery()->GetSequenceIndex(), _sceneryPrimaryColour, _scenerySecondaryColour,
|
||||
_sceneryTertiaryColour);
|
||||
@@ -2294,10 +2287,10 @@ namespace OpenRCT2::Ui::Windows
|
||||
auto banner = info.Element->AsBanner()->GetBanner();
|
||||
if (banner != nullptr)
|
||||
{
|
||||
auto* bannerEntry = OpenRCT2::ObjectManager::GetObjectEntry<BannerSceneryEntry>(banner->type);
|
||||
auto* bannerEntry = ObjectManager::GetObjectEntry<BannerSceneryEntry>(banner->type);
|
||||
if (bannerEntry->flags & BANNER_ENTRY_FLAG_HAS_PRIMARY_COLOUR)
|
||||
{
|
||||
auto repaintScenery = BannerSetColourAction(
|
||||
auto repaintScenery = GameActions::BannerSetColourAction(
|
||||
{ info.Loc, info.Element->GetBaseZ(), info.Element->AsBanner()->GetPosition() },
|
||||
_sceneryPrimaryColour);
|
||||
|
||||
@@ -2323,7 +2316,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
SmallSceneryElement* sceneryElement = info.Element->AsSmallScenery();
|
||||
auto entryIndex = sceneryElement->GetEntryIndex();
|
||||
auto* sceneryEntry = OpenRCT2::ObjectManager::GetObjectEntry<SmallSceneryEntry>(entryIndex);
|
||||
auto* sceneryEntry = ObjectManager::GetObjectEntry<SmallSceneryEntry>(entryIndex);
|
||||
if (sceneryEntry != nullptr)
|
||||
{
|
||||
WindowScenerySetSelectedItem(
|
||||
@@ -2336,7 +2329,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
case ViewportInteractionItem::Wall:
|
||||
{
|
||||
auto entryIndex = info.Element->AsWall()->GetEntryIndex();
|
||||
auto* sceneryEntry = OpenRCT2::ObjectManager::GetObjectEntry<WallSceneryEntry>(entryIndex);
|
||||
auto* sceneryEntry = ObjectManager::GetObjectEntry<WallSceneryEntry>(entryIndex);
|
||||
if (sceneryEntry != nullptr)
|
||||
{
|
||||
WindowScenerySetSelectedItem(
|
||||
@@ -2349,7 +2342,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
case ViewportInteractionItem::LargeScenery:
|
||||
{
|
||||
auto entryIndex = info.Element->AsLargeScenery()->GetEntryIndex();
|
||||
auto* sceneryEntry = OpenRCT2::ObjectManager::GetObjectEntry<LargeSceneryEntry>(entryIndex);
|
||||
auto* sceneryEntry = ObjectManager::GetObjectEntry<LargeSceneryEntry>(entryIndex);
|
||||
if (sceneryEntry != nullptr)
|
||||
{
|
||||
WindowScenerySetSelectedItem(
|
||||
@@ -2364,7 +2357,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
auto banner = info.Element->AsBanner()->GetBanner();
|
||||
if (banner != nullptr)
|
||||
{
|
||||
auto sceneryEntry = OpenRCT2::ObjectManager::GetObjectEntry<BannerSceneryEntry>(banner->type);
|
||||
auto sceneryEntry = ObjectManager::GetObjectEntry<BannerSceneryEntry>(banner->type);
|
||||
if (sceneryEntry != nullptr)
|
||||
{
|
||||
WindowScenerySetSelectedItem(
|
||||
@@ -2376,7 +2369,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
case ViewportInteractionItem::PathAddition:
|
||||
{
|
||||
auto entryIndex = info.Element->AsPath()->GetAdditionEntryIndex();
|
||||
auto* pathAdditionEntry = OpenRCT2::ObjectManager::GetObjectEntry<PathAdditionEntry>(entryIndex);
|
||||
auto* pathAdditionEntry = ObjectManager::GetObjectEntry<PathAdditionEntry>(entryIndex);
|
||||
if (pathAdditionEntry != nullptr)
|
||||
{
|
||||
WindowScenerySetSelectedItem(
|
||||
@@ -2481,7 +2474,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
std::numeric_limits<decltype(TileElement::BaseHeight)>::max() - 32);
|
||||
bool can_raise_item = false;
|
||||
|
||||
const auto* sceneryEntry = OpenRCT2::ObjectManager::GetObjectEntry<SmallSceneryEntry>(sceneryIndex);
|
||||
const auto* sceneryEntry = ObjectManager::GetObjectEntry<SmallSceneryEntry>(sceneryIndex);
|
||||
if (sceneryEntry == nullptr)
|
||||
{
|
||||
gridPos.SetNull();
|
||||
@@ -2712,7 +2705,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
uint16_t maxPossibleHeight = ZoomLevel::max().ApplyTo(
|
||||
std::numeric_limits<decltype(TileElement::BaseHeight)>::max() - 32);
|
||||
|
||||
auto* wallEntry = OpenRCT2::ObjectManager::GetObjectEntry<WallSceneryEntry>(sceneryIndex);
|
||||
auto* wallEntry = ObjectManager::GetObjectEntry<WallSceneryEntry>(sceneryIndex);
|
||||
if (wallEntry != nullptr)
|
||||
{
|
||||
maxPossibleHeight -= wallEntry->height;
|
||||
@@ -2803,7 +2796,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
uint16_t maxPossibleHeight = ZoomLevel::max().ApplyTo(
|
||||
std::numeric_limits<decltype(TileElement::BaseHeight)>::max() - 32);
|
||||
|
||||
auto* sceneryEntry = OpenRCT2::ObjectManager::GetObjectEntry<LargeSceneryEntry>(sceneryIndex);
|
||||
auto* sceneryEntry = ObjectManager::GetObjectEntry<LargeSceneryEntry>(sceneryIndex);
|
||||
if (sceneryEntry)
|
||||
{
|
||||
int16_t maxClearZ = 0;
|
||||
@@ -3000,7 +2993,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
for (int32_t q = 0; q < quantity; q++)
|
||||
{
|
||||
int32_t zCoordinate = gSceneryPlaceZ;
|
||||
auto* sceneryEntry = OpenRCT2::ObjectManager::GetObjectEntry<SmallSceneryEntry>(selectedScenery);
|
||||
auto* sceneryEntry = ObjectManager::GetObjectEntry<SmallSceneryEntry>(selectedScenery);
|
||||
|
||||
int16_t cur_grid_x = gridPos.x;
|
||||
int16_t cur_grid_y = gridPos.y;
|
||||
@@ -3038,7 +3031,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
// Try find a valid z coordinate
|
||||
for (; zAttemptRange != 0; zAttemptRange--)
|
||||
{
|
||||
auto smallSceneryPlaceAction = SmallSceneryPlaceAction(
|
||||
auto smallSceneryPlaceAction = GameActions::SmallSceneryPlaceAction(
|
||||
{ cur_grid_x, cur_grid_y, gSceneryPlaceZ, gSceneryPlaceRotation }, quadrant, selectedScenery,
|
||||
_sceneryPrimaryColour, _scenerySecondaryColour, _sceneryTertiaryColour);
|
||||
auto res = GameActions::Query(&smallSceneryPlaceAction);
|
||||
@@ -3061,14 +3054,14 @@ namespace OpenRCT2::Ui::Windows
|
||||
// Actually place
|
||||
if (success == GameActions::Status::Ok || ((q + 1 == quantity) && forceError))
|
||||
{
|
||||
auto smallSceneryPlaceAction = SmallSceneryPlaceAction(
|
||||
auto smallSceneryPlaceAction = GameActions::SmallSceneryPlaceAction(
|
||||
{ cur_grid_x, cur_grid_y, gSceneryPlaceZ, gSceneryPlaceRotation }, quadrant, selectedScenery,
|
||||
_sceneryPrimaryColour, _scenerySecondaryColour, _sceneryTertiaryColour);
|
||||
|
||||
smallSceneryPlaceAction.SetCallback([=](const GameAction* ga, const GameActions::Result* result) {
|
||||
if (result->Error == GameActions::Status::Ok)
|
||||
{
|
||||
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::PlaceItem, result->Position);
|
||||
Audio::Play3D(Audio::SoundId::PlaceItem, result->Position);
|
||||
}
|
||||
});
|
||||
auto res = GameActions::Execute(&smallSceneryPlaceAction);
|
||||
@@ -3093,14 +3086,15 @@ namespace OpenRCT2::Ui::Windows
|
||||
if (gridPos.IsNull())
|
||||
return;
|
||||
|
||||
auto footpathAdditionPlaceAction = FootpathAdditionPlaceAction({ gridPos, z }, selectedScenery);
|
||||
auto footpathAdditionPlaceAction = GameActions::FootpathAdditionPlaceAction(
|
||||
{ gridPos, z }, selectedScenery);
|
||||
|
||||
footpathAdditionPlaceAction.SetCallback([](const GameAction* ga, const GameActions::Result* result) {
|
||||
if (result->Error != GameActions::Status::Ok)
|
||||
{
|
||||
return;
|
||||
}
|
||||
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::PlaceItem, result->Position);
|
||||
Audio::Play3D(Audio::SoundId::PlaceItem, result->Position);
|
||||
});
|
||||
auto res = GameActions::Execute(&footpathAdditionPlaceAction);
|
||||
break;
|
||||
@@ -3120,7 +3114,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
for (; zAttemptRange != 0; zAttemptRange--)
|
||||
{
|
||||
auto wallPlaceAction = WallPlaceAction(
|
||||
auto wallPlaceAction = GameActions::WallPlaceAction(
|
||||
selectedScenery, { gridPos, gSceneryPlaceZ }, edges, _sceneryPrimaryColour, _scenerySecondaryColour,
|
||||
_sceneryTertiaryColour);
|
||||
|
||||
@@ -3144,14 +3138,14 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
}
|
||||
|
||||
auto wallPlaceAction = WallPlaceAction(
|
||||
auto wallPlaceAction = GameActions::WallPlaceAction(
|
||||
selectedScenery, { gridPos, gSceneryPlaceZ }, edges, _sceneryPrimaryColour, _scenerySecondaryColour,
|
||||
_sceneryTertiaryColour);
|
||||
|
||||
wallPlaceAction.SetCallback([](const GameAction* ga, const GameActions::Result* result) {
|
||||
if (result->Error == GameActions::Status::Ok)
|
||||
{
|
||||
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::PlaceItem, result->Position);
|
||||
Audio::Play3D(Audio::SoundId::PlaceItem, result->Position);
|
||||
}
|
||||
});
|
||||
auto res = GameActions::Execute(&wallPlaceAction);
|
||||
@@ -3174,7 +3168,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
CoordsXYZD loc = { gridPos, gSceneryPlaceZ, direction };
|
||||
|
||||
auto sceneryPlaceAction = LargeSceneryPlaceAction(
|
||||
auto sceneryPlaceAction = GameActions::LargeSceneryPlaceAction(
|
||||
loc, selectedScenery, _sceneryPrimaryColour, _scenerySecondaryColour, _sceneryTertiaryColour);
|
||||
|
||||
auto res = GameActions::Query(&sceneryPlaceAction);
|
||||
@@ -3199,16 +3193,16 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
CoordsXYZD loc = { gridPos, gSceneryPlaceZ, direction };
|
||||
|
||||
auto sceneryPlaceAction = LargeSceneryPlaceAction(
|
||||
auto sceneryPlaceAction = GameActions::LargeSceneryPlaceAction(
|
||||
loc, selectedScenery, _sceneryPrimaryColour, _scenerySecondaryColour, _sceneryTertiaryColour);
|
||||
sceneryPlaceAction.SetCallback([=](const GameAction* ga, const GameActions::Result* result) {
|
||||
if (result->Error == GameActions::Status::Ok)
|
||||
{
|
||||
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::PlaceItem, result->Position);
|
||||
Audio::Play3D(Audio::SoundId::PlaceItem, result->Position);
|
||||
}
|
||||
else
|
||||
{
|
||||
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::Error, { loc.x, loc.y, gSceneryPlaceZ });
|
||||
Audio::Play3D(Audio::SoundId::Error, { loc.x, loc.y, gSceneryPlaceZ });
|
||||
}
|
||||
});
|
||||
auto res = GameActions::Execute(&sceneryPlaceAction);
|
||||
@@ -3224,12 +3218,12 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
CoordsXYZD loc{ gridPos, z, direction };
|
||||
auto primaryColour = _sceneryPrimaryColour;
|
||||
auto bannerPlaceAction = BannerPlaceAction(loc, selectedScenery, primaryColour);
|
||||
auto bannerPlaceAction = GameActions::BannerPlaceAction(loc, selectedScenery, primaryColour);
|
||||
bannerPlaceAction.SetCallback([=](const GameAction* ga, const GameActions::Result* result) {
|
||||
if (result->Error == GameActions::Status::Ok)
|
||||
{
|
||||
auto data = result->GetData<BannerPlaceActionResult>();
|
||||
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::PlaceItem, result->Position);
|
||||
auto data = result->GetData<GameActions::BannerPlaceActionResult>();
|
||||
Audio::Play3D(Audio::SoundId::PlaceItem, result->Position);
|
||||
ContextOpenDetailWindow(WD_BANNER, data.bannerId.ToUnderlying());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -172,12 +172,12 @@ namespace OpenRCT2::Ui::Windows
|
||||
if (_isSmall)
|
||||
{
|
||||
CoordsXYZD wallLocation = { bannerCoords, tileElement->GetBaseZ(), tileElement->GetDirection() };
|
||||
auto wallRemoveAction = WallRemoveAction(wallLocation);
|
||||
auto wallRemoveAction = GameActions::WallRemoveAction(wallLocation);
|
||||
GameActions::Execute(&wallRemoveAction);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto sceneryRemoveAction = LargeSceneryRemoveAction(
|
||||
auto sceneryRemoveAction = GameActions::LargeSceneryRemoveAction(
|
||||
{ bannerCoords, tileElement->GetBaseZ(), tileElement->GetDirection() },
|
||||
tileElement->AsLargeScenery()->GetSequenceIndex());
|
||||
GameActions::Execute(&sceneryRemoveAction);
|
||||
@@ -213,7 +213,8 @@ namespace OpenRCT2::Ui::Windows
|
||||
if (dropdownIndex == -1)
|
||||
return;
|
||||
_mainColour = ColourDropDownIndexToColour(dropdownIndex);
|
||||
auto signSetStyleAction = SignSetStyleAction(GetBannerIndex(), _mainColour, _textColour, !_isSmall);
|
||||
auto signSetStyleAction = GameActions::SignSetStyleAction(
|
||||
GetBannerIndex(), _mainColour, _textColour, !_isSmall);
|
||||
GameActions::Execute(&signSetStyleAction);
|
||||
break;
|
||||
}
|
||||
@@ -222,7 +223,8 @@ namespace OpenRCT2::Ui::Windows
|
||||
if (dropdownIndex == -1)
|
||||
return;
|
||||
_textColour = ColourDropDownIndexToColour(dropdownIndex);
|
||||
auto signSetStyleAction = SignSetStyleAction(GetBannerIndex(), _mainColour, _textColour, !_isSmall);
|
||||
auto signSetStyleAction = GameActions::SignSetStyleAction(
|
||||
GetBannerIndex(), _mainColour, _textColour, !_isSmall);
|
||||
GameActions::Execute(&signSetStyleAction);
|
||||
break;
|
||||
}
|
||||
@@ -237,7 +239,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
if (widgetIndex == WIDX_SIGN_TEXT && !text.empty())
|
||||
{
|
||||
auto signSetNameAction = SignSetNameAction(GetBannerIndex(), std::string(text));
|
||||
auto signSetNameAction = GameActions::SignSetNameAction(GetBannerIndex(), std::string(text));
|
||||
GameActions::Execute(&signSetNameAction);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,8 +381,9 @@ namespace OpenRCT2::Ui::Windows
|
||||
_pickedPeepOldX = staff->x;
|
||||
CoordsXYZ nullLoc{};
|
||||
nullLoc.SetNull();
|
||||
PeepPickupAction pickupAction{ PeepPickupType::Pickup, EntityId::FromUnderlying(number), nullLoc,
|
||||
NetworkGetCurrentPlayerId() };
|
||||
GameActions::PeepPickupAction pickupAction{ GameActions::PeepPickupType::Pickup,
|
||||
EntityId::FromUnderlying(number), nullLoc,
|
||||
NetworkGetCurrentPlayerId() };
|
||||
pickupAction.SetCallback([peepnum = number](const GameAction* ga, const GameActions::Result* result) {
|
||||
if (result->Error != GameActions::Status::Ok)
|
||||
return;
|
||||
@@ -480,8 +481,8 @@ namespace OpenRCT2::Ui::Windows
|
||||
auto* windowMgr = Ui::GetWindowManager();
|
||||
windowMgr->CloseByClass(WindowClass::PatrolArea);
|
||||
|
||||
auto staffSetPatrolAreaAction = StaffSetPatrolAreaAction(
|
||||
staff->Id, {}, StaffSetPatrolAreaMode::ClearAll);
|
||||
auto staffSetPatrolAreaAction = GameActions::StaffSetPatrolAreaAction(
|
||||
staff->Id, {}, GameActions::StaffSetPatrolAreaMode::ClearAll);
|
||||
GameActions::Execute(&staffSetPatrolAreaAction);
|
||||
}
|
||||
else
|
||||
@@ -706,9 +707,10 @@ namespace OpenRCT2::Ui::Windows
|
||||
if (destCoords.IsNull())
|
||||
return;
|
||||
|
||||
PeepPickupAction pickupAction{
|
||||
PeepPickupType::Place, staffEntityId, { destCoords, tileElement->GetBaseZ() }, NetworkGetCurrentPlayerId()
|
||||
};
|
||||
GameActions::PeepPickupAction pickupAction{ GameActions::PeepPickupType::Place,
|
||||
staffEntityId,
|
||||
{ destCoords, tileElement->GetBaseZ() },
|
||||
NetworkGetCurrentPlayerId() };
|
||||
pickupAction.SetCallback([](const GameAction* ga, const GameActions::Result* result) {
|
||||
if (result->Error != GameActions::Status::Ok)
|
||||
return;
|
||||
@@ -723,9 +725,10 @@ namespace OpenRCT2::Ui::Windows
|
||||
if (widgetIndex != WIDX_PICKUP)
|
||||
return;
|
||||
|
||||
PeepPickupAction pickupAction{
|
||||
PeepPickupType::Cancel, EntityId::FromUnderlying(number), { _pickedPeepOldX, 0, 0 }, NetworkGetCurrentPlayerId()
|
||||
};
|
||||
GameActions::PeepPickupAction pickupAction{ GameActions::PeepPickupType::Cancel,
|
||||
EntityId::FromUnderlying(number),
|
||||
{ _pickedPeepOldX, 0, 0 },
|
||||
NetworkGetCurrentPlayerId() };
|
||||
GameActions::Execute(&pickupAction);
|
||||
}
|
||||
|
||||
@@ -742,7 +745,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
if (text.empty())
|
||||
return;
|
||||
|
||||
auto gameAction = StaffSetNameAction(EntityId::FromUnderlying(number), std::string{ text });
|
||||
auto gameAction = GameActions::StaffSetNameAction(EntityId::FromUnderlying(number), std::string{ text });
|
||||
GameActions::Execute(&gameAction);
|
||||
}
|
||||
#pragma endregion
|
||||
@@ -812,7 +815,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
return;
|
||||
|
||||
ObjectEntryIndex costume = _availableCostumes[dropdownIndex].index;
|
||||
auto staffSetCostumeAction = StaffSetCostumeAction(EntityId::FromUnderlying(number), costume);
|
||||
auto staffSetCostumeAction = GameActions::StaffSetCostumeAction(EntityId::FromUnderlying(number), costume);
|
||||
GameActions::Execute(&staffSetCostumeAction);
|
||||
}
|
||||
|
||||
@@ -1099,7 +1102,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
|
||||
uint8_t newOrders = staff->StaffOrders ^ (1 << orderId);
|
||||
auto staffSetOrdersAction = StaffSetOrdersAction(EntityId::FromUnderlying(number), newOrders);
|
||||
auto staffSetOrdersAction = GameActions::StaffSetOrdersAction(EntityId::FromUnderlying(number), newOrders);
|
||||
GameActions::Execute(&staffSetOrdersAction);
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
case WIDX_YES:
|
||||
{
|
||||
auto staffFireAction = StaffFireAction(EntityId::FromUnderlying(number));
|
||||
auto staffFireAction = GameActions::StaffFireAction(EntityId::FromUnderlying(number));
|
||||
GameActions::Execute(&staffFireAction);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -232,7 +232,8 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
if (widgetIndex == WIDX_STAFF_LIST_UNIFORM_COLOUR_PICKER)
|
||||
{
|
||||
auto action = StaffSetColourAction(GetSelectedStaffType(), ColourDropDownIndexToColour(dropdownIndex));
|
||||
auto action = GameActions::StaffSetColourAction(
|
||||
GetSelectedStaffType(), ColourDropDownIndexToColour(dropdownIndex));
|
||||
GameActions::Execute(&action);
|
||||
}
|
||||
}
|
||||
@@ -341,7 +342,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
if (_quickFireMode)
|
||||
{
|
||||
auto staffFireAction = StaffFireAction(entry.Id);
|
||||
auto staffFireAction = GameActions::StaffFireAction(entry.Id);
|
||||
GameActions::Execute(&staffFireAction);
|
||||
}
|
||||
else
|
||||
@@ -536,12 +537,12 @@ namespace OpenRCT2::Ui::Windows
|
||||
else
|
||||
costume = findPeepAnimationsIndexForType(animPeepType);
|
||||
|
||||
auto hireStaffAction = StaffHireNewAction(autoPosition, staffType, costume, staffOrders);
|
||||
auto hireStaffAction = GameActions::StaffHireNewAction(autoPosition, staffType, costume, staffOrders);
|
||||
hireStaffAction.SetCallback([=](const GameAction*, const GameActions::Result* res) -> void {
|
||||
if (res->Error != GameActions::Status::Ok)
|
||||
return;
|
||||
|
||||
auto actionResult = res->GetData<StaffHireNewActionResult>();
|
||||
auto actionResult = res->GetData<GameActions::StaffHireNewActionResult>();
|
||||
auto* staff = GetEntity<Staff>(actionResult.StaffEntityId);
|
||||
if (staff == nullptr)
|
||||
return;
|
||||
@@ -552,7 +553,8 @@ namespace OpenRCT2::Ui::Windows
|
||||
CoordsXYZ nullLoc{};
|
||||
nullLoc.SetNull();
|
||||
|
||||
PeepPickupAction pickupAction{ PeepPickupType::Pickup, staff->Id, nullLoc, NetworkGetCurrentPlayerId() };
|
||||
GameActions::PeepPickupAction pickupAction{ GameActions::PeepPickupType::Pickup, staff->Id, nullLoc,
|
||||
NetworkGetCurrentPlayerId() };
|
||||
pickupAction.SetCallback([staffId = staff->Id](const GameAction* ga, const GameActions::Result* result) {
|
||||
if (result->Error != GameActions::Status::Ok)
|
||||
return;
|
||||
|
||||
@@ -1866,14 +1866,14 @@ static uint64_t PageDisabledWidgets[] = {
|
||||
void RemoveElement(int32_t elementIndex)
|
||||
{
|
||||
Guard::Assert(elementIndex >= 0 && elementIndex < windowTileInspectorElementCount, "elementIndex out of range");
|
||||
auto modifyTile = TileModifyAction(_toolMap, TileModifyType::AnyRemove, elementIndex);
|
||||
auto modifyTile = GameActions::TileModifyAction(_toolMap, GameActions::TileModifyType::AnyRemove, elementIndex);
|
||||
GameActions::Execute(&modifyTile);
|
||||
}
|
||||
|
||||
void RotateElement(int32_t elementIndex)
|
||||
{
|
||||
Guard::Assert(elementIndex >= 0 && elementIndex < windowTileInspectorElementCount, "elementIndex out of range");
|
||||
auto modifyTile = TileModifyAction(_toolMap, TileModifyType::AnyRotate, elementIndex);
|
||||
auto modifyTile = GameActions::TileModifyAction(_toolMap, GameActions::TileModifyType::AnyRotate, elementIndex);
|
||||
GameActions::Execute(&modifyTile);
|
||||
}
|
||||
|
||||
@@ -1885,14 +1885,14 @@ static uint64_t PageDisabledWidgets[] = {
|
||||
// This might happen if two people are modifying the same tile.
|
||||
if (!firstInRange || !secondInRange)
|
||||
return;
|
||||
auto modifyTile = TileModifyAction(_toolMap, TileModifyType::AnySwap, first, second);
|
||||
auto modifyTile = GameActions::TileModifyAction(_toolMap, GameActions::TileModifyType::AnySwap, first, second);
|
||||
GameActions::Execute(&modifyTile);
|
||||
}
|
||||
|
||||
void SortElements()
|
||||
{
|
||||
Guard::Assert(_tileSelected, "No tile selected");
|
||||
auto modifyTile = TileModifyAction(_toolMap, TileModifyType::AnySort);
|
||||
auto modifyTile = GameActions::TileModifyAction(_toolMap, GameActions::TileModifyType::AnySort);
|
||||
GameActions::Execute(&modifyTile);
|
||||
}
|
||||
|
||||
@@ -1916,50 +1916,56 @@ static uint64_t PageDisabledWidgets[] = {
|
||||
|
||||
void PasteElement()
|
||||
{
|
||||
auto modifyTile = TileModifyAction(_toolMap, TileModifyType::AnyPaste, 0, 0, _copiedElement, _copiedBanner);
|
||||
auto modifyTile = GameActions::TileModifyAction(
|
||||
_toolMap, GameActions::TileModifyType::AnyPaste, 0, 0, _copiedElement, _copiedBanner);
|
||||
GameActions::Execute(&modifyTile);
|
||||
}
|
||||
|
||||
void BaseHeightOffset(int16_t elementIndex, int8_t heightOffset)
|
||||
{
|
||||
auto modifyTile = TileModifyAction(_toolMap, TileModifyType::AnyBaseHeightOffset, elementIndex, heightOffset);
|
||||
auto modifyTile = GameActions::TileModifyAction(
|
||||
_toolMap, GameActions::TileModifyType::AnyBaseHeightOffset, elementIndex, heightOffset);
|
||||
GameActions::Execute(&modifyTile);
|
||||
}
|
||||
|
||||
void SurfaceShowParkFences(bool showFences)
|
||||
{
|
||||
auto modifyTile = TileModifyAction(_toolMap, TileModifyType::SurfaceShowParkFences, showFences);
|
||||
auto modifyTile = GameActions::TileModifyAction(
|
||||
_toolMap, GameActions::TileModifyType::SurfaceShowParkFences, showFences);
|
||||
GameActions::Execute(&modifyTile);
|
||||
}
|
||||
|
||||
void SurfaceToggleCorner(int32_t cornerIndex)
|
||||
{
|
||||
auto modifyTile = TileModifyAction(_toolMap, TileModifyType::SurfaceToggleCorner, cornerIndex);
|
||||
auto modifyTile = GameActions::TileModifyAction(
|
||||
_toolMap, GameActions::TileModifyType::SurfaceToggleCorner, cornerIndex);
|
||||
GameActions::Execute(&modifyTile);
|
||||
}
|
||||
|
||||
void SurfaceToggleDiagonal()
|
||||
{
|
||||
auto modifyTile = TileModifyAction(_toolMap, TileModifyType::SurfaceToggleDiagonal);
|
||||
auto modifyTile = GameActions::TileModifyAction(_toolMap, GameActions::TileModifyType::SurfaceToggleDiagonal);
|
||||
GameActions::Execute(&modifyTile);
|
||||
}
|
||||
|
||||
void PathSetSloped(int32_t elementIndex, bool sloped)
|
||||
{
|
||||
auto modifyTile = TileModifyAction(_toolMap, TileModifyType::PathSetSlope, elementIndex, sloped);
|
||||
auto modifyTile = GameActions::TileModifyAction(
|
||||
_toolMap, GameActions::TileModifyType::PathSetSlope, elementIndex, sloped);
|
||||
GameActions::Execute(&modifyTile);
|
||||
}
|
||||
|
||||
void PathSetJunctionRailings(int32_t elementIndex, bool hasJunctionRailings)
|
||||
{
|
||||
auto modifyTile = TileModifyAction(
|
||||
_toolMap, TileModifyType::PathSetJunctionRailings, elementIndex, hasJunctionRailings);
|
||||
auto modifyTile = GameActions::TileModifyAction(
|
||||
_toolMap, GameActions::TileModifyType::PathSetJunctionRailings, elementIndex, hasJunctionRailings);
|
||||
GameActions::Execute(&modifyTile);
|
||||
}
|
||||
|
||||
void PathSetBroken(int32_t elementIndex, bool broken)
|
||||
{
|
||||
auto modifyTile = TileModifyAction(_toolMap, TileModifyType::PathSetBroken, elementIndex, broken);
|
||||
auto modifyTile = GameActions::TileModifyAction(
|
||||
_toolMap, GameActions::TileModifyType::PathSetBroken, elementIndex, broken);
|
||||
GameActions::Execute(&modifyTile);
|
||||
}
|
||||
|
||||
@@ -1967,14 +1973,16 @@ static uint64_t PageDisabledWidgets[] = {
|
||||
{
|
||||
Guard::Assert(elementIndex >= 0 && elementIndex < windowTileInspectorElementCount, "elementIndex out of range");
|
||||
Guard::Assert(cornerIndex >= 0 && cornerIndex < 8, "cornerIndex out of range");
|
||||
auto modifyTile = TileModifyAction(_toolMap, TileModifyType::PathToggleEdge, elementIndex, cornerIndex);
|
||||
auto modifyTile = GameActions::TileModifyAction(
|
||||
_toolMap, GameActions::TileModifyType::PathToggleEdge, elementIndex, cornerIndex);
|
||||
GameActions::Execute(&modifyTile);
|
||||
}
|
||||
|
||||
void EntranceMakeUsable(int32_t elementIndex)
|
||||
{
|
||||
Guard::ArgumentInRange(elementIndex, 0, windowTileInspectorElementCount - 1);
|
||||
auto modifyTile = TileModifyAction(_toolMap, TileModifyType::EntranceMakeUsable, elementIndex);
|
||||
auto modifyTile = GameActions::TileModifyAction(
|
||||
_toolMap, GameActions::TileModifyType::EntranceMakeUsable, elementIndex);
|
||||
GameActions::Execute(&modifyTile);
|
||||
}
|
||||
|
||||
@@ -1982,41 +1990,45 @@ static uint64_t PageDisabledWidgets[] = {
|
||||
{
|
||||
// Make sure only the correct bits are set
|
||||
Guard::Assert((slopeValue & 3) == slopeValue, "slopeValue doesn't match its mask");
|
||||
auto modifyTile = TileModifyAction(_toolMap, TileModifyType::WallSetSlope, elementIndex, slopeValue);
|
||||
auto modifyTile = GameActions::TileModifyAction(
|
||||
_toolMap, GameActions::TileModifyType::WallSetSlope, elementIndex, slopeValue);
|
||||
GameActions::Execute(&modifyTile);
|
||||
}
|
||||
|
||||
void WallAnimationFrameOffset(int16_t elementIndex, int8_t animationFrameOffset)
|
||||
{
|
||||
auto modifyTile = TileModifyAction(
|
||||
_toolMap, TileModifyType::WallSetAnimationFrame, elementIndex, animationFrameOffset);
|
||||
auto modifyTile = GameActions::TileModifyAction(
|
||||
_toolMap, GameActions::TileModifyType::WallSetAnimationFrame, elementIndex, animationFrameOffset);
|
||||
GameActions::Execute(&modifyTile);
|
||||
}
|
||||
|
||||
void TrackBlockHeightOffset(int32_t elementIndex, int8_t heightOffset)
|
||||
{
|
||||
auto modifyTile = TileModifyAction(_toolMap, TileModifyType::TrackBaseHeightOffset, elementIndex, heightOffset);
|
||||
auto modifyTile = GameActions::TileModifyAction(
|
||||
_toolMap, GameActions::TileModifyType::TrackBaseHeightOffset, elementIndex, heightOffset);
|
||||
GameActions::Execute(&modifyTile);
|
||||
}
|
||||
|
||||
void TrackBlockSetLift(int32_t elementIndex, bool entireTrackBlock, bool chain)
|
||||
{
|
||||
auto modifyTile = TileModifyAction(
|
||||
_toolMap, entireTrackBlock ? TileModifyType::TrackSetChainBlock : TileModifyType::TrackSetChain, elementIndex,
|
||||
chain);
|
||||
auto modifyTile = GameActions::TileModifyAction(
|
||||
_toolMap,
|
||||
entireTrackBlock ? GameActions::TileModifyType::TrackSetChainBlock : GameActions::TileModifyType::TrackSetChain,
|
||||
elementIndex, chain);
|
||||
GameActions::Execute(&modifyTile);
|
||||
}
|
||||
|
||||
void TrackSetBrakeClosed(int32_t elementIndex, bool isClosed)
|
||||
{
|
||||
auto modifyTile = TileModifyAction(_toolMap, TileModifyType::TrackSetBrake, elementIndex, isClosed);
|
||||
auto modifyTile = GameActions::TileModifyAction(
|
||||
_toolMap, GameActions::TileModifyType::TrackSetBrake, elementIndex, isClosed);
|
||||
GameActions::Execute(&modifyTile);
|
||||
}
|
||||
|
||||
void TrackSetIndestructible(int32_t elementIndex, bool isIndestructible)
|
||||
{
|
||||
auto modifyTile = TileModifyAction(
|
||||
_toolMap, TileModifyType::TrackSetIndestructible, elementIndex, isIndestructible);
|
||||
auto modifyTile = GameActions::TileModifyAction(
|
||||
_toolMap, GameActions::TileModifyType::TrackSetIndestructible, elementIndex, isIndestructible);
|
||||
GameActions::Execute(&modifyTile);
|
||||
}
|
||||
|
||||
@@ -2024,16 +2036,17 @@ static uint64_t PageDisabledWidgets[] = {
|
||||
{
|
||||
// quarterIndex is widget index relative to WIDX_SCENERY_CHECK_QUARTER_N, so a value from 0-3
|
||||
Guard::Assert(quarterIndex >= 0 && quarterIndex < 4, "quarterIndex out of range");
|
||||
auto modifyTile = TileModifyAction(
|
||||
_toolMap, TileModifyType::ScenerySetQuarterLocation, elementIndex, (quarterIndex - GetCurrentRotation()) & 3);
|
||||
auto modifyTile = GameActions::TileModifyAction(
|
||||
_toolMap, GameActions::TileModifyType::ScenerySetQuarterLocation, elementIndex,
|
||||
(quarterIndex - GetCurrentRotation()) & 3);
|
||||
GameActions::Execute(&modifyTile);
|
||||
}
|
||||
|
||||
// ToggleQuadrantCollision?
|
||||
void ToggleQuadrantCollosion(int32_t elementIndex, const int32_t quadrantIndex)
|
||||
{
|
||||
auto modifyTile = TileModifyAction(
|
||||
_toolMap, TileModifyType::ScenerySetQuarterCollision, elementIndex,
|
||||
auto modifyTile = GameActions::TileModifyAction(
|
||||
_toolMap, GameActions::TileModifyType::ScenerySetQuarterCollision, elementIndex,
|
||||
(quadrantIndex + 2 - GetCurrentRotation()) & 3);
|
||||
GameActions::Execute(&modifyTile);
|
||||
}
|
||||
@@ -2043,20 +2056,23 @@ static uint64_t PageDisabledWidgets[] = {
|
||||
Guard::Assert(edgeIndex >= 0 && edgeIndex < 4, "edgeIndex out of range");
|
||||
// Make edgeIndex = 0
|
||||
edgeIndex = (edgeIndex - GetCurrentRotation()) & 3;
|
||||
auto modifyTile = TileModifyAction(_toolMap, TileModifyType::BannerToggleBlockingEdge, elementIndex, edgeIndex);
|
||||
auto modifyTile = GameActions::TileModifyAction(
|
||||
_toolMap, GameActions::TileModifyType::BannerToggleBlockingEdge, elementIndex, edgeIndex);
|
||||
GameActions::Execute(&modifyTile);
|
||||
}
|
||||
|
||||
void ToggleInvisibility(int32_t elementIndex)
|
||||
{
|
||||
Guard::Assert(elementIndex >= 0 && elementIndex < windowTileInspectorElementCount, "elementIndex out of range");
|
||||
auto modifyTile = TileModifyAction(_toolMap, TileModifyType::AnyToggleInvisilibity, elementIndex);
|
||||
auto modifyTile = GameActions::TileModifyAction(
|
||||
_toolMap, GameActions::TileModifyType::AnyToggleInvisilibity, elementIndex);
|
||||
GameActions::Execute(&modifyTile);
|
||||
}
|
||||
|
||||
void WallSetAnimationIsBackwards(int32_t elementIndex, bool backwards)
|
||||
{
|
||||
auto modifyTile = TileModifyAction(_toolMap, TileModifyType::WallSetAnimationIsBackwards, elementIndex, backwards);
|
||||
auto modifyTile = GameActions::TileModifyAction(
|
||||
_toolMap, GameActions::TileModifyType::WallSetAnimationIsBackwards, elementIndex, backwards);
|
||||
GameActions::Execute(&modifyTile);
|
||||
}
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
windowMgr->CloseByClass(WindowClass::ScenarioSelect);
|
||||
windowMgr->CloseByClass(WindowClass::ServerList);
|
||||
auto loadOrQuitAction = LoadOrQuitAction(LoadOrQuitModes::OpenSavePrompt);
|
||||
auto loadOrQuitAction = GameActions::LoadOrQuitAction(GameActions::LoadOrQuitModes::OpenSavePrompt);
|
||||
GameActions::Execute(&loadOrQuitAction);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -308,7 +308,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
case WIDX_PAUSE:
|
||||
if (NetworkGetMode() != NETWORK_MODE_CLIENT)
|
||||
{
|
||||
auto pauseToggleAction = PauseToggleAction();
|
||||
auto pauseToggleAction = GameActions::PauseToggleAction();
|
||||
GameActions::Execute(&pauseToggleAction);
|
||||
_waitingForPause = true;
|
||||
}
|
||||
@@ -444,14 +444,14 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
case DDIDX_NEW_GAME:
|
||||
{
|
||||
auto loadOrQuitAction = LoadOrQuitAction(
|
||||
LoadOrQuitModes::OpenSavePrompt, PromptMode::saveBeforeNewGame);
|
||||
auto loadOrQuitAction = GameActions::LoadOrQuitAction(
|
||||
GameActions::LoadOrQuitModes::OpenSavePrompt, PromptMode::saveBeforeNewGame);
|
||||
GameActions::Execute(&loadOrQuitAction);
|
||||
break;
|
||||
}
|
||||
case DDIDX_LOAD_GAME:
|
||||
{
|
||||
auto loadOrQuitAction = LoadOrQuitAction(LoadOrQuitModes::OpenSavePrompt);
|
||||
auto loadOrQuitAction = GameActions::LoadOrQuitAction(GameActions::LoadOrQuitModes::OpenSavePrompt);
|
||||
GameActions::Execute(&loadOrQuitAction);
|
||||
break;
|
||||
}
|
||||
@@ -504,8 +504,8 @@ namespace OpenRCT2::Ui::Windows
|
||||
auto* windowMgr = Ui::GetWindowManager();
|
||||
windowMgr->CloseByClass(WindowClass::ManageTrackDesign);
|
||||
windowMgr->CloseByClass(WindowClass::TrackDeletePrompt);
|
||||
auto loadOrQuitAction = LoadOrQuitAction(
|
||||
LoadOrQuitModes::OpenSavePrompt, PromptMode::saveBeforeQuit);
|
||||
auto loadOrQuitAction = GameActions::LoadOrQuitAction(
|
||||
GameActions::LoadOrQuitModes::OpenSavePrompt, PromptMode::saveBeforeQuit);
|
||||
GameActions::Execute(&loadOrQuitAction);
|
||||
break;
|
||||
}
|
||||
@@ -1299,7 +1299,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
if (newSpeed >= 5)
|
||||
newSpeed = 8;
|
||||
|
||||
auto setSpeedAction = GameSetSpeedAction(newSpeed);
|
||||
auto setSpeedAction = GameActions::GameSetSpeedAction(newSpeed);
|
||||
GameActions::Execute(&setSpeedAction);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
if (res.Error == GameActions::Status::Ok)
|
||||
{
|
||||
// Valid location found. Place the ghost at the location.
|
||||
auto tdAction = TrackDesignAction(trackLoc, *_trackDesign);
|
||||
auto tdAction = GameActions::TrackDesignAction(trackLoc, *_trackDesign);
|
||||
tdAction.SetFlags(GAME_COMMAND_FLAG_NO_SPEND | GAME_COMMAND_FLAG_GHOST);
|
||||
tdAction.SetCallback([&](const GameAction*, const GameActions::Result* result) {
|
||||
if (result->Error == GameActions::Status::Ok)
|
||||
@@ -282,7 +282,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
return;
|
||||
}
|
||||
|
||||
auto tdAction = TrackDesignAction({ trackLoc, _currentTrackPieceDirection }, *_trackDesign);
|
||||
auto tdAction = GameActions::TrackDesignAction({ trackLoc, _currentTrackPieceDirection }, *_trackDesign);
|
||||
tdAction.SetCallback([&](const GameAction*, const GameActions::Result* result) {
|
||||
if (result->Error != GameActions::Status::Ok)
|
||||
{
|
||||
@@ -378,7 +378,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
if (_hasPlacementGhost)
|
||||
{
|
||||
auto tdAction = TrackDesignAction({ _placementGhostLoc }, *_trackDesign);
|
||||
auto tdAction = GameActions::TrackDesignAction({ _placementGhostLoc }, *_trackDesign);
|
||||
tdAction.SetFlags(GAME_COMMAND_FLAG_NO_SPEND | GAME_COMMAND_FLAG_GHOST);
|
||||
auto res = GameActions::Execute(&tdAction);
|
||||
if (res.Error != GameActions::Status::Ok)
|
||||
@@ -703,7 +703,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
GameActions::Result res;
|
||||
for (int32_t i = 0; i < 7; i++, loc.z += kCoordsZStep)
|
||||
{
|
||||
auto tdAction = TrackDesignAction(
|
||||
auto tdAction = GameActions::TrackDesignAction(
|
||||
CoordsXYZD{ loc.x, loc.y, loc.z, _currentTrackPieceDirection }, *_trackDesign);
|
||||
tdAction.SetFlags(newFlags);
|
||||
res = GameActions::Query(&tdAction);
|
||||
|
||||
@@ -260,7 +260,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
gInputDragLast.y += dx;
|
||||
|
||||
auto waterRaiseAction = WaterRaiseAction(
|
||||
auto waterRaiseAction = GameActions::WaterRaiseAction(
|
||||
{ gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y });
|
||||
GameActions::Execute(&waterRaiseAction);
|
||||
|
||||
@@ -276,7 +276,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
gInputDragLast.y += dx;
|
||||
|
||||
auto waterLowerAction = WaterLowerAction(
|
||||
auto waterLowerAction = GameActions::WaterLowerAction(
|
||||
{ gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y });
|
||||
GameActions::Execute(&waterLowerAction);
|
||||
_waterToolRaiseCost = kMoney64Undefined;
|
||||
@@ -301,9 +301,9 @@ namespace OpenRCT2::Ui::Windows
|
||||
if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE))
|
||||
return;
|
||||
|
||||
auto waterLowerAction = WaterLowerAction(
|
||||
auto waterLowerAction = GameActions::WaterLowerAction(
|
||||
{ gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y });
|
||||
auto waterRaiseAction = WaterRaiseAction(
|
||||
auto waterRaiseAction = GameActions::WaterRaiseAction(
|
||||
{ gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y });
|
||||
|
||||
auto res = GameActions::Query(&waterLowerAction);
|
||||
@@ -392,9 +392,9 @@ namespace OpenRCT2::Ui::Windows
|
||||
if (!state_changed)
|
||||
return;
|
||||
|
||||
auto waterLowerAction = WaterLowerAction(
|
||||
auto waterLowerAction = GameActions::WaterLowerAction(
|
||||
{ gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y });
|
||||
auto waterRaiseAction = WaterRaiseAction(
|
||||
auto waterRaiseAction = GameActions::WaterRaiseAction(
|
||||
{ gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y });
|
||||
|
||||
auto res = GameActions::Query(&waterLowerAction);
|
||||
|
||||
@@ -61,7 +61,7 @@ void CheatsReset()
|
||||
|
||||
void CheatsSet(CheatType cheatType, int64_t param1 /* = 0*/, int64_t param2 /* = 0*/)
|
||||
{
|
||||
auto cheatSetAction = CheatSetAction(cheatType, param1, param2);
|
||||
auto cheatSetAction = GameActions::CheatSetAction(cheatType, param1, param2);
|
||||
GameActions::Execute(&cheatSetAction);
|
||||
}
|
||||
|
||||
|
||||
@@ -238,11 +238,12 @@ namespace OpenRCT2::Editor
|
||||
auto& gameState = getGameState();
|
||||
MapRange range = { 2 * kCoordsXYStep, 2 * kCoordsXYStep, (gameState.mapSize.x - 3) * kCoordsXYStep,
|
||||
(gameState.mapSize.y - 3) * kCoordsXYStep };
|
||||
auto landSetRightsAction = LandSetRightsAction(range, LandSetRightSetting::SetForSale);
|
||||
|
||||
auto landSetRightsAction = GameActions::LandSetRightsAction(range, GameActions::LandSetRightSetting::SetForSale);
|
||||
landSetRightsAction.SetFlags(GAME_COMMAND_FLAG_NO_SPEND);
|
||||
GameActions::Execute(&landSetRightsAction);
|
||||
|
||||
auto landBuyRightsAction = LandBuyRightsAction(range, LandBuyRightSetting::BuyLand);
|
||||
auto landBuyRightsAction = GameActions::LandBuyRightsAction(range, GameActions::LandBuyRightSetting::BuyLand);
|
||||
landBuyRightsAction.SetFlags(GAME_COMMAND_FLAG_NO_SPEND);
|
||||
GameActions::Execute(&landBuyRightsAction);
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ using namespace OpenRCT2;
|
||||
|
||||
void GameResetSpeed()
|
||||
{
|
||||
auto setSpeedAction = GameSetSpeedAction(1);
|
||||
auto setSpeedAction = GameActions::GameSetSpeedAction(1);
|
||||
GameActions::Execute(&setSpeedAction);
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ void GameIncreaseGameSpeed()
|
||||
if (newSpeed == 5)
|
||||
newSpeed = 8;
|
||||
|
||||
auto setSpeedAction = GameSetSpeedAction(newSpeed);
|
||||
auto setSpeedAction = GameActions::GameSetSpeedAction(newSpeed);
|
||||
GameActions::Execute(&setSpeedAction);
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ void GameReduceGameSpeed()
|
||||
if (newSpeed == 7)
|
||||
newSpeed = 4;
|
||||
|
||||
auto setSpeedAction = GameSetSpeedAction(newSpeed);
|
||||
auto setSpeedAction = GameActions::GameSetSpeedAction(newSpeed);
|
||||
GameActions::Execute(&setSpeedAction);
|
||||
}
|
||||
|
||||
@@ -655,7 +655,7 @@ void GameLoadOrQuitNoSavePrompt()
|
||||
{
|
||||
case PromptMode::saveBeforeLoad:
|
||||
{
|
||||
auto loadOrQuitAction = LoadOrQuitAction(LoadOrQuitModes::CloseSavePrompt);
|
||||
auto loadOrQuitAction = GameActions::LoadOrQuitAction(GameActions::LoadOrQuitModes::CloseSavePrompt);
|
||||
GameActions::Execute(&loadOrQuitAction);
|
||||
ToolCancel();
|
||||
if (gLegacyScene == LegacyScene::scenarioEditor)
|
||||
@@ -674,7 +674,7 @@ void GameLoadOrQuitNoSavePrompt()
|
||||
}
|
||||
case PromptMode::saveBeforeQuit:
|
||||
{
|
||||
auto loadOrQuitAction = LoadOrQuitAction(LoadOrQuitModes::CloseSavePrompt);
|
||||
auto loadOrQuitAction = GameActions::LoadOrQuitAction(GameActions::LoadOrQuitModes::CloseSavePrompt);
|
||||
GameActions::Execute(&loadOrQuitAction);
|
||||
ToolCancel();
|
||||
if (gInputFlags.has(InputFlag::unk5))
|
||||
@@ -692,7 +692,7 @@ void GameLoadOrQuitNoSavePrompt()
|
||||
}
|
||||
case PromptMode::saveBeforeNewGame:
|
||||
{
|
||||
auto loadOrQuitAction = LoadOrQuitAction(LoadOrQuitModes::CloseSavePrompt);
|
||||
auto loadOrQuitAction = GameActions::LoadOrQuitAction(GameActions::LoadOrQuitModes::CloseSavePrompt);
|
||||
GameActions::Execute(&loadOrQuitAction);
|
||||
ToolCancel();
|
||||
auto intent = Intent(WindowClass::ScenarioSelect);
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "actions/FootpathPlaceAction.h"
|
||||
#include "actions/GameAction.h"
|
||||
#include "actions/RideEntranceExitPlaceAction.h"
|
||||
#include "actions/RideSetSettingAction.h"
|
||||
// #include "actions/RideSetSettingAction.h"
|
||||
#include "actions/TileModifyAction.h"
|
||||
#include "actions/TrackPlaceAction.h"
|
||||
#include "config/Config.h"
|
||||
|
||||
@@ -14,52 +14,51 @@
|
||||
#include "../entity/EntityRegistry.h"
|
||||
#include "GameAction.h"
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
BalloonPressAction::BalloonPressAction(EntityId spriteIndex)
|
||||
: _spriteIndex(spriteIndex)
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
}
|
||||
|
||||
void BalloonPressAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
visitor.Visit("id", _spriteIndex);
|
||||
}
|
||||
|
||||
uint16_t BalloonPressAction::GetActionFlags() const
|
||||
{
|
||||
return GameAction::GetActionFlags();
|
||||
}
|
||||
|
||||
void BalloonPressAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
stream << DS_TAG(_spriteIndex);
|
||||
}
|
||||
|
||||
GameActions::Result BalloonPressAction::Query() const
|
||||
{
|
||||
auto balloon = TryGetEntity<Balloon>(_spriteIndex);
|
||||
if (balloon == nullptr)
|
||||
BalloonPressAction::BalloonPressAction(EntityId spriteIndex)
|
||||
: _spriteIndex(spriteIndex)
|
||||
{
|
||||
LOG_ERROR("Balloon not found for spriteIndex %u", _spriteIndex);
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_ERR_INVALID_PARAMETER, STR_ERR_BALLOON_NOT_FOUND);
|
||||
}
|
||||
return GameActions::Result();
|
||||
}
|
||||
|
||||
GameActions::Result BalloonPressAction::Execute() const
|
||||
{
|
||||
auto balloon = TryGetEntity<Balloon>(_spriteIndex);
|
||||
if (balloon == nullptr)
|
||||
{
|
||||
LOG_ERROR("Balloon not found for spriteIndex %u", _spriteIndex);
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_ERR_INVALID_PARAMETER, STR_ERR_BALLOON_NOT_FOUND);
|
||||
}
|
||||
|
||||
balloon->Press();
|
||||
void BalloonPressAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
visitor.Visit("id", _spriteIndex);
|
||||
}
|
||||
|
||||
return GameActions::Result();
|
||||
}
|
||||
uint16_t BalloonPressAction::GetActionFlags() const
|
||||
{
|
||||
return GameAction::GetActionFlags();
|
||||
}
|
||||
|
||||
void BalloonPressAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
stream << DS_TAG(_spriteIndex);
|
||||
}
|
||||
|
||||
Result BalloonPressAction::Query() const
|
||||
{
|
||||
auto balloon = TryGetEntity<Balloon>(_spriteIndex);
|
||||
if (balloon == nullptr)
|
||||
{
|
||||
LOG_ERROR("Balloon not found for spriteIndex %u", _spriteIndex);
|
||||
return Result(Status::InvalidParameters, STR_ERR_INVALID_PARAMETER, STR_ERR_BALLOON_NOT_FOUND);
|
||||
}
|
||||
return Result();
|
||||
}
|
||||
|
||||
Result BalloonPressAction::Execute() const
|
||||
{
|
||||
auto balloon = TryGetEntity<Balloon>(_spriteIndex);
|
||||
if (balloon == nullptr)
|
||||
{
|
||||
LOG_ERROR("Balloon not found for spriteIndex %u", _spriteIndex);
|
||||
return Result(Status::InvalidParameters, STR_ERR_INVALID_PARAMETER, STR_ERR_BALLOON_NOT_FOUND);
|
||||
}
|
||||
|
||||
balloon->Press();
|
||||
|
||||
return Result();
|
||||
}
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -12,19 +12,22 @@
|
||||
#include "../Identifiers.h"
|
||||
#include "GameAction.h"
|
||||
|
||||
class BalloonPressAction final : public GameActionBase<GameCommand::BalloonPress>
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
EntityId _spriteIndex{ EntityId::GetNull() };
|
||||
class BalloonPressAction final : public GameActionBase<GameCommand::BalloonPress>
|
||||
{
|
||||
EntityId _spriteIndex{ EntityId::GetNull() };
|
||||
|
||||
public:
|
||||
BalloonPressAction() = default;
|
||||
BalloonPressAction(EntityId spriteIndex);
|
||||
public:
|
||||
BalloonPressAction() = default;
|
||||
BalloonPressAction(EntityId spriteIndex);
|
||||
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
|
||||
uint16_t GetActionFlags() const override;
|
||||
uint16_t GetActionFlags() const override;
|
||||
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
OpenRCT2::GameActions::Result Query() const override;
|
||||
OpenRCT2::GameActions::Result Execute() const override;
|
||||
};
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
Result Query() const override;
|
||||
Result Execute() const override;
|
||||
};
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -22,166 +22,159 @@
|
||||
#include "../world/tile_element/PathElement.h"
|
||||
#include "GameAction.h"
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
BannerPlaceAction::BannerPlaceAction(const CoordsXYZD& loc, ObjectEntryIndex bannerType, colour_t primaryColour)
|
||||
: _loc(loc)
|
||||
, _bannerType(bannerType)
|
||||
, _primaryColour(primaryColour)
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
}
|
||||
|
||||
void BannerPlaceAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
visitor.Visit(_loc);
|
||||
visitor.Visit("object", _bannerType);
|
||||
visitor.Visit("primaryColour", _primaryColour);
|
||||
}
|
||||
|
||||
uint16_t BannerPlaceAction::GetActionFlags() const
|
||||
{
|
||||
return GameAction::GetActionFlags();
|
||||
}
|
||||
|
||||
void BannerPlaceAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_loc) << DS_TAG(_bannerType) << DS_TAG(_primaryColour);
|
||||
}
|
||||
|
||||
GameActions::Result BannerPlaceAction::Query() const
|
||||
{
|
||||
auto res = GameActions::Result();
|
||||
res.Position.x = _loc.x + 16;
|
||||
res.Position.y = _loc.y + 16;
|
||||
res.Position.z = _loc.z;
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
res.ErrorTitle = STR_CANT_POSITION_THIS_HERE;
|
||||
|
||||
if (!LocationValid(_loc))
|
||||
BannerPlaceAction::BannerPlaceAction(const CoordsXYZD& loc, ObjectEntryIndex bannerType, colour_t primaryColour)
|
||||
: _loc(loc)
|
||||
, _bannerType(bannerType)
|
||||
, _primaryColour(primaryColour)
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_OFF_EDGE_OF_MAP);
|
||||
}
|
||||
|
||||
if (!MapCheckCapacityAndReorganise(_loc))
|
||||
void BannerPlaceAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
LOG_ERROR("No free map elements.");
|
||||
return GameActions::Result(
|
||||
GameActions::Status::NoFreeElements, STR_CANT_POSITION_THIS_HERE, STR_TILE_ELEMENT_LIMIT_REACHED);
|
||||
visitor.Visit(_loc);
|
||||
visitor.Visit("object", _bannerType);
|
||||
visitor.Visit("primaryColour", _primaryColour);
|
||||
}
|
||||
|
||||
auto pathElement = GetValidPathElement();
|
||||
|
||||
if (pathElement == nullptr)
|
||||
uint16_t BannerPlaceAction::GetActionFlags() const
|
||||
{
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_CAN_ONLY_BE_BUILT_ACROSS_PATHS);
|
||||
return GameAction::GetActionFlags();
|
||||
}
|
||||
|
||||
if (!MapCanBuildAt(_loc))
|
||||
void BannerPlaceAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::NotOwned, STR_CANT_POSITION_THIS_HERE, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_loc) << DS_TAG(_bannerType) << DS_TAG(_primaryColour);
|
||||
}
|
||||
|
||||
auto baseHeight = _loc.z + kPathHeightStep;
|
||||
BannerElement* existingBannerElement = MapGetBannerElementAt({ _loc.x, _loc.y, baseHeight }, _loc.direction);
|
||||
if (existingBannerElement != nullptr)
|
||||
Result BannerPlaceAction::Query() const
|
||||
{
|
||||
return GameActions::Result(
|
||||
GameActions::Status::ItemAlreadyPlaced, STR_CANT_POSITION_THIS_HERE, STR_BANNER_SIGN_IN_THE_WAY);
|
||||
auto res = Result();
|
||||
res.Position.x = _loc.x + 16;
|
||||
res.Position.y = _loc.y + 16;
|
||||
res.Position.z = _loc.z;
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
res.ErrorTitle = STR_CANT_POSITION_THIS_HERE;
|
||||
|
||||
if (!LocationValid(_loc))
|
||||
{
|
||||
return Result(Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_OFF_EDGE_OF_MAP);
|
||||
}
|
||||
|
||||
if (!MapCheckCapacityAndReorganise(_loc))
|
||||
{
|
||||
LOG_ERROR("No free map elements.");
|
||||
return Result(Status::NoFreeElements, STR_CANT_POSITION_THIS_HERE, STR_TILE_ELEMENT_LIMIT_REACHED);
|
||||
}
|
||||
|
||||
auto pathElement = GetValidPathElement();
|
||||
|
||||
if (pathElement == nullptr)
|
||||
{
|
||||
return Result(Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_CAN_ONLY_BE_BUILT_ACROSS_PATHS);
|
||||
}
|
||||
|
||||
if (!MapCanBuildAt(_loc))
|
||||
{
|
||||
return Result(Status::NotOwned, STR_CANT_POSITION_THIS_HERE, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
}
|
||||
|
||||
auto baseHeight = _loc.z + kPathHeightStep;
|
||||
BannerElement* existingBannerElement = MapGetBannerElementAt({ _loc.x, _loc.y, baseHeight }, _loc.direction);
|
||||
if (existingBannerElement != nullptr)
|
||||
{
|
||||
return Result(Status::ItemAlreadyPlaced, STR_CANT_POSITION_THIS_HERE, STR_BANNER_SIGN_IN_THE_WAY);
|
||||
}
|
||||
|
||||
if (HasReachedBannerLimit())
|
||||
{
|
||||
LOG_ERROR("No free banners available");
|
||||
return Result(Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_TOO_MANY_BANNERS_IN_GAME);
|
||||
}
|
||||
|
||||
auto* bannerEntry = OpenRCT2::ObjectManager::GetObjectEntry<BannerSceneryEntry>(_bannerType);
|
||||
if (bannerEntry == nullptr)
|
||||
{
|
||||
LOG_ERROR("Banner entry not found for bannerType %u", _bannerType);
|
||||
return Result(Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_ERR_BANNER_ELEMENT_NOT_FOUND);
|
||||
}
|
||||
res.Cost = bannerEntry->price;
|
||||
res.SetData(BannerPlaceActionResult{});
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
if (HasReachedBannerLimit())
|
||||
Result BannerPlaceAction::Execute() const
|
||||
{
|
||||
LOG_ERROR("No free banners available");
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_TOO_MANY_BANNERS_IN_GAME);
|
||||
auto res = Result();
|
||||
res.Position.x = _loc.x + 16;
|
||||
res.Position.y = _loc.y + 16;
|
||||
res.Position.z = _loc.z;
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
res.ErrorTitle = STR_CANT_POSITION_THIS_HERE;
|
||||
|
||||
if (!MapCheckCapacityAndReorganise(_loc))
|
||||
{
|
||||
LOG_ERROR("No free map elements.");
|
||||
return Result(Status::NoFreeElements, STR_CANT_POSITION_THIS_HERE, STR_TILE_ELEMENT_LIMIT_REACHED);
|
||||
}
|
||||
|
||||
auto* bannerEntry = OpenRCT2::ObjectManager::GetObjectEntry<BannerSceneryEntry>(_bannerType);
|
||||
if (bannerEntry == nullptr)
|
||||
{
|
||||
LOG_ERROR("Banner entry not found for bannerType %u", _bannerType);
|
||||
return Result(Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_ERR_BANNER_ELEMENT_NOT_FOUND);
|
||||
}
|
||||
|
||||
auto banner = CreateBanner();
|
||||
if (banner == nullptr)
|
||||
{
|
||||
LOG_ERROR("No free banners available");
|
||||
return Result(Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_TOO_MANY_BANNERS_IN_GAME);
|
||||
}
|
||||
banner->flags = {};
|
||||
banner->text = {};
|
||||
banner->textColour = TextColour::white;
|
||||
banner->type = _bannerType; // Banner must be deleted after this point in an early return
|
||||
banner->colour = _primaryColour;
|
||||
banner->position = TileCoordsXY(_loc);
|
||||
|
||||
res.SetData(BannerPlaceActionResult{ banner->id });
|
||||
auto* bannerElement = TileElementInsert<BannerElement>({ _loc, _loc.z + (2 * kCoordsZStep) }, 0b0000);
|
||||
Guard::Assert(bannerElement != nullptr);
|
||||
|
||||
bannerElement->SetClearanceZ(_loc.z + kPathClearance);
|
||||
bannerElement->SetPosition(_loc.direction);
|
||||
bannerElement->ResetAllowedEdges();
|
||||
bannerElement->SetIndex(banner->id);
|
||||
bannerElement->SetGhost(GetFlags() & GAME_COMMAND_FLAG_GHOST);
|
||||
|
||||
MapInvalidateTileFull(_loc);
|
||||
MapAnimations::MarkTileForInvalidation(TileCoordsXY(_loc));
|
||||
|
||||
res.Cost = bannerEntry->price;
|
||||
return res;
|
||||
}
|
||||
|
||||
auto* bannerEntry = OpenRCT2::ObjectManager::GetObjectEntry<BannerSceneryEntry>(_bannerType);
|
||||
if (bannerEntry == nullptr)
|
||||
PathElement* BannerPlaceAction::GetValidPathElement() const
|
||||
{
|
||||
LOG_ERROR("Banner entry not found for bannerType %u", _bannerType);
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_ERR_BANNER_ELEMENT_NOT_FOUND);
|
||||
for (auto* pathElement : TileElementsView<PathElement>(_loc))
|
||||
{
|
||||
if (pathElement->GetBaseZ() != _loc.z && pathElement->GetBaseZ() != _loc.z - kPathHeightStep)
|
||||
continue;
|
||||
|
||||
if (!(pathElement->GetEdges() & (1 << _loc.direction)))
|
||||
continue;
|
||||
|
||||
if (pathElement->IsGhost() && !(GetFlags() & GAME_COMMAND_FLAG_GHOST))
|
||||
continue;
|
||||
|
||||
return pathElement;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
res.Cost = bannerEntry->price;
|
||||
res.SetData(BannerPlaceActionResult{});
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
GameActions::Result BannerPlaceAction::Execute() const
|
||||
{
|
||||
auto res = GameActions::Result();
|
||||
res.Position.x = _loc.x + 16;
|
||||
res.Position.y = _loc.y + 16;
|
||||
res.Position.z = _loc.z;
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
res.ErrorTitle = STR_CANT_POSITION_THIS_HERE;
|
||||
|
||||
if (!MapCheckCapacityAndReorganise(_loc))
|
||||
{
|
||||
LOG_ERROR("No free map elements.");
|
||||
return GameActions::Result(
|
||||
GameActions::Status::NoFreeElements, STR_CANT_POSITION_THIS_HERE, STR_TILE_ELEMENT_LIMIT_REACHED);
|
||||
}
|
||||
|
||||
auto* bannerEntry = OpenRCT2::ObjectManager::GetObjectEntry<BannerSceneryEntry>(_bannerType);
|
||||
if (bannerEntry == nullptr)
|
||||
{
|
||||
LOG_ERROR("Banner entry not found for bannerType %u", _bannerType);
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_ERR_BANNER_ELEMENT_NOT_FOUND);
|
||||
}
|
||||
|
||||
auto banner = CreateBanner();
|
||||
if (banner == nullptr)
|
||||
{
|
||||
LOG_ERROR("No free banners available");
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_TOO_MANY_BANNERS_IN_GAME);
|
||||
}
|
||||
banner->flags = {};
|
||||
banner->text = {};
|
||||
banner->textColour = TextColour::white;
|
||||
banner->type = _bannerType; // Banner must be deleted after this point in an early return
|
||||
banner->colour = _primaryColour;
|
||||
banner->position = TileCoordsXY(_loc);
|
||||
|
||||
res.SetData(BannerPlaceActionResult{ banner->id });
|
||||
auto* bannerElement = TileElementInsert<BannerElement>({ _loc, _loc.z + (2 * kCoordsZStep) }, 0b0000);
|
||||
Guard::Assert(bannerElement != nullptr);
|
||||
|
||||
bannerElement->SetClearanceZ(_loc.z + kPathClearance);
|
||||
bannerElement->SetPosition(_loc.direction);
|
||||
bannerElement->ResetAllowedEdges();
|
||||
bannerElement->SetIndex(banner->id);
|
||||
bannerElement->SetGhost(GetFlags() & GAME_COMMAND_FLAG_GHOST);
|
||||
|
||||
MapInvalidateTileFull(_loc);
|
||||
MapAnimations::MarkTileForInvalidation(TileCoordsXY(_loc));
|
||||
|
||||
res.Cost = bannerEntry->price;
|
||||
return res;
|
||||
}
|
||||
|
||||
PathElement* BannerPlaceAction::GetValidPathElement() const
|
||||
{
|
||||
for (auto* pathElement : TileElementsView<PathElement>(_loc))
|
||||
{
|
||||
if (pathElement->GetBaseZ() != _loc.z && pathElement->GetBaseZ() != _loc.z - kPathHeightStep)
|
||||
continue;
|
||||
|
||||
if (!(pathElement->GetEdges() & (1 << _loc.direction)))
|
||||
continue;
|
||||
|
||||
if (pathElement->IsGhost() && !(GetFlags() & GAME_COMMAND_FLAG_GHOST))
|
||||
continue;
|
||||
|
||||
return pathElement;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -11,30 +11,33 @@
|
||||
|
||||
#include "GameAction.h"
|
||||
|
||||
struct BannerPlaceActionResult
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
BannerIndex bannerId = BannerIndex::GetNull();
|
||||
};
|
||||
struct BannerPlaceActionResult
|
||||
{
|
||||
BannerIndex bannerId = BannerIndex::GetNull();
|
||||
};
|
||||
|
||||
class BannerPlaceAction final : public GameActionBase<GameCommand::PlaceBanner>
|
||||
{
|
||||
private:
|
||||
CoordsXYZD _loc;
|
||||
OpenRCT2::ObjectEntryIndex _bannerType{ kBannerNull };
|
||||
uint8_t _primaryColour{};
|
||||
class BannerPlaceAction final : public GameActionBase<GameCommand::PlaceBanner>
|
||||
{
|
||||
private:
|
||||
CoordsXYZD _loc;
|
||||
ObjectEntryIndex _bannerType{ kBannerNull };
|
||||
uint8_t _primaryColour{};
|
||||
|
||||
public:
|
||||
BannerPlaceAction() = default;
|
||||
BannerPlaceAction(const CoordsXYZD& loc, OpenRCT2::ObjectEntryIndex bannerType, colour_t primaryColour);
|
||||
public:
|
||||
BannerPlaceAction() = default;
|
||||
BannerPlaceAction(const CoordsXYZD& loc, ObjectEntryIndex bannerType, colour_t primaryColour);
|
||||
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
|
||||
uint16_t GetActionFlags() const override;
|
||||
uint16_t GetActionFlags() const override;
|
||||
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
OpenRCT2::GameActions::Result Query() const override;
|
||||
OpenRCT2::GameActions::Result Execute() const override;
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
Result Query() const override;
|
||||
Result Execute() const override;
|
||||
|
||||
private:
|
||||
OpenRCT2::PathElement* GetValidPathElement() const;
|
||||
};
|
||||
private:
|
||||
PathElement* GetValidPathElement() const;
|
||||
};
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -19,135 +19,138 @@
|
||||
#include "../world/tile_element/BannerElement.h"
|
||||
#include "GameAction.h"
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
BannerRemoveAction::BannerRemoveAction(const CoordsXYZD& loc)
|
||||
: _loc(loc)
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
}
|
||||
|
||||
void BannerRemoveAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
visitor.Visit(_loc);
|
||||
}
|
||||
|
||||
uint16_t BannerRemoveAction::GetActionFlags() const
|
||||
{
|
||||
return GameAction::GetActionFlags();
|
||||
}
|
||||
|
||||
void BannerRemoveAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_loc);
|
||||
}
|
||||
|
||||
GameActions::Result BannerRemoveAction::Query() const
|
||||
{
|
||||
auto res = GameActions::Result();
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
res.Position.x = _loc.x + 16;
|
||||
res.Position.y = _loc.y + 16;
|
||||
res.Position.z = _loc.z;
|
||||
res.ErrorTitle = STR_CANT_REMOVE_THIS;
|
||||
|
||||
if (!LocationValid(_loc))
|
||||
BannerRemoveAction::BannerRemoveAction(const CoordsXYZD& loc)
|
||||
: _loc(loc)
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_OFF_EDGE_OF_MAP);
|
||||
}
|
||||
if (!MapCanBuildAt({ _loc.x, _loc.y, _loc.z - 16 }))
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::NotOwned, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
}
|
||||
|
||||
BannerElement* bannerElement = GetBannerElementAt();
|
||||
if (bannerElement == nullptr)
|
||||
void BannerRemoveAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
LOG_ERROR("Invalid banner location, x = %d, y = %d, z = %d, direction = %d", _loc.x, _loc.y, _loc.z, _loc.direction);
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS, kStringIdNone);
|
||||
visitor.Visit(_loc);
|
||||
}
|
||||
|
||||
auto bannerIndex = bannerElement->GetIndex();
|
||||
if (bannerIndex == BannerIndex::GetNull())
|
||||
uint16_t BannerRemoveAction::GetActionFlags() const
|
||||
{
|
||||
LOG_ERROR("Invalid banner index %u", bannerIndex);
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS, kStringIdNone);
|
||||
return GameAction::GetActionFlags();
|
||||
}
|
||||
|
||||
auto banner = bannerElement->GetBanner();
|
||||
if (banner == nullptr)
|
||||
void BannerRemoveAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
LOG_ERROR("Invalid banner index %u", bannerIndex);
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS, kStringIdNone);
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_loc);
|
||||
}
|
||||
|
||||
auto* bannerEntry = OpenRCT2::ObjectManager::GetObjectEntry<BannerSceneryEntry>(banner->type);
|
||||
if (bannerEntry != nullptr)
|
||||
Result BannerRemoveAction::Query() const
|
||||
{
|
||||
res.Cost = -((bannerEntry->price * 3) / 4);
|
||||
auto res = Result();
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
res.Position.x = _loc.x + 16;
|
||||
res.Position.y = _loc.y + 16;
|
||||
res.Position.z = _loc.z;
|
||||
res.ErrorTitle = STR_CANT_REMOVE_THIS;
|
||||
|
||||
if (!LocationValid(_loc))
|
||||
{
|
||||
return Result(Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_OFF_EDGE_OF_MAP);
|
||||
}
|
||||
if (!MapCanBuildAt({ _loc.x, _loc.y, _loc.z - 16 }))
|
||||
{
|
||||
return Result(Status::NotOwned, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
}
|
||||
|
||||
BannerElement* bannerElement = GetBannerElementAt();
|
||||
if (bannerElement == nullptr)
|
||||
{
|
||||
LOG_ERROR(
|
||||
"Invalid banner location, x = %d, y = %d, z = %d, direction = %d", _loc.x, _loc.y, _loc.z, _loc.direction);
|
||||
return Result(Status::InvalidParameters, STR_CANT_REMOVE_THIS, kStringIdNone);
|
||||
}
|
||||
|
||||
auto bannerIndex = bannerElement->GetIndex();
|
||||
if (bannerIndex == BannerIndex::GetNull())
|
||||
{
|
||||
LOG_ERROR("Invalid banner index %u", bannerIndex);
|
||||
return Result(Status::InvalidParameters, STR_CANT_REMOVE_THIS, kStringIdNone);
|
||||
}
|
||||
|
||||
auto banner = bannerElement->GetBanner();
|
||||
if (banner == nullptr)
|
||||
{
|
||||
LOG_ERROR("Invalid banner index %u", bannerIndex);
|
||||
return Result(Status::InvalidParameters, STR_CANT_REMOVE_THIS, kStringIdNone);
|
||||
}
|
||||
|
||||
auto* bannerEntry = ObjectManager::GetObjectEntry<BannerSceneryEntry>(banner->type);
|
||||
if (bannerEntry != nullptr)
|
||||
{
|
||||
res.Cost = -((bannerEntry->price * 3) / 4);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
GameActions::Result BannerRemoveAction::Execute() const
|
||||
{
|
||||
auto res = GameActions::Result();
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
res.Position.x = _loc.x + 16;
|
||||
res.Position.y = _loc.y + 16;
|
||||
res.Position.z = _loc.z;
|
||||
res.ErrorTitle = STR_CANT_REMOVE_THIS;
|
||||
|
||||
BannerElement* bannerElement = GetBannerElementAt();
|
||||
if (bannerElement == nullptr)
|
||||
Result BannerRemoveAction::Execute() const
|
||||
{
|
||||
LOG_ERROR("Invalid banner location, x = %d, y = %d, z = %d, direction = %d", _loc.x, _loc.y, _loc.z, _loc.direction);
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS, kStringIdNone);
|
||||
auto res = Result();
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
res.Position.x = _loc.x + 16;
|
||||
res.Position.y = _loc.y + 16;
|
||||
res.Position.z = _loc.z;
|
||||
res.ErrorTitle = STR_CANT_REMOVE_THIS;
|
||||
|
||||
BannerElement* bannerElement = GetBannerElementAt();
|
||||
if (bannerElement == nullptr)
|
||||
{
|
||||
LOG_ERROR(
|
||||
"Invalid banner location, x = %d, y = %d, z = %d, direction = %d", _loc.x, _loc.y, _loc.z, _loc.direction);
|
||||
return Result(Status::InvalidParameters, STR_CANT_REMOVE_THIS, kStringIdNone);
|
||||
}
|
||||
|
||||
auto bannerIndex = bannerElement->GetIndex();
|
||||
if (bannerIndex == BannerIndex::GetNull())
|
||||
{
|
||||
LOG_ERROR("Invalid banner index %u", bannerIndex);
|
||||
return Result(Status::InvalidParameters, STR_CANT_REMOVE_THIS, kStringIdNone);
|
||||
}
|
||||
|
||||
auto banner = bannerElement->GetBanner();
|
||||
if (banner == nullptr)
|
||||
{
|
||||
LOG_ERROR("Invalid banner index %u", bannerIndex);
|
||||
return Result(Status::InvalidParameters, STR_CANT_REMOVE_THIS, kStringIdNone);
|
||||
}
|
||||
|
||||
auto* bannerEntry = ObjectManager::GetObjectEntry<BannerSceneryEntry>(banner->type);
|
||||
if (bannerEntry != nullptr)
|
||||
{
|
||||
res.Cost = -((bannerEntry->price * 3) / 4);
|
||||
}
|
||||
|
||||
reinterpret_cast<TileElement*>(bannerElement)->RemoveBannerEntry();
|
||||
MapInvalidateTileZoom1({ _loc, _loc.z, _loc.z + 32 });
|
||||
bannerElement->Remove();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
auto bannerIndex = bannerElement->GetIndex();
|
||||
if (bannerIndex == BannerIndex::GetNull())
|
||||
BannerElement* BannerRemoveAction::GetBannerElementAt() const
|
||||
{
|
||||
LOG_ERROR("Invalid banner index %u", bannerIndex);
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS, kStringIdNone);
|
||||
// Find the banner element at known z and position
|
||||
for (auto* bannerElement : TileElementsView<BannerElement>(_loc))
|
||||
{
|
||||
if (bannerElement->GetBaseZ() != _loc.z)
|
||||
continue;
|
||||
if (bannerElement->IsGhost() && !(GetFlags() & GAME_COMMAND_FLAG_GHOST))
|
||||
continue;
|
||||
if (bannerElement->GetPosition() != _loc.direction)
|
||||
continue;
|
||||
|
||||
return bannerElement;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto banner = bannerElement->GetBanner();
|
||||
if (banner == nullptr)
|
||||
{
|
||||
LOG_ERROR("Invalid banner index %u", bannerIndex);
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS, kStringIdNone);
|
||||
}
|
||||
|
||||
auto* bannerEntry = OpenRCT2::ObjectManager::GetObjectEntry<BannerSceneryEntry>(banner->type);
|
||||
if (bannerEntry != nullptr)
|
||||
{
|
||||
res.Cost = -((bannerEntry->price * 3) / 4);
|
||||
}
|
||||
|
||||
reinterpret_cast<TileElement*>(bannerElement)->RemoveBannerEntry();
|
||||
MapInvalidateTileZoom1({ _loc, _loc.z, _loc.z + 32 });
|
||||
bannerElement->Remove();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
BannerElement* BannerRemoveAction::GetBannerElementAt() const
|
||||
{
|
||||
// Find the banner element at known z and position
|
||||
for (auto* bannerElement : TileElementsView<BannerElement>(_loc))
|
||||
{
|
||||
if (bannerElement->GetBaseZ() != _loc.z)
|
||||
continue;
|
||||
if (bannerElement->IsGhost() && !(GetFlags() & GAME_COMMAND_FLAG_GHOST))
|
||||
continue;
|
||||
if (bannerElement->GetPosition() != _loc.direction)
|
||||
continue;
|
||||
|
||||
return bannerElement;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -11,23 +11,26 @@
|
||||
|
||||
#include "GameAction.h"
|
||||
|
||||
class BannerRemoveAction final : public GameActionBase<GameCommand::RemoveBanner>
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
private:
|
||||
CoordsXYZD _loc;
|
||||
class BannerRemoveAction final : public GameActionBase<GameCommand::RemoveBanner>
|
||||
{
|
||||
private:
|
||||
CoordsXYZD _loc;
|
||||
|
||||
public:
|
||||
BannerRemoveAction() = default;
|
||||
BannerRemoveAction(const CoordsXYZD& loc);
|
||||
public:
|
||||
BannerRemoveAction() = default;
|
||||
BannerRemoveAction(const CoordsXYZD& loc);
|
||||
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
|
||||
uint16_t GetActionFlags() const override;
|
||||
uint16_t GetActionFlags() const override;
|
||||
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
OpenRCT2::GameActions::Result Query() const override;
|
||||
OpenRCT2::GameActions::Result Execute() const override;
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
Result Query() const override;
|
||||
Result Execute() const override;
|
||||
|
||||
private:
|
||||
OpenRCT2::BannerElement* GetBannerElementAt() const;
|
||||
};
|
||||
private:
|
||||
BannerElement* GetBannerElementAt() const;
|
||||
};
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -17,93 +17,94 @@
|
||||
#include "../world/tile_element/BannerElement.h"
|
||||
#include "GameAction.h"
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
BannerSetColourAction::BannerSetColourAction(const CoordsXYZD& loc, uint8_t primaryColour)
|
||||
: _loc(loc)
|
||||
, _primaryColour(primaryColour)
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
}
|
||||
|
||||
void BannerSetColourAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
visitor.Visit(_loc);
|
||||
visitor.Visit("primaryColour", _primaryColour);
|
||||
}
|
||||
|
||||
uint16_t BannerSetColourAction::GetActionFlags() const
|
||||
{
|
||||
return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused;
|
||||
}
|
||||
|
||||
void BannerSetColourAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_loc) << DS_TAG(_primaryColour);
|
||||
}
|
||||
|
||||
GameActions::Result BannerSetColourAction::Query() const
|
||||
{
|
||||
return QueryExecute(false);
|
||||
}
|
||||
|
||||
GameActions::Result BannerSetColourAction::Execute() const
|
||||
{
|
||||
return QueryExecute(true);
|
||||
}
|
||||
|
||||
GameActions::Result BannerSetColourAction::QueryExecute(bool isExecuting) const
|
||||
{
|
||||
auto res = GameActions::Result();
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
res.Position.x = _loc.x + 16;
|
||||
res.Position.y = _loc.y + 16;
|
||||
res.Position.z = _loc.z;
|
||||
res.ErrorTitle = STR_CANT_REPAINT_THIS;
|
||||
|
||||
if (!LocationValid(_loc))
|
||||
BannerSetColourAction::BannerSetColourAction(const CoordsXYZD& loc, uint8_t primaryColour)
|
||||
: _loc(loc)
|
||||
, _primaryColour(primaryColour)
|
||||
{
|
||||
LOG_ERROR("Invalid x / y coordinates: x = %d, y = %d", _loc.x, _loc.y);
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_REPAINT_THIS, STR_OFF_EDGE_OF_MAP);
|
||||
}
|
||||
|
||||
if (_primaryColour > 31)
|
||||
void BannerSetColourAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
LOG_ERROR("Invalid primary colour %u", _primaryColour);
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_REPAINT_THIS, STR_ERR_INVALID_COLOUR);
|
||||
visitor.Visit(_loc);
|
||||
visitor.Visit("primaryColour", _primaryColour);
|
||||
}
|
||||
|
||||
if (!MapCanBuildAt({ _loc.x, _loc.y, _loc.z - 16 }))
|
||||
uint16_t BannerSetColourAction::GetActionFlags() const
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::NotOwned, STR_CANT_REPAINT_THIS, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
return GameAction::GetActionFlags() | Flags::AllowWhilePaused;
|
||||
}
|
||||
|
||||
auto bannerElement = MapGetBannerElementAt(_loc, _loc.direction);
|
||||
|
||||
if (bannerElement == nullptr)
|
||||
void BannerSetColourAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
LOG_ERROR("No banner at x = %d, y = %d, z = %d, direction = %u", _loc.x, _loc.y, _loc.z, _loc.direction);
|
||||
return GameActions::Result(GameActions::Status::Unknown, STR_CANT_REPAINT_THIS, STR_ERR_BANNER_ELEMENT_NOT_FOUND);
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_loc) << DS_TAG(_primaryColour);
|
||||
}
|
||||
|
||||
auto index = bannerElement->GetIndex();
|
||||
auto banner = GetBanner(index);
|
||||
if (banner == nullptr)
|
||||
Result BannerSetColourAction::Query() const
|
||||
{
|
||||
LOG_ERROR("Invalid banner index %u", index);
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_REPAINT_THIS, kStringIdNone);
|
||||
return QueryExecute(false);
|
||||
}
|
||||
|
||||
if (isExecuting)
|
||||
Result BannerSetColourAction::Execute() const
|
||||
{
|
||||
auto intent = Intent(INTENT_ACTION_UPDATE_BANNER);
|
||||
intent.PutExtra(INTENT_EXTRA_BANNER_INDEX, index);
|
||||
ContextBroadcastIntent(&intent);
|
||||
|
||||
banner->colour = _primaryColour;
|
||||
MapInvalidateTileZoom1({ _loc, _loc.z, _loc.z + 32 });
|
||||
return QueryExecute(true);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
Result BannerSetColourAction::QueryExecute(bool isExecuting) const
|
||||
{
|
||||
auto res = Result();
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
res.Position.x = _loc.x + 16;
|
||||
res.Position.y = _loc.y + 16;
|
||||
res.Position.z = _loc.z;
|
||||
res.ErrorTitle = STR_CANT_REPAINT_THIS;
|
||||
|
||||
if (!LocationValid(_loc))
|
||||
{
|
||||
LOG_ERROR("Invalid x / y coordinates: x = %d, y = %d", _loc.x, _loc.y);
|
||||
return Result(Status::InvalidParameters, STR_CANT_REPAINT_THIS, STR_OFF_EDGE_OF_MAP);
|
||||
}
|
||||
|
||||
if (_primaryColour > 31)
|
||||
{
|
||||
LOG_ERROR("Invalid primary colour %u", _primaryColour);
|
||||
return Result(Status::InvalidParameters, STR_CANT_REPAINT_THIS, STR_ERR_INVALID_COLOUR);
|
||||
}
|
||||
|
||||
if (!MapCanBuildAt({ _loc.x, _loc.y, _loc.z - 16 }))
|
||||
{
|
||||
return Result(Status::NotOwned, STR_CANT_REPAINT_THIS, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
}
|
||||
|
||||
auto bannerElement = MapGetBannerElementAt(_loc, _loc.direction);
|
||||
|
||||
if (bannerElement == nullptr)
|
||||
{
|
||||
LOG_ERROR("No banner at x = %d, y = %d, z = %d, direction = %u", _loc.x, _loc.y, _loc.z, _loc.direction);
|
||||
return Result(Status::Unknown, STR_CANT_REPAINT_THIS, STR_ERR_BANNER_ELEMENT_NOT_FOUND);
|
||||
}
|
||||
|
||||
auto index = bannerElement->GetIndex();
|
||||
auto banner = GetBanner(index);
|
||||
if (banner == nullptr)
|
||||
{
|
||||
LOG_ERROR("Invalid banner index %u", index);
|
||||
return Result(Status::InvalidParameters, STR_CANT_REPAINT_THIS, kStringIdNone);
|
||||
}
|
||||
|
||||
if (isExecuting)
|
||||
{
|
||||
auto intent = Intent(INTENT_ACTION_UPDATE_BANNER);
|
||||
intent.PutExtra(INTENT_EXTRA_BANNER_INDEX, index);
|
||||
ContextBroadcastIntent(&intent);
|
||||
|
||||
banner->colour = _primaryColour;
|
||||
MapInvalidateTileZoom1({ _loc, _loc.z, _loc.z + 32 });
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -11,24 +11,27 @@
|
||||
|
||||
#include "GameAction.h"
|
||||
|
||||
class BannerSetColourAction final : public GameActionBase<GameCommand::SetBannerColour>
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
private:
|
||||
CoordsXYZD _loc;
|
||||
uint8_t _primaryColour{};
|
||||
class BannerSetColourAction final : public GameActionBase<GameCommand::SetBannerColour>
|
||||
{
|
||||
private:
|
||||
CoordsXYZD _loc;
|
||||
uint8_t _primaryColour{};
|
||||
|
||||
public:
|
||||
BannerSetColourAction() = default;
|
||||
BannerSetColourAction(const CoordsXYZD& loc, uint8_t primaryColour);
|
||||
public:
|
||||
BannerSetColourAction() = default;
|
||||
BannerSetColourAction(const CoordsXYZD& loc, uint8_t primaryColour);
|
||||
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
|
||||
uint16_t GetActionFlags() const override;
|
||||
uint16_t GetActionFlags() const override;
|
||||
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
OpenRCT2::GameActions::Result Query() const override;
|
||||
OpenRCT2::GameActions::Result Execute() const override;
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
Result Query() const override;
|
||||
Result Execute() const override;
|
||||
|
||||
private:
|
||||
OpenRCT2::GameActions::Result QueryExecute(bool isExecuting) const;
|
||||
};
|
||||
private:
|
||||
Result QueryExecute(bool isExecuting) const;
|
||||
};
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -19,83 +19,81 @@
|
||||
#include "../world/tile_element/BannerElement.h"
|
||||
#include "GameAction.h"
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
BannerSetNameAction::BannerSetNameAction(BannerIndex bannerIndex, const std::string& name)
|
||||
: _bannerIndex(bannerIndex)
|
||||
, _name(name)
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
}
|
||||
|
||||
void BannerSetNameAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
visitor.Visit("id", _bannerIndex);
|
||||
visitor.Visit("name", _name);
|
||||
}
|
||||
|
||||
uint16_t BannerSetNameAction::GetActionFlags() const
|
||||
{
|
||||
return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused;
|
||||
}
|
||||
|
||||
void BannerSetNameAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
stream << DS_TAG(_bannerIndex) << DS_TAG(_name);
|
||||
}
|
||||
|
||||
GameActions::Result BannerSetNameAction::Query() const
|
||||
{
|
||||
auto banner = GetBanner(_bannerIndex);
|
||||
if (banner == nullptr)
|
||||
BannerSetNameAction::BannerSetNameAction(BannerIndex bannerIndex, const std::string& name)
|
||||
: _bannerIndex(bannerIndex)
|
||||
, _name(name)
|
||||
{
|
||||
LOG_ERROR("Banner not found for bannerIndex %d", _bannerIndex);
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_RENAME_BANNER, STR_ERR_BANNER_ELEMENT_NOT_FOUND);
|
||||
}
|
||||
|
||||
TileElement* tileElement = BannerGetTileElement(_bannerIndex);
|
||||
|
||||
if (tileElement == nullptr)
|
||||
void BannerSetNameAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
LOG_ERROR("Banner tile element not found for bannerIndex %d", _bannerIndex);
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_RENAME_BANNER, STR_ERR_BANNER_ELEMENT_NOT_FOUND);
|
||||
visitor.Visit("id", _bannerIndex);
|
||||
visitor.Visit("name", _name);
|
||||
}
|
||||
|
||||
BannerElement* bannerElement = tileElement->AsBanner();
|
||||
CoordsXYZD loc = { banner->position.ToCoordsXY(), bannerElement->GetBaseZ(), bannerElement->GetPosition() };
|
||||
|
||||
if (!LocationValid(loc))
|
||||
uint16_t BannerSetNameAction::GetActionFlags() const
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_RENAME_BANNER, STR_OFF_EDGE_OF_MAP);
|
||||
}
|
||||
if (!MapCanBuildAt({ loc.x, loc.y, loc.z - 16 }))
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::NotOwned, STR_CANT_RENAME_BANNER, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
return GameAction::GetActionFlags() | Flags::AllowWhilePaused;
|
||||
}
|
||||
|
||||
return GameActions::Result();
|
||||
}
|
||||
|
||||
GameActions::Result BannerSetNameAction::Execute() const
|
||||
{
|
||||
auto banner = GetBanner(_bannerIndex);
|
||||
if (banner == nullptr)
|
||||
void BannerSetNameAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
LOG_ERROR("Banner not found for bannerIndex %d", _bannerIndex);
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_RENAME_BANNER, STR_ERR_BANNER_ELEMENT_NOT_FOUND);
|
||||
GameAction::Serialise(stream);
|
||||
stream << DS_TAG(_bannerIndex) << DS_TAG(_name);
|
||||
}
|
||||
|
||||
banner->text = _name;
|
||||
Result BannerSetNameAction::Query() const
|
||||
{
|
||||
auto banner = GetBanner(_bannerIndex);
|
||||
if (banner == nullptr)
|
||||
{
|
||||
LOG_ERROR("Banner not found for bannerIndex %d", _bannerIndex);
|
||||
return Result(Status::InvalidParameters, STR_CANT_RENAME_BANNER, STR_ERR_BANNER_ELEMENT_NOT_FOUND);
|
||||
}
|
||||
|
||||
auto intent = Intent(INTENT_ACTION_UPDATE_BANNER);
|
||||
intent.PutExtra(INTENT_EXTRA_BANNER_INDEX, _bannerIndex);
|
||||
ContextBroadcastIntent(&intent);
|
||||
TileElement* tileElement = BannerGetTileElement(_bannerIndex);
|
||||
|
||||
ScrollingTextInvalidate();
|
||||
GfxInvalidateScreen();
|
||||
if (tileElement == nullptr)
|
||||
{
|
||||
LOG_ERROR("Banner tile element not found for bannerIndex %d", _bannerIndex);
|
||||
return Result(Status::InvalidParameters, STR_CANT_RENAME_BANNER, STR_ERR_BANNER_ELEMENT_NOT_FOUND);
|
||||
}
|
||||
|
||||
return GameActions::Result();
|
||||
}
|
||||
BannerElement* bannerElement = tileElement->AsBanner();
|
||||
CoordsXYZD loc = { banner->position.ToCoordsXY(), bannerElement->GetBaseZ(), bannerElement->GetPosition() };
|
||||
|
||||
if (!LocationValid(loc))
|
||||
{
|
||||
return Result(Status::InvalidParameters, STR_CANT_RENAME_BANNER, STR_OFF_EDGE_OF_MAP);
|
||||
}
|
||||
if (!MapCanBuildAt({ loc.x, loc.y, loc.z - 16 }))
|
||||
{
|
||||
return Result(Status::NotOwned, STR_CANT_RENAME_BANNER, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
}
|
||||
|
||||
return Result();
|
||||
}
|
||||
|
||||
Result BannerSetNameAction::Execute() const
|
||||
{
|
||||
auto banner = GetBanner(_bannerIndex);
|
||||
if (banner == nullptr)
|
||||
{
|
||||
LOG_ERROR("Banner not found for bannerIndex %d", _bannerIndex);
|
||||
return Result(Status::InvalidParameters, STR_CANT_RENAME_BANNER, STR_ERR_BANNER_ELEMENT_NOT_FOUND);
|
||||
}
|
||||
|
||||
banner->text = _name;
|
||||
|
||||
auto intent = Intent(INTENT_ACTION_UPDATE_BANNER);
|
||||
intent.PutExtra(INTENT_EXTRA_BANNER_INDEX, _bannerIndex);
|
||||
ContextBroadcastIntent(&intent);
|
||||
|
||||
ScrollingTextInvalidate();
|
||||
GfxInvalidateScreen();
|
||||
|
||||
return Result();
|
||||
}
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -11,21 +11,24 @@
|
||||
|
||||
#include "GameAction.h"
|
||||
|
||||
class BannerSetNameAction final : public GameActionBase<GameCommand::SetBannerName>
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
private:
|
||||
BannerIndex _bannerIndex{ BannerIndex::GetNull() };
|
||||
std::string _name;
|
||||
class BannerSetNameAction final : public GameActionBase<GameCommand::SetBannerName>
|
||||
{
|
||||
private:
|
||||
BannerIndex _bannerIndex{ BannerIndex::GetNull() };
|
||||
std::string _name;
|
||||
|
||||
public:
|
||||
BannerSetNameAction() = default;
|
||||
BannerSetNameAction(BannerIndex bannerIndex, const std::string& name);
|
||||
public:
|
||||
BannerSetNameAction() = default;
|
||||
BannerSetNameAction(BannerIndex bannerIndex, const std::string& name);
|
||||
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
|
||||
uint16_t GetActionFlags() const override;
|
||||
uint16_t GetActionFlags() const override;
|
||||
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
OpenRCT2::GameActions::Result Query() const override;
|
||||
OpenRCT2::GameActions::Result Execute() const override;
|
||||
};
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
Result Query() const override;
|
||||
Result Execute() const override;
|
||||
};
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -18,172 +18,167 @@
|
||||
#include "../world/tile_element/BannerElement.h"
|
||||
#include "GameAction.h"
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
BannerSetStyleAction::BannerSetStyleAction(BannerSetStyleType type, BannerIndex bannerIndex, uint8_t parameter)
|
||||
: _type(type)
|
||||
, _bannerIndex(bannerIndex)
|
||||
, _parameter(parameter)
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
}
|
||||
|
||||
void BannerSetStyleAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
visitor.Visit("id", _bannerIndex);
|
||||
visitor.Visit("type", _type);
|
||||
visitor.Visit("parameter", _parameter);
|
||||
}
|
||||
|
||||
uint16_t BannerSetStyleAction::GetActionFlags() const
|
||||
{
|
||||
return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused;
|
||||
}
|
||||
|
||||
void BannerSetStyleAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_type) << DS_TAG(_bannerIndex) << DS_TAG(_parameter);
|
||||
}
|
||||
|
||||
GameActions::Result BannerSetStyleAction::Query() const
|
||||
{
|
||||
StringId errorTitle = STR_CANT_REPAINT_THIS;
|
||||
if (_type == BannerSetStyleType::NoEntry)
|
||||
BannerSetStyleAction::BannerSetStyleAction(BannerSetStyleType type, BannerIndex bannerIndex, uint8_t parameter)
|
||||
: _type(type)
|
||||
, _bannerIndex(bannerIndex)
|
||||
, _parameter(parameter)
|
||||
{
|
||||
errorTitle = STR_CANT_RENAME_BANNER;
|
||||
}
|
||||
|
||||
auto res = GameActions::Result();
|
||||
|
||||
auto banner = GetBanner(_bannerIndex);
|
||||
if (banner == nullptr)
|
||||
void BannerSetStyleAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
LOG_ERROR("Banner not found for bannerIndex %d", _bannerIndex);
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, errorTitle, STR_ERR_BANNER_ELEMENT_NOT_FOUND);
|
||||
visitor.Visit("id", _bannerIndex);
|
||||
visitor.Visit("type", _type);
|
||||
visitor.Visit("parameter", _parameter);
|
||||
}
|
||||
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
auto location = banner->position.ToCoordsXY().ToTileCentre();
|
||||
res.Position = { location, TileElementHeight(location) };
|
||||
|
||||
TileElement* tileElement = BannerGetTileElement(_bannerIndex);
|
||||
|
||||
if (tileElement == nullptr)
|
||||
uint16_t BannerSetStyleAction::GetActionFlags() const
|
||||
{
|
||||
LOG_ERROR("Banner tile element not found for bannerIndex %d", _bannerIndex);
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, errorTitle, STR_ERR_BANNER_ELEMENT_NOT_FOUND);
|
||||
return GameAction::GetActionFlags() | Flags::AllowWhilePaused;
|
||||
}
|
||||
|
||||
BannerElement* bannerElement = tileElement->AsBanner();
|
||||
CoordsXYZ loc = { banner->position.ToCoordsXY(), bannerElement->GetBaseZ() };
|
||||
void BannerSetStyleAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
if (!LocationValid(loc))
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, errorTitle, STR_OFF_EDGE_OF_MAP);
|
||||
}
|
||||
if (!MapCanBuildAt({ loc.x, loc.y, loc.z - 16 }))
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::NotOwned, errorTitle, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
stream << DS_TAG(_type) << DS_TAG(_bannerIndex) << DS_TAG(_parameter);
|
||||
}
|
||||
|
||||
switch (_type)
|
||||
Result BannerSetStyleAction::Query() const
|
||||
{
|
||||
case BannerSetStyleType::PrimaryColour:
|
||||
if (_parameter > COLOUR_COUNT)
|
||||
{
|
||||
LOG_ERROR("Invalid primary colour %u", _parameter);
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_REPAINT_THIS, STR_ERR_INVALID_COLOUR);
|
||||
}
|
||||
break;
|
||||
|
||||
case BannerSetStyleType::TextColour:
|
||||
if (_parameter > 13)
|
||||
{
|
||||
LOG_ERROR("Invalid text colour %u", _parameter);
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_REPAINT_THIS, STR_ERR_INVALID_COLOUR);
|
||||
}
|
||||
break;
|
||||
case BannerSetStyleType::NoEntry:
|
||||
if (tileElement->AsBanner() == nullptr)
|
||||
{
|
||||
LOG_ERROR("Tile element was not a banner.");
|
||||
return GameActions::Result(GameActions::Status::Unknown, STR_CANT_RENAME_BANNER, kStringIdNone);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("Invalid banner style type %u", _type);
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_REPAINT_THIS, STR_ERR_VALUE_OUT_OF_RANGE);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
GameActions::Result BannerSetStyleAction::Execute() const
|
||||
{
|
||||
auto res = GameActions::Result();
|
||||
|
||||
auto banner = GetBanner(_bannerIndex);
|
||||
if (banner == nullptr)
|
||||
{
|
||||
LOG_ERROR("Banner not found for bannerIndex %d", _bannerIndex);
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_REPAINT_THIS, STR_ERR_BANNER_ELEMENT_NOT_FOUND);
|
||||
}
|
||||
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
auto location = banner->position.ToCoordsXY().ToTileCentre();
|
||||
res.Position = { location, TileElementHeight(location) };
|
||||
|
||||
TileElement* tileElement = BannerGetTileElement(_bannerIndex);
|
||||
|
||||
if (tileElement == nullptr)
|
||||
{
|
||||
LOG_ERROR("Banner tile element not found for bannerIndex &u", _bannerIndex);
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_REPAINT_THIS, kStringIdNone);
|
||||
}
|
||||
|
||||
switch (_type)
|
||||
{
|
||||
case BannerSetStyleType::PrimaryColour:
|
||||
banner->colour = _parameter;
|
||||
break;
|
||||
case BannerSetStyleType::TextColour:
|
||||
banner->textColour = static_cast<TextColour>(_parameter);
|
||||
break;
|
||||
case BannerSetStyleType::NoEntry:
|
||||
StringId errorTitle = STR_CANT_REPAINT_THIS;
|
||||
if (_type == BannerSetStyleType::NoEntry)
|
||||
{
|
||||
BannerElement* bannerElement = tileElement->AsBanner();
|
||||
if (bannerElement == nullptr)
|
||||
{
|
||||
LOG_ERROR("Tile element was not a banner.");
|
||||
return GameActions::Result(
|
||||
GameActions::Status::Unknown, STR_CANT_REPAINT_THIS, STR_ERR_BANNER_ELEMENT_NOT_FOUND);
|
||||
}
|
||||
|
||||
banner->flags.set(BannerFlag::noEntry, (_parameter != 0));
|
||||
uint8_t allowedEdges = 0xF;
|
||||
if (banner->flags.has(BannerFlag::noEntry))
|
||||
{
|
||||
allowedEdges &= ~(1 << bannerElement->GetPosition());
|
||||
}
|
||||
bannerElement->SetAllowedEdges(allowedEdges);
|
||||
break;
|
||||
errorTitle = STR_CANT_RENAME_BANNER;
|
||||
}
|
||||
default:
|
||||
LOG_ERROR("Invalid banner style type %u", _type);
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_REPAINT_THIS, STR_ERR_VALUE_OUT_OF_RANGE);
|
||||
|
||||
auto res = Result();
|
||||
|
||||
auto banner = GetBanner(_bannerIndex);
|
||||
if (banner == nullptr)
|
||||
{
|
||||
LOG_ERROR("Banner not found for bannerIndex %d", _bannerIndex);
|
||||
return Result(Status::InvalidParameters, errorTitle, STR_ERR_BANNER_ELEMENT_NOT_FOUND);
|
||||
}
|
||||
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
auto location = banner->position.ToCoordsXY().ToTileCentre();
|
||||
res.Position = { location, TileElementHeight(location) };
|
||||
|
||||
TileElement* tileElement = BannerGetTileElement(_bannerIndex);
|
||||
|
||||
if (tileElement == nullptr)
|
||||
{
|
||||
LOG_ERROR("Banner tile element not found for bannerIndex %d", _bannerIndex);
|
||||
return Result(Status::InvalidParameters, errorTitle, STR_ERR_BANNER_ELEMENT_NOT_FOUND);
|
||||
}
|
||||
|
||||
BannerElement* bannerElement = tileElement->AsBanner();
|
||||
CoordsXYZ loc = { banner->position.ToCoordsXY(), bannerElement->GetBaseZ() };
|
||||
|
||||
if (!LocationValid(loc))
|
||||
{
|
||||
return Result(Status::InvalidParameters, errorTitle, STR_OFF_EDGE_OF_MAP);
|
||||
}
|
||||
if (!MapCanBuildAt({ loc.x, loc.y, loc.z - 16 }))
|
||||
{
|
||||
return Result(Status::NotOwned, errorTitle, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
}
|
||||
|
||||
switch (_type)
|
||||
{
|
||||
case BannerSetStyleType::PrimaryColour:
|
||||
if (_parameter > COLOUR_COUNT)
|
||||
{
|
||||
LOG_ERROR("Invalid primary colour %u", _parameter);
|
||||
return Result(Status::InvalidParameters, STR_CANT_REPAINT_THIS, STR_ERR_INVALID_COLOUR);
|
||||
}
|
||||
break;
|
||||
|
||||
case BannerSetStyleType::TextColour:
|
||||
if (_parameter > 13)
|
||||
{
|
||||
LOG_ERROR("Invalid text colour %u", _parameter);
|
||||
return Result(Status::InvalidParameters, STR_CANT_REPAINT_THIS, STR_ERR_INVALID_COLOUR);
|
||||
}
|
||||
break;
|
||||
case BannerSetStyleType::NoEntry:
|
||||
if (tileElement->AsBanner() == nullptr)
|
||||
{
|
||||
LOG_ERROR("Tile element was not a banner.");
|
||||
return Result(Status::Unknown, STR_CANT_RENAME_BANNER, kStringIdNone);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("Invalid banner style type %u", _type);
|
||||
return Result(Status::InvalidParameters, STR_CANT_REPAINT_THIS, STR_ERR_VALUE_OUT_OF_RANGE);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
auto intent = Intent(INTENT_ACTION_UPDATE_BANNER);
|
||||
intent.PutExtra(INTENT_EXTRA_BANNER_INDEX, _bannerIndex);
|
||||
ContextBroadcastIntent(&intent);
|
||||
Result BannerSetStyleAction::Execute() const
|
||||
{
|
||||
auto res = Result();
|
||||
|
||||
ScrollingTextInvalidate();
|
||||
GfxInvalidateScreen();
|
||||
auto banner = GetBanner(_bannerIndex);
|
||||
if (banner == nullptr)
|
||||
{
|
||||
LOG_ERROR("Banner not found for bannerIndex %d", _bannerIndex);
|
||||
return Result(Status::InvalidParameters, STR_CANT_REPAINT_THIS, STR_ERR_BANNER_ELEMENT_NOT_FOUND);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
auto location = banner->position.ToCoordsXY().ToTileCentre();
|
||||
res.Position = { location, TileElementHeight(location) };
|
||||
|
||||
TileElement* tileElement = BannerGetTileElement(_bannerIndex);
|
||||
|
||||
if (tileElement == nullptr)
|
||||
{
|
||||
LOG_ERROR("Banner tile element not found for bannerIndex &u", _bannerIndex);
|
||||
return Result(Status::InvalidParameters, STR_CANT_REPAINT_THIS, kStringIdNone);
|
||||
}
|
||||
|
||||
switch (_type)
|
||||
{
|
||||
case BannerSetStyleType::PrimaryColour:
|
||||
banner->colour = _parameter;
|
||||
break;
|
||||
case BannerSetStyleType::TextColour:
|
||||
banner->textColour = static_cast<TextColour>(_parameter);
|
||||
break;
|
||||
case BannerSetStyleType::NoEntry:
|
||||
{
|
||||
BannerElement* bannerElement = tileElement->AsBanner();
|
||||
if (bannerElement == nullptr)
|
||||
{
|
||||
LOG_ERROR("Tile element was not a banner.");
|
||||
return Result(Status::Unknown, STR_CANT_REPAINT_THIS, STR_ERR_BANNER_ELEMENT_NOT_FOUND);
|
||||
}
|
||||
|
||||
banner->flags.set(BannerFlag::noEntry, (_parameter != 0));
|
||||
uint8_t allowedEdges = 0xF;
|
||||
if (banner->flags.has(BannerFlag::noEntry))
|
||||
{
|
||||
allowedEdges &= ~(1 << bannerElement->GetPosition());
|
||||
}
|
||||
bannerElement->SetAllowedEdges(allowedEdges);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG_ERROR("Invalid banner style type %u", _type);
|
||||
return Result(Status::InvalidParameters, STR_CANT_REPAINT_THIS, STR_ERR_VALUE_OUT_OF_RANGE);
|
||||
}
|
||||
|
||||
auto intent = Intent(INTENT_ACTION_UPDATE_BANNER);
|
||||
intent.PutExtra(INTENT_EXTRA_BANNER_INDEX, _bannerIndex);
|
||||
ContextBroadcastIntent(&intent);
|
||||
|
||||
ScrollingTextInvalidate();
|
||||
GfxInvalidateScreen();
|
||||
|
||||
return res;
|
||||
}
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -11,32 +11,35 @@
|
||||
|
||||
#include "GameAction.h"
|
||||
|
||||
// There is also the BannerSetColourAction that sets primary colour but this action takes banner index rather than x, y, z,
|
||||
// direction
|
||||
enum class BannerSetStyleType : uint8_t
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
PrimaryColour,
|
||||
TextColour,
|
||||
NoEntry,
|
||||
Count
|
||||
};
|
||||
// There is also the BannerSetColourAction that sets primary colour but this action takes banner index rather than x, y, z,
|
||||
// direction
|
||||
enum class BannerSetStyleType : uint8_t
|
||||
{
|
||||
PrimaryColour,
|
||||
TextColour,
|
||||
NoEntry,
|
||||
Count
|
||||
};
|
||||
|
||||
class BannerSetStyleAction final : public GameActionBase<GameCommand::SetBannerStyle>
|
||||
{
|
||||
private:
|
||||
BannerSetStyleType _type{ BannerSetStyleType::Count };
|
||||
BannerIndex _bannerIndex{ BannerIndex::GetNull() };
|
||||
uint8_t _parameter{};
|
||||
class BannerSetStyleAction final : public GameActionBase<GameCommand::SetBannerStyle>
|
||||
{
|
||||
private:
|
||||
BannerSetStyleType _type{ BannerSetStyleType::Count };
|
||||
BannerIndex _bannerIndex{ BannerIndex::GetNull() };
|
||||
uint8_t _parameter{};
|
||||
|
||||
public:
|
||||
BannerSetStyleAction() = default;
|
||||
BannerSetStyleAction(BannerSetStyleType type, BannerIndex bannerIndex, uint8_t parameter);
|
||||
public:
|
||||
BannerSetStyleAction() = default;
|
||||
BannerSetStyleAction(BannerSetStyleType type, BannerIndex bannerIndex, uint8_t parameter);
|
||||
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
|
||||
uint16_t GetActionFlags() const override;
|
||||
uint16_t GetActionFlags() const override;
|
||||
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
OpenRCT2::GameActions::Result Query() const override;
|
||||
OpenRCT2::GameActions::Result Execute() const override;
|
||||
};
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
Result Query() const override;
|
||||
Result Execute() const override;
|
||||
};
|
||||
} // namespace OpenRCT2::GameActions
|
||||
File diff suppressed because it is too large.
Load diff
@@ -11,48 +11,51 @@
|
||||
|
||||
#include "GameAction.h"
|
||||
|
||||
class CheatSetAction final : public GameActionBase<GameCommand::Cheat>
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
using ParametersRange = std::pair<std::pair<int64_t, int64_t>, std::pair<int64_t, int64_t>>;
|
||||
class CheatSetAction final : public GameActionBase<GameCommand::Cheat>
|
||||
{
|
||||
using ParametersRange = std::pair<std::pair<int64_t, int64_t>, std::pair<int64_t, int64_t>>;
|
||||
|
||||
private:
|
||||
NetworkCheatType_t _cheatType{ EnumValue(CheatType::Count) };
|
||||
int64_t _param1{};
|
||||
int64_t _param2{};
|
||||
private:
|
||||
NetworkCheatType_t _cheatType{ EnumValue(CheatType::Count) };
|
||||
int64_t _param1{};
|
||||
int64_t _param2{};
|
||||
|
||||
public:
|
||||
CheatSetAction() = default;
|
||||
CheatSetAction(CheatType cheatType, int64_t param1 = 0, int64_t param2 = 0);
|
||||
public:
|
||||
CheatSetAction() = default;
|
||||
CheatSetAction(CheatType cheatType, int64_t param1 = 0, int64_t param2 = 0);
|
||||
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
|
||||
uint16_t GetActionFlags() const override;
|
||||
uint16_t GetActionFlags() const override;
|
||||
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
OpenRCT2::GameActions::Result Query() const override;
|
||||
OpenRCT2::GameActions::Result Execute() const override;
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
Result Query() const override;
|
||||
Result Execute() const override;
|
||||
|
||||
private:
|
||||
ParametersRange GetParameterRange(CheatType cheatType) const;
|
||||
void SetGrassLength(int32_t length) const;
|
||||
void WaterPlants() const;
|
||||
void FixVandalism() const;
|
||||
void RemoveLitter() const;
|
||||
void FixBrokenRides() const;
|
||||
void RenewRides() const;
|
||||
void ResetRideCrashStatus() const;
|
||||
void Set10MinuteInspection() const;
|
||||
void SetScenarioNoMoney(bool enabled) const;
|
||||
void SetMoney(money64 amount) const;
|
||||
void AddMoney(money64 amount) const;
|
||||
void ClearLoan() const;
|
||||
void GenerateGuests(int32_t count) const;
|
||||
void SetGuestParameter(int32_t parameter, int32_t value) const;
|
||||
void GiveObjectToGuests(int32_t object) const;
|
||||
void RemoveAllGuests() const;
|
||||
void SetStaffSpeed(uint8_t value) const;
|
||||
void OwnAllLand() const;
|
||||
void ParkSetOpen(bool isOpen) const;
|
||||
void CreateDucks(int count) const;
|
||||
void RemoveParkFences() const;
|
||||
};
|
||||
private:
|
||||
ParametersRange GetParameterRange(CheatType cheatType) const;
|
||||
void SetGrassLength(int32_t length) const;
|
||||
void WaterPlants() const;
|
||||
void FixVandalism() const;
|
||||
void RemoveLitter() const;
|
||||
void FixBrokenRides() const;
|
||||
void RenewRides() const;
|
||||
void ResetRideCrashStatus() const;
|
||||
void Set10MinuteInspection() const;
|
||||
void SetScenarioNoMoney(bool enabled) const;
|
||||
void SetMoney(money64 amount) const;
|
||||
void AddMoney(money64 amount) const;
|
||||
void ClearLoan() const;
|
||||
void GenerateGuests(int32_t count) const;
|
||||
void SetGuestParameter(int32_t parameter, int32_t value) const;
|
||||
void GiveObjectToGuests(int32_t object) const;
|
||||
void RemoveAllGuests() const;
|
||||
void SetStaffSpeed(uint8_t value) const;
|
||||
void OwnAllLand() const;
|
||||
void ParkSetOpen(bool isOpen) const;
|
||||
void CreateDucks(int count) const;
|
||||
void RemoveParkFences() const;
|
||||
};
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -143,7 +143,7 @@ money64 ClearAction::ClearSceneryFromTile(const CoordsXY& tilePos, bool executin
|
||||
case TileElementType::Path:
|
||||
if (_itemsToClear & CLEARABLE_ITEMS::kSceneryFootpath)
|
||||
{
|
||||
auto footpathRemoveAction = FootpathRemoveAction({ tilePos, tileElement->GetBaseZ() });
|
||||
auto footpathRemoveAction = GameActions::FootpathRemoveAction({ tilePos, tileElement->GetBaseZ() });
|
||||
footpathRemoveAction.SetFlags(GetFlags());
|
||||
|
||||
auto res = executing ? GameActions::ExecuteNested(&footpathRemoveAction)
|
||||
@@ -159,7 +159,7 @@ money64 ClearAction::ClearSceneryFromTile(const CoordsXY& tilePos, bool executin
|
||||
case TileElementType::SmallScenery:
|
||||
if (_itemsToClear & CLEARABLE_ITEMS::kScenerySmall)
|
||||
{
|
||||
auto removeSceneryAction = SmallSceneryRemoveAction(
|
||||
auto removeSceneryAction = GameActions::SmallSceneryRemoveAction(
|
||||
{ tilePos, tileElement->GetBaseZ() }, tileElement->AsSmallScenery()->GetSceneryQuadrant(),
|
||||
tileElement->AsSmallScenery()->GetEntryIndex());
|
||||
removeSceneryAction.SetFlags(GetFlags());
|
||||
@@ -178,7 +178,7 @@ money64 ClearAction::ClearSceneryFromTile(const CoordsXY& tilePos, bool executin
|
||||
if (_itemsToClear & CLEARABLE_ITEMS::kScenerySmall)
|
||||
{
|
||||
CoordsXYZD wallLocation = { tilePos, tileElement->GetBaseZ(), tileElement->GetDirection() };
|
||||
auto wallRemoveAction = WallRemoveAction(wallLocation);
|
||||
auto wallRemoveAction = GameActions::WallRemoveAction(wallLocation);
|
||||
wallRemoveAction.SetFlags(GetFlags());
|
||||
|
||||
auto res = executing ? GameActions::ExecuteNested(&wallRemoveAction)
|
||||
@@ -194,7 +194,7 @@ money64 ClearAction::ClearSceneryFromTile(const CoordsXY& tilePos, bool executin
|
||||
case TileElementType::LargeScenery:
|
||||
if (_itemsToClear & CLEARABLE_ITEMS::kSceneryLarge)
|
||||
{
|
||||
auto removeSceneryAction = LargeSceneryRemoveAction(
|
||||
auto removeSceneryAction = GameActions::LargeSceneryRemoveAction(
|
||||
{ tilePos, tileElement->GetBaseZ(), tileElement->GetDirection() },
|
||||
tileElement->AsLargeScenery()->GetSequenceIndex());
|
||||
removeSceneryAction.SetFlags(GetFlags() | GAME_COMMAND_FLAG_TRACK_DESIGN);
|
||||
|
||||
@@ -13,51 +13,52 @@
|
||||
#include "../Context.h"
|
||||
#include "../scripting/ScriptEngine.h"
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
CustomAction::CustomAction(const std::string& id, const std::string& json, const std::string& pluginName)
|
||||
: _id(id)
|
||||
, _json(json)
|
||||
, _pluginName(pluginName)
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
}
|
||||
CustomAction::CustomAction(const std::string& id, const std::string& json, const std::string& pluginName)
|
||||
: _id(id)
|
||||
, _json(json)
|
||||
, _pluginName(pluginName)
|
||||
{
|
||||
}
|
||||
|
||||
std::string CustomAction::GetId() const
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
std::string CustomAction::GetId() const
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
std::string CustomAction::GetJson() const
|
||||
{
|
||||
return _json;
|
||||
}
|
||||
std::string CustomAction::GetJson() const
|
||||
{
|
||||
return _json;
|
||||
}
|
||||
|
||||
std::string CustomAction::GetPluginName() const
|
||||
{
|
||||
return _pluginName;
|
||||
}
|
||||
std::string CustomAction::GetPluginName() const
|
||||
{
|
||||
return _pluginName;
|
||||
}
|
||||
|
||||
uint16_t CustomAction::GetActionFlags() const
|
||||
{
|
||||
return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused;
|
||||
}
|
||||
uint16_t CustomAction::GetActionFlags() const
|
||||
{
|
||||
return GameAction::GetActionFlags() | Flags::AllowWhilePaused;
|
||||
}
|
||||
|
||||
void CustomAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
stream << DS_TAG(_id) << DS_TAG(_json);
|
||||
}
|
||||
void CustomAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
stream << DS_TAG(_id) << DS_TAG(_json);
|
||||
}
|
||||
|
||||
GameActions::Result CustomAction::Query() const
|
||||
{
|
||||
auto& scriptingEngine = OpenRCT2::GetContext()->GetScriptEngine();
|
||||
return scriptingEngine.QueryOrExecuteCustomGameAction(*this, false);
|
||||
}
|
||||
Result CustomAction::Query() const
|
||||
{
|
||||
auto& scriptingEngine = GetContext()->GetScriptEngine();
|
||||
return scriptingEngine.QueryOrExecuteCustomGameAction(*this, false);
|
||||
}
|
||||
|
||||
GameActions::Result CustomAction::Execute() const
|
||||
{
|
||||
auto& scriptingEngine = OpenRCT2::GetContext()->GetScriptEngine();
|
||||
return scriptingEngine.QueryOrExecuteCustomGameAction(*this, true);
|
||||
}
|
||||
Result CustomAction::Execute() const
|
||||
{
|
||||
auto& scriptingEngine = GetContext()->GetScriptEngine();
|
||||
return scriptingEngine.QueryOrExecuteCustomGameAction(*this, true);
|
||||
}
|
||||
} // namespace OpenRCT2::GameActions
|
||||
|
||||
#endif
|
||||
@@ -13,26 +13,29 @@
|
||||
|
||||
#include "GameAction.h"
|
||||
|
||||
class CustomAction final : public GameActionBase<GameCommand::Custom>
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
private:
|
||||
std::string _id;
|
||||
std::string _json;
|
||||
std::string _pluginName;
|
||||
class CustomAction final : public GameActionBase<GameCommand::Custom>
|
||||
{
|
||||
private:
|
||||
std::string _id;
|
||||
std::string _json;
|
||||
std::string _pluginName;
|
||||
|
||||
public:
|
||||
CustomAction() = default;
|
||||
CustomAction(const std::string& id, const std::string& json, const std::string& pluginName);
|
||||
public:
|
||||
CustomAction() = default;
|
||||
CustomAction(const std::string& id, const std::string& json, const std::string& pluginName);
|
||||
|
||||
std::string GetId() const;
|
||||
std::string GetJson() const;
|
||||
std::string GetPluginName() const;
|
||||
std::string GetId() const;
|
||||
std::string GetJson() const;
|
||||
std::string GetPluginName() const;
|
||||
|
||||
uint16_t GetActionFlags() const override;
|
||||
uint16_t GetActionFlags() const override;
|
||||
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
OpenRCT2::GameActions::Result Query() const override;
|
||||
OpenRCT2::GameActions::Result Execute() const override;
|
||||
};
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
Result Query() const override;
|
||||
Result Execute() const override;
|
||||
};
|
||||
} // namespace OpenRCT2::GameActions
|
||||
|
||||
#endif
|
||||
@@ -24,177 +24,169 @@
|
||||
#include "../world/Scenery.h"
|
||||
#include "../world/tile_element/PathElement.h"
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
FootpathAdditionPlaceAction::FootpathAdditionPlaceAction(const CoordsXYZ& loc, ObjectEntryIndex pathItemType)
|
||||
: _loc(loc)
|
||||
, _entryIndex(pathItemType)
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
}
|
||||
|
||||
void FootpathAdditionPlaceAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
visitor.Visit(_loc);
|
||||
visitor.Visit("object", _entryIndex);
|
||||
}
|
||||
|
||||
uint16_t FootpathAdditionPlaceAction::GetActionFlags() const
|
||||
{
|
||||
return GameAction::GetActionFlags();
|
||||
}
|
||||
|
||||
void FootpathAdditionPlaceAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_loc) << DS_TAG(_entryIndex);
|
||||
}
|
||||
|
||||
GameActions::Result FootpathAdditionPlaceAction::Query() const
|
||||
{
|
||||
auto res = GameActions::Result();
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
res.Position = _loc;
|
||||
if (!LocationValid(_loc))
|
||||
FootpathAdditionPlaceAction::FootpathAdditionPlaceAction(const CoordsXYZ& loc, ObjectEntryIndex pathItemType)
|
||||
: _loc(loc)
|
||||
, _entryIndex(pathItemType)
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_OFF_EDGE_OF_MAP);
|
||||
}
|
||||
|
||||
if (!(gLegacyScene == LegacyScene::scenarioEditor || getGameState().cheats.sandboxMode) && !MapIsLocationOwned(_loc))
|
||||
void FootpathAdditionPlaceAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::Disallowed, STR_CANT_POSITION_THIS_HERE, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
visitor.Visit(_loc);
|
||||
visitor.Visit("object", _entryIndex);
|
||||
}
|
||||
|
||||
if (_loc.z < kFootpathMinHeight)
|
||||
uint16_t FootpathAdditionPlaceAction::GetActionFlags() const
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_TOO_LOW);
|
||||
return GameAction::GetActionFlags();
|
||||
}
|
||||
|
||||
if (_loc.z > kFootpathMaxHeight)
|
||||
void FootpathAdditionPlaceAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_TOO_HIGH);
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_loc) << DS_TAG(_entryIndex);
|
||||
}
|
||||
|
||||
auto tileElement = MapGetFootpathElement(_loc);
|
||||
if (tileElement == nullptr)
|
||||
Result FootpathAdditionPlaceAction::Query() const
|
||||
{
|
||||
LOG_ERROR("No path element at x = %d, y = %d, z = %d", _loc.x, _loc.y, _loc.z);
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_ERR_PATH_ELEMENT_NOT_FOUND);
|
||||
}
|
||||
|
||||
auto pathElement = tileElement->AsPath();
|
||||
if (pathElement->IsLevelCrossing(_loc))
|
||||
{
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE,
|
||||
STR_CANNOT_BUILD_PATH_ADDITIONS_ON_LEVEL_CROSSINGS);
|
||||
}
|
||||
|
||||
// No change
|
||||
if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST) && pathElement->GetAdditionEntryIndex() == _entryIndex
|
||||
&& !(pathElement->IsBroken()))
|
||||
{
|
||||
return res;
|
||||
}
|
||||
|
||||
auto* pathAdditionEntry = ObjectManager::GetObjectEntry<PathAdditionEntry>(_entryIndex);
|
||||
if (pathAdditionEntry == nullptr)
|
||||
{
|
||||
LOG_ERROR("Unknown footpath addition entry for entryIndex %d", _entryIndex);
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_UNKNOWN_OBJECT_TYPE);
|
||||
}
|
||||
uint16_t sceneryFlags = pathAdditionEntry->flags;
|
||||
|
||||
if ((sceneryFlags & PATH_ADDITION_FLAG_DONT_ALLOW_ON_SLOPE) && pathElement->IsSloped())
|
||||
{
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_CANT_BUILD_THIS_ON_SLOPED_FOOTPATH);
|
||||
}
|
||||
|
||||
if ((sceneryFlags & PATH_ADDITION_FLAG_DONT_ALLOW_ON_QUEUE) && pathElement->IsQueue())
|
||||
{
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_CANNOT_PLACE_THESE_ON_QUEUE_LINE_AREA);
|
||||
}
|
||||
|
||||
if (!(sceneryFlags & (PATH_ADDITION_FLAG_JUMPING_FOUNTAIN_WATER | PATH_ADDITION_FLAG_JUMPING_FOUNTAIN_SNOW))
|
||||
&& (pathElement->GetEdges()) == 0x0F)
|
||||
{
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_CAN_ONLY_BE_PLACED_ON_PATH_EDGES);
|
||||
}
|
||||
|
||||
if ((sceneryFlags & PATH_ADDITION_FLAG_IS_QUEUE_SCREEN) && !pathElement->IsQueue())
|
||||
{
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_CAN_ONLY_PLACE_THESE_ON_QUEUE_AREA);
|
||||
}
|
||||
|
||||
res.Cost = pathAdditionEntry->price;
|
||||
|
||||
// Should place a ghost?
|
||||
if (GetFlags() & GAME_COMMAND_FLAG_GHOST)
|
||||
{
|
||||
// Check if there is something on the path already
|
||||
if (pathElement->HasAddition())
|
||||
auto res = Result();
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
res.Position = _loc;
|
||||
if (!LocationValid(_loc))
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::ItemAlreadyPlaced, STR_CANT_POSITION_THIS_HERE, kStringIdNone);
|
||||
return Result(Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_OFF_EDGE_OF_MAP);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
GameActions::Result FootpathAdditionPlaceAction::Execute() const
|
||||
{
|
||||
auto res = GameActions::Result();
|
||||
res.Position = _loc;
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
if (!(gLegacyScene == LegacyScene::scenarioEditor || getGameState().cheats.sandboxMode) && !MapIsLocationOwned(_loc))
|
||||
{
|
||||
return Result(Status::Disallowed, STR_CANT_POSITION_THIS_HERE, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
}
|
||||
|
||||
auto tileElement = MapGetFootpathElement(_loc);
|
||||
auto pathElement = tileElement->AsPath();
|
||||
if (_loc.z < kFootpathMinHeight)
|
||||
{
|
||||
return Result(Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_TOO_LOW);
|
||||
}
|
||||
|
||||
if (pathElement == nullptr)
|
||||
{
|
||||
LOG_ERROR("No path element at x = %d, y = %d, z = %d", _loc.x, _loc.y, _loc.z);
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_ERR_PATH_ELEMENT_NOT_FOUND);
|
||||
}
|
||||
if (_loc.z > kFootpathMaxHeight)
|
||||
{
|
||||
return Result(Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_TOO_HIGH);
|
||||
}
|
||||
|
||||
// No change
|
||||
if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST) && pathElement->GetAdditionEntryIndex() == _entryIndex
|
||||
&& !(pathElement->IsBroken()) && !pathElement->AdditionIsGhost())
|
||||
{
|
||||
auto tileElement = MapGetFootpathElement(_loc);
|
||||
if (tileElement == nullptr)
|
||||
{
|
||||
LOG_ERROR("No path element at x = %d, y = %d, z = %d", _loc.x, _loc.y, _loc.z);
|
||||
return Result(Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_ERR_PATH_ELEMENT_NOT_FOUND);
|
||||
}
|
||||
|
||||
auto pathElement = tileElement->AsPath();
|
||||
if (pathElement->IsLevelCrossing(_loc))
|
||||
{
|
||||
return Result(
|
||||
Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_CANNOT_BUILD_PATH_ADDITIONS_ON_LEVEL_CROSSINGS);
|
||||
}
|
||||
|
||||
// No change
|
||||
if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST) && pathElement->GetAdditionEntryIndex() == _entryIndex
|
||||
&& !(pathElement->IsBroken()))
|
||||
{
|
||||
return res;
|
||||
}
|
||||
|
||||
auto* pathAdditionEntry = ObjectManager::GetObjectEntry<PathAdditionEntry>(_entryIndex);
|
||||
if (pathAdditionEntry == nullptr)
|
||||
{
|
||||
LOG_ERROR("Unknown footpath addition entry for entryIndex %d", _entryIndex);
|
||||
return Result(Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_UNKNOWN_OBJECT_TYPE);
|
||||
}
|
||||
uint16_t sceneryFlags = pathAdditionEntry->flags;
|
||||
|
||||
if ((sceneryFlags & PATH_ADDITION_FLAG_DONT_ALLOW_ON_SLOPE) && pathElement->IsSloped())
|
||||
{
|
||||
return Result(Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_CANT_BUILD_THIS_ON_SLOPED_FOOTPATH);
|
||||
}
|
||||
|
||||
if ((sceneryFlags & PATH_ADDITION_FLAG_DONT_ALLOW_ON_QUEUE) && pathElement->IsQueue())
|
||||
{
|
||||
return Result(Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_CANNOT_PLACE_THESE_ON_QUEUE_LINE_AREA);
|
||||
}
|
||||
|
||||
if (!(sceneryFlags & (PATH_ADDITION_FLAG_JUMPING_FOUNTAIN_WATER | PATH_ADDITION_FLAG_JUMPING_FOUNTAIN_SNOW))
|
||||
&& (pathElement->GetEdges()) == 0x0F)
|
||||
{
|
||||
return Result(Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_CAN_ONLY_BE_PLACED_ON_PATH_EDGES);
|
||||
}
|
||||
|
||||
if ((sceneryFlags & PATH_ADDITION_FLAG_IS_QUEUE_SCREEN) && !pathElement->IsQueue())
|
||||
{
|
||||
return Result(Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_CAN_ONLY_PLACE_THESE_ON_QUEUE_AREA);
|
||||
}
|
||||
|
||||
res.Cost = pathAdditionEntry->price;
|
||||
|
||||
// Should place a ghost?
|
||||
if (GetFlags() & GAME_COMMAND_FLAG_GHOST)
|
||||
{
|
||||
// Check if there is something on the path already
|
||||
if (pathElement->HasAddition())
|
||||
{
|
||||
return Result(Status::ItemAlreadyPlaced, STR_CANT_POSITION_THIS_HERE, kStringIdNone);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
auto* pathAdditionEntry = OpenRCT2::ObjectManager::GetObjectEntry<PathAdditionEntry>(_entryIndex);
|
||||
if (pathAdditionEntry == nullptr)
|
||||
Result FootpathAdditionPlaceAction::Execute() const
|
||||
{
|
||||
LOG_ERROR("Unknown footpath addition entry for entryIndex %d", _entryIndex);
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_UNKNOWN_OBJECT_TYPE);
|
||||
}
|
||||
auto res = Result();
|
||||
res.Position = _loc;
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
|
||||
res.Cost = pathAdditionEntry->price;
|
||||
auto tileElement = MapGetFootpathElement(_loc);
|
||||
auto pathElement = tileElement->AsPath();
|
||||
|
||||
if (GetFlags() & GAME_COMMAND_FLAG_GHOST)
|
||||
{
|
||||
pathElement->SetAdditionIsGhost(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
FootpathInterruptPeeps(_loc);
|
||||
pathElement->SetAdditionIsGhost(false);
|
||||
}
|
||||
if (pathElement == nullptr)
|
||||
{
|
||||
LOG_ERROR("No path element at x = %d, y = %d, z = %d", _loc.x, _loc.y, _loc.z);
|
||||
return Result(Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_ERR_PATH_ELEMENT_NOT_FOUND);
|
||||
}
|
||||
|
||||
pathElement->SetAdditionEntryIndex(_entryIndex);
|
||||
pathElement->SetIsBroken(false);
|
||||
if (pathAdditionEntry->flags & PATH_ADDITION_FLAG_IS_BIN)
|
||||
{
|
||||
pathElement->SetAdditionStatus(255);
|
||||
// No change
|
||||
if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST) && pathElement->GetAdditionEntryIndex() == _entryIndex
|
||||
&& !(pathElement->IsBroken()) && !pathElement->AdditionIsGhost())
|
||||
{
|
||||
return res;
|
||||
}
|
||||
|
||||
auto* pathAdditionEntry = OpenRCT2::ObjectManager::GetObjectEntry<PathAdditionEntry>(_entryIndex);
|
||||
if (pathAdditionEntry == nullptr)
|
||||
{
|
||||
LOG_ERROR("Unknown footpath addition entry for entryIndex %d", _entryIndex);
|
||||
return Result(Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_UNKNOWN_OBJECT_TYPE);
|
||||
}
|
||||
|
||||
res.Cost = pathAdditionEntry->price;
|
||||
|
||||
if (GetFlags() & GAME_COMMAND_FLAG_GHOST)
|
||||
{
|
||||
pathElement->SetAdditionIsGhost(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
FootpathInterruptPeeps(_loc);
|
||||
pathElement->SetAdditionIsGhost(false);
|
||||
}
|
||||
|
||||
pathElement->SetAdditionEntryIndex(_entryIndex);
|
||||
pathElement->SetIsBroken(false);
|
||||
if (pathAdditionEntry->flags & PATH_ADDITION_FLAG_IS_BIN)
|
||||
{
|
||||
pathElement->SetAdditionStatus(255);
|
||||
}
|
||||
MapInvalidateTileFull(_loc);
|
||||
return res;
|
||||
}
|
||||
MapInvalidateTileFull(_loc);
|
||||
return res;
|
||||
}
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -11,21 +11,24 @@
|
||||
|
||||
#include "GameAction.h"
|
||||
|
||||
class FootpathAdditionPlaceAction final : public GameActionBase<GameCommand::PlaceFootpathAddition>
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
private:
|
||||
CoordsXYZ _loc;
|
||||
OpenRCT2::ObjectEntryIndex _entryIndex{};
|
||||
class FootpathAdditionPlaceAction final : public GameActionBase<GameCommand::PlaceFootpathAddition>
|
||||
{
|
||||
private:
|
||||
CoordsXYZ _loc;
|
||||
ObjectEntryIndex _entryIndex{};
|
||||
|
||||
public:
|
||||
FootpathAdditionPlaceAction() = default;
|
||||
FootpathAdditionPlaceAction(const CoordsXYZ& loc, OpenRCT2::ObjectEntryIndex pathItemType);
|
||||
public:
|
||||
FootpathAdditionPlaceAction() = default;
|
||||
FootpathAdditionPlaceAction(const CoordsXYZ& loc, ObjectEntryIndex pathItemType);
|
||||
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
|
||||
uint16_t GetActionFlags() const override;
|
||||
uint16_t GetActionFlags() const override;
|
||||
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
OpenRCT2::GameActions::Result Query() const override;
|
||||
OpenRCT2::GameActions::Result Execute() const override;
|
||||
};
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
Result Query() const override;
|
||||
Result Execute() const override;
|
||||
};
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -21,99 +21,97 @@
|
||||
#include "../world/Park.h"
|
||||
#include "../world/tile_element/PathElement.h"
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
FootpathAdditionRemoveAction::FootpathAdditionRemoveAction(const CoordsXYZ& loc)
|
||||
: _loc(loc)
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
}
|
||||
|
||||
void FootpathAdditionRemoveAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
visitor.Visit(_loc);
|
||||
}
|
||||
|
||||
uint16_t FootpathAdditionRemoveAction::GetActionFlags() const
|
||||
{
|
||||
return GameAction::GetActionFlags();
|
||||
}
|
||||
|
||||
void FootpathAdditionRemoveAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_loc);
|
||||
}
|
||||
|
||||
GameActions::Result FootpathAdditionRemoveAction::Query() const
|
||||
{
|
||||
if (!LocationValid(_loc))
|
||||
FootpathAdditionRemoveAction::FootpathAdditionRemoveAction(const CoordsXYZ& loc)
|
||||
: _loc(loc)
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_OFF_EDGE_OF_MAP);
|
||||
}
|
||||
|
||||
if (!(gLegacyScene == LegacyScene::scenarioEditor || getGameState().cheats.sandboxMode) && !MapIsLocationOwned(_loc))
|
||||
void FootpathAdditionRemoveAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::Disallowed, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
visitor.Visit(_loc);
|
||||
}
|
||||
|
||||
if (_loc.z < kFootpathMinHeight)
|
||||
uint16_t FootpathAdditionRemoveAction::GetActionFlags() const
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_TOO_LOW);
|
||||
return GameAction::GetActionFlags();
|
||||
}
|
||||
|
||||
if (_loc.z > kFootpathMaxHeight)
|
||||
void FootpathAdditionRemoveAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_TOO_HIGH);
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_loc);
|
||||
}
|
||||
|
||||
auto tileElement = MapGetFootpathElement(_loc);
|
||||
if (tileElement == nullptr)
|
||||
Result FootpathAdditionRemoveAction::Query() const
|
||||
{
|
||||
LOG_ERROR("No path element at x = %d, y = %d, z = %d", _loc.x, _loc.y, _loc.z);
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_ERR_PATH_ELEMENT_NOT_FOUND);
|
||||
if (!LocationValid(_loc))
|
||||
{
|
||||
return Result(Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_OFF_EDGE_OF_MAP);
|
||||
}
|
||||
|
||||
if (!(gLegacyScene == LegacyScene::scenarioEditor || getGameState().cheats.sandboxMode) && !MapIsLocationOwned(_loc))
|
||||
{
|
||||
return Result(Status::Disallowed, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
}
|
||||
|
||||
if (_loc.z < kFootpathMinHeight)
|
||||
{
|
||||
return Result(Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_TOO_LOW);
|
||||
}
|
||||
|
||||
if (_loc.z > kFootpathMaxHeight)
|
||||
{
|
||||
return Result(Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_TOO_HIGH);
|
||||
}
|
||||
|
||||
auto tileElement = MapGetFootpathElement(_loc);
|
||||
if (tileElement == nullptr)
|
||||
{
|
||||
LOG_ERROR("No path element at x = %d, y = %d, z = %d", _loc.x, _loc.y, _loc.z);
|
||||
return Result(Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_ERR_PATH_ELEMENT_NOT_FOUND);
|
||||
}
|
||||
|
||||
auto pathElement = tileElement->AsPath();
|
||||
if (pathElement == nullptr)
|
||||
{
|
||||
LOG_ERROR("No path element at x = %d, y = %d, z = %d", _loc.x, _loc.y, _loc.z);
|
||||
return Result(Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_ERR_PATH_ELEMENT_NOT_FOUND);
|
||||
}
|
||||
|
||||
if (!pathElement->AdditionIsGhost() && (GetFlags() & GAME_COMMAND_FLAG_GHOST))
|
||||
{
|
||||
LOG_WARNING("Tried to remove non ghost during ghost removal.");
|
||||
return Result(Status::Disallowed, STR_CANT_REMOVE_THIS, kStringIdNone);
|
||||
}
|
||||
auto res = Result();
|
||||
res.Position = _loc;
|
||||
res.Cost = 0.00_GBP;
|
||||
return res;
|
||||
}
|
||||
|
||||
auto pathElement = tileElement->AsPath();
|
||||
if (pathElement == nullptr)
|
||||
Result FootpathAdditionRemoveAction::Execute() const
|
||||
{
|
||||
LOG_ERROR("No path element at x = %d, y = %d, z = %d", _loc.x, _loc.y, _loc.z);
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_ERR_PATH_ELEMENT_NOT_FOUND);
|
||||
auto* pathElement = MapGetFootpathElement(_loc);
|
||||
if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST))
|
||||
{
|
||||
FootpathInterruptPeeps(_loc);
|
||||
}
|
||||
|
||||
if (pathElement == nullptr)
|
||||
{
|
||||
LOG_ERROR("No path element at x = %d, y = %d, z = %d", _loc.x, _loc.y, _loc.z);
|
||||
return Result(Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_ERR_PATH_ELEMENT_NOT_FOUND);
|
||||
}
|
||||
|
||||
pathElement->SetAddition(0);
|
||||
MapInvalidateTileFull(_loc);
|
||||
|
||||
auto res = Result();
|
||||
res.Position = _loc;
|
||||
res.Cost = 0.00_GBP;
|
||||
return res;
|
||||
}
|
||||
|
||||
if (!pathElement->AdditionIsGhost() && (GetFlags() & GAME_COMMAND_FLAG_GHOST))
|
||||
{
|
||||
LOG_WARNING("Tried to remove non ghost during ghost removal.");
|
||||
return GameActions::Result(GameActions::Status::Disallowed, STR_CANT_REMOVE_THIS, kStringIdNone);
|
||||
}
|
||||
auto res = GameActions::Result();
|
||||
res.Position = _loc;
|
||||
res.Cost = 0.00_GBP;
|
||||
return res;
|
||||
}
|
||||
|
||||
GameActions::Result FootpathAdditionRemoveAction::Execute() const
|
||||
{
|
||||
auto* pathElement = MapGetFootpathElement(_loc);
|
||||
if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST))
|
||||
{
|
||||
FootpathInterruptPeeps(_loc);
|
||||
}
|
||||
|
||||
if (pathElement == nullptr)
|
||||
{
|
||||
LOG_ERROR("No path element at x = %d, y = %d, z = %d", _loc.x, _loc.y, _loc.z);
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_ERR_PATH_ELEMENT_NOT_FOUND);
|
||||
}
|
||||
|
||||
pathElement->SetAddition(0);
|
||||
MapInvalidateTileFull(_loc);
|
||||
|
||||
auto res = GameActions::Result();
|
||||
res.Position = _loc;
|
||||
res.Cost = 0.00_GBP;
|
||||
return res;
|
||||
}
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -11,20 +11,23 @@
|
||||
|
||||
#include "GameAction.h"
|
||||
|
||||
class FootpathAdditionRemoveAction final : public GameActionBase<GameCommand::RemoveFootpathAddition>
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
private:
|
||||
CoordsXYZ _loc;
|
||||
class FootpathAdditionRemoveAction final : public GameActionBase<GameCommand::RemoveFootpathAddition>
|
||||
{
|
||||
private:
|
||||
CoordsXYZ _loc;
|
||||
|
||||
public:
|
||||
FootpathAdditionRemoveAction() = default;
|
||||
FootpathAdditionRemoveAction(const CoordsXYZ& loc);
|
||||
public:
|
||||
FootpathAdditionRemoveAction() = default;
|
||||
FootpathAdditionRemoveAction(const CoordsXYZ& loc);
|
||||
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
|
||||
uint16_t GetActionFlags() const override;
|
||||
uint16_t GetActionFlags() const override;
|
||||
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
OpenRCT2::GameActions::Result Query() const override;
|
||||
OpenRCT2::GameActions::Result Execute() const override;
|
||||
};
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
Result Query() const override;
|
||||
Result Execute() const override;
|
||||
};
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -26,295 +26,291 @@
|
||||
#include "../world/tile_element/Slope.h"
|
||||
#include "../world/tile_element/SurfaceElement.h"
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
FootpathLayoutPlaceAction::FootpathLayoutPlaceAction(
|
||||
const CoordsXYZ& loc, uint8_t slope, ObjectEntryIndex type, ObjectEntryIndex railingsType, uint8_t edges,
|
||||
PathConstructFlags constructFlags)
|
||||
: _loc(loc)
|
||||
, _slope(slope)
|
||||
, _type(type)
|
||||
, _railingsType(railingsType)
|
||||
, _edges(edges)
|
||||
, _constructFlags(constructFlags)
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
}
|
||||
|
||||
void FootpathLayoutPlaceAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_loc) << DS_TAG(_slope) << DS_TAG(_type) << DS_TAG(_railingsType) << DS_TAG(_edges)
|
||||
<< DS_TAG(_constructFlags);
|
||||
}
|
||||
|
||||
void FootpathLayoutPlaceAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
visitor.Visit(_loc);
|
||||
visitor.Visit("slope", _slope);
|
||||
visitor.Visit("object", _type);
|
||||
visitor.Visit("railingsObject", _railingsType);
|
||||
visitor.Visit("edges", _edges);
|
||||
visitor.Visit("constructFlags", _constructFlags);
|
||||
}
|
||||
|
||||
uint16_t FootpathLayoutPlaceAction::GetActionFlags() const
|
||||
{
|
||||
return GameAction::GetActionFlags();
|
||||
}
|
||||
|
||||
GameActions::Result FootpathLayoutPlaceAction::Query() const
|
||||
{
|
||||
auto res = GameActions::Result();
|
||||
res.Cost = 0;
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
res.Position = _loc.ToTileCentre();
|
||||
|
||||
gFootpathGroundFlags = 0;
|
||||
|
||||
if (!LocationValid(_loc) || MapIsEdge(_loc))
|
||||
FootpathLayoutPlaceAction::FootpathLayoutPlaceAction(
|
||||
const CoordsXYZ& loc, uint8_t slope, ObjectEntryIndex type, ObjectEntryIndex railingsType, uint8_t edges,
|
||||
PathConstructFlags constructFlags)
|
||||
: _loc(loc)
|
||||
, _slope(slope)
|
||||
, _type(type)
|
||||
, _railingsType(railingsType)
|
||||
, _edges(edges)
|
||||
, _constructFlags(constructFlags)
|
||||
{
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_OFF_EDGE_OF_MAP);
|
||||
}
|
||||
|
||||
if (!(gLegacyScene == LegacyScene::scenarioEditor || getGameState().cheats.sandboxMode) && !MapIsLocationOwned(_loc))
|
||||
void FootpathLayoutPlaceAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
return GameActions::Result(
|
||||
GameActions::Status::Disallowed, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_loc) << DS_TAG(_slope) << DS_TAG(_type) << DS_TAG(_railingsType) << DS_TAG(_edges)
|
||||
<< DS_TAG(_constructFlags);
|
||||
}
|
||||
|
||||
if (_loc.z < kFootpathMinHeight)
|
||||
void FootpathLayoutPlaceAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
return GameActions::Result(
|
||||
GameActions::Status::Disallowed, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_TOO_LOW);
|
||||
visitor.Visit(_loc);
|
||||
visitor.Visit("slope", _slope);
|
||||
visitor.Visit("object", _type);
|
||||
visitor.Visit("railingsObject", _railingsType);
|
||||
visitor.Visit("edges", _edges);
|
||||
visitor.Visit("constructFlags", _constructFlags);
|
||||
}
|
||||
|
||||
if (_loc.z > kFootpathMaxHeight)
|
||||
uint16_t FootpathLayoutPlaceAction::GetActionFlags() const
|
||||
{
|
||||
return GameActions::Result(
|
||||
GameActions::Status::Disallowed, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_TOO_HIGH);
|
||||
return GameAction::GetActionFlags();
|
||||
}
|
||||
|
||||
return ElementInsertQuery(std::move(res));
|
||||
}
|
||||
|
||||
GameActions::Result FootpathLayoutPlaceAction::Execute() const
|
||||
{
|
||||
auto res = GameActions::Result();
|
||||
res.Cost = 0;
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
res.Position = _loc.ToTileCentre();
|
||||
|
||||
if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST))
|
||||
Result FootpathLayoutPlaceAction::Query() const
|
||||
{
|
||||
FootpathInterruptPeeps(_loc);
|
||||
}
|
||||
|
||||
gFootpathGroundFlags = 0;
|
||||
|
||||
// Force ride construction to recheck area
|
||||
_currentTrackSelectionFlags.set(TrackSelectionFlag::recheck);
|
||||
|
||||
return ElementInsertExecute(std::move(res));
|
||||
}
|
||||
|
||||
GameActions::Result FootpathLayoutPlaceAction::ElementInsertQuery(GameActions::Result res) const
|
||||
{
|
||||
bool entrancePath = false, entranceIsSamePath = false;
|
||||
|
||||
if (!MapCheckCapacityAndReorganise(_loc))
|
||||
{
|
||||
return GameActions::Result(
|
||||
GameActions::Status::NoFreeElements, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE,
|
||||
STR_TILE_ELEMENT_LIMIT_REACHED);
|
||||
}
|
||||
|
||||
res.Cost = 12.00_GBP;
|
||||
|
||||
QuarterTile quarterTile{ 0b1111, 0 };
|
||||
auto zLow = _loc.z;
|
||||
auto zHigh = zLow + kPathClearance;
|
||||
if (_slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED)
|
||||
{
|
||||
quarterTile = QuarterTile{ 0b1111, 0b1100 }.Rotate(_slope & kTileElementDirectionMask);
|
||||
zHigh += kPathHeightStep;
|
||||
}
|
||||
|
||||
auto entranceElement = MapGetParkEntranceElementAt(_loc, false);
|
||||
// Make sure the entrance part is the middle
|
||||
if (entranceElement != nullptr && (entranceElement->GetSequenceIndex()) == 0)
|
||||
{
|
||||
entrancePath = true;
|
||||
// Make the price the same as replacing a path
|
||||
if (IsSameAsEntranceElement(*entranceElement))
|
||||
entranceIsSamePath = true;
|
||||
else
|
||||
res.Cost -= 6.00_GBP;
|
||||
}
|
||||
|
||||
// Do not attempt to build a crossing with a queue or a sloped path.
|
||||
auto isQueue = _constructFlags & PathConstructFlag::IsQueue;
|
||||
auto crossingMode = isQueue || (_slope != kTileSlopeFlat) ? CreateCrossingMode::none : CreateCrossingMode::pathOverTrack;
|
||||
auto canBuild = MapCanConstructWithClearAt(
|
||||
{ _loc, zLow, zHigh }, &MapPlaceNonSceneryClearFunc, quarterTile, GetFlags(), crossingMode);
|
||||
if (!entrancePath && canBuild.Error != GameActions::Status::Ok)
|
||||
{
|
||||
canBuild.ErrorTitle = STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE;
|
||||
return canBuild;
|
||||
}
|
||||
res.Cost += canBuild.Cost;
|
||||
|
||||
const auto clearanceData = canBuild.GetData<ConstructClearResult>();
|
||||
gFootpathGroundFlags = clearanceData.GroundFlags;
|
||||
|
||||
if (!getGameState().cheats.disableClearanceChecks && (clearanceData.GroundFlags & ELEMENT_IS_UNDERWATER))
|
||||
{
|
||||
return GameActions::Result(
|
||||
GameActions::Status::Disallowed, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_CANT_BUILD_THIS_UNDERWATER);
|
||||
}
|
||||
|
||||
auto surfaceElement = MapGetSurfaceElementAt(_loc);
|
||||
if (surfaceElement == nullptr)
|
||||
{
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE,
|
||||
STR_ERR_SURFACE_ELEMENT_NOT_FOUND);
|
||||
}
|
||||
int32_t supportHeight = zLow - surfaceElement->GetBaseZ();
|
||||
res.Cost += supportHeight < 0 ? 20.00_GBP : (supportHeight / kPathHeightStep) * 5.00_GBP;
|
||||
|
||||
// Prevent the place sound from being spammed
|
||||
if (entranceIsSamePath)
|
||||
auto res = Result();
|
||||
res.Cost = 0;
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
res.Position = _loc.ToTileCentre();
|
||||
|
||||
return res;
|
||||
}
|
||||
gFootpathGroundFlags = 0;
|
||||
|
||||
GameActions::Result FootpathLayoutPlaceAction::ElementInsertExecute(GameActions::Result res) const
|
||||
{
|
||||
bool entrancePath = false, entranceIsSamePath = false;
|
||||
|
||||
if (!(GetFlags() & (GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_GHOST)))
|
||||
{
|
||||
FootpathRemoveLitter(_loc);
|
||||
}
|
||||
|
||||
res.Cost = 12.00_GBP;
|
||||
|
||||
QuarterTile quarterTile{ 0b1111, 0 };
|
||||
auto zLow = _loc.z;
|
||||
auto zHigh = zLow + kPathClearance;
|
||||
if (_slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED)
|
||||
{
|
||||
quarterTile = QuarterTile{ 0b1111, 0b1100 }.Rotate(_slope & kTileElementDirectionMask);
|
||||
zHigh += kPathHeightStep;
|
||||
}
|
||||
|
||||
auto entranceElement = MapGetParkEntranceElementAt(_loc, false);
|
||||
// Make sure the entrance part is the middle
|
||||
if (entranceElement != nullptr && (entranceElement->GetSequenceIndex()) == 0)
|
||||
{
|
||||
entrancePath = true;
|
||||
// Make the price the same as replacing a path
|
||||
if (IsSameAsEntranceElement(*entranceElement))
|
||||
entranceIsSamePath = true;
|
||||
else
|
||||
res.Cost -= 6.00_GBP;
|
||||
}
|
||||
|
||||
// Do not attempt to build a crossing with a queue or a sloped path.
|
||||
auto isQueue = _constructFlags & PathConstructFlag::IsQueue;
|
||||
auto crossingMode = isQueue || (_slope != kTileSlopeFlat) ? CreateCrossingMode::none : CreateCrossingMode::pathOverTrack;
|
||||
auto canBuild = MapCanConstructWithClearAt(
|
||||
{ _loc, zLow, zHigh }, &MapPlaceNonSceneryClearFunc, quarterTile, GAME_COMMAND_FLAG_APPLY | GetFlags(), crossingMode);
|
||||
if (!entrancePath && canBuild.Error != GameActions::Status::Ok)
|
||||
{
|
||||
canBuild.ErrorTitle = STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE;
|
||||
return canBuild;
|
||||
}
|
||||
res.Cost += canBuild.Cost;
|
||||
|
||||
const auto clearanceData = canBuild.GetData<ConstructClearResult>();
|
||||
gFootpathGroundFlags = clearanceData.GroundFlags;
|
||||
|
||||
auto surfaceElement = MapGetSurfaceElementAt(_loc);
|
||||
if (surfaceElement == nullptr)
|
||||
{
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE,
|
||||
STR_ERR_SURFACE_ELEMENT_NOT_FOUND);
|
||||
}
|
||||
int32_t supportHeight = zLow - surfaceElement->GetBaseZ();
|
||||
res.Cost += supportHeight < 0 ? 20.00_GBP : (supportHeight / kPathHeightStep) * 5.00_GBP;
|
||||
|
||||
if (entrancePath)
|
||||
{
|
||||
if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST) && !entranceIsSamePath)
|
||||
if (!LocationValid(_loc) || MapIsEdge(_loc))
|
||||
{
|
||||
return Result(Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_OFF_EDGE_OF_MAP);
|
||||
}
|
||||
|
||||
if (!(gLegacyScene == LegacyScene::scenarioEditor || getGameState().cheats.sandboxMode) && !MapIsLocationOwned(_loc))
|
||||
{
|
||||
return Result(Status::Disallowed, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
}
|
||||
|
||||
if (_loc.z < kFootpathMinHeight)
|
||||
{
|
||||
return Result(Status::Disallowed, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_TOO_LOW);
|
||||
}
|
||||
|
||||
if (_loc.z > kFootpathMaxHeight)
|
||||
{
|
||||
return Result(Status::Disallowed, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_TOO_HIGH);
|
||||
}
|
||||
|
||||
return ElementInsertQuery(std::move(res));
|
||||
}
|
||||
|
||||
Result FootpathLayoutPlaceAction::Execute() const
|
||||
{
|
||||
auto res = Result();
|
||||
res.Cost = 0;
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
res.Position = _loc.ToTileCentre();
|
||||
|
||||
if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST))
|
||||
{
|
||||
FootpathInterruptPeeps(_loc);
|
||||
}
|
||||
|
||||
gFootpathGroundFlags = 0;
|
||||
|
||||
// Force ride construction to recheck area
|
||||
_currentTrackSelectionFlags.set(TrackSelectionFlag::recheck);
|
||||
|
||||
return ElementInsertExecute(std::move(res));
|
||||
}
|
||||
|
||||
Result FootpathLayoutPlaceAction::ElementInsertQuery(Result res) const
|
||||
{
|
||||
bool entrancePath = false, entranceIsSamePath = false;
|
||||
|
||||
if (!MapCheckCapacityAndReorganise(_loc))
|
||||
{
|
||||
return Result(
|
||||
Status::NoFreeElements, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_TILE_ELEMENT_LIMIT_REACHED);
|
||||
}
|
||||
|
||||
res.Cost = 12.00_GBP;
|
||||
|
||||
QuarterTile quarterTile{ 0b1111, 0 };
|
||||
auto zLow = _loc.z;
|
||||
auto zHigh = zLow + kPathClearance;
|
||||
if (_slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED)
|
||||
{
|
||||
quarterTile = QuarterTile{ 0b1111, 0b1100 }.Rotate(_slope & kTileElementDirectionMask);
|
||||
zHigh += kPathHeightStep;
|
||||
}
|
||||
|
||||
auto entranceElement = MapGetParkEntranceElementAt(_loc, false);
|
||||
// Make sure the entrance part is the middle
|
||||
if (entranceElement != nullptr && (entranceElement->GetSequenceIndex()) == 0)
|
||||
{
|
||||
entrancePath = true;
|
||||
// Make the price the same as replacing a path
|
||||
if (IsSameAsEntranceElement(*entranceElement))
|
||||
entranceIsSamePath = true;
|
||||
else
|
||||
res.Cost -= 6.00_GBP;
|
||||
}
|
||||
|
||||
// Do not attempt to build a crossing with a queue or a sloped path.
|
||||
auto isQueue = _constructFlags & PathConstructFlag::IsQueue;
|
||||
auto crossingMode = isQueue || (_slope != kTileSlopeFlat) ? CreateCrossingMode::none
|
||||
: CreateCrossingMode::pathOverTrack;
|
||||
auto canBuild = MapCanConstructWithClearAt(
|
||||
{ _loc, zLow, zHigh }, &MapPlaceNonSceneryClearFunc, quarterTile, GetFlags(), crossingMode);
|
||||
if (!entrancePath && canBuild.Error != Status::Ok)
|
||||
{
|
||||
canBuild.ErrorTitle = STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE;
|
||||
return canBuild;
|
||||
}
|
||||
res.Cost += canBuild.Cost;
|
||||
|
||||
const auto clearanceData = canBuild.GetData<ConstructClearResult>();
|
||||
gFootpathGroundFlags = clearanceData.GroundFlags;
|
||||
|
||||
if (!getGameState().cheats.disableClearanceChecks && (clearanceData.GroundFlags & ELEMENT_IS_UNDERWATER))
|
||||
{
|
||||
return Result(Status::Disallowed, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_CANT_BUILD_THIS_UNDERWATER);
|
||||
}
|
||||
|
||||
auto surfaceElement = MapGetSurfaceElementAt(_loc);
|
||||
if (surfaceElement == nullptr)
|
||||
{
|
||||
return Result(
|
||||
Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_ERR_SURFACE_ELEMENT_NOT_FOUND);
|
||||
}
|
||||
int32_t supportHeight = zLow - surfaceElement->GetBaseZ();
|
||||
res.Cost += supportHeight < 0 ? 20.00_GBP : (supportHeight / kPathHeightStep) * 5.00_GBP;
|
||||
|
||||
// Prevent the place sound from being spammed
|
||||
if (entranceIsSamePath)
|
||||
res.Cost = 0;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
Result FootpathLayoutPlaceAction::ElementInsertExecute(Result res) const
|
||||
{
|
||||
bool entrancePath = false, entranceIsSamePath = false;
|
||||
|
||||
if (!(GetFlags() & (GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_GHOST)))
|
||||
{
|
||||
FootpathRemoveLitter(_loc);
|
||||
}
|
||||
|
||||
res.Cost = 12.00_GBP;
|
||||
|
||||
QuarterTile quarterTile{ 0b1111, 0 };
|
||||
auto zLow = _loc.z;
|
||||
auto zHigh = zLow + kPathClearance;
|
||||
if (_slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED)
|
||||
{
|
||||
quarterTile = QuarterTile{ 0b1111, 0b1100 }.Rotate(_slope & kTileElementDirectionMask);
|
||||
zHigh += kPathHeightStep;
|
||||
}
|
||||
|
||||
auto entranceElement = MapGetParkEntranceElementAt(_loc, false);
|
||||
// Make sure the entrance part is the middle
|
||||
if (entranceElement != nullptr && (entranceElement->GetSequenceIndex()) == 0)
|
||||
{
|
||||
entrancePath = true;
|
||||
// Make the price the same as replacing a path
|
||||
if (IsSameAsEntranceElement(*entranceElement))
|
||||
entranceIsSamePath = true;
|
||||
else
|
||||
res.Cost -= 6.00_GBP;
|
||||
}
|
||||
|
||||
// Do not attempt to build a crossing with a queue or a sloped path.
|
||||
auto isQueue = _constructFlags & PathConstructFlag::IsQueue;
|
||||
auto crossingMode = isQueue || (_slope != kTileSlopeFlat) ? CreateCrossingMode::none
|
||||
: CreateCrossingMode::pathOverTrack;
|
||||
auto canBuild = MapCanConstructWithClearAt(
|
||||
{ _loc, zLow, zHigh }, &MapPlaceNonSceneryClearFunc, quarterTile, GAME_COMMAND_FLAG_APPLY | GetFlags(),
|
||||
crossingMode);
|
||||
if (!entrancePath && canBuild.Error != Status::Ok)
|
||||
{
|
||||
canBuild.ErrorTitle = STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE;
|
||||
return canBuild;
|
||||
}
|
||||
res.Cost += canBuild.Cost;
|
||||
|
||||
const auto clearanceData = canBuild.GetData<ConstructClearResult>();
|
||||
gFootpathGroundFlags = clearanceData.GroundFlags;
|
||||
|
||||
auto surfaceElement = MapGetSurfaceElementAt(_loc);
|
||||
if (surfaceElement == nullptr)
|
||||
{
|
||||
return Result(
|
||||
Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_ERR_SURFACE_ELEMENT_NOT_FOUND);
|
||||
}
|
||||
int32_t supportHeight = zLow - surfaceElement->GetBaseZ();
|
||||
res.Cost += supportHeight < 0 ? 20.00_GBP : (supportHeight / kPathHeightStep) * 5.00_GBP;
|
||||
|
||||
if (entrancePath)
|
||||
{
|
||||
if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST) && !entranceIsSamePath)
|
||||
{
|
||||
if (_constructFlags & PathConstructFlag::IsLegacyPathObject)
|
||||
{
|
||||
entranceElement->SetLegacyPathEntryIndex(_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
entranceElement->SetSurfaceEntryIndex(_type);
|
||||
}
|
||||
MapInvalidateTileFull(_loc);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
auto* pathElement = TileElementInsert<PathElement>(_loc, 0b1111);
|
||||
Guard::Assert(pathElement != nullptr);
|
||||
|
||||
pathElement->SetClearanceZ(zHigh);
|
||||
if (_constructFlags & PathConstructFlag::IsLegacyPathObject)
|
||||
{
|
||||
entranceElement->SetLegacyPathEntryIndex(_type);
|
||||
pathElement->SetLegacyPathEntryIndex(_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
entranceElement->SetSurfaceEntryIndex(_type);
|
||||
pathElement->SetSurfaceEntryIndex(_type);
|
||||
pathElement->SetRailingsEntryIndex(_railingsType);
|
||||
}
|
||||
pathElement->SetSlopeDirection(_slope & FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK);
|
||||
pathElement->SetSloped(_slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED);
|
||||
pathElement->SetIsQueue(isQueue);
|
||||
pathElement->SetAddition(0);
|
||||
pathElement->SetRideIndex(RideId::GetNull());
|
||||
pathElement->SetAdditionStatus(255);
|
||||
pathElement->SetIsBroken(false);
|
||||
pathElement->SetEdges(_edges);
|
||||
pathElement->SetCorners(0);
|
||||
pathElement->SetGhost(GetFlags() & GAME_COMMAND_FLAG_GHOST);
|
||||
|
||||
MapInvalidateTileFull(_loc);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
auto* pathElement = TileElementInsert<PathElement>(_loc, 0b1111);
|
||||
Guard::Assert(pathElement != nullptr);
|
||||
|
||||
pathElement->SetClearanceZ(zHigh);
|
||||
// Prevent the place sound from being spammed
|
||||
if (entranceIsSamePath)
|
||||
res.Cost = 0;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool FootpathLayoutPlaceAction::IsSameAsEntranceElement(const EntranceElement& entranceElement) const
|
||||
{
|
||||
if (entranceElement.HasLegacyPathEntry())
|
||||
{
|
||||
if (_constructFlags & PathConstructFlag::IsLegacyPathObject)
|
||||
{
|
||||
return entranceElement.GetLegacyPathEntryIndex() == _type;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_constructFlags & PathConstructFlag::IsLegacyPathObject)
|
||||
{
|
||||
pathElement->SetLegacyPathEntryIndex(_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
pathElement->SetSurfaceEntryIndex(_type);
|
||||
pathElement->SetRailingsEntryIndex(_railingsType);
|
||||
}
|
||||
pathElement->SetSlopeDirection(_slope & FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK);
|
||||
pathElement->SetSloped(_slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED);
|
||||
pathElement->SetIsQueue(isQueue);
|
||||
pathElement->SetAddition(0);
|
||||
pathElement->SetRideIndex(RideId::GetNull());
|
||||
pathElement->SetAdditionStatus(255);
|
||||
pathElement->SetIsBroken(false);
|
||||
pathElement->SetEdges(_edges);
|
||||
pathElement->SetCorners(0);
|
||||
pathElement->SetGhost(GetFlags() & GAME_COMMAND_FLAG_GHOST);
|
||||
|
||||
MapInvalidateTileFull(_loc);
|
||||
}
|
||||
|
||||
// Prevent the place sound from being spammed
|
||||
if (entranceIsSamePath)
|
||||
res.Cost = 0;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool FootpathLayoutPlaceAction::IsSameAsEntranceElement(const EntranceElement& entranceElement) const
|
||||
{
|
||||
if (entranceElement.HasLegacyPathEntry())
|
||||
{
|
||||
if (_constructFlags & PathConstructFlag::IsLegacyPathObject)
|
||||
{
|
||||
return entranceElement.GetLegacyPathEntryIndex() == _type;
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
return entranceElement.GetSurfaceEntryIndex() == _type;
|
||||
}
|
||||
|
||||
if (_constructFlags & PathConstructFlag::IsLegacyPathObject)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return entranceElement.GetSurfaceEntryIndex() == _type;
|
||||
}
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -12,32 +12,35 @@
|
||||
#include "../world/Footpath.h"
|
||||
#include "GameAction.h"
|
||||
|
||||
class FootpathLayoutPlaceAction final : public GameActionBase<GameCommand::PlacePathLayout>
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
private:
|
||||
CoordsXYZ _loc;
|
||||
uint8_t _slope{};
|
||||
OpenRCT2::ObjectEntryIndex _type{};
|
||||
OpenRCT2::ObjectEntryIndex _railingsType{};
|
||||
uint8_t _edges{};
|
||||
PathConstructFlags _constructFlags{};
|
||||
class FootpathLayoutPlaceAction final : public GameActionBase<GameCommand::PlacePathLayout>
|
||||
{
|
||||
private:
|
||||
CoordsXYZ _loc;
|
||||
uint8_t _slope{};
|
||||
ObjectEntryIndex _type{};
|
||||
ObjectEntryIndex _railingsType{};
|
||||
uint8_t _edges{};
|
||||
PathConstructFlags _constructFlags{};
|
||||
|
||||
public:
|
||||
FootpathLayoutPlaceAction() = default;
|
||||
FootpathLayoutPlaceAction(
|
||||
const CoordsXYZ& loc, uint8_t slope, OpenRCT2::ObjectEntryIndex type, OpenRCT2::ObjectEntryIndex railingsType,
|
||||
uint8_t edges, PathConstructFlags constructFlags = 0);
|
||||
public:
|
||||
FootpathLayoutPlaceAction() = default;
|
||||
FootpathLayoutPlaceAction(
|
||||
const CoordsXYZ& loc, uint8_t slope, ObjectEntryIndex type, ObjectEntryIndex railingsType, uint8_t edges,
|
||||
PathConstructFlags constructFlags = 0);
|
||||
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
|
||||
uint16_t GetActionFlags() const override;
|
||||
uint16_t GetActionFlags() const override;
|
||||
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
OpenRCT2::GameActions::Result Query() const override;
|
||||
OpenRCT2::GameActions::Result Execute() const override;
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
Result Query() const override;
|
||||
Result Execute() const override;
|
||||
|
||||
private:
|
||||
OpenRCT2::GameActions::Result ElementInsertQuery(OpenRCT2::GameActions::Result res) const;
|
||||
OpenRCT2::GameActions::Result ElementInsertExecute(OpenRCT2::GameActions::Result res) const;
|
||||
bool IsSameAsEntranceElement(const OpenRCT2::EntranceElement& entranceElement) const;
|
||||
};
|
||||
private:
|
||||
Result ElementInsertQuery(Result res) const;
|
||||
Result ElementInsertExecute(Result res) const;
|
||||
bool IsSameAsEntranceElement(const EntranceElement& entranceElement) const;
|
||||
};
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -35,399 +35,212 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
FootpathPlaceAction::FootpathPlaceAction(
|
||||
const CoordsXYZ& loc, uint8_t slope, ObjectEntryIndex type, ObjectEntryIndex railingsType, Direction direction,
|
||||
PathConstructFlags constructFlags)
|
||||
: _loc(loc)
|
||||
, _slope(slope)
|
||||
, _type(type)
|
||||
, _railingsType(railingsType)
|
||||
, _direction(direction)
|
||||
, _constructFlags(constructFlags)
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
}
|
||||
|
||||
void FootpathPlaceAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
visitor.Visit(_loc);
|
||||
visitor.Visit("object", _type);
|
||||
visitor.Visit("railingsObject", _railingsType);
|
||||
visitor.Visit("direction", _direction);
|
||||
visitor.Visit("slope", _slope);
|
||||
visitor.Visit("constructFlags", _constructFlags);
|
||||
}
|
||||
|
||||
uint16_t FootpathPlaceAction::GetActionFlags() const
|
||||
{
|
||||
return GameAction::GetActionFlags();
|
||||
}
|
||||
|
||||
void FootpathPlaceAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_loc) << DS_TAG(_slope) << DS_TAG(_type) << DS_TAG(_railingsType) << DS_TAG(_direction)
|
||||
<< DS_TAG(_constructFlags);
|
||||
}
|
||||
|
||||
GameActions::Result FootpathPlaceAction::Query() const
|
||||
{
|
||||
auto res = GameActions::Result();
|
||||
res.Cost = 0;
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
res.Position = _loc.ToTileCentre();
|
||||
|
||||
gFootpathGroundFlags = 0;
|
||||
|
||||
if (!LocationValid(_loc) || MapIsEdge(_loc))
|
||||
FootpathPlaceAction::FootpathPlaceAction(
|
||||
const CoordsXYZ& loc, uint8_t slope, ObjectEntryIndex type, ObjectEntryIndex railingsType, Direction direction,
|
||||
PathConstructFlags constructFlags)
|
||||
: _loc(loc)
|
||||
, _slope(slope)
|
||||
, _type(type)
|
||||
, _railingsType(railingsType)
|
||||
, _direction(direction)
|
||||
, _constructFlags(constructFlags)
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_BUILD_FOOTPATH_HERE, STR_OFF_EDGE_OF_MAP);
|
||||
}
|
||||
|
||||
if (!(gLegacyScene == LegacyScene::scenarioEditor || getGameState().cheats.sandboxMode) && !MapIsLocationOwned(_loc))
|
||||
void FootpathPlaceAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::Disallowed, STR_CANT_BUILD_FOOTPATH_HERE, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
visitor.Visit(_loc);
|
||||
visitor.Visit("object", _type);
|
||||
visitor.Visit("railingsObject", _railingsType);
|
||||
visitor.Visit("direction", _direction);
|
||||
visitor.Visit("slope", _slope);
|
||||
visitor.Visit("constructFlags", _constructFlags);
|
||||
}
|
||||
|
||||
if (_slope & SLOPE_IS_IRREGULAR_FLAG)
|
||||
uint16_t FootpathPlaceAction::GetActionFlags() const
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::Disallowed, STR_CANT_BUILD_FOOTPATH_HERE, STR_LAND_SLOPE_UNSUITABLE);
|
||||
return GameAction::GetActionFlags();
|
||||
}
|
||||
|
||||
if (_loc.z < kFootpathMinHeight)
|
||||
void FootpathPlaceAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::Disallowed, STR_CANT_BUILD_FOOTPATH_HERE, STR_TOO_LOW);
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_loc) << DS_TAG(_slope) << DS_TAG(_type) << DS_TAG(_railingsType) << DS_TAG(_direction)
|
||||
<< DS_TAG(_constructFlags);
|
||||
}
|
||||
|
||||
if (_loc.z > kFootpathMaxHeight)
|
||||
Result FootpathPlaceAction::Query() const
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::Disallowed, STR_CANT_BUILD_FOOTPATH_HERE, STR_TOO_HIGH);
|
||||
}
|
||||
auto res = Result();
|
||||
res.Cost = 0;
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
res.Position = _loc.ToTileCentre();
|
||||
|
||||
if (_direction != kInvalidDirection && !DirectionValid(_direction))
|
||||
{
|
||||
LOG_ERROR("Direction invalid. direction = %u", _direction);
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_BUILD_FOOTPATH_HERE, STR_ERR_VALUE_OUT_OF_RANGE);
|
||||
}
|
||||
gFootpathGroundFlags = 0;
|
||||
|
||||
auto intent = Intent(INTENT_ACTION_REMOVE_PROVISIONAL_FOOTPATH);
|
||||
ContextBroadcastIntent(&intent);
|
||||
|
||||
auto tileElement = MapGetFootpathElementSlope(_loc, _slope);
|
||||
if (tileElement == nullptr)
|
||||
{
|
||||
return ElementInsertQuery(std::move(res));
|
||||
}
|
||||
return ElementUpdateQuery(tileElement, std::move(res));
|
||||
}
|
||||
|
||||
GameActions::Result FootpathPlaceAction::Execute() const
|
||||
{
|
||||
auto res = GameActions::Result();
|
||||
res.Cost = 0;
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
res.Position = _loc.ToTileCentre();
|
||||
|
||||
if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST))
|
||||
{
|
||||
FootpathInterruptPeeps(_loc);
|
||||
}
|
||||
|
||||
gFootpathGroundFlags = 0;
|
||||
|
||||
// Force ride construction to recheck area
|
||||
_currentTrackSelectionFlags.set(TrackSelectionFlag::recheck);
|
||||
|
||||
if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST))
|
||||
{
|
||||
if (_direction != kInvalidDirection && !getGameState().cheats.disableClearanceChecks)
|
||||
if (!LocationValid(_loc) || MapIsEdge(_loc))
|
||||
{
|
||||
// It is possible, let's remove walls between the old and new piece of path
|
||||
auto zLow = _loc.z;
|
||||
auto zHigh = zLow + kPathClearance;
|
||||
WallRemoveIntersectingWalls(
|
||||
{ _loc, zLow, zHigh + ((_slope & kTileSlopeRaisedCornersMask) ? 16 : 0) }, DirectionReverse(_direction));
|
||||
WallRemoveIntersectingWalls(
|
||||
{ _loc.x - CoordsDirectionDelta[_direction].x, _loc.y - CoordsDirectionDelta[_direction].y, zLow, zHigh },
|
||||
_direction);
|
||||
return Result(Status::InvalidParameters, STR_CANT_BUILD_FOOTPATH_HERE, STR_OFF_EDGE_OF_MAP);
|
||||
}
|
||||
|
||||
if (!(gLegacyScene == LegacyScene::scenarioEditor || getGameState().cheats.sandboxMode) && !MapIsLocationOwned(_loc))
|
||||
{
|
||||
return Result(Status::Disallowed, STR_CANT_BUILD_FOOTPATH_HERE, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
}
|
||||
|
||||
if (_slope & SLOPE_IS_IRREGULAR_FLAG)
|
||||
{
|
||||
return Result(Status::Disallowed, STR_CANT_BUILD_FOOTPATH_HERE, STR_LAND_SLOPE_UNSUITABLE);
|
||||
}
|
||||
|
||||
if (_loc.z < kFootpathMinHeight)
|
||||
{
|
||||
return Result(Status::Disallowed, STR_CANT_BUILD_FOOTPATH_HERE, STR_TOO_LOW);
|
||||
}
|
||||
|
||||
if (_loc.z > kFootpathMaxHeight)
|
||||
{
|
||||
return Result(Status::Disallowed, STR_CANT_BUILD_FOOTPATH_HERE, STR_TOO_HIGH);
|
||||
}
|
||||
|
||||
if (_direction != kInvalidDirection && !DirectionValid(_direction))
|
||||
{
|
||||
LOG_ERROR("Direction invalid. direction = %u", _direction);
|
||||
return Result(Status::InvalidParameters, STR_CANT_BUILD_FOOTPATH_HERE, STR_ERR_VALUE_OUT_OF_RANGE);
|
||||
}
|
||||
|
||||
auto intent = Intent(INTENT_ACTION_REMOVE_PROVISIONAL_FOOTPATH);
|
||||
ContextBroadcastIntent(&intent);
|
||||
|
||||
auto tileElement = MapGetFootpathElementSlope(_loc, _slope);
|
||||
if (tileElement == nullptr)
|
||||
{
|
||||
return ElementInsertQuery(std::move(res));
|
||||
}
|
||||
return ElementUpdateQuery(tileElement, std::move(res));
|
||||
}
|
||||
|
||||
auto tileElement = MapGetFootpathElementSlope(_loc, _slope);
|
||||
if (tileElement == nullptr)
|
||||
Result FootpathPlaceAction::Execute() const
|
||||
{
|
||||
return ElementInsertExecute(std::move(res));
|
||||
auto res = Result();
|
||||
res.Cost = 0;
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
res.Position = _loc.ToTileCentre();
|
||||
|
||||
if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST))
|
||||
{
|
||||
FootpathInterruptPeeps(_loc);
|
||||
}
|
||||
|
||||
gFootpathGroundFlags = 0;
|
||||
|
||||
// Force ride construction to recheck area
|
||||
_currentTrackSelectionFlags.set(TrackSelectionFlag::recheck);
|
||||
|
||||
if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST))
|
||||
{
|
||||
if (_direction != kInvalidDirection && !getGameState().cheats.disableClearanceChecks)
|
||||
{
|
||||
// It is possible, let's remove walls between the old and new piece of path
|
||||
auto zLow = _loc.z;
|
||||
auto zHigh = zLow + kPathClearance;
|
||||
WallRemoveIntersectingWalls(
|
||||
{ _loc, zLow, zHigh + ((_slope & kTileSlopeRaisedCornersMask) ? 16 : 0) }, DirectionReverse(_direction));
|
||||
WallRemoveIntersectingWalls(
|
||||
{ _loc.x - CoordsDirectionDelta[_direction].x, _loc.y - CoordsDirectionDelta[_direction].y, zLow, zHigh },
|
||||
_direction);
|
||||
}
|
||||
}
|
||||
|
||||
auto tileElement = MapGetFootpathElementSlope(_loc, _slope);
|
||||
if (tileElement == nullptr)
|
||||
{
|
||||
return ElementInsertExecute(std::move(res));
|
||||
}
|
||||
return ElementUpdateExecute(tileElement, std::move(res));
|
||||
}
|
||||
return ElementUpdateExecute(tileElement, std::move(res));
|
||||
}
|
||||
|
||||
bool FootpathPlaceAction::IsSameAsPathElement(const PathElement* pathElement) const
|
||||
{
|
||||
// Check if both this action and the element is queue
|
||||
if (pathElement->IsQueue() != ((_constructFlags & PathConstructFlag::IsQueue) != 0))
|
||||
return false;
|
||||
|
||||
auto footpathObj = pathElement->GetLegacyPathEntry();
|
||||
if (footpathObj == nullptr)
|
||||
{
|
||||
if (_constructFlags & PathConstructFlag::IsLegacyPathObject)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return pathElement->GetSurfaceEntryIndex() == _type && pathElement->GetRailingsEntryIndex() == _railingsType;
|
||||
}
|
||||
|
||||
if (_constructFlags & PathConstructFlag::IsLegacyPathObject)
|
||||
{
|
||||
return pathElement->GetLegacyPathEntryIndex() == _type;
|
||||
}
|
||||
|
||||
bool FootpathPlaceAction::IsSameAsPathElement(const PathElement* pathElement) const
|
||||
{
|
||||
// Check if both this action and the element is queue
|
||||
if (pathElement->IsQueue() != ((_constructFlags & PathConstructFlag::IsQueue) != 0))
|
||||
return false;
|
||||
}
|
||||
|
||||
auto footpathObj = pathElement->GetLegacyPathEntry();
|
||||
if (footpathObj == nullptr)
|
||||
bool FootpathPlaceAction::IsSameAsEntranceElement(const EntranceElement& entranceElement) const
|
||||
{
|
||||
if (entranceElement.HasLegacyPathEntry())
|
||||
{
|
||||
if (_constructFlags & PathConstructFlag::IsLegacyPathObject)
|
||||
{
|
||||
return entranceElement.GetLegacyPathEntryIndex() == _type;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_constructFlags & PathConstructFlag::IsLegacyPathObject)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return pathElement->GetSurfaceEntryIndex() == _type && pathElement->GetRailingsEntryIndex() == _railingsType;
|
||||
return entranceElement.GetSurfaceEntryIndex() == _type;
|
||||
}
|
||||
|
||||
if (_constructFlags & PathConstructFlag::IsLegacyPathObject)
|
||||
Result FootpathPlaceAction::ElementUpdateQuery(PathElement* pathElement, Result res) const
|
||||
{
|
||||
return pathElement->GetLegacyPathEntryIndex() == _type;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FootpathPlaceAction::IsSameAsEntranceElement(const EntranceElement& entranceElement) const
|
||||
{
|
||||
if (entranceElement.HasLegacyPathEntry())
|
||||
{
|
||||
if (_constructFlags & PathConstructFlag::IsLegacyPathObject)
|
||||
if (_constructFlags & PathConstructFlag::IsQueue && pathElement->IsLevelCrossing(_loc))
|
||||
{
|
||||
return entranceElement.GetLegacyPathEntryIndex() == _type;
|
||||
return Result(Status::Disallowed, STR_CANT_BUILD_FOOTPATH_HERE, STR_QUEUE_PATHS_CANNOT_BE_USED_FOR_LEVEL_CROSSINGS);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_constructFlags & PathConstructFlag::IsLegacyPathObject)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return entranceElement.GetSurfaceEntryIndex() == _type;
|
||||
}
|
||||
|
||||
GameActions::Result FootpathPlaceAction::ElementUpdateQuery(PathElement* pathElement, GameActions::Result res) const
|
||||
{
|
||||
if (_constructFlags & PathConstructFlag::IsQueue && pathElement->IsLevelCrossing(_loc))
|
||||
{
|
||||
return GameActions::Result(
|
||||
GameActions::Status::Disallowed, STR_CANT_BUILD_FOOTPATH_HERE, STR_QUEUE_PATHS_CANNOT_BE_USED_FOR_LEVEL_CROSSINGS);
|
||||
}
|
||||
|
||||
if (!IsSameAsPathElement(pathElement))
|
||||
{
|
||||
res.Cost += 6.00_GBP;
|
||||
}
|
||||
|
||||
if (GetFlags() & GAME_COMMAND_FLAG_GHOST && !pathElement->IsGhost())
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::Unknown, STR_CANT_BUILD_FOOTPATH_HERE, kStringIdNone);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
GameActions::Result FootpathPlaceAction::ElementUpdateExecute(PathElement* pathElement, GameActions::Result res) const
|
||||
{
|
||||
if (!IsSameAsPathElement(pathElement))
|
||||
{
|
||||
res.Cost += 6.00_GBP;
|
||||
}
|
||||
|
||||
FootpathQueueChainReset();
|
||||
|
||||
if (!(GetFlags() & GAME_COMMAND_FLAG_TRACK_DESIGN))
|
||||
{
|
||||
FootpathRemoveEdgesAt(_loc, reinterpret_cast<TileElement*>(pathElement));
|
||||
}
|
||||
|
||||
if (_constructFlags & PathConstructFlag::IsLegacyPathObject)
|
||||
{
|
||||
pathElement->SetLegacyPathEntryIndex(_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
pathElement->SetSurfaceEntryIndex(_type);
|
||||
pathElement->SetRailingsEntryIndex(_railingsType);
|
||||
}
|
||||
|
||||
pathElement->SetIsQueue((_constructFlags & PathConstructFlag::IsQueue) != 0);
|
||||
|
||||
auto* elem = pathElement->GetAdditionEntry();
|
||||
if (elem != nullptr)
|
||||
{
|
||||
if (_constructFlags & PathConstructFlag::IsQueue)
|
||||
if (!IsSameAsPathElement(pathElement))
|
||||
{
|
||||
// remove any addition that isn't a TV or a lamp
|
||||
if ((elem->flags & PATH_ADDITION_FLAG_IS_QUEUE_SCREEN) == 0 && (elem->flags & PATH_ADDITION_FLAG_LAMP) == 0)
|
||||
{
|
||||
pathElement->SetIsBroken(false);
|
||||
pathElement->SetAddition(0);
|
||||
}
|
||||
res.Cost += 6.00_GBP;
|
||||
}
|
||||
else
|
||||
|
||||
if (GetFlags() & GAME_COMMAND_FLAG_GHOST && !pathElement->IsGhost())
|
||||
{
|
||||
// remove all TVs
|
||||
if ((elem->flags & PATH_ADDITION_FLAG_IS_QUEUE_SCREEN) != 0)
|
||||
{
|
||||
pathElement->SetIsBroken(false);
|
||||
pathElement->SetAddition(0);
|
||||
}
|
||||
return Result(Status::Unknown, STR_CANT_BUILD_FOOTPATH_HERE, kStringIdNone);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
RemoveIntersectingWalls(pathElement);
|
||||
return res;
|
||||
}
|
||||
|
||||
GameActions::Result FootpathPlaceAction::ElementInsertQuery(GameActions::Result res) const
|
||||
{
|
||||
bool entrancePath = false, entranceIsSamePath = false;
|
||||
|
||||
if (!MapCheckCapacityAndReorganise(_loc))
|
||||
Result FootpathPlaceAction::ElementUpdateExecute(PathElement* pathElement, Result res) const
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::NoFreeElements, STR_CANT_BUILD_FOOTPATH_HERE, kStringIdNone);
|
||||
}
|
||||
|
||||
res.Cost = 12.00_GBP;
|
||||
|
||||
QuarterTile quarterTile{ 0b1111, 0 };
|
||||
auto zLow = _loc.z;
|
||||
auto zHigh = zLow + kPathClearance;
|
||||
if (_slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED)
|
||||
{
|
||||
quarterTile = QuarterTile{ 0b1111, 0b1100 }.Rotate(_slope & kTileElementDirectionMask);
|
||||
zHigh += kPathHeightStep;
|
||||
}
|
||||
|
||||
auto entranceElement = MapGetParkEntranceElementAt(_loc, false);
|
||||
// Make sure the entrance part is the middle
|
||||
if (entranceElement != nullptr && (entranceElement->GetSequenceIndex()) == 0)
|
||||
{
|
||||
entrancePath = true;
|
||||
// Make the price the same as replacing a path
|
||||
if (IsSameAsEntranceElement(*entranceElement))
|
||||
entranceIsSamePath = true;
|
||||
else
|
||||
res.Cost -= 6.00_GBP;
|
||||
}
|
||||
|
||||
// Do not attempt to build a crossing with a queue or a sloped path.
|
||||
auto isQueue = _constructFlags & PathConstructFlag::IsQueue;
|
||||
auto crossingMode = isQueue || (_slope != kTileSlopeFlat) ? CreateCrossingMode::none : CreateCrossingMode::pathOverTrack;
|
||||
auto canBuild = MapCanConstructWithClearAt(
|
||||
{ _loc, zLow, zHigh }, &MapPlaceNonSceneryClearFunc, quarterTile, GetFlags(), crossingMode);
|
||||
if (!entrancePath && canBuild.Error != GameActions::Status::Ok)
|
||||
{
|
||||
canBuild.ErrorTitle = STR_CANT_BUILD_FOOTPATH_HERE;
|
||||
return canBuild;
|
||||
}
|
||||
res.Cost += canBuild.Cost;
|
||||
|
||||
const auto clearanceData = canBuild.GetData<ConstructClearResult>();
|
||||
|
||||
gFootpathGroundFlags = clearanceData.GroundFlags;
|
||||
if (!getGameState().cheats.disableClearanceChecks && (clearanceData.GroundFlags & ELEMENT_IS_UNDERWATER))
|
||||
{
|
||||
return GameActions::Result(
|
||||
GameActions::Status::Disallowed, STR_CANT_BUILD_FOOTPATH_HERE, STR_CANT_BUILD_THIS_UNDERWATER);
|
||||
}
|
||||
|
||||
auto surfaceElement = MapGetSurfaceElementAt(_loc);
|
||||
if (surfaceElement == nullptr)
|
||||
{
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_BUILD_FOOTPATH_HERE, STR_ERR_SURFACE_ELEMENT_NOT_FOUND);
|
||||
}
|
||||
int32_t supportHeight = zLow - surfaceElement->GetBaseZ();
|
||||
res.Cost += supportHeight < 0 ? 20.00_GBP : (supportHeight / kPathHeightStep) * 5.00_GBP;
|
||||
|
||||
// Prevent the place sound from being spammed
|
||||
if (entranceIsSamePath)
|
||||
res.Cost = 0;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
GameActions::Result FootpathPlaceAction::ElementInsertExecute(GameActions::Result res) const
|
||||
{
|
||||
bool entrancePath = false, entranceIsSamePath = false;
|
||||
|
||||
if (!(GetFlags() & (GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_GHOST)))
|
||||
{
|
||||
FootpathRemoveLitter(_loc);
|
||||
}
|
||||
|
||||
res.Cost = 12.00_GBP;
|
||||
|
||||
QuarterTile quarterTile{ 0b1111, 0 };
|
||||
auto zLow = _loc.z;
|
||||
auto zHigh = zLow + kPathClearance;
|
||||
if (_slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED)
|
||||
{
|
||||
quarterTile = QuarterTile{ 0b1111, 0b1100 }.Rotate(_slope & kTileElementDirectionMask);
|
||||
zHigh += kPathHeightStep;
|
||||
}
|
||||
|
||||
auto entranceElement = MapGetParkEntranceElementAt(_loc, false);
|
||||
// Make sure the entrance part is the middle
|
||||
if (entranceElement != nullptr && (entranceElement->GetSequenceIndex()) == 0)
|
||||
{
|
||||
entrancePath = true;
|
||||
// Make the price the same as replacing a path
|
||||
if (IsSameAsEntranceElement(*entranceElement))
|
||||
entranceIsSamePath = true;
|
||||
else
|
||||
res.Cost -= 6.00_GBP;
|
||||
}
|
||||
|
||||
// Do not attempt to build a crossing with a queue or a sloped.
|
||||
auto isQueue = _constructFlags & PathConstructFlag::IsQueue;
|
||||
auto crossingMode = isQueue || (_slope != kTileSlopeFlat) ? CreateCrossingMode::none : CreateCrossingMode::pathOverTrack;
|
||||
auto canBuild = MapCanConstructWithClearAt(
|
||||
{ _loc, zLow, zHigh }, &MapPlaceNonSceneryClearFunc, quarterTile, GAME_COMMAND_FLAG_APPLY | GetFlags(), crossingMode);
|
||||
if (!entrancePath && canBuild.Error != GameActions::Status::Ok)
|
||||
{
|
||||
canBuild.ErrorTitle = STR_CANT_BUILD_FOOTPATH_HERE;
|
||||
return canBuild;
|
||||
}
|
||||
res.Cost += canBuild.Cost;
|
||||
|
||||
const auto clearanceData = canBuild.GetData<ConstructClearResult>();
|
||||
gFootpathGroundFlags = clearanceData.GroundFlags;
|
||||
|
||||
auto surfaceElement = MapGetSurfaceElementAt(_loc);
|
||||
if (surfaceElement == nullptr)
|
||||
{
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_BUILD_FOOTPATH_HERE, STR_ERR_SURFACE_ELEMENT_NOT_FOUND);
|
||||
}
|
||||
int32_t supportHeight = zLow - surfaceElement->GetBaseZ();
|
||||
res.Cost += supportHeight < 0 ? 20.00_GBP : (supportHeight / kPathHeightStep) * 5.00_GBP;
|
||||
|
||||
if (entrancePath)
|
||||
{
|
||||
if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST) && !entranceIsSamePath)
|
||||
if (!IsSameAsPathElement(pathElement))
|
||||
{
|
||||
if (_constructFlags & PathConstructFlag::IsLegacyPathObject)
|
||||
{
|
||||
entranceElement->SetLegacyPathEntryIndex(_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
entranceElement->SetSurfaceEntryIndex(_type);
|
||||
}
|
||||
MapInvalidateTileFull(_loc);
|
||||
res.Cost += 6.00_GBP;
|
||||
}
|
||||
|
||||
FootpathQueueChainReset();
|
||||
|
||||
if (!(GetFlags() & GAME_COMMAND_FLAG_TRACK_DESIGN))
|
||||
{
|
||||
FootpathRemoveEdgesAt(_loc, reinterpret_cast<TileElement*>(pathElement));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
auto* pathElement = TileElementInsert<PathElement>(_loc, 0b1111);
|
||||
Guard::Assert(pathElement != nullptr);
|
||||
|
||||
pathElement->SetClearanceZ(zHigh);
|
||||
if (_constructFlags & PathConstructFlag::IsLegacyPathObject)
|
||||
{
|
||||
pathElement->SetLegacyPathEntryIndex(_type);
|
||||
@@ -437,110 +250,296 @@ GameActions::Result FootpathPlaceAction::ElementInsertExecute(GameActions::Resul
|
||||
pathElement->SetSurfaceEntryIndex(_type);
|
||||
pathElement->SetRailingsEntryIndex(_railingsType);
|
||||
}
|
||||
pathElement->SetSlopeDirection(_slope & FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK);
|
||||
pathElement->SetSloped(_slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED);
|
||||
pathElement->SetIsQueue(isQueue);
|
||||
pathElement->SetAddition(0);
|
||||
pathElement->SetRideIndex(RideId::GetNull());
|
||||
pathElement->SetAdditionStatus(255);
|
||||
pathElement->SetIsBroken(false);
|
||||
pathElement->SetGhost(GetFlags() & GAME_COMMAND_FLAG_GHOST);
|
||||
|
||||
FootpathQueueChainReset();
|
||||
pathElement->SetIsQueue((_constructFlags & PathConstructFlag::IsQueue) != 0);
|
||||
|
||||
if (!(GetFlags() & GAME_COMMAND_FLAG_TRACK_DESIGN))
|
||||
auto* elem = pathElement->GetAdditionEntry();
|
||||
if (elem != nullptr)
|
||||
{
|
||||
FootpathRemoveEdgesAt(_loc, pathElement->as<TileElement>());
|
||||
}
|
||||
if (gLegacyScene == LegacyScene::scenarioEditor && !(GetFlags() & GAME_COMMAND_FLAG_GHOST))
|
||||
{
|
||||
AutomaticallySetPeepSpawn();
|
||||
if (_constructFlags & PathConstructFlag::IsQueue)
|
||||
{
|
||||
// remove any addition that isn't a TV or a lamp
|
||||
if ((elem->flags & PATH_ADDITION_FLAG_IS_QUEUE_SCREEN) == 0 && (elem->flags & PATH_ADDITION_FLAG_LAMP) == 0)
|
||||
{
|
||||
pathElement->SetIsBroken(false);
|
||||
pathElement->SetAddition(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// remove all TVs
|
||||
if ((elem->flags & PATH_ADDITION_FLAG_IS_QUEUE_SCREEN) != 0)
|
||||
{
|
||||
pathElement->SetIsBroken(false);
|
||||
pathElement->SetAddition(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RemoveIntersectingWalls(pathElement);
|
||||
return res;
|
||||
}
|
||||
|
||||
// Prevent the place sound from being spammed
|
||||
if (entranceIsSamePath)
|
||||
res.Cost = 0;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006A65AD
|
||||
*/
|
||||
void FootpathPlaceAction::AutomaticallySetPeepSpawn() const
|
||||
{
|
||||
auto mapSizeUnits = GetMapSizeUnits();
|
||||
uint8_t direction = 0;
|
||||
if (_loc.x != kCoordsXYStep)
|
||||
Result FootpathPlaceAction::ElementInsertQuery(Result res) const
|
||||
{
|
||||
direction++;
|
||||
if (_loc.y != mapSizeUnits.y - kCoordsXYStep)
|
||||
bool entrancePath = false, entranceIsSamePath = false;
|
||||
|
||||
if (!MapCheckCapacityAndReorganise(_loc))
|
||||
{
|
||||
direction++;
|
||||
if (_loc.x != mapSizeUnits.x - kCoordsXYStep)
|
||||
return Result(Status::NoFreeElements, STR_CANT_BUILD_FOOTPATH_HERE, kStringIdNone);
|
||||
}
|
||||
|
||||
res.Cost = 12.00_GBP;
|
||||
|
||||
QuarterTile quarterTile{ 0b1111, 0 };
|
||||
auto zLow = _loc.z;
|
||||
auto zHigh = zLow + kPathClearance;
|
||||
if (_slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED)
|
||||
{
|
||||
quarterTile = QuarterTile{ 0b1111, 0b1100 }.Rotate(_slope & kTileElementDirectionMask);
|
||||
zHigh += kPathHeightStep;
|
||||
}
|
||||
|
||||
auto entranceElement = MapGetParkEntranceElementAt(_loc, false);
|
||||
// Make sure the entrance part is the middle
|
||||
if (entranceElement != nullptr && (entranceElement->GetSequenceIndex()) == 0)
|
||||
{
|
||||
entrancePath = true;
|
||||
// Make the price the same as replacing a path
|
||||
if (IsSameAsEntranceElement(*entranceElement))
|
||||
entranceIsSamePath = true;
|
||||
else
|
||||
res.Cost -= 6.00_GBP;
|
||||
}
|
||||
|
||||
// Do not attempt to build a crossing with a queue or a sloped path.
|
||||
auto isQueue = _constructFlags & PathConstructFlag::IsQueue;
|
||||
auto crossingMode = isQueue || (_slope != kTileSlopeFlat) ? CreateCrossingMode::none
|
||||
: CreateCrossingMode::pathOverTrack;
|
||||
auto canBuild = MapCanConstructWithClearAt(
|
||||
{ _loc, zLow, zHigh }, &MapPlaceNonSceneryClearFunc, quarterTile, GetFlags(), crossingMode);
|
||||
if (!entrancePath && canBuild.Error != Status::Ok)
|
||||
{
|
||||
canBuild.ErrorTitle = STR_CANT_BUILD_FOOTPATH_HERE;
|
||||
return canBuild;
|
||||
}
|
||||
res.Cost += canBuild.Cost;
|
||||
|
||||
const auto clearanceData = canBuild.GetData<ConstructClearResult>();
|
||||
|
||||
gFootpathGroundFlags = clearanceData.GroundFlags;
|
||||
if (!getGameState().cheats.disableClearanceChecks && (clearanceData.GroundFlags & ELEMENT_IS_UNDERWATER))
|
||||
{
|
||||
return Result(Status::Disallowed, STR_CANT_BUILD_FOOTPATH_HERE, STR_CANT_BUILD_THIS_UNDERWATER);
|
||||
}
|
||||
|
||||
auto surfaceElement = MapGetSurfaceElementAt(_loc);
|
||||
if (surfaceElement == nullptr)
|
||||
{
|
||||
return Result(Status::InvalidParameters, STR_CANT_BUILD_FOOTPATH_HERE, STR_ERR_SURFACE_ELEMENT_NOT_FOUND);
|
||||
}
|
||||
int32_t supportHeight = zLow - surfaceElement->GetBaseZ();
|
||||
res.Cost += supportHeight < 0 ? 20.00_GBP : (supportHeight / kPathHeightStep) * 5.00_GBP;
|
||||
|
||||
// Prevent the place sound from being spammed
|
||||
if (entranceIsSamePath)
|
||||
res.Cost = 0;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
Result FootpathPlaceAction::ElementInsertExecute(Result res) const
|
||||
{
|
||||
bool entrancePath = false, entranceIsSamePath = false;
|
||||
|
||||
if (!(GetFlags() & (GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_GHOST)))
|
||||
{
|
||||
FootpathRemoveLitter(_loc);
|
||||
}
|
||||
|
||||
res.Cost = 12.00_GBP;
|
||||
|
||||
QuarterTile quarterTile{ 0b1111, 0 };
|
||||
auto zLow = _loc.z;
|
||||
auto zHigh = zLow + kPathClearance;
|
||||
if (_slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED)
|
||||
{
|
||||
quarterTile = QuarterTile{ 0b1111, 0b1100 }.Rotate(_slope & kTileElementDirectionMask);
|
||||
zHigh += kPathHeightStep;
|
||||
}
|
||||
|
||||
auto entranceElement = MapGetParkEntranceElementAt(_loc, false);
|
||||
// Make sure the entrance part is the middle
|
||||
if (entranceElement != nullptr && (entranceElement->GetSequenceIndex()) == 0)
|
||||
{
|
||||
entrancePath = true;
|
||||
// Make the price the same as replacing a path
|
||||
if (IsSameAsEntranceElement(*entranceElement))
|
||||
entranceIsSamePath = true;
|
||||
else
|
||||
res.Cost -= 6.00_GBP;
|
||||
}
|
||||
|
||||
// Do not attempt to build a crossing with a queue or a sloped.
|
||||
auto isQueue = _constructFlags & PathConstructFlag::IsQueue;
|
||||
auto crossingMode = isQueue || (_slope != kTileSlopeFlat) ? CreateCrossingMode::none
|
||||
: CreateCrossingMode::pathOverTrack;
|
||||
auto canBuild = MapCanConstructWithClearAt(
|
||||
{ _loc, zLow, zHigh }, &MapPlaceNonSceneryClearFunc, quarterTile, GAME_COMMAND_FLAG_APPLY | GetFlags(),
|
||||
crossingMode);
|
||||
if (!entrancePath && canBuild.Error != Status::Ok)
|
||||
{
|
||||
canBuild.ErrorTitle = STR_CANT_BUILD_FOOTPATH_HERE;
|
||||
return canBuild;
|
||||
}
|
||||
res.Cost += canBuild.Cost;
|
||||
|
||||
const auto clearanceData = canBuild.GetData<ConstructClearResult>();
|
||||
gFootpathGroundFlags = clearanceData.GroundFlags;
|
||||
|
||||
auto surfaceElement = MapGetSurfaceElementAt(_loc);
|
||||
if (surfaceElement == nullptr)
|
||||
{
|
||||
return Result(Status::InvalidParameters, STR_CANT_BUILD_FOOTPATH_HERE, STR_ERR_SURFACE_ELEMENT_NOT_FOUND);
|
||||
}
|
||||
int32_t supportHeight = zLow - surfaceElement->GetBaseZ();
|
||||
res.Cost += supportHeight < 0 ? 20.00_GBP : (supportHeight / kPathHeightStep) * 5.00_GBP;
|
||||
|
||||
if (entrancePath)
|
||||
{
|
||||
if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST) && !entranceIsSamePath)
|
||||
{
|
||||
direction++;
|
||||
if (_loc.y != kCoordsXYStep)
|
||||
return;
|
||||
if (_constructFlags & PathConstructFlag::IsLegacyPathObject)
|
||||
{
|
||||
entranceElement->SetLegacyPathEntryIndex(_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
entranceElement->SetSurfaceEntryIndex(_type);
|
||||
}
|
||||
MapInvalidateTileFull(_loc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto& gameState = getGameState();
|
||||
if (gameState.peepSpawns.empty())
|
||||
{
|
||||
gameState.peepSpawns.emplace_back();
|
||||
}
|
||||
PeepSpawn* peepSpawn = &gameState.peepSpawns[0];
|
||||
peepSpawn->x = _loc.x + (DirectionOffsets[direction].x * 15) + 16;
|
||||
peepSpawn->y = _loc.y + (DirectionOffsets[direction].y * 15) + 16;
|
||||
peepSpawn->direction = direction;
|
||||
peepSpawn->z = _loc.z;
|
||||
}
|
||||
|
||||
void FootpathPlaceAction::RemoveIntersectingWalls(PathElement* pathElement) const
|
||||
{
|
||||
if (pathElement->IsSloped() && !(GetFlags() & GAME_COMMAND_FLAG_GHOST))
|
||||
{
|
||||
auto direction = pathElement->GetSlopeDirection();
|
||||
int32_t z = pathElement->GetBaseZ();
|
||||
WallRemoveIntersectingWalls({ _loc, z, z + (6 * kCoordsZStep) }, DirectionReverse(direction));
|
||||
WallRemoveIntersectingWalls({ _loc, z, z + (6 * kCoordsZStep) }, direction);
|
||||
// Removing walls may have made the pointer invalid, so find it again
|
||||
pathElement = MapGetFootpathElement(CoordsXYZ(_loc, z));
|
||||
if (pathElement == nullptr)
|
||||
else
|
||||
{
|
||||
LOG_ERROR("Something went wrong. Could not refind footpath.");
|
||||
return;
|
||||
auto* pathElement = TileElementInsert<PathElement>(_loc, 0b1111);
|
||||
Guard::Assert(pathElement != nullptr);
|
||||
|
||||
pathElement->SetClearanceZ(zHigh);
|
||||
if (_constructFlags & PathConstructFlag::IsLegacyPathObject)
|
||||
{
|
||||
pathElement->SetLegacyPathEntryIndex(_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
pathElement->SetSurfaceEntryIndex(_type);
|
||||
pathElement->SetRailingsEntryIndex(_railingsType);
|
||||
}
|
||||
pathElement->SetSlopeDirection(_slope & FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK);
|
||||
pathElement->SetSloped(_slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED);
|
||||
pathElement->SetIsQueue(isQueue);
|
||||
pathElement->SetAddition(0);
|
||||
pathElement->SetRideIndex(RideId::GetNull());
|
||||
pathElement->SetAdditionStatus(255);
|
||||
pathElement->SetIsBroken(false);
|
||||
pathElement->SetGhost(GetFlags() & GAME_COMMAND_FLAG_GHOST);
|
||||
|
||||
FootpathQueueChainReset();
|
||||
|
||||
if (!(GetFlags() & GAME_COMMAND_FLAG_TRACK_DESIGN))
|
||||
{
|
||||
FootpathRemoveEdgesAt(_loc, pathElement->as<TileElement>());
|
||||
}
|
||||
if (gLegacyScene == LegacyScene::scenarioEditor && !(GetFlags() & GAME_COMMAND_FLAG_GHOST))
|
||||
{
|
||||
AutomaticallySetPeepSpawn();
|
||||
}
|
||||
|
||||
RemoveIntersectingWalls(pathElement);
|
||||
}
|
||||
|
||||
// Prevent the place sound from being spammed
|
||||
if (entranceIsSamePath)
|
||||
res.Cost = 0;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
if (!(GetFlags() & GAME_COMMAND_FLAG_TRACK_DESIGN))
|
||||
FootpathConnectEdges(_loc, reinterpret_cast<TileElement*>(pathElement), GetFlags());
|
||||
|
||||
FootpathUpdateQueueChains();
|
||||
MapInvalidateTileFull(_loc);
|
||||
}
|
||||
|
||||
PathElement* FootpathPlaceAction::MapGetFootpathElementSlope(const CoordsXYZ& footpathPos, int32_t slope) const
|
||||
{
|
||||
const bool isSloped = slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED;
|
||||
const auto slopeDirection = slope & FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK;
|
||||
|
||||
for (auto* pathElement : TileElementsView<PathElement>(footpathPos))
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006A65AD
|
||||
*/
|
||||
void FootpathPlaceAction::AutomaticallySetPeepSpawn() const
|
||||
{
|
||||
if (pathElement->GetBaseZ() != footpathPos.z)
|
||||
continue;
|
||||
if (pathElement->IsSloped() != isSloped)
|
||||
continue;
|
||||
if (pathElement->GetSlopeDirection() != slopeDirection)
|
||||
continue;
|
||||
return pathElement;
|
||||
auto mapSizeUnits = GetMapSizeUnits();
|
||||
uint8_t direction = 0;
|
||||
if (_loc.x != kCoordsXYStep)
|
||||
{
|
||||
direction++;
|
||||
if (_loc.y != mapSizeUnits.y - kCoordsXYStep)
|
||||
{
|
||||
direction++;
|
||||
if (_loc.x != mapSizeUnits.x - kCoordsXYStep)
|
||||
{
|
||||
direction++;
|
||||
if (_loc.y != kCoordsXYStep)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto& gameState = getGameState();
|
||||
if (gameState.peepSpawns.empty())
|
||||
{
|
||||
gameState.peepSpawns.emplace_back();
|
||||
}
|
||||
PeepSpawn* peepSpawn = &gameState.peepSpawns[0];
|
||||
peepSpawn->x = _loc.x + (DirectionOffsets[direction].x * 15) + 16;
|
||||
peepSpawn->y = _loc.y + (DirectionOffsets[direction].y * 15) + 16;
|
||||
peepSpawn->direction = direction;
|
||||
peepSpawn->z = _loc.z;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
void FootpathPlaceAction::RemoveIntersectingWalls(PathElement* pathElement) const
|
||||
{
|
||||
if (pathElement->IsSloped() && !(GetFlags() & GAME_COMMAND_FLAG_GHOST))
|
||||
{
|
||||
auto direction = pathElement->GetSlopeDirection();
|
||||
int32_t z = pathElement->GetBaseZ();
|
||||
WallRemoveIntersectingWalls({ _loc, z, z + (6 * kCoordsZStep) }, DirectionReverse(direction));
|
||||
WallRemoveIntersectingWalls({ _loc, z, z + (6 * kCoordsZStep) }, direction);
|
||||
// Removing walls may have made the pointer invalid, so find it again
|
||||
pathElement = MapGetFootpathElement(CoordsXYZ(_loc, z));
|
||||
if (pathElement == nullptr)
|
||||
{
|
||||
LOG_ERROR("Something went wrong. Could not refind footpath.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(GetFlags() & GAME_COMMAND_FLAG_TRACK_DESIGN))
|
||||
FootpathConnectEdges(_loc, reinterpret_cast<TileElement*>(pathElement), GetFlags());
|
||||
|
||||
FootpathUpdateQueueChains();
|
||||
MapInvalidateTileFull(_loc);
|
||||
}
|
||||
|
||||
PathElement* FootpathPlaceAction::MapGetFootpathElementSlope(const CoordsXYZ& footpathPos, int32_t slope) const
|
||||
{
|
||||
const bool isSloped = slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED;
|
||||
const auto slopeDirection = slope & FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK;
|
||||
|
||||
for (auto* pathElement : TileElementsView<PathElement>(footpathPos))
|
||||
{
|
||||
if (pathElement->GetBaseZ() != footpathPos.z)
|
||||
continue;
|
||||
if (pathElement->IsSloped() != isSloped)
|
||||
continue;
|
||||
if (pathElement->GetSlopeDirection() != slopeDirection)
|
||||
continue;
|
||||
return pathElement;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -12,39 +12,40 @@
|
||||
#include "../world/Footpath.h"
|
||||
#include "GameAction.h"
|
||||
|
||||
class FootpathPlaceAction final : public GameActionBase<GameCommand::PlacePath>
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
private:
|
||||
CoordsXYZ _loc;
|
||||
uint8_t _slope{};
|
||||
OpenRCT2::ObjectEntryIndex _type{};
|
||||
OpenRCT2::ObjectEntryIndex _railingsType{};
|
||||
Direction _direction{ kInvalidDirection };
|
||||
PathConstructFlags _constructFlags{};
|
||||
class FootpathPlaceAction final : public GameActionBase<GameCommand::PlacePath>
|
||||
{
|
||||
private:
|
||||
CoordsXYZ _loc;
|
||||
uint8_t _slope{};
|
||||
ObjectEntryIndex _type{};
|
||||
ObjectEntryIndex _railingsType{};
|
||||
Direction _direction{ kInvalidDirection };
|
||||
PathConstructFlags _constructFlags{};
|
||||
|
||||
public:
|
||||
FootpathPlaceAction() = default;
|
||||
FootpathPlaceAction(
|
||||
const CoordsXYZ& loc, uint8_t slope, OpenRCT2::ObjectEntryIndex type, OpenRCT2::ObjectEntryIndex railingsType,
|
||||
Direction direction = kInvalidDirection, PathConstructFlags constructFlags = 0);
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
public:
|
||||
FootpathPlaceAction() = default;
|
||||
FootpathPlaceAction(
|
||||
const CoordsXYZ& loc, uint8_t slope, ObjectEntryIndex type, ObjectEntryIndex railingsType,
|
||||
Direction direction = kInvalidDirection, PathConstructFlags constructFlags = 0);
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
|
||||
uint16_t GetActionFlags() const override;
|
||||
uint16_t GetActionFlags() const override;
|
||||
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
OpenRCT2::GameActions::Result Query() const override;
|
||||
OpenRCT2::GameActions::Result Execute() const override;
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
Result Query() const override;
|
||||
Result Execute() const override;
|
||||
|
||||
private:
|
||||
OpenRCT2::GameActions::Result ElementUpdateQuery(
|
||||
OpenRCT2::PathElement* pathElement, OpenRCT2::GameActions::Result res) const;
|
||||
OpenRCT2::GameActions::Result ElementUpdateExecute(
|
||||
OpenRCT2::PathElement* pathElement, OpenRCT2::GameActions::Result res) const;
|
||||
OpenRCT2::GameActions::Result ElementInsertQuery(OpenRCT2::GameActions::Result res) const;
|
||||
OpenRCT2::GameActions::Result ElementInsertExecute(OpenRCT2::GameActions::Result res) const;
|
||||
void AutomaticallySetPeepSpawn() const;
|
||||
void RemoveIntersectingWalls(OpenRCT2::PathElement* pathElement) const;
|
||||
OpenRCT2::PathElement* MapGetFootpathElementSlope(const CoordsXYZ& footpathPos, int32_t slope) const;
|
||||
bool IsSameAsPathElement(const OpenRCT2::PathElement* pathElement) const;
|
||||
bool IsSameAsEntranceElement(const OpenRCT2::EntranceElement& entranceElement) const;
|
||||
};
|
||||
private:
|
||||
Result ElementUpdateQuery(PathElement* pathElement, Result res) const;
|
||||
Result ElementUpdateExecute(PathElement* pathElement, Result res) const;
|
||||
Result ElementInsertQuery(Result res) const;
|
||||
Result ElementInsertExecute(Result res) const;
|
||||
void AutomaticallySetPeepSpawn() const;
|
||||
void RemoveIntersectingWalls(PathElement* pathElement) const;
|
||||
PathElement* MapGetFootpathElementSlope(const CoordsXYZ& footpathPos, int32_t slope) const;
|
||||
bool IsSameAsPathElement(const PathElement* pathElement) const;
|
||||
bool IsSameAsEntranceElement(const EntranceElement& entranceElement) const;
|
||||
};
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -22,172 +22,171 @@
|
||||
#include "../world/tile_element/PathElement.h"
|
||||
#include "BannerRemoveAction.h"
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
FootpathRemoveAction::FootpathRemoveAction(const CoordsXYZ& location)
|
||||
: _loc(location)
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
}
|
||||
|
||||
void FootpathRemoveAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
visitor.Visit(_loc);
|
||||
}
|
||||
|
||||
uint16_t FootpathRemoveAction::GetActionFlags() const
|
||||
{
|
||||
return GameAction::GetActionFlags();
|
||||
}
|
||||
|
||||
void FootpathRemoveAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_loc);
|
||||
}
|
||||
|
||||
GameActions::Result FootpathRemoveAction::Query() const
|
||||
{
|
||||
auto res = GameActions::Result();
|
||||
res.Cost = 0;
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
res.Position = { _loc.x + 16, _loc.y + 16, _loc.z };
|
||||
|
||||
if (!LocationValid(_loc))
|
||||
FootpathRemoveAction::FootpathRemoveAction(const CoordsXYZ& location)
|
||||
: _loc(location)
|
||||
{
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_REMOVE_FOOTPATH_FROM_HERE, STR_OFF_EDGE_OF_MAP);
|
||||
}
|
||||
|
||||
if (!(gLegacyScene == LegacyScene::scenarioEditor || getGameState().cheats.sandboxMode) && !MapIsLocationOwned(_loc))
|
||||
void FootpathRemoveAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
return GameActions::Result(
|
||||
GameActions::Status::NotOwned, STR_CANT_REMOVE_FOOTPATH_FROM_HERE, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
visitor.Visit(_loc);
|
||||
}
|
||||
|
||||
TileElement* footpathElement = GetFootpathElement();
|
||||
if (footpathElement == nullptr)
|
||||
uint16_t FootpathRemoveAction::GetActionFlags() const
|
||||
{
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_REMOVE_FOOTPATH_FROM_HERE, STR_ERR_PATH_ELEMENT_NOT_FOUND);
|
||||
return GameAction::GetActionFlags();
|
||||
}
|
||||
|
||||
res.Cost = GetRefundPrice(footpathElement);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
GameActions::Result FootpathRemoveAction::Execute() const
|
||||
{
|
||||
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))
|
||||
void FootpathRemoveAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
FootpathInterruptPeeps(_loc);
|
||||
FootpathRemoveLitter(_loc);
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_loc);
|
||||
}
|
||||
|
||||
TileElement* footpathElement = GetFootpathElement();
|
||||
if (footpathElement != nullptr)
|
||||
Result FootpathRemoveAction::Query() const
|
||||
{
|
||||
FootpathQueueChainReset();
|
||||
auto bannerRes = RemoveBannersAtElement(_loc, footpathElement);
|
||||
if (bannerRes.Error == GameActions::Status::Ok)
|
||||
auto res = Result();
|
||||
res.Cost = 0;
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
res.Position = { _loc.x + 16, _loc.y + 16, _loc.z };
|
||||
|
||||
if (!LocationValid(_loc))
|
||||
{
|
||||
res.Cost += bannerRes.Cost;
|
||||
return Result(Status::InvalidParameters, STR_CANT_REMOVE_FOOTPATH_FROM_HERE, STR_OFF_EDGE_OF_MAP);
|
||||
}
|
||||
FootpathRemoveEdgesAt(_loc, footpathElement);
|
||||
MapInvalidateTileFull(_loc);
|
||||
TileElementRemove(footpathElement);
|
||||
FootpathUpdateQueueChains();
|
||||
|
||||
auto& gameState = getGameState();
|
||||
// Remove the spawn point (if there is one in the current tile)
|
||||
gameState.peepSpawns.erase(
|
||||
std::remove_if(
|
||||
gameState.peepSpawns.begin(), gameState.peepSpawns.end(),
|
||||
[this](const CoordsXYZ& spawn) {
|
||||
{
|
||||
return spawn.ToTileStart() == _loc.ToTileStart();
|
||||
}
|
||||
}),
|
||||
gameState.peepSpawns.end());
|
||||
}
|
||||
else
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_FOOTPATH_FROM_HERE, kStringIdNone);
|
||||
}
|
||||
|
||||
res.Cost += GetRefundPrice(footpathElement);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
TileElement* FootpathRemoveAction::GetFootpathElement() const
|
||||
{
|
||||
bool getGhostPath = GetFlags() & GAME_COMMAND_FLAG_GHOST;
|
||||
|
||||
// FIXME: This is a hack to get the footpath element. It should be done in a better way.
|
||||
TileElement* tileElement = MapGetFootpathElement(_loc)->as<TileElement>();
|
||||
TileElement* footpathElement = nullptr;
|
||||
if (tileElement != nullptr)
|
||||
{
|
||||
if (getGhostPath && !tileElement->IsGhost())
|
||||
if (!(gLegacyScene == LegacyScene::scenarioEditor || getGameState().cheats.sandboxMode) && !MapIsLocationOwned(_loc))
|
||||
{
|
||||
while (!(tileElement++)->IsLastForTile())
|
||||
return Result(Status::NotOwned, STR_CANT_REMOVE_FOOTPATH_FROM_HERE, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
}
|
||||
|
||||
TileElement* footpathElement = GetFootpathElement();
|
||||
if (footpathElement == nullptr)
|
||||
{
|
||||
return Result(Status::InvalidParameters, STR_CANT_REMOVE_FOOTPATH_FROM_HERE, STR_ERR_PATH_ELEMENT_NOT_FOUND);
|
||||
}
|
||||
|
||||
res.Cost = GetRefundPrice(footpathElement);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
Result FootpathRemoveAction::Execute() const
|
||||
{
|
||||
auto res = Result();
|
||||
res.Cost = 0;
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
res.Position = { _loc.x + 16, _loc.y + 16, _loc.z };
|
||||
|
||||
if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST))
|
||||
{
|
||||
FootpathInterruptPeeps(_loc);
|
||||
FootpathRemoveLitter(_loc);
|
||||
}
|
||||
|
||||
TileElement* footpathElement = GetFootpathElement();
|
||||
if (footpathElement != nullptr)
|
||||
{
|
||||
FootpathQueueChainReset();
|
||||
auto bannerRes = RemoveBannersAtElement(_loc, footpathElement);
|
||||
if (bannerRes.Error == Status::Ok)
|
||||
{
|
||||
if (tileElement->GetType() != TileElementType::Path && !tileElement->IsGhost())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
footpathElement = tileElement;
|
||||
break;
|
||||
res.Cost += bannerRes.Cost;
|
||||
}
|
||||
FootpathRemoveEdgesAt(_loc, footpathElement);
|
||||
MapInvalidateTileFull(_loc);
|
||||
TileElementRemove(footpathElement);
|
||||
FootpathUpdateQueueChains();
|
||||
|
||||
auto& gameState = getGameState();
|
||||
// Remove the spawn point (if there is one in the current tile)
|
||||
gameState.peepSpawns.erase(
|
||||
std::remove_if(
|
||||
gameState.peepSpawns.begin(), gameState.peepSpawns.end(),
|
||||
[this](const CoordsXYZ& spawn) {
|
||||
{
|
||||
return spawn.ToTileStart() == _loc.ToTileStart();
|
||||
}
|
||||
}),
|
||||
gameState.peepSpawns.end());
|
||||
}
|
||||
else
|
||||
{
|
||||
footpathElement = tileElement;
|
||||
return Result(Status::InvalidParameters, STR_CANT_REMOVE_FOOTPATH_FROM_HERE, kStringIdNone);
|
||||
}
|
||||
|
||||
res.Cost += GetRefundPrice(footpathElement);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
return footpathElement;
|
||||
}
|
||||
|
||||
money64 FootpathRemoveAction::GetRefundPrice(TileElement* footpathElement) const
|
||||
{
|
||||
money64 cost = -10.00_GBP;
|
||||
return cost;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006BA23E
|
||||
*/
|
||||
GameActions::Result FootpathRemoveAction::RemoveBannersAtElement(const CoordsXY& loc, TileElement* tileElement) const
|
||||
{
|
||||
auto result = GameActions::Result();
|
||||
while (!(tileElement++)->IsLastForTile())
|
||||
TileElement* FootpathRemoveAction::GetFootpathElement() const
|
||||
{
|
||||
if (tileElement->GetType() == TileElementType::Path)
|
||||
return result;
|
||||
bool getGhostPath = GetFlags() & GAME_COMMAND_FLAG_GHOST;
|
||||
|
||||
if (tileElement->GetType() != TileElementType::Banner)
|
||||
continue;
|
||||
|
||||
auto bannerRemoveAction = BannerRemoveAction({ loc, tileElement->GetBaseZ(), tileElement->AsBanner()->GetPosition() });
|
||||
bool isGhost = tileElement->IsGhost();
|
||||
auto bannerFlags = GetFlags() | (isGhost ? static_cast<uint32_t>(GAME_COMMAND_FLAG_GHOST) : 0);
|
||||
bannerRemoveAction.SetFlags(bannerFlags);
|
||||
auto res = GameActions::ExecuteNested(&bannerRemoveAction);
|
||||
// Ghost removal is free
|
||||
if (res.Error == GameActions::Status::Ok && !isGhost)
|
||||
// FIXME: This is a hack to get the footpath element. It should be done in a better way.
|
||||
TileElement* tileElement = MapGetFootpathElement(_loc)->as<TileElement>();
|
||||
TileElement* footpathElement = nullptr;
|
||||
if (tileElement != nullptr)
|
||||
{
|
||||
result.Cost += res.Cost;
|
||||
if (getGhostPath && !tileElement->IsGhost())
|
||||
{
|
||||
while (!(tileElement++)->IsLastForTile())
|
||||
{
|
||||
if (tileElement->GetType() != TileElementType::Path && !tileElement->IsGhost())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
footpathElement = tileElement;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
footpathElement = tileElement;
|
||||
}
|
||||
}
|
||||
tileElement--;
|
||||
|
||||
return footpathElement;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
money64 FootpathRemoveAction::GetRefundPrice(TileElement* footpathElement) const
|
||||
{
|
||||
money64 cost = -10.00_GBP;
|
||||
return cost;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006BA23E
|
||||
*/
|
||||
Result FootpathRemoveAction::RemoveBannersAtElement(const CoordsXY& loc, TileElement* tileElement) const
|
||||
{
|
||||
auto result = Result();
|
||||
while (!(tileElement++)->IsLastForTile())
|
||||
{
|
||||
if (tileElement->GetType() == TileElementType::Path)
|
||||
return result;
|
||||
|
||||
if (tileElement->GetType() != TileElementType::Banner)
|
||||
continue;
|
||||
|
||||
auto bannerRemoveAction = BannerRemoveAction(
|
||||
{ loc, tileElement->GetBaseZ(), tileElement->AsBanner()->GetPosition() });
|
||||
bool isGhost = tileElement->IsGhost();
|
||||
auto bannerFlags = GetFlags() | (isGhost ? static_cast<uint32_t>(GAME_COMMAND_FLAG_GHOST) : 0);
|
||||
bannerRemoveAction.SetFlags(bannerFlags);
|
||||
auto res = ExecuteNested(&bannerRemoveAction);
|
||||
// Ghost removal is free
|
||||
if (res.Error == Status::Ok && !isGhost)
|
||||
{
|
||||
result.Cost += res.Cost;
|
||||
}
|
||||
tileElement--;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -12,25 +12,28 @@
|
||||
#include "../management/Finance.h"
|
||||
#include "GameAction.h"
|
||||
|
||||
class FootpathRemoveAction final : public GameActionBase<GameCommand::RemovePath>
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
private:
|
||||
CoordsXYZ _loc;
|
||||
class FootpathRemoveAction final : public GameActionBase<GameCommand::RemovePath>
|
||||
{
|
||||
private:
|
||||
CoordsXYZ _loc;
|
||||
|
||||
public:
|
||||
FootpathRemoveAction() = default;
|
||||
FootpathRemoveAction(const CoordsXYZ& location);
|
||||
public:
|
||||
FootpathRemoveAction() = default;
|
||||
FootpathRemoveAction(const CoordsXYZ& location);
|
||||
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
|
||||
uint16_t GetActionFlags() const override;
|
||||
uint16_t GetActionFlags() const override;
|
||||
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
OpenRCT2::GameActions::Result Query() const override;
|
||||
OpenRCT2::GameActions::Result Execute() const override;
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
Result Query() const override;
|
||||
Result Execute() const override;
|
||||
|
||||
private:
|
||||
OpenRCT2::TileElement* GetFootpathElement() const;
|
||||
money64 GetRefundPrice(OpenRCT2::TileElement* footpathElement) const;
|
||||
OpenRCT2::GameActions::Result RemoveBannersAtElement(const CoordsXY& loc, OpenRCT2::TileElement* tileElement) const;
|
||||
};
|
||||
private:
|
||||
TileElement* GetFootpathElement() const;
|
||||
money64 GetRefundPrice(TileElement* footpathElement) const;
|
||||
Result RemoveBannersAtElement(const CoordsXY& loc, TileElement* tileElement) const;
|
||||
};
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -31,8 +31,6 @@
|
||||
|
||||
#include <iterator>
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
struct QueuedGameAction
|
||||
@@ -143,8 +141,8 @@ namespace OpenRCT2::GameActions
|
||||
|
||||
Guard::Assert(action != nullptr);
|
||||
|
||||
GameActions::Result result = Execute(action);
|
||||
if (result.Error == GameActions::Status::Ok && NetworkGetMode() == NETWORK_MODE_SERVER)
|
||||
Result result = Execute(action);
|
||||
if (result.Error == Status::Ok && NetworkGetMode() == NETWORK_MODE_SERVER)
|
||||
{
|
||||
// Relay this action to all other clients.
|
||||
NetworkSendGameAction(action);
|
||||
@@ -161,7 +159,7 @@ namespace OpenRCT2::GameActions
|
||||
|
||||
GameAction::Ptr Clone(const GameAction* action)
|
||||
{
|
||||
std::unique_ptr<GameAction> ga = GameActions::Create(action->GetType());
|
||||
std::unique_ptr<GameAction> ga = Create(action->GetType());
|
||||
ga->SetCallback(action->GetCallback());
|
||||
|
||||
// Serialise action data into stream.
|
||||
@@ -184,21 +182,21 @@ namespace OpenRCT2::GameActions
|
||||
return true;
|
||||
if (getGameState().cheats.buildInPauseMode)
|
||||
return true;
|
||||
if (actionFlags & GameActions::Flags::AllowWhilePaused)
|
||||
if (actionFlags & Flags::AllowWhilePaused)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static GameActions::Result QueryInternal(const GameAction* action, bool topLevel)
|
||||
static Result QueryInternal(const GameAction* action, bool topLevel)
|
||||
{
|
||||
Guard::ArgumentNotNull(action);
|
||||
|
||||
uint16_t actionFlags = action->GetActionFlags();
|
||||
if (topLevel && !CheckActionInPausedMode(actionFlags))
|
||||
{
|
||||
GameActions::Result result = GameActions::Result();
|
||||
Result result = Result();
|
||||
|
||||
result.Error = GameActions::Status::GamePaused;
|
||||
result.Error = Status::GamePaused;
|
||||
result.ErrorTitle = STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE;
|
||||
result.ErrorMessage = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED;
|
||||
|
||||
@@ -207,11 +205,11 @@ namespace OpenRCT2::GameActions
|
||||
|
||||
auto result = action->Query();
|
||||
|
||||
if (result.Error == GameActions::Status::Ok)
|
||||
if (result.Error == Status::Ok)
|
||||
{
|
||||
if (!FinanceCheckAffordability(result.Cost, action->GetFlags()))
|
||||
{
|
||||
result.Error = GameActions::Status::InsufficientFunds;
|
||||
result.Error = Status::InsufficientFunds;
|
||||
result.ErrorTitle = STR_CANT_DO_THIS;
|
||||
result.ErrorMessage = STR_NOT_ENOUGH_CASH_REQUIRES;
|
||||
Formatter(result.ErrorMessageArgs.data()).Add<uint32_t>(result.Cost);
|
||||
@@ -220,12 +218,12 @@ namespace OpenRCT2::GameActions
|
||||
return result;
|
||||
}
|
||||
|
||||
GameActions::Result Query(const GameAction* action)
|
||||
Result Query(const GameAction* action)
|
||||
{
|
||||
return QueryInternal(action, true);
|
||||
}
|
||||
|
||||
GameActions::Result QueryNested(const GameAction* action)
|
||||
Result QueryNested(const GameAction* action)
|
||||
{
|
||||
return QueryInternal(action, false);
|
||||
}
|
||||
@@ -261,13 +259,13 @@ namespace OpenRCT2::GameActions
|
||||
action->Serialise(ds);
|
||||
}
|
||||
|
||||
static void LogActionFinish(ActionLogContext& ctx, const GameAction* action, const GameActions::Result& result)
|
||||
static void LogActionFinish(ActionLogContext& ctx, const GameAction* action, const Result& result)
|
||||
{
|
||||
MemoryStream& output = ctx.output;
|
||||
|
||||
char temp[128] = {};
|
||||
|
||||
if (result.Error != GameActions::Status::Ok)
|
||||
if (result.Error != Status::Ok)
|
||||
{
|
||||
snprintf(temp, sizeof(temp), ") Failed, %u", static_cast<uint32_t>(result.Error));
|
||||
}
|
||||
@@ -284,7 +282,7 @@ namespace OpenRCT2::GameActions
|
||||
NetworkAppendServerLog(text);
|
||||
}
|
||||
|
||||
static GameActions::Result ExecuteInternal(const GameAction* action, bool topLevel)
|
||||
static Result ExecuteInternal(const GameAction* action, bool topLevel)
|
||||
{
|
||||
Guard::ArgumentNotNull(action);
|
||||
|
||||
@@ -292,7 +290,7 @@ namespace OpenRCT2::GameActions
|
||||
uint32_t flags = action->GetFlags();
|
||||
|
||||
// Some actions are not recorded in the replay.
|
||||
const auto ignoreForReplays = (actionFlags & GameActions::Flags::IgnoreForReplays) != 0;
|
||||
const auto ignoreForReplays = (actionFlags & Flags::IgnoreForReplays) != 0;
|
||||
|
||||
auto* replayManager = OpenRCT2::GetContext()->GetReplayManager();
|
||||
if (replayManager != nullptr && (replayManager->IsReplaying() || replayManager->IsNormalising()))
|
||||
@@ -301,8 +299,8 @@ namespace OpenRCT2::GameActions
|
||||
if ((flags & GAME_COMMAND_FLAG_REPLAY) == 0 && !ignoreForReplays)
|
||||
{
|
||||
// TODO: Introduce proper error.
|
||||
auto result = GameActions::Result();
|
||||
result.Error = GameActions::Status::GamePaused;
|
||||
auto result = Result();
|
||||
result.Error = Status::GamePaused;
|
||||
result.ErrorTitle = STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE;
|
||||
result.ErrorMessage = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED;
|
||||
|
||||
@@ -310,17 +308,16 @@ namespace OpenRCT2::GameActions
|
||||
}
|
||||
}
|
||||
|
||||
GameActions::Result result = QueryInternal(action, topLevel);
|
||||
Result result = QueryInternal(action, topLevel);
|
||||
#ifdef ENABLE_SCRIPTING
|
||||
if (result.Error == GameActions::Status::Ok
|
||||
&& ((NetworkGetMode() == NETWORK_MODE_NONE) || (flags & GAME_COMMAND_FLAG_NETWORKED)))
|
||||
if (result.Error == Status::Ok && ((NetworkGetMode() == NETWORK_MODE_NONE) || (flags & GAME_COMMAND_FLAG_NETWORKED)))
|
||||
{
|
||||
auto& scriptEngine = GetContext()->GetScriptEngine();
|
||||
scriptEngine.RunGameActionHooks(*action, result, false);
|
||||
// Script hooks may now have changed the game action result...
|
||||
}
|
||||
#endif
|
||||
if (result.Error == GameActions::Status::Ok)
|
||||
if (result.Error == Status::Ok)
|
||||
{
|
||||
if (topLevel)
|
||||
{
|
||||
@@ -328,7 +325,7 @@ namespace OpenRCT2::GameActions
|
||||
if (NetworkGetMode() == NETWORK_MODE_CLIENT)
|
||||
{
|
||||
// As a client we have to wait or send it first.
|
||||
if (!(actionFlags & GameActions::Flags::ClientOnly) && !(flags & GAME_COMMAND_FLAG_NETWORKED))
|
||||
if (!(actionFlags & Flags::ClientOnly) && !(flags & GAME_COMMAND_FLAG_NETWORKED))
|
||||
{
|
||||
LOG_VERBOSE("[%s] GameAction::Execute %s (Out)", GetRealm(), action->GetName());
|
||||
NetworkSendGameAction(action);
|
||||
@@ -341,7 +338,7 @@ namespace OpenRCT2::GameActions
|
||||
// If player is the server it would execute right away as where clients execute the commands
|
||||
// at the beginning of the frame, so we have to put them into the queue.
|
||||
// This is also the case when its executed from the UI update.
|
||||
if (!(actionFlags & GameActions::Flags::ClientOnly) && !(flags & GAME_COMMAND_FLAG_NETWORKED))
|
||||
if (!(actionFlags & Flags::ClientOnly) && !(flags & GAME_COMMAND_FLAG_NETWORKED))
|
||||
{
|
||||
LOG_VERBOSE("[%s] GameAction::Execute %s (Queue)", GetRealm(), action->GetName());
|
||||
Enqueue(action, getGameState().currentTicks);
|
||||
@@ -357,7 +354,7 @@ namespace OpenRCT2::GameActions
|
||||
// Execute the action, changing the game state
|
||||
result = action->Execute();
|
||||
#ifdef ENABLE_SCRIPTING
|
||||
if (result.Error == GameActions::Status::Ok)
|
||||
if (result.Error == Status::Ok)
|
||||
{
|
||||
auto& scriptEngine = GetContext()->GetScriptEngine();
|
||||
scriptEngine.RunGameActionHooks(*action, result, true);
|
||||
@@ -372,13 +369,13 @@ namespace OpenRCT2::GameActions
|
||||
return result;
|
||||
|
||||
// Update money balance
|
||||
if (result.Error == GameActions::Status::Ok && FinanceCheckMoneyRequired(flags) && result.Cost != 0)
|
||||
if (result.Error == Status::Ok && FinanceCheckMoneyRequired(flags) && result.Cost != 0)
|
||||
{
|
||||
FinancePayment(result.Cost, result.Expenditure);
|
||||
MoneyEffect::Create(result.Cost, result.Position);
|
||||
}
|
||||
|
||||
if (!(actionFlags & GameActions::Flags::ClientOnly) && result.Error == GameActions::Status::Ok)
|
||||
if (!(actionFlags & Flags::ClientOnly) && result.Error == Status::Ok)
|
||||
{
|
||||
if (NetworkGetMode() != NETWORK_MODE_NONE)
|
||||
{
|
||||
@@ -448,7 +445,7 @@ namespace OpenRCT2::GameActions
|
||||
}
|
||||
}
|
||||
|
||||
if (result.Error != GameActions::Status::Ok && shouldShowError)
|
||||
if (result.Error != Status::Ok && shouldShowError)
|
||||
{
|
||||
auto windowManager = Ui::GetWindowManager();
|
||||
windowManager->ShowError(result.GetErrorTitle(), result.GetErrorMessage());
|
||||
@@ -457,12 +454,12 @@ namespace OpenRCT2::GameActions
|
||||
return result;
|
||||
}
|
||||
|
||||
GameActions::Result Execute(const GameAction* action)
|
||||
Result Execute(const GameAction* action)
|
||||
{
|
||||
return ExecuteInternal(action, true);
|
||||
}
|
||||
|
||||
GameActions::Result ExecuteNested(const GameAction* action)
|
||||
Result ExecuteNested(const GameAction* action)
|
||||
{
|
||||
return ExecuteInternal(action, false);
|
||||
}
|
||||
@@ -470,7 +467,7 @@ namespace OpenRCT2::GameActions
|
||||
|
||||
const char* GameAction::GetName() const
|
||||
{
|
||||
return GameActions::GetName(_type);
|
||||
return OpenRCT2::GameActions::GetName(_type);
|
||||
}
|
||||
|
||||
bool GameAction::LocationValid(const CoordsXY& coords) const
|
||||
@@ -479,10 +476,10 @@ bool GameAction::LocationValid(const CoordsXY& coords) const
|
||||
if (!result)
|
||||
return false;
|
||||
#ifdef ENABLE_SCRIPTING
|
||||
auto& hookEngine = GetContext()->GetScriptEngine().GetHookEngine();
|
||||
auto& hookEngine = OpenRCT2::GetContext()->GetScriptEngine().GetHookEngine();
|
||||
if (hookEngine.HasSubscriptions(OpenRCT2::Scripting::HookType::actionLocation))
|
||||
{
|
||||
auto ctx = GetContext()->GetScriptEngine().GetContext();
|
||||
auto ctx = OpenRCT2::GetContext()->GetScriptEngine().GetContext();
|
||||
|
||||
// Create event args object
|
||||
auto obj = OpenRCT2::Scripting::DukObject(ctx);
|
||||
@@ -492,7 +489,7 @@ bool GameAction::LocationValid(const CoordsXY& coords) const
|
||||
obj.Set("type", EnumValue(_type));
|
||||
|
||||
auto flags = GetActionFlags();
|
||||
obj.Set("isClientOnly", (flags & GameActions::Flags::ClientOnly) != 0);
|
||||
obj.Set("isClientOnly", (flags & OpenRCT2::GameActions::Flags::ClientOnly) != 0);
|
||||
obj.Set("result", true);
|
||||
|
||||
// Call the subscriptions
|
||||
|
||||
@@ -288,11 +288,11 @@ namespace OpenRCT2::GameActions
|
||||
GameAction::Ptr Clone(const GameAction* action);
|
||||
|
||||
// This should be used if a round trip is to be expected.
|
||||
OpenRCT2::GameActions::Result Query(const GameAction* action);
|
||||
OpenRCT2::GameActions::Result Execute(const GameAction* action);
|
||||
Result Query(const GameAction* action);
|
||||
Result Execute(const GameAction* action);
|
||||
|
||||
// This should be used from within game actions.
|
||||
OpenRCT2::GameActions::Result QueryNested(const GameAction* action);
|
||||
OpenRCT2::GameActions::Result ExecuteNested(const GameAction* action);
|
||||
Result QueryNested(const GameAction* action);
|
||||
Result ExecuteNested(const GameAction* action);
|
||||
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -94,8 +94,6 @@
|
||||
|
||||
#include <array>
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
struct GameActionEntry
|
||||
|
||||
@@ -8,7 +8,7 @@ using namespace OpenRCT2;
|
||||
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
Result::Result(GameActions::Status error, StringId title, StringId message, uint8_t* args /*= nullptr*/)
|
||||
Result::Result(Status error, StringId title, StringId message, uint8_t* args /*= nullptr*/)
|
||||
: Error(error)
|
||||
, ErrorTitle(title)
|
||||
, ErrorMessage(message)
|
||||
@@ -33,12 +33,12 @@ namespace OpenRCT2::GameActions
|
||||
}
|
||||
};
|
||||
|
||||
std::string GameActions::Result::GetErrorTitle() const
|
||||
std::string Result::GetErrorTitle() const
|
||||
{
|
||||
return std::visit(StringVariantVisitor{ ErrorMessageArgs.data() }, ErrorTitle);
|
||||
}
|
||||
|
||||
std::string GameActions::Result::GetErrorMessage() const
|
||||
std::string Result::GetErrorMessage() const
|
||||
{
|
||||
return std::visit(StringVariantVisitor{ ErrorMessageArgs.data() }, ErrorMessage);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*
|
||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../management/Finance.h"
|
||||
@@ -56,7 +57,7 @@ namespace OpenRCT2::GameActions
|
||||
public:
|
||||
using StringVariant = std::variant<std::string, StringId>;
|
||||
|
||||
OpenRCT2::GameActions::Status Error = OpenRCT2::GameActions::Status::Ok;
|
||||
Status Error = Status::Ok;
|
||||
StringVariant ErrorTitle = kStringIdNone;
|
||||
StringVariant ErrorMessage = kStringIdNone;
|
||||
std::array<uint8_t, 32> ErrorMessageArgs{};
|
||||
@@ -74,7 +75,7 @@ namespace OpenRCT2::GameActions
|
||||
#endif
|
||||
|
||||
Result() = default;
|
||||
Result(OpenRCT2::GameActions::Status error, StringId title, StringId message, uint8_t* args = nullptr);
|
||||
Result(Status error, StringId title, StringId message, uint8_t* args = nullptr);
|
||||
|
||||
std::string GetErrorTitle() const;
|
||||
std::string GetErrorMessage() const;
|
||||
|
||||
@@ -13,64 +13,63 @@
|
||||
#include "../config/Config.h"
|
||||
#include "../ui/WindowManager.h"
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
GameSetSpeedAction::GameSetSpeedAction(uint8_t speed)
|
||||
: _speed(speed)
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
}
|
||||
|
||||
void GameSetSpeedAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
visitor.Visit("speed", _speed);
|
||||
}
|
||||
|
||||
uint16_t GameSetSpeedAction::GetActionFlags() const
|
||||
{
|
||||
return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused | GameActions::Flags::IgnoreForReplays;
|
||||
}
|
||||
|
||||
void GameSetSpeedAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_speed);
|
||||
}
|
||||
|
||||
GameActions::Result GameSetSpeedAction::Query() const
|
||||
{
|
||||
GameActions::Result res = GameActions::Result();
|
||||
|
||||
if (!IsValidSpeed(_speed))
|
||||
GameSetSpeedAction::GameSetSpeedAction(uint8_t speed)
|
||||
: _speed(speed)
|
||||
{
|
||||
LOG_ERROR("Invalid speed %u", _speed);
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_ERR_INVALID_PARAMETER, STR_ERR_VALUE_OUT_OF_RANGE);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
GameActions::Result GameSetSpeedAction::Execute() const
|
||||
{
|
||||
GameActions::Result res = GameActions::Result();
|
||||
|
||||
if (!IsValidSpeed(_speed))
|
||||
void GameSetSpeedAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
LOG_ERROR("Invalid speed %u", _speed);
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_ERR_INVALID_PARAMETER, STR_ERR_VALUE_OUT_OF_RANGE);
|
||||
visitor.Visit("speed", _speed);
|
||||
}
|
||||
|
||||
gGameSpeed = _speed;
|
||||
uint16_t GameSetSpeedAction::GetActionFlags() const
|
||||
{
|
||||
return GameAction::GetActionFlags() | Flags::AllowWhilePaused | Flags::IgnoreForReplays;
|
||||
}
|
||||
|
||||
auto* windowMgr = Ui::GetWindowManager();
|
||||
windowMgr->InvalidateByClass(WindowClass::TopToolbar);
|
||||
void GameSetSpeedAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
return res;
|
||||
}
|
||||
stream << DS_TAG(_speed);
|
||||
}
|
||||
|
||||
bool GameSetSpeedAction::IsValidSpeed(uint8_t speed) const
|
||||
{
|
||||
return speed >= 1 && (speed <= 4 || (Config::Get().general.DebuggingTools && speed <= 8));
|
||||
}
|
||||
Result GameSetSpeedAction::Query() const
|
||||
{
|
||||
Result res = Result();
|
||||
|
||||
if (!IsValidSpeed(_speed))
|
||||
{
|
||||
LOG_ERROR("Invalid speed %u", _speed);
|
||||
return Result(Status::InvalidParameters, STR_ERR_INVALID_PARAMETER, STR_ERR_VALUE_OUT_OF_RANGE);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
Result GameSetSpeedAction::Execute() const
|
||||
{
|
||||
Result res = Result();
|
||||
|
||||
if (!IsValidSpeed(_speed))
|
||||
{
|
||||
LOG_ERROR("Invalid speed %u", _speed);
|
||||
return Result(Status::InvalidParameters, STR_ERR_INVALID_PARAMETER, STR_ERR_VALUE_OUT_OF_RANGE);
|
||||
}
|
||||
|
||||
gGameSpeed = _speed;
|
||||
|
||||
auto* windowMgr = Ui::GetWindowManager();
|
||||
windowMgr->InvalidateByClass(WindowClass::TopToolbar);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool GameSetSpeedAction::IsValidSpeed(uint8_t speed) const
|
||||
{
|
||||
return speed >= 1 && (speed <= 4 || (Config::Get().general.DebuggingTools && speed <= 8));
|
||||
}
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -11,23 +11,26 @@
|
||||
|
||||
#include "GameAction.h"
|
||||
|
||||
class GameSetSpeedAction final : public GameActionBase<GameCommand::SetGameSpeed>
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
private:
|
||||
uint8_t _speed{ 1 };
|
||||
class GameSetSpeedAction final : public GameActionBase<GameCommand::SetGameSpeed>
|
||||
{
|
||||
private:
|
||||
uint8_t _speed{ 1 };
|
||||
|
||||
public:
|
||||
GameSetSpeedAction() = default;
|
||||
GameSetSpeedAction(uint8_t speed);
|
||||
public:
|
||||
GameSetSpeedAction() = default;
|
||||
GameSetSpeedAction(uint8_t speed);
|
||||
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
|
||||
uint16_t GetActionFlags() const override;
|
||||
uint16_t GetActionFlags() const override;
|
||||
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
OpenRCT2::GameActions::Result Query() const override;
|
||||
OpenRCT2::GameActions::Result Execute() const override;
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
Result Query() const override;
|
||||
Result Execute() const override;
|
||||
|
||||
private:
|
||||
bool IsValidSpeed(uint8_t speed) const;
|
||||
};
|
||||
private:
|
||||
bool IsValidSpeed(uint8_t speed) const;
|
||||
};
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -14,53 +14,54 @@
|
||||
#include "../OpenRCT2.h"
|
||||
#include "../entity/EntityRegistry.h"
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
GuestSetFlagsAction::GuestSetFlagsAction(EntityId peepId, uint32_t flags)
|
||||
: _peepId(peepId)
|
||||
, _newFlags(flags)
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
}
|
||||
|
||||
void GuestSetFlagsAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
visitor.Visit("peep", _peepId);
|
||||
visitor.Visit("guestFlags", _newFlags);
|
||||
}
|
||||
|
||||
uint16_t GuestSetFlagsAction::GetActionFlags() const
|
||||
{
|
||||
return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused;
|
||||
}
|
||||
|
||||
void GuestSetFlagsAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_peepId) << DS_TAG(_newFlags);
|
||||
}
|
||||
|
||||
GameActions::Result GuestSetFlagsAction::Query() const
|
||||
{
|
||||
auto* peep = TryGetEntity<Guest>(_peepId);
|
||||
if (peep == nullptr)
|
||||
GuestSetFlagsAction::GuestSetFlagsAction(EntityId peepId, uint32_t flags)
|
||||
: _peepId(peepId)
|
||||
, _newFlags(flags)
|
||||
{
|
||||
LOG_ERROR("Guest entity not found for peepID %u", _peepId.ToUnderlying());
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_CHANGE_THIS, kStringIdNone);
|
||||
}
|
||||
return GameActions::Result();
|
||||
}
|
||||
|
||||
GameActions::Result GuestSetFlagsAction::Execute() const
|
||||
{
|
||||
auto* peep = TryGetEntity<Guest>(_peepId);
|
||||
if (peep == nullptr)
|
||||
{
|
||||
LOG_ERROR("Guest entity not found for peepID %u", _peepId.ToUnderlying());
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_CHANGE_THIS, kStringIdNone);
|
||||
}
|
||||
|
||||
peep->PeepFlags = _newFlags;
|
||||
void GuestSetFlagsAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
visitor.Visit("peep", _peepId);
|
||||
visitor.Visit("guestFlags", _newFlags);
|
||||
}
|
||||
|
||||
return GameActions::Result();
|
||||
}
|
||||
uint16_t GuestSetFlagsAction::GetActionFlags() const
|
||||
{
|
||||
return GameAction::GetActionFlags() | Flags::AllowWhilePaused;
|
||||
}
|
||||
|
||||
void GuestSetFlagsAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_peepId) << DS_TAG(_newFlags);
|
||||
}
|
||||
|
||||
Result GuestSetFlagsAction::Query() const
|
||||
{
|
||||
auto* peep = TryGetEntity<Guest>(_peepId);
|
||||
if (peep == nullptr)
|
||||
{
|
||||
LOG_ERROR("Guest entity not found for peepID %u", _peepId.ToUnderlying());
|
||||
return Result(Status::InvalidParameters, STR_CANT_CHANGE_THIS, kStringIdNone);
|
||||
}
|
||||
return Result();
|
||||
}
|
||||
|
||||
Result GuestSetFlagsAction::Execute() const
|
||||
{
|
||||
auto* peep = TryGetEntity<Guest>(_peepId);
|
||||
if (peep == nullptr)
|
||||
{
|
||||
LOG_ERROR("Guest entity not found for peepID %u", _peepId.ToUnderlying());
|
||||
return Result(Status::InvalidParameters, STR_CANT_CHANGE_THIS, kStringIdNone);
|
||||
}
|
||||
|
||||
peep->PeepFlags = _newFlags;
|
||||
|
||||
return Result();
|
||||
}
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -11,21 +11,24 @@
|
||||
|
||||
#include "GameAction.h"
|
||||
|
||||
class GuestSetFlagsAction final : public GameActionBase<GameCommand::GuestSetFlags>
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
private:
|
||||
EntityId _peepId{ EntityId::GetNull() };
|
||||
uint32_t _newFlags{};
|
||||
class GuestSetFlagsAction final : public GameActionBase<GameCommand::GuestSetFlags>
|
||||
{
|
||||
private:
|
||||
EntityId _peepId{ EntityId::GetNull() };
|
||||
uint32_t _newFlags{};
|
||||
|
||||
public:
|
||||
GuestSetFlagsAction() = default;
|
||||
GuestSetFlagsAction(EntityId peepId, uint32_t flags);
|
||||
public:
|
||||
GuestSetFlagsAction() = default;
|
||||
GuestSetFlagsAction(EntityId peepId, uint32_t flags);
|
||||
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
|
||||
uint16_t GetActionFlags() const override;
|
||||
uint16_t GetActionFlags() const override;
|
||||
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
OpenRCT2::GameActions::Result Query() const override;
|
||||
OpenRCT2::GameActions::Result Execute() const override;
|
||||
};
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
Result Query() const override;
|
||||
Result Execute() const override;
|
||||
};
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -19,89 +19,90 @@
|
||||
#include "../windows/Intent.h"
|
||||
#include "../world/Park.h"
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
GuestSetNameAction::GuestSetNameAction(EntityId spriteIndex, const std::string& name)
|
||||
: _spriteIndex(spriteIndex)
|
||||
, _name(name)
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
}
|
||||
|
||||
EntityId GuestSetNameAction::GetSpriteIndex() const
|
||||
{
|
||||
return _spriteIndex;
|
||||
}
|
||||
|
||||
std::string GuestSetNameAction::GetGuestName() const
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
void GuestSetNameAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
visitor.Visit("peep", _spriteIndex);
|
||||
visitor.Visit("name", _name);
|
||||
}
|
||||
|
||||
uint16_t GuestSetNameAction::GetActionFlags() const
|
||||
{
|
||||
return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused;
|
||||
}
|
||||
|
||||
void GuestSetNameAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_spriteIndex) << DS_TAG(_name);
|
||||
}
|
||||
|
||||
GameActions::Result GuestSetNameAction::Query() const
|
||||
{
|
||||
if (_spriteIndex.ToUnderlying() >= kMaxEntities || _spriteIndex.IsNull())
|
||||
GuestSetNameAction::GuestSetNameAction(EntityId spriteIndex, const std::string& name)
|
||||
: _spriteIndex(spriteIndex)
|
||||
, _name(name)
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_NAME_GUEST, STR_ERR_VALUE_OUT_OF_RANGE);
|
||||
}
|
||||
|
||||
auto guest = TryGetEntity<Guest>(_spriteIndex);
|
||||
if (guest == nullptr)
|
||||
EntityId GuestSetNameAction::GetSpriteIndex() const
|
||||
{
|
||||
LOG_ERROR("Guest entity not found for spriteIndex %u", _spriteIndex);
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_NAME_GUEST, kStringIdNone);
|
||||
return _spriteIndex;
|
||||
}
|
||||
|
||||
return GameActions::Result();
|
||||
}
|
||||
|
||||
GameActions::Result GuestSetNameAction::Execute() const
|
||||
{
|
||||
auto guest = TryGetEntity<Guest>(_spriteIndex);
|
||||
if (guest == nullptr)
|
||||
std::string GuestSetNameAction::GetGuestName() const
|
||||
{
|
||||
LOG_ERROR("Guest entity not found for spriteIndex %u", _spriteIndex);
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_NAME_GUEST, kStringIdNone);
|
||||
return _name;
|
||||
}
|
||||
|
||||
auto curName = guest->GetName();
|
||||
if (curName == _name)
|
||||
void GuestSetNameAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
return GameActions::Result();
|
||||
visitor.Visit("peep", _spriteIndex);
|
||||
visitor.Visit("name", _name);
|
||||
}
|
||||
|
||||
if (!guest->SetName(_name))
|
||||
uint16_t GuestSetNameAction::GetActionFlags() const
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::Unknown, STR_CANT_NAME_GUEST, kStringIdNone);
|
||||
return GameAction::GetActionFlags() | Flags::AllowWhilePaused;
|
||||
}
|
||||
|
||||
// Easter egg functions are for guests only
|
||||
guest->HandleEasterEggName();
|
||||
void GuestSetNameAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
GfxInvalidateScreen();
|
||||
stream << DS_TAG(_spriteIndex) << DS_TAG(_name);
|
||||
}
|
||||
|
||||
auto intent = Intent(INTENT_ACTION_REFRESH_GUEST_LIST);
|
||||
ContextBroadcastIntent(&intent);
|
||||
Result GuestSetNameAction::Query() const
|
||||
{
|
||||
if (_spriteIndex.ToUnderlying() >= kMaxEntities || _spriteIndex.IsNull())
|
||||
{
|
||||
return Result(Status::InvalidParameters, STR_CANT_NAME_GUEST, STR_ERR_VALUE_OUT_OF_RANGE);
|
||||
}
|
||||
|
||||
auto res = GameActions::Result();
|
||||
res.Position = guest->GetLocation();
|
||||
auto guest = TryGetEntity<Guest>(_spriteIndex);
|
||||
if (guest == nullptr)
|
||||
{
|
||||
LOG_ERROR("Guest entity not found for spriteIndex %u", _spriteIndex);
|
||||
return Result(Status::InvalidParameters, STR_CANT_NAME_GUEST, kStringIdNone);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
return Result();
|
||||
}
|
||||
|
||||
Result GuestSetNameAction::Execute() const
|
||||
{
|
||||
auto guest = TryGetEntity<Guest>(_spriteIndex);
|
||||
if (guest == nullptr)
|
||||
{
|
||||
LOG_ERROR("Guest entity not found for spriteIndex %u", _spriteIndex);
|
||||
return Result(Status::InvalidParameters, STR_CANT_NAME_GUEST, kStringIdNone);
|
||||
}
|
||||
|
||||
auto curName = guest->GetName();
|
||||
if (curName == _name)
|
||||
{
|
||||
return Result();
|
||||
}
|
||||
|
||||
if (!guest->SetName(_name))
|
||||
{
|
||||
return Result(Status::Unknown, STR_CANT_NAME_GUEST, kStringIdNone);
|
||||
}
|
||||
|
||||
// Easter egg functions are for guests only
|
||||
guest->HandleEasterEggName();
|
||||
|
||||
GfxInvalidateScreen();
|
||||
|
||||
auto intent = Intent(INTENT_ACTION_REFRESH_GUEST_LIST);
|
||||
ContextBroadcastIntent(&intent);
|
||||
|
||||
auto res = Result();
|
||||
res.Position = guest->GetLocation();
|
||||
|
||||
return res;
|
||||
}
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -11,24 +11,27 @@
|
||||
|
||||
#include "GameAction.h"
|
||||
|
||||
class GuestSetNameAction final : public GameActionBase<GameCommand::SetGuestName>
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
private:
|
||||
EntityId _spriteIndex{ EntityId::GetNull() };
|
||||
std::string _name;
|
||||
class GuestSetNameAction final : public GameActionBase<GameCommand::SetGuestName>
|
||||
{
|
||||
private:
|
||||
EntityId _spriteIndex{ EntityId::GetNull() };
|
||||
std::string _name;
|
||||
|
||||
public:
|
||||
GuestSetNameAction() = default;
|
||||
GuestSetNameAction(EntityId spriteIndex, const std::string& name);
|
||||
public:
|
||||
GuestSetNameAction() = default;
|
||||
GuestSetNameAction(EntityId spriteIndex, const std::string& name);
|
||||
|
||||
EntityId GetSpriteIndex() const;
|
||||
std::string GetGuestName() const;
|
||||
EntityId GetSpriteIndex() const;
|
||||
std::string GetGuestName() const;
|
||||
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
|
||||
uint16_t GetActionFlags() const override;
|
||||
uint16_t GetActionFlags() const override;
|
||||
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
OpenRCT2::GameActions::Result Query() const override;
|
||||
OpenRCT2::GameActions::Result Execute() const override;
|
||||
};
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
Result Query() const override;
|
||||
Result Execute() const override;
|
||||
};
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -24,152 +24,150 @@
|
||||
#include "../world/Scenery.h"
|
||||
#include "../world/tile_element/SurfaceElement.h"
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
LandBuyRightsAction::LandBuyRightsAction(const MapRange& range, LandBuyRightSetting setting)
|
||||
: _range(range)
|
||||
, _setting(setting)
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
}
|
||||
|
||||
LandBuyRightsAction::LandBuyRightsAction(const CoordsXY& coord, LandBuyRightSetting setting)
|
||||
: _range(coord.x, coord.y, coord.x, coord.y)
|
||||
, _setting(setting)
|
||||
{
|
||||
}
|
||||
|
||||
void LandBuyRightsAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
visitor.Visit(_range);
|
||||
visitor.Visit("setting", _setting);
|
||||
}
|
||||
|
||||
uint16_t LandBuyRightsAction::GetActionFlags() const
|
||||
{
|
||||
return GameAction::GetActionFlags();
|
||||
}
|
||||
|
||||
void LandBuyRightsAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_range) << DS_TAG(_setting);
|
||||
}
|
||||
|
||||
GameActions::Result LandBuyRightsAction::Query() const
|
||||
{
|
||||
return QueryExecute(false);
|
||||
}
|
||||
|
||||
GameActions::Result LandBuyRightsAction::Execute() const
|
||||
{
|
||||
return QueryExecute(true);
|
||||
}
|
||||
|
||||
GameActions::Result LandBuyRightsAction::QueryExecute(bool isExecuting) const
|
||||
{
|
||||
auto res = GameActions::Result();
|
||||
|
||||
MapRange normRange = _range.Normalise();
|
||||
// Keep big coordinates within map boundaries
|
||||
auto mapSizeMaxXY = GetMapSizeMaxXY();
|
||||
auto aX = std::max<decltype(normRange.GetLeft())>(32, normRange.GetLeft());
|
||||
auto bX = std::min<decltype(normRange.GetRight())>(mapSizeMaxXY.x, normRange.GetRight());
|
||||
auto aY = std::max<decltype(normRange.GetTop())>(32, normRange.GetTop());
|
||||
auto bY = std::min<decltype(normRange.GetBottom())>(mapSizeMaxXY.y, normRange.GetBottom());
|
||||
|
||||
MapRange validRange = MapRange{ aX, aY, bX, bY };
|
||||
|
||||
CoordsXYZ centre{ (validRange.GetLeft() + validRange.GetRight()) / 2 + 16,
|
||||
(validRange.GetTop() + validRange.GetBottom()) / 2 + 16, 0 };
|
||||
centre.z = TileElementHeight(centre);
|
||||
|
||||
res.Position = centre;
|
||||
res.Expenditure = ExpenditureType::landPurchase;
|
||||
|
||||
// Game command modified to accept selection size
|
||||
for (auto y = validRange.GetTop(); y <= validRange.GetBottom(); y += kCoordsXYStep)
|
||||
LandBuyRightsAction::LandBuyRightsAction(const MapRange& range, LandBuyRightSetting setting)
|
||||
: _range(range)
|
||||
, _setting(setting)
|
||||
{
|
||||
for (auto x = validRange.GetLeft(); x <= validRange.GetRight(); x += kCoordsXYStep)
|
||||
}
|
||||
|
||||
LandBuyRightsAction::LandBuyRightsAction(const CoordsXY& coord, LandBuyRightSetting setting)
|
||||
: _range(coord.x, coord.y, coord.x, coord.y)
|
||||
, _setting(setting)
|
||||
{
|
||||
}
|
||||
|
||||
void LandBuyRightsAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
visitor.Visit(_range);
|
||||
visitor.Visit("setting", _setting);
|
||||
}
|
||||
|
||||
uint16_t LandBuyRightsAction::GetActionFlags() const
|
||||
{
|
||||
return GameAction::GetActionFlags();
|
||||
}
|
||||
|
||||
void LandBuyRightsAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_range) << DS_TAG(_setting);
|
||||
}
|
||||
|
||||
Result LandBuyRightsAction::Query() const
|
||||
{
|
||||
return QueryExecute(false);
|
||||
}
|
||||
|
||||
Result LandBuyRightsAction::Execute() const
|
||||
{
|
||||
return QueryExecute(true);
|
||||
}
|
||||
|
||||
Result LandBuyRightsAction::QueryExecute(bool isExecuting) const
|
||||
{
|
||||
auto res = Result();
|
||||
|
||||
MapRange normRange = _range.Normalise();
|
||||
// Keep big coordinates within map boundaries
|
||||
auto mapSizeMaxXY = GetMapSizeMaxXY();
|
||||
auto aX = std::max<decltype(normRange.GetLeft())>(32, normRange.GetLeft());
|
||||
auto bX = std::min<decltype(normRange.GetRight())>(mapSizeMaxXY.x, normRange.GetRight());
|
||||
auto aY = std::max<decltype(normRange.GetTop())>(32, normRange.GetTop());
|
||||
auto bY = std::min<decltype(normRange.GetBottom())>(mapSizeMaxXY.y, normRange.GetBottom());
|
||||
|
||||
MapRange validRange = MapRange{ aX, aY, bX, bY };
|
||||
|
||||
CoordsXYZ centre{ (validRange.GetLeft() + validRange.GetRight()) / 2 + 16,
|
||||
(validRange.GetTop() + validRange.GetBottom()) / 2 + 16, 0 };
|
||||
centre.z = TileElementHeight(centre);
|
||||
|
||||
res.Position = centre;
|
||||
res.Expenditure = ExpenditureType::landPurchase;
|
||||
|
||||
// Game command modified to accept selection size
|
||||
for (auto y = validRange.GetTop(); y <= validRange.GetBottom(); y += kCoordsXYStep)
|
||||
{
|
||||
if (!LocationValid({ x, y }))
|
||||
continue;
|
||||
auto result = MapBuyLandRightsForTile({ x, y }, isExecuting);
|
||||
if (result.Error == GameActions::Status::Ok)
|
||||
for (auto x = validRange.GetLeft(); x <= validRange.GetRight(); x += kCoordsXYStep)
|
||||
{
|
||||
res.Cost += result.Cost;
|
||||
if (!LocationValid({ x, y }))
|
||||
continue;
|
||||
auto result = MapBuyLandRightsForTile({ x, y }, isExecuting);
|
||||
if (result.Error == Status::Ok)
|
||||
{
|
||||
res.Cost += result.Cost;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isExecuting)
|
||||
{
|
||||
MapCountRemainingLandRights();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
GameActions::Result LandBuyRightsAction::MapBuyLandRightsForTile(const CoordsXY& loc, bool isExecuting) const
|
||||
{
|
||||
if (_setting >= LandBuyRightSetting::Count)
|
||||
{
|
||||
LOG_ERROR("Invalid land buying setting %u", _setting);
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, kErrorTitles[0], STR_ERR_VALUE_OUT_OF_RANGE);
|
||||
if (isExecuting)
|
||||
{
|
||||
MapCountRemainingLandRights();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
SurfaceElement* surfaceElement = MapGetSurfaceElementAt(loc);
|
||||
if (surfaceElement == nullptr)
|
||||
Result LandBuyRightsAction::MapBuyLandRightsForTile(const CoordsXY& loc, bool isExecuting) const
|
||||
{
|
||||
LOG_ERROR("No surface at x = %d, y = %d", loc.x, loc.y);
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, kErrorTitles[EnumValue(_setting)], STR_ERR_SURFACE_ELEMENT_NOT_FOUND);
|
||||
}
|
||||
|
||||
auto res = GameActions::Result();
|
||||
switch (_setting)
|
||||
{
|
||||
case LandBuyRightSetting::BuyLand: // 0
|
||||
if ((surfaceElement->GetOwnership() & OWNERSHIP_OWNED) != 0)
|
||||
{ // If the land is already owned
|
||||
return res;
|
||||
}
|
||||
|
||||
if (gLegacyScene == LegacyScene::scenarioEditor || (surfaceElement->GetOwnership() & OWNERSHIP_AVAILABLE) == 0)
|
||||
{
|
||||
return GameActions::Result(
|
||||
GameActions::Status::NotOwned, kErrorTitles[EnumValue(_setting)], STR_LAND_NOT_FOR_SALE);
|
||||
}
|
||||
if (isExecuting)
|
||||
{
|
||||
surfaceElement->SetOwnership(OWNERSHIP_OWNED);
|
||||
Park::UpdateFencesAroundTile(loc);
|
||||
}
|
||||
res.Cost = getGameState().scenarioOptions.landPrice;
|
||||
return res;
|
||||
|
||||
case LandBuyRightSetting::BuyConstructionRights: // 2
|
||||
if ((surfaceElement->GetOwnership() & (OWNERSHIP_OWNED | OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED)) != 0)
|
||||
{ // If the land or construction rights are already owned
|
||||
return res;
|
||||
}
|
||||
|
||||
if (gLegacyScene == LegacyScene::scenarioEditor
|
||||
|| (surfaceElement->GetOwnership() & OWNERSHIP_CONSTRUCTION_RIGHTS_AVAILABLE) == 0)
|
||||
{
|
||||
return GameActions::Result(
|
||||
GameActions::Status::NotOwned, kErrorTitles[EnumValue(_setting)], STR_CONSTRUCTION_RIGHTS_NOT_FOR_SALE);
|
||||
}
|
||||
|
||||
if (isExecuting)
|
||||
{
|
||||
surfaceElement->SetOwnership(surfaceElement->GetOwnership() | OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED);
|
||||
uint16_t baseZ = surfaceElement->GetBaseZ();
|
||||
MapInvalidateTile({ loc, baseZ, baseZ + 16 });
|
||||
}
|
||||
res.Cost = getGameState().scenarioOptions.constructionRightsPrice;
|
||||
return res;
|
||||
|
||||
default:
|
||||
if (_setting >= LandBuyRightSetting::Count)
|
||||
{
|
||||
LOG_ERROR("Invalid land buying setting %u", _setting);
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, kErrorTitles[0], STR_ERR_VALUE_OUT_OF_RANGE);
|
||||
return Result(Status::InvalidParameters, kErrorTitles[0], STR_ERR_VALUE_OUT_OF_RANGE);
|
||||
}
|
||||
|
||||
SurfaceElement* surfaceElement = MapGetSurfaceElementAt(loc);
|
||||
if (surfaceElement == nullptr)
|
||||
{
|
||||
LOG_ERROR("No surface at x = %d, y = %d", loc.x, loc.y);
|
||||
return Result(Status::InvalidParameters, kErrorTitles[EnumValue(_setting)], STR_ERR_SURFACE_ELEMENT_NOT_FOUND);
|
||||
}
|
||||
|
||||
auto res = Result();
|
||||
switch (_setting)
|
||||
{
|
||||
case LandBuyRightSetting::BuyLand: // 0
|
||||
if ((surfaceElement->GetOwnership() & OWNERSHIP_OWNED) != 0)
|
||||
{ // If the land is already owned
|
||||
return res;
|
||||
}
|
||||
|
||||
if (gLegacyScene == LegacyScene::scenarioEditor || (surfaceElement->GetOwnership() & OWNERSHIP_AVAILABLE) == 0)
|
||||
{
|
||||
return Result(Status::NotOwned, kErrorTitles[EnumValue(_setting)], STR_LAND_NOT_FOR_SALE);
|
||||
}
|
||||
if (isExecuting)
|
||||
{
|
||||
surfaceElement->SetOwnership(OWNERSHIP_OWNED);
|
||||
Park::UpdateFencesAroundTile(loc);
|
||||
}
|
||||
res.Cost = getGameState().scenarioOptions.landPrice;
|
||||
return res;
|
||||
|
||||
case LandBuyRightSetting::BuyConstructionRights: // 2
|
||||
if ((surfaceElement->GetOwnership() & (OWNERSHIP_OWNED | OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED)) != 0)
|
||||
{ // If the land or construction rights are already owned
|
||||
return res;
|
||||
}
|
||||
|
||||
if (gLegacyScene == LegacyScene::scenarioEditor
|
||||
|| (surfaceElement->GetOwnership() & OWNERSHIP_CONSTRUCTION_RIGHTS_AVAILABLE) == 0)
|
||||
{
|
||||
return Result(Status::NotOwned, kErrorTitles[EnumValue(_setting)], STR_CONSTRUCTION_RIGHTS_NOT_FOR_SALE);
|
||||
}
|
||||
|
||||
if (isExecuting)
|
||||
{
|
||||
surfaceElement->SetOwnership(surfaceElement->GetOwnership() | OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED);
|
||||
uint16_t baseZ = surfaceElement->GetBaseZ();
|
||||
MapInvalidateTile({ loc, baseZ, baseZ + 16 });
|
||||
}
|
||||
res.Cost = getGameState().scenarioOptions.constructionRightsPrice;
|
||||
return res;
|
||||
|
||||
default:
|
||||
LOG_ERROR("Invalid land buying setting %u", _setting);
|
||||
return Result(Status::InvalidParameters, kErrorTitles[0], STR_ERR_VALUE_OUT_OF_RANGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -11,38 +11,41 @@
|
||||
|
||||
#include "GameAction.h"
|
||||
|
||||
enum class LandBuyRightSetting : uint8_t
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
BuyLand,
|
||||
BuyConstructionRights,
|
||||
Count
|
||||
};
|
||||
|
||||
class LandBuyRightsAction final : public GameActionBase<GameCommand::BuyLandRights>
|
||||
{
|
||||
private:
|
||||
MapRange _range;
|
||||
LandBuyRightSetting _setting{ LandBuyRightSetting::Count };
|
||||
|
||||
constexpr static StringId kErrorTitles[] = {
|
||||
STR_CANT_BUY_LAND,
|
||||
STR_CANT_BUY_CONSTRUCTION_RIGHTS_HERE,
|
||||
enum class LandBuyRightSetting : uint8_t
|
||||
{
|
||||
BuyLand,
|
||||
BuyConstructionRights,
|
||||
Count
|
||||
};
|
||||
|
||||
public:
|
||||
LandBuyRightsAction() = default;
|
||||
LandBuyRightsAction(const MapRange& range, LandBuyRightSetting setting);
|
||||
LandBuyRightsAction(const CoordsXY& coord, LandBuyRightSetting setting);
|
||||
class LandBuyRightsAction final : public GameActionBase<GameCommand::BuyLandRights>
|
||||
{
|
||||
private:
|
||||
MapRange _range;
|
||||
LandBuyRightSetting _setting{ LandBuyRightSetting::Count };
|
||||
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
constexpr static StringId kErrorTitles[] = {
|
||||
STR_CANT_BUY_LAND,
|
||||
STR_CANT_BUY_CONSTRUCTION_RIGHTS_HERE,
|
||||
};
|
||||
|
||||
uint16_t GetActionFlags() const override;
|
||||
public:
|
||||
LandBuyRightsAction() = default;
|
||||
LandBuyRightsAction(const MapRange& range, LandBuyRightSetting setting);
|
||||
LandBuyRightsAction(const CoordsXY& coord, LandBuyRightSetting setting);
|
||||
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
OpenRCT2::GameActions::Result Query() const override;
|
||||
OpenRCT2::GameActions::Result Execute() const override;
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
|
||||
private:
|
||||
OpenRCT2::GameActions::Result QueryExecute(bool isExecuting) const;
|
||||
OpenRCT2::GameActions::Result MapBuyLandRightsForTile(const CoordsXY& loc, bool isExecuting) const;
|
||||
};
|
||||
uint16_t GetActionFlags() const override;
|
||||
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
Result Query() const override;
|
||||
Result Execute() const override;
|
||||
|
||||
private:
|
||||
Result QueryExecute(bool isExecuting) const;
|
||||
Result MapBuyLandRightsForTile(const CoordsXY& loc, bool isExecuting) const;
|
||||
};
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -25,125 +25,125 @@
|
||||
#include "../world/tile_element/Slope.h"
|
||||
#include "../world/tile_element/SurfaceElement.h"
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
LandLowerAction::LandLowerAction(const CoordsXY& coords, MapRange range, uint8_t selectionType)
|
||||
: _coords(coords)
|
||||
, _range(range)
|
||||
, _selectionType(selectionType)
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
}
|
||||
|
||||
void LandLowerAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
visitor.Visit(_coords);
|
||||
visitor.Visit(_range);
|
||||
visitor.Visit("selectionType", _selectionType);
|
||||
}
|
||||
|
||||
uint16_t LandLowerAction::GetActionFlags() const
|
||||
{
|
||||
return GameAction::GetActionFlags();
|
||||
}
|
||||
|
||||
void LandLowerAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_coords) << DS_TAG(_range) << DS_TAG(_selectionType);
|
||||
}
|
||||
|
||||
GameActions::Result LandLowerAction::Query() const
|
||||
{
|
||||
return QueryExecute(false);
|
||||
}
|
||||
|
||||
GameActions::Result LandLowerAction::Execute() const
|
||||
{
|
||||
return QueryExecute(true);
|
||||
}
|
||||
|
||||
GameActions::Result LandLowerAction::QueryExecute(bool isExecuting) const
|
||||
{
|
||||
auto res = GameActions::Result();
|
||||
size_t tableRow = _selectionType;
|
||||
|
||||
// The selections between MAP_SELECT_TYPE_FULL and MAP_SELECT_TYPE_EDGE_0 are not included in the tables
|
||||
if (_selectionType >= MAP_SELECT_TYPE_EDGE_0 && _selectionType <= MAP_SELECT_TYPE_EDGE_3)
|
||||
tableRow -= MAP_SELECT_TYPE_EDGE_0 - MAP_SELECT_TYPE_FULL - 1;
|
||||
|
||||
auto validRange = ClampRangeWithinMap(_range);
|
||||
|
||||
res.Position = { _coords.x, _coords.y, TileElementHeight(_coords) };
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
|
||||
if (isExecuting)
|
||||
LandLowerAction::LandLowerAction(const CoordsXY& coords, MapRange range, uint8_t selectionType)
|
||||
: _coords(coords)
|
||||
, _range(range)
|
||||
, _selectionType(selectionType)
|
||||
{
|
||||
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::PlaceItem, { _coords.x, _coords.y, TileElementHeight(_coords) });
|
||||
}
|
||||
|
||||
uint8_t maxHeight = MapGetHighestLandHeight(validRange);
|
||||
bool withinOwnership = false;
|
||||
|
||||
for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += kCoordsXYStep)
|
||||
void LandLowerAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += kCoordsXYStep)
|
||||
{
|
||||
if (!LocationValid({ x, y }))
|
||||
continue;
|
||||
auto* surfaceElement = MapGetSurfaceElementAt(CoordsXY{ x, y });
|
||||
if (surfaceElement == nullptr)
|
||||
continue;
|
||||
visitor.Visit(_coords);
|
||||
visitor.Visit(_range);
|
||||
visitor.Visit("selectionType", _selectionType);
|
||||
}
|
||||
|
||||
if (gLegacyScene != LegacyScene::scenarioEditor && !getGameState().cheats.sandboxMode)
|
||||
uint16_t LandLowerAction::GetActionFlags() const
|
||||
{
|
||||
return GameAction::GetActionFlags();
|
||||
}
|
||||
|
||||
void LandLowerAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_coords) << DS_TAG(_range) << DS_TAG(_selectionType);
|
||||
}
|
||||
|
||||
Result LandLowerAction::Query() const
|
||||
{
|
||||
return QueryExecute(false);
|
||||
}
|
||||
|
||||
Result LandLowerAction::Execute() const
|
||||
{
|
||||
return QueryExecute(true);
|
||||
}
|
||||
|
||||
Result LandLowerAction::QueryExecute(bool isExecuting) const
|
||||
{
|
||||
auto res = Result();
|
||||
size_t tableRow = _selectionType;
|
||||
|
||||
// The selections between MAP_SELECT_TYPE_FULL and MAP_SELECT_TYPE_EDGE_0 are not included in the tables
|
||||
if (_selectionType >= MAP_SELECT_TYPE_EDGE_0 && _selectionType <= MAP_SELECT_TYPE_EDGE_3)
|
||||
tableRow -= MAP_SELECT_TYPE_EDGE_0 - MAP_SELECT_TYPE_FULL - 1;
|
||||
|
||||
auto validRange = ClampRangeWithinMap(_range);
|
||||
|
||||
res.Position = { _coords.x, _coords.y, TileElementHeight(_coords) };
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
|
||||
if (isExecuting)
|
||||
{
|
||||
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::PlaceItem, { _coords.x, _coords.y, TileElementHeight(_coords) });
|
||||
}
|
||||
|
||||
uint8_t maxHeight = MapGetHighestLandHeight(validRange);
|
||||
bool withinOwnership = false;
|
||||
|
||||
for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += kCoordsXYStep)
|
||||
{
|
||||
for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += kCoordsXYStep)
|
||||
{
|
||||
if (!MapIsLocationInPark(CoordsXY{ x, y }))
|
||||
{
|
||||
if (!LocationValid({ x, y }))
|
||||
continue;
|
||||
auto* surfaceElement = MapGetSurfaceElementAt(CoordsXY{ x, y });
|
||||
if (surfaceElement == nullptr)
|
||||
continue;
|
||||
|
||||
if (gLegacyScene != LegacyScene::scenarioEditor && !getGameState().cheats.sandboxMode)
|
||||
{
|
||||
if (!MapIsLocationInPark(CoordsXY{ x, y }))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
withinOwnership = true;
|
||||
|
||||
uint8_t height = surfaceElement->BaseHeight;
|
||||
if (surfaceElement->GetSlope() & kTileSlopeRaisedCornersMask)
|
||||
height += 2;
|
||||
if (surfaceElement->GetSlope() & kTileSlopeDiagonalFlag)
|
||||
height += 2;
|
||||
|
||||
if (height < maxHeight)
|
||||
continue;
|
||||
|
||||
height = surfaceElement->BaseHeight;
|
||||
uint8_t currentSlope = surfaceElement->GetSlope();
|
||||
uint8_t newSlope = LowerSurfaceCornerFlags(tableRow, currentSlope);
|
||||
if (newSlope & kTileSlopeRaiseOrLowerBaseHeight)
|
||||
height -= 2;
|
||||
|
||||
newSlope &= kTileSlopeMask;
|
||||
|
||||
auto landSetHeightAction = LandSetHeightAction({ x, y }, height, newSlope);
|
||||
landSetHeightAction.SetFlags(GetFlags());
|
||||
auto result = isExecuting ? ExecuteNested(&landSetHeightAction) : QueryNested(&landSetHeightAction);
|
||||
if (result.Error == Status::Ok)
|
||||
{
|
||||
res.Cost += result.Cost;
|
||||
}
|
||||
else
|
||||
{
|
||||
result.ErrorTitle = STR_CANT_LOWER_LAND_HERE;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
withinOwnership = true;
|
||||
|
||||
uint8_t height = surfaceElement->BaseHeight;
|
||||
if (surfaceElement->GetSlope() & kTileSlopeRaisedCornersMask)
|
||||
height += 2;
|
||||
if (surfaceElement->GetSlope() & kTileSlopeDiagonalFlag)
|
||||
height += 2;
|
||||
|
||||
if (height < maxHeight)
|
||||
continue;
|
||||
|
||||
height = surfaceElement->BaseHeight;
|
||||
uint8_t currentSlope = surfaceElement->GetSlope();
|
||||
uint8_t newSlope = LowerSurfaceCornerFlags(tableRow, currentSlope);
|
||||
if (newSlope & kTileSlopeRaiseOrLowerBaseHeight)
|
||||
height -= 2;
|
||||
|
||||
newSlope &= kTileSlopeMask;
|
||||
|
||||
auto landSetHeightAction = LandSetHeightAction({ x, y }, height, newSlope);
|
||||
landSetHeightAction.SetFlags(GetFlags());
|
||||
auto result = isExecuting ? GameActions::ExecuteNested(&landSetHeightAction)
|
||||
: GameActions::QueryNested(&landSetHeightAction);
|
||||
if (result.Error == GameActions::Status::Ok)
|
||||
{
|
||||
res.Cost += result.Cost;
|
||||
}
|
||||
else
|
||||
{
|
||||
result.ErrorTitle = STR_CANT_LOWER_LAND_HERE;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
if (!withinOwnership)
|
||||
{
|
||||
return Result(Status::Disallowed, STR_CANT_LOWER_LAND_HERE, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
}
|
||||
|
||||
// Force ride construction to recheck area
|
||||
_currentTrackSelectionFlags.set(TrackSelectionFlag::recheck);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
if (!withinOwnership)
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::Disallowed, STR_CANT_LOWER_LAND_HERE, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
}
|
||||
|
||||
// Force ride construction to recheck area
|
||||
_currentTrackSelectionFlags.set(TrackSelectionFlag::recheck);
|
||||
|
||||
return res;
|
||||
}
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -11,25 +11,28 @@
|
||||
|
||||
#include "GameAction.h"
|
||||
|
||||
class LandLowerAction final : public GameActionBase<GameCommand::LowerLand>
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
private:
|
||||
CoordsXY _coords;
|
||||
MapRange _range;
|
||||
uint8_t _selectionType{};
|
||||
class LandLowerAction final : public GameActionBase<GameCommand::LowerLand>
|
||||
{
|
||||
private:
|
||||
CoordsXY _coords;
|
||||
MapRange _range;
|
||||
uint8_t _selectionType{};
|
||||
|
||||
public:
|
||||
LandLowerAction() = default;
|
||||
LandLowerAction(const CoordsXY& coords, MapRange range, uint8_t selectionType);
|
||||
public:
|
||||
LandLowerAction() = default;
|
||||
LandLowerAction(const CoordsXY& coords, MapRange range, uint8_t selectionType);
|
||||
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
|
||||
uint16_t GetActionFlags() const override;
|
||||
uint16_t GetActionFlags() const override;
|
||||
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
OpenRCT2::GameActions::Result Query() const override;
|
||||
OpenRCT2::GameActions::Result Execute() const override;
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
Result Query() const override;
|
||||
Result Execute() const override;
|
||||
|
||||
private:
|
||||
OpenRCT2::GameActions::Result QueryExecute(bool isExecuting) const;
|
||||
};
|
||||
private:
|
||||
Result QueryExecute(bool isExecuting) const;
|
||||
};
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -26,128 +26,128 @@
|
||||
#include "../world/tile_element/Slope.h"
|
||||
#include "../world/tile_element/SurfaceElement.h"
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
LandRaiseAction::LandRaiseAction(const CoordsXY& coords, MapRange range, uint8_t selectionType)
|
||||
: _coords(coords)
|
||||
, _range(range)
|
||||
, _selectionType(selectionType)
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
}
|
||||
|
||||
void LandRaiseAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
visitor.Visit(_coords);
|
||||
visitor.Visit(_range);
|
||||
visitor.Visit("selectionType", _selectionType);
|
||||
}
|
||||
|
||||
uint16_t LandRaiseAction::GetActionFlags() const
|
||||
{
|
||||
return GameAction::GetActionFlags();
|
||||
}
|
||||
|
||||
void LandRaiseAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_coords) << DS_TAG(_range) << DS_TAG(_selectionType);
|
||||
}
|
||||
|
||||
GameActions::Result LandRaiseAction::Query() const
|
||||
{
|
||||
return QueryExecute(false);
|
||||
}
|
||||
|
||||
GameActions::Result LandRaiseAction::Execute() const
|
||||
{
|
||||
return QueryExecute(true);
|
||||
}
|
||||
|
||||
GameActions::Result LandRaiseAction::QueryExecute(bool isExecuting) const
|
||||
{
|
||||
auto res = GameActions::Result();
|
||||
size_t tableRow = _selectionType;
|
||||
|
||||
// The selections between MAP_SELECT_TYPE_FULL and MAP_SELECT_TYPE_EDGE_0 are not included in the tables
|
||||
if (_selectionType >= MAP_SELECT_TYPE_EDGE_0 && _selectionType <= MAP_SELECT_TYPE_EDGE_3)
|
||||
tableRow -= MAP_SELECT_TYPE_EDGE_0 - MAP_SELECT_TYPE_FULL - 1;
|
||||
|
||||
auto validRange = ClampRangeWithinMap(_range);
|
||||
|
||||
res.Position = { _coords.x, _coords.y, TileElementHeight(_coords) };
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
|
||||
if (isExecuting)
|
||||
LandRaiseAction::LandRaiseAction(const CoordsXY& coords, MapRange range, uint8_t selectionType)
|
||||
: _coords(coords)
|
||||
, _range(range)
|
||||
, _selectionType(selectionType)
|
||||
{
|
||||
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::PlaceItem, { _coords.x, _coords.y, TileElementHeight(_coords) });
|
||||
}
|
||||
|
||||
uint8_t minHeight = MapGetLowestLandHeight(validRange);
|
||||
bool withinOwnership = false;
|
||||
|
||||
for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += kCoordsXYStep)
|
||||
void LandRaiseAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += kCoordsXYStep)
|
||||
visitor.Visit(_coords);
|
||||
visitor.Visit(_range);
|
||||
visitor.Visit("selectionType", _selectionType);
|
||||
}
|
||||
|
||||
uint16_t LandRaiseAction::GetActionFlags() const
|
||||
{
|
||||
return GameAction::GetActionFlags();
|
||||
}
|
||||
|
||||
void LandRaiseAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_coords) << DS_TAG(_range) << DS_TAG(_selectionType);
|
||||
}
|
||||
|
||||
Result LandRaiseAction::Query() const
|
||||
{
|
||||
return QueryExecute(false);
|
||||
}
|
||||
|
||||
Result LandRaiseAction::Execute() const
|
||||
{
|
||||
return QueryExecute(true);
|
||||
}
|
||||
|
||||
Result LandRaiseAction::QueryExecute(bool isExecuting) const
|
||||
{
|
||||
auto res = Result();
|
||||
size_t tableRow = _selectionType;
|
||||
|
||||
// The selections between MAP_SELECT_TYPE_FULL and MAP_SELECT_TYPE_EDGE_0 are not included in the tables
|
||||
if (_selectionType >= MAP_SELECT_TYPE_EDGE_0 && _selectionType <= MAP_SELECT_TYPE_EDGE_3)
|
||||
tableRow -= MAP_SELECT_TYPE_EDGE_0 - MAP_SELECT_TYPE_FULL - 1;
|
||||
|
||||
auto validRange = ClampRangeWithinMap(_range);
|
||||
|
||||
res.Position = { _coords.x, _coords.y, TileElementHeight(_coords) };
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
|
||||
if (isExecuting)
|
||||
{
|
||||
if (!LocationValid({ x, y }))
|
||||
continue;
|
||||
auto* surfaceElement = MapGetSurfaceElementAt(CoordsXY{ x, y });
|
||||
if (surfaceElement == nullptr)
|
||||
continue;
|
||||
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::PlaceItem, { _coords.x, _coords.y, TileElementHeight(_coords) });
|
||||
}
|
||||
|
||||
if (gLegacyScene != LegacyScene::scenarioEditor && !getGameState().cheats.sandboxMode)
|
||||
uint8_t minHeight = MapGetLowestLandHeight(validRange);
|
||||
bool withinOwnership = false;
|
||||
|
||||
for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += kCoordsXYStep)
|
||||
{
|
||||
for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += kCoordsXYStep)
|
||||
{
|
||||
if (!MapIsLocationInPark(CoordsXY{ x, y }))
|
||||
{
|
||||
if (!LocationValid({ x, y }))
|
||||
continue;
|
||||
auto* surfaceElement = MapGetSurfaceElementAt(CoordsXY{ x, y });
|
||||
if (surfaceElement == nullptr)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
withinOwnership = true;
|
||||
|
||||
uint8_t height = surfaceElement->BaseHeight;
|
||||
|
||||
if (height > minHeight)
|
||||
continue;
|
||||
|
||||
uint8_t currentSlope = surfaceElement->GetSlope();
|
||||
uint8_t newSlope = RaiseSurfaceCornerFlags(tableRow, currentSlope);
|
||||
if (newSlope & kTileSlopeRaiseOrLowerBaseHeight)
|
||||
{
|
||||
if (height + 2 > UINT8_MAX)
|
||||
if (gLegacyScene != LegacyScene::scenarioEditor && !getGameState().cheats.sandboxMode)
|
||||
{
|
||||
height = UINT8_MAX;
|
||||
if (!MapIsLocationInPark(CoordsXY{ x, y }))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
withinOwnership = true;
|
||||
|
||||
uint8_t height = surfaceElement->BaseHeight;
|
||||
|
||||
if (height > minHeight)
|
||||
continue;
|
||||
|
||||
uint8_t currentSlope = surfaceElement->GetSlope();
|
||||
uint8_t newSlope = RaiseSurfaceCornerFlags(tableRow, currentSlope);
|
||||
if (newSlope & kTileSlopeRaiseOrLowerBaseHeight)
|
||||
{
|
||||
if (height + 2 > UINT8_MAX)
|
||||
{
|
||||
height = UINT8_MAX;
|
||||
}
|
||||
else
|
||||
{
|
||||
height += 2;
|
||||
}
|
||||
}
|
||||
newSlope &= kTileSlopeMask;
|
||||
|
||||
auto landSetHeightAction = LandSetHeightAction({ x, y }, height, newSlope);
|
||||
landSetHeightAction.SetFlags(GetFlags());
|
||||
auto result = isExecuting ? ExecuteNested(&landSetHeightAction) : QueryNested(&landSetHeightAction);
|
||||
if (result.Error == Status::Ok)
|
||||
{
|
||||
res.Cost += result.Cost;
|
||||
}
|
||||
else
|
||||
{
|
||||
height += 2;
|
||||
result.ErrorTitle = STR_CANT_RAISE_LAND_HERE;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
newSlope &= kTileSlopeMask;
|
||||
|
||||
auto landSetHeightAction = LandSetHeightAction({ x, y }, height, newSlope);
|
||||
landSetHeightAction.SetFlags(GetFlags());
|
||||
auto result = isExecuting ? GameActions::ExecuteNested(&landSetHeightAction)
|
||||
: GameActions::QueryNested(&landSetHeightAction);
|
||||
if (result.Error == GameActions::Status::Ok)
|
||||
{
|
||||
res.Cost += result.Cost;
|
||||
}
|
||||
else
|
||||
{
|
||||
result.ErrorTitle = STR_CANT_RAISE_LAND_HERE;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
if (!withinOwnership)
|
||||
{
|
||||
return Result(Status::Disallowed, STR_CANT_RAISE_LAND_HERE, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
}
|
||||
|
||||
// Force ride construction to recheck area
|
||||
_currentTrackSelectionFlags.set(TrackSelectionFlag::recheck);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
if (!withinOwnership)
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::Disallowed, STR_CANT_RAISE_LAND_HERE, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
}
|
||||
|
||||
// Force ride construction to recheck area
|
||||
_currentTrackSelectionFlags.set(TrackSelectionFlag::recheck);
|
||||
|
||||
return res;
|
||||
}
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -11,25 +11,28 @@
|
||||
|
||||
#include "GameAction.h"
|
||||
|
||||
class LandRaiseAction final : public GameActionBase<GameCommand::RaiseLand>
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
private:
|
||||
CoordsXY _coords;
|
||||
MapRange _range;
|
||||
uint8_t _selectionType{};
|
||||
class LandRaiseAction final : public GameActionBase<GameCommand::RaiseLand>
|
||||
{
|
||||
private:
|
||||
CoordsXY _coords;
|
||||
MapRange _range;
|
||||
uint8_t _selectionType{};
|
||||
|
||||
public:
|
||||
LandRaiseAction() = default;
|
||||
LandRaiseAction(const CoordsXY& coords, MapRange range, uint8_t selectionType);
|
||||
public:
|
||||
LandRaiseAction() = default;
|
||||
LandRaiseAction(const CoordsXY& coords, MapRange range, uint8_t selectionType);
|
||||
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
|
||||
uint16_t GetActionFlags() const override;
|
||||
uint16_t GetActionFlags() const override;
|
||||
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
OpenRCT2::GameActions::Result Query() const override;
|
||||
OpenRCT2::GameActions::Result Execute() const override;
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
Result Query() const override;
|
||||
Result Execute() const override;
|
||||
|
||||
private:
|
||||
OpenRCT2::GameActions::Result QueryExecute(bool isExecuting) const;
|
||||
};
|
||||
private:
|
||||
Result QueryExecute(bool isExecuting) const;
|
||||
};
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -29,284 +29,108 @@
|
||||
#include "../world/tile_element/SurfaceElement.h"
|
||||
#include "../world/tile_element/TrackElement.h"
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
LandSetHeightAction::LandSetHeightAction(const CoordsXY& coords, uint8_t height, uint8_t style)
|
||||
: _coords(coords)
|
||||
, _height(height)
|
||||
, _style(style)
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
}
|
||||
|
||||
void LandSetHeightAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
visitor.Visit(_coords);
|
||||
visitor.Visit("height", _height);
|
||||
visitor.Visit("style", _style);
|
||||
}
|
||||
|
||||
uint16_t LandSetHeightAction::GetActionFlags() const
|
||||
{
|
||||
return GameAction::GetActionFlags() | GameActions::Flags::EditorOnly;
|
||||
}
|
||||
|
||||
void LandSetHeightAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_coords) << DS_TAG(_height) << DS_TAG(_style);
|
||||
}
|
||||
|
||||
GameActions::Result LandSetHeightAction::Query() const
|
||||
{
|
||||
auto& gameState = getGameState();
|
||||
if (gameState.park.flags & PARK_FLAGS_FORBID_LANDSCAPE_CHANGES)
|
||||
LandSetHeightAction::LandSetHeightAction(const CoordsXY& coords, uint8_t height, uint8_t style)
|
||||
: _coords(coords)
|
||||
, _height(height)
|
||||
, _style(style)
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::Disallowed, STR_FORBIDDEN_BY_THE_LOCAL_AUTHORITY, kStringIdNone);
|
||||
}
|
||||
|
||||
StringId errorMessage = CheckParameters();
|
||||
if (errorMessage != kStringIdNone)
|
||||
void LandSetHeightAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::Disallowed, kStringIdNone, errorMessage);
|
||||
visitor.Visit(_coords);
|
||||
visitor.Visit("height", _height);
|
||||
visitor.Visit("style", _style);
|
||||
}
|
||||
|
||||
if (gLegacyScene != LegacyScene::scenarioEditor && !gameState.cheats.sandboxMode)
|
||||
uint16_t LandSetHeightAction::GetActionFlags() const
|
||||
{
|
||||
if (!MapIsLocationInPark(_coords))
|
||||
return GameAction::GetActionFlags() | Flags::EditorOnly;
|
||||
}
|
||||
|
||||
void LandSetHeightAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_coords) << DS_TAG(_height) << DS_TAG(_style);
|
||||
}
|
||||
|
||||
Result LandSetHeightAction::Query() const
|
||||
{
|
||||
auto& gameState = getGameState();
|
||||
if (gameState.park.flags & PARK_FLAGS_FORBID_LANDSCAPE_CHANGES)
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::Disallowed, STR_LAND_NOT_OWNED_BY_PARK, kStringIdNone);
|
||||
return Result(Status::Disallowed, STR_FORBIDDEN_BY_THE_LOCAL_AUTHORITY, kStringIdNone);
|
||||
}
|
||||
}
|
||||
|
||||
money64 sceneryRemovalCost = 0;
|
||||
if (!gameState.cheats.disableClearanceChecks)
|
||||
{
|
||||
if (gameState.park.flags & PARK_FLAGS_FORBID_TREE_REMOVAL)
|
||||
{
|
||||
// Check for obstructing large trees
|
||||
TileElement* tileElement = CheckTreeObstructions();
|
||||
if (tileElement != nullptr)
|
||||
{
|
||||
auto res = GameActions::Result(GameActions::Status::Disallowed, kStringIdNone, kStringIdNone);
|
||||
MapGetObstructionErrorText(tileElement, res);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
sceneryRemovalCost = GetSmallSceneryRemovalCost();
|
||||
}
|
||||
|
||||
// Check for ride support limits
|
||||
if (!gameState.cheats.disableSupportLimits)
|
||||
{
|
||||
errorMessage = CheckRideSupports();
|
||||
StringId errorMessage = CheckParameters();
|
||||
if (errorMessage != kStringIdNone)
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::Disallowed, kStringIdNone, errorMessage);
|
||||
return Result(Status::Disallowed, kStringIdNone, errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
auto* surfaceElement = MapGetSurfaceElementAt(_coords);
|
||||
if (surfaceElement == nullptr)
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_ERR_INVALID_PARAMETER, STR_ERR_SURFACE_ELEMENT_NOT_FOUND);
|
||||
|
||||
// We need to check if there is _currently_ a level crossing on the tile.
|
||||
// For that, we need the old height, so we can't use the _height variable.
|
||||
auto oldCoords = CoordsXYZ{ _coords, surfaceElement->GetBaseZ() };
|
||||
auto* pathElement = MapGetFootpathElement(oldCoords);
|
||||
if (pathElement != nullptr && pathElement->AsPath()->IsLevelCrossing(oldCoords))
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::Disallowed, STR_REMOVE_LEVEL_CROSSING_FIRST, kStringIdNone);
|
||||
}
|
||||
|
||||
TileElement* tileElement = CheckFloatingStructures(reinterpret_cast<TileElement*>(surfaceElement), _height);
|
||||
if (tileElement != nullptr)
|
||||
{
|
||||
auto res = GameActions::Result(GameActions::Status::Disallowed, kStringIdNone, kStringIdNone);
|
||||
MapGetObstructionErrorText(tileElement, res);
|
||||
return res;
|
||||
}
|
||||
|
||||
if (!gameState.cheats.disableClearanceChecks)
|
||||
{
|
||||
uint8_t zCorner = _height;
|
||||
if (_style & kTileSlopeRaisedCornersMask)
|
||||
if (gLegacyScene != LegacyScene::scenarioEditor && !gameState.cheats.sandboxMode)
|
||||
{
|
||||
zCorner += 2;
|
||||
if (_style & kTileSlopeDiagonalFlag)
|
||||
if (!MapIsLocationInPark(_coords))
|
||||
{
|
||||
zCorner += 2;
|
||||
return Result(Status::Disallowed, STR_LAND_NOT_OWNED_BY_PARK, kStringIdNone);
|
||||
}
|
||||
}
|
||||
|
||||
auto clearResult = MapCanConstructWithClearAt(
|
||||
{ _coords, _height * kCoordsZStep, zCorner * kCoordsZStep }, &MapSetLandHeightClearFunc, { 0b1111, 0 }, 0,
|
||||
CreateCrossingMode::none);
|
||||
if (clearResult.Error != GameActions::Status::Ok)
|
||||
money64 sceneryRemovalCost = 0;
|
||||
if (!gameState.cheats.disableClearanceChecks)
|
||||
{
|
||||
clearResult.Error = GameActions::Status::Disallowed;
|
||||
return clearResult;
|
||||
}
|
||||
}
|
||||
auto res = GameActions::Result();
|
||||
res.Cost = sceneryRemovalCost + GetSurfaceHeightChangeCost(surfaceElement);
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
return res;
|
||||
}
|
||||
|
||||
GameActions::Result LandSetHeightAction::Execute() const
|
||||
{
|
||||
money64 cost = 0.00_GBP;
|
||||
auto surfaceHeight = TileElementHeight(_coords);
|
||||
FootpathRemoveLitter({ _coords, surfaceHeight });
|
||||
|
||||
if (!getGameState().cheats.disableClearanceChecks)
|
||||
{
|
||||
WallRemoveAt({ _coords, _height * 8 - 16, _height * 8 + 32 });
|
||||
cost += GetSmallSceneryRemovalCost();
|
||||
SmallSceneryRemoval();
|
||||
}
|
||||
|
||||
auto* surfaceElement = MapGetSurfaceElementAt(_coords);
|
||||
if (surfaceElement == nullptr)
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_ERR_INVALID_PARAMETER, STR_ERR_SURFACE_ELEMENT_NOT_FOUND);
|
||||
|
||||
cost += GetSurfaceHeightChangeCost(surfaceElement);
|
||||
SetSurfaceHeight(reinterpret_cast<TileElement*>(surfaceElement));
|
||||
|
||||
auto res = GameActions::Result();
|
||||
res.Position = { _coords.x + 16, _coords.y + 16, surfaceHeight };
|
||||
res.Cost = cost;
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
return res;
|
||||
}
|
||||
|
||||
StringId LandSetHeightAction::CheckParameters() const
|
||||
{
|
||||
if (!LocationValid(_coords) || MapIsEdge(_coords))
|
||||
{
|
||||
return STR_OFF_EDGE_OF_MAP;
|
||||
}
|
||||
|
||||
if (_height < kMinimumLandHeight)
|
||||
{
|
||||
return STR_TOO_LOW;
|
||||
}
|
||||
|
||||
// Divide by 2 and subtract 7 to get the in-game units.
|
||||
if (_height > kMaximumLandHeight)
|
||||
{
|
||||
return STR_TOO_HIGH;
|
||||
}
|
||||
|
||||
if (_height > kMaximumLandHeight - 2 && (_style & kTileSlopeMask) != 0)
|
||||
{
|
||||
return STR_TOO_HIGH;
|
||||
}
|
||||
|
||||
if (_height == kMaximumLandHeight - 2 && (_style & kTileSlopeDiagonalFlag))
|
||||
{
|
||||
return STR_TOO_HIGH;
|
||||
}
|
||||
|
||||
return kStringIdNone;
|
||||
}
|
||||
|
||||
TileElement* LandSetHeightAction::CheckTreeObstructions() const
|
||||
{
|
||||
for (auto* sceneryElement : TileElementsView<SmallSceneryElement>(_coords))
|
||||
{
|
||||
if (_height > sceneryElement->ClearanceHeight)
|
||||
continue;
|
||||
if (_height + 4 < sceneryElement->BaseHeight)
|
||||
continue;
|
||||
|
||||
auto* sceneryEntry = sceneryElement->GetEntry();
|
||||
if (!sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_IS_TREE))
|
||||
continue;
|
||||
|
||||
return sceneryElement->as<TileElement>();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
money64 LandSetHeightAction::GetSmallSceneryRemovalCost() const
|
||||
{
|
||||
money64 cost{ 0 };
|
||||
|
||||
for (auto* sceneryElement : TileElementsView<SmallSceneryElement>(_coords))
|
||||
{
|
||||
if (_height > sceneryElement->ClearanceHeight)
|
||||
continue;
|
||||
if (_height + 4 < sceneryElement->BaseHeight)
|
||||
continue;
|
||||
|
||||
auto* sceneryEntry = sceneryElement->GetEntry();
|
||||
if (sceneryEntry == nullptr)
|
||||
continue;
|
||||
|
||||
cost += sceneryEntry->removal_price;
|
||||
}
|
||||
|
||||
return cost;
|
||||
}
|
||||
|
||||
void LandSetHeightAction::SmallSceneryRemoval() const
|
||||
{
|
||||
TileElement* tileElement = MapGetFirstElementAt(_coords);
|
||||
do
|
||||
{
|
||||
if (tileElement == nullptr)
|
||||
break;
|
||||
if (tileElement->GetType() != TileElementType::SmallScenery)
|
||||
continue;
|
||||
if (_height > tileElement->ClearanceHeight)
|
||||
continue;
|
||||
if (_height + 4 < tileElement->BaseHeight)
|
||||
continue;
|
||||
TileElementRemove(tileElement--);
|
||||
} while (!(tileElement++)->IsLastForTile());
|
||||
}
|
||||
|
||||
StringId LandSetHeightAction::CheckRideSupports() const
|
||||
{
|
||||
for (auto* trackElement : TileElementsView<TrackElement>(_coords))
|
||||
{
|
||||
RideId rideIndex = trackElement->GetRideIndex();
|
||||
|
||||
auto ride = GetRide(rideIndex);
|
||||
if (ride == nullptr)
|
||||
continue;
|
||||
|
||||
const auto* rideEntry = ride->getRideEntry();
|
||||
if (rideEntry == nullptr)
|
||||
continue;
|
||||
|
||||
int32_t maxHeight = rideEntry->max_height;
|
||||
if (maxHeight == 0)
|
||||
{
|
||||
maxHeight = ride->getRideTypeDescriptor().Heights.MaxHeight;
|
||||
if (gameState.park.flags & PARK_FLAGS_FORBID_TREE_REMOVAL)
|
||||
{
|
||||
// Check for obstructing large trees
|
||||
TileElement* tileElement = CheckTreeObstructions();
|
||||
if (tileElement != nullptr)
|
||||
{
|
||||
auto res = Result(Status::Disallowed, kStringIdNone, kStringIdNone);
|
||||
MapGetObstructionErrorText(tileElement, res);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
sceneryRemovalCost = GetSmallSceneryRemovalCost();
|
||||
}
|
||||
|
||||
int32_t zDelta = trackElement->ClearanceHeight - _height;
|
||||
if (zDelta >= 0 && zDelta / 2 > maxHeight)
|
||||
// Check for ride support limits
|
||||
if (!gameState.cheats.disableSupportLimits)
|
||||
{
|
||||
return STR_SUPPORTS_CANT_BE_EXTENDED;
|
||||
errorMessage = CheckRideSupports();
|
||||
if (errorMessage != kStringIdNone)
|
||||
{
|
||||
return Result(Status::Disallowed, kStringIdNone, errorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
return kStringIdNone;
|
||||
}
|
||||
|
||||
TileElement* LandSetHeightAction::CheckFloatingStructures(TileElement* surfaceElement, uint8_t zCorner) const
|
||||
{
|
||||
if (surfaceElement->AsSurface()->HasTrackThatNeedsWater())
|
||||
{
|
||||
uint32_t waterHeight = surfaceElement->AsSurface()->GetWaterHeight();
|
||||
if (waterHeight != 0)
|
||||
auto* surfaceElement = MapGetSurfaceElementAt(_coords);
|
||||
if (surfaceElement == nullptr)
|
||||
return Result(Status::InvalidParameters, STR_ERR_INVALID_PARAMETER, STR_ERR_SURFACE_ELEMENT_NOT_FOUND);
|
||||
|
||||
// We need to check if there is _currently_ a level crossing on the tile.
|
||||
// For that, we need the old height, so we can't use the _height variable.
|
||||
auto oldCoords = CoordsXYZ{ _coords, surfaceElement->GetBaseZ() };
|
||||
auto* pathElement = MapGetFootpathElement(oldCoords);
|
||||
if (pathElement != nullptr && pathElement->AsPath()->IsLevelCrossing(oldCoords))
|
||||
{
|
||||
if (_style & kTileSlopeMask)
|
||||
return Result(Status::Disallowed, STR_REMOVE_LEVEL_CROSSING_FIRST, kStringIdNone);
|
||||
}
|
||||
|
||||
TileElement* tileElement = CheckFloatingStructures(reinterpret_cast<TileElement*>(surfaceElement), _height);
|
||||
if (tileElement != nullptr)
|
||||
{
|
||||
auto res = Result(Status::Disallowed, kStringIdNone, kStringIdNone);
|
||||
MapGetObstructionErrorText(tileElement, res);
|
||||
return res;
|
||||
}
|
||||
|
||||
if (!gameState.cheats.disableClearanceChecks)
|
||||
{
|
||||
uint8_t zCorner = _height;
|
||||
if (_style & kTileSlopeRaisedCornersMask)
|
||||
{
|
||||
zCorner += 2;
|
||||
if (_style & kTileSlopeDiagonalFlag)
|
||||
@@ -314,50 +138,225 @@ TileElement* LandSetHeightAction::CheckFloatingStructures(TileElement* surfaceEl
|
||||
zCorner += 2;
|
||||
}
|
||||
}
|
||||
if (zCorner > (waterHeight / kCoordsZStep) - 2)
|
||||
|
||||
auto clearResult = MapCanConstructWithClearAt(
|
||||
{ _coords, _height * kCoordsZStep, zCorner * kCoordsZStep }, &MapSetLandHeightClearFunc, { 0b1111, 0 }, 0,
|
||||
CreateCrossingMode::none);
|
||||
if (clearResult.Error != Status::Ok)
|
||||
{
|
||||
return ++surfaceElement;
|
||||
clearResult.Error = Status::Disallowed;
|
||||
return clearResult;
|
||||
}
|
||||
}
|
||||
auto res = Result();
|
||||
res.Cost = sceneryRemovalCost + GetSurfaceHeightChangeCost(surfaceElement);
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
return res;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
money64 LandSetHeightAction::GetSurfaceHeightChangeCost(SurfaceElement* surfaceElement) const
|
||||
{
|
||||
money64 cost{ 0 };
|
||||
for (Direction i : kAllDirections)
|
||||
Result LandSetHeightAction::Execute() const
|
||||
{
|
||||
int32_t cornerHeight = TileElementGetCornerHeight(surfaceElement, i);
|
||||
cornerHeight -= MapGetCornerHeight(_height, _style & kTileSlopeMask, i);
|
||||
cost += 2.50_GBP * abs(cornerHeight);
|
||||
}
|
||||
return cost;
|
||||
}
|
||||
money64 cost = 0.00_GBP;
|
||||
auto surfaceHeight = TileElementHeight(_coords);
|
||||
FootpathRemoveLitter({ _coords, surfaceHeight });
|
||||
|
||||
void LandSetHeightAction::SetSurfaceHeight(TileElement* surfaceElement) const
|
||||
{
|
||||
surfaceElement->BaseHeight = _height;
|
||||
surfaceElement->ClearanceHeight = _height;
|
||||
surfaceElement->AsSurface()->SetSlope(_style);
|
||||
int32_t waterHeight = surfaceElement->AsSurface()->GetWaterHeight() / kCoordsZStep;
|
||||
if (waterHeight != 0 && waterHeight <= _height)
|
||||
if (!getGameState().cheats.disableClearanceChecks)
|
||||
{
|
||||
WallRemoveAt({ _coords, _height * 8 - 16, _height * 8 + 32 });
|
||||
cost += GetSmallSceneryRemovalCost();
|
||||
SmallSceneryRemoval();
|
||||
}
|
||||
|
||||
auto* surfaceElement = MapGetSurfaceElementAt(_coords);
|
||||
if (surfaceElement == nullptr)
|
||||
return Result(Status::InvalidParameters, STR_ERR_INVALID_PARAMETER, STR_ERR_SURFACE_ELEMENT_NOT_FOUND);
|
||||
|
||||
cost += GetSurfaceHeightChangeCost(surfaceElement);
|
||||
SetSurfaceHeight(reinterpret_cast<TileElement*>(surfaceElement));
|
||||
|
||||
auto res = Result();
|
||||
res.Position = { _coords.x + 16, _coords.y + 16, surfaceHeight };
|
||||
res.Cost = cost;
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
return res;
|
||||
}
|
||||
|
||||
StringId LandSetHeightAction::CheckParameters() const
|
||||
{
|
||||
surfaceElement->AsSurface()->SetWaterHeight(0);
|
||||
if (!LocationValid(_coords) || MapIsEdge(_coords))
|
||||
{
|
||||
return STR_OFF_EDGE_OF_MAP;
|
||||
}
|
||||
|
||||
if (_height < kMinimumLandHeight)
|
||||
{
|
||||
return STR_TOO_LOW;
|
||||
}
|
||||
|
||||
// Divide by 2 and subtract 7 to get the in-game units.
|
||||
if (_height > kMaximumLandHeight)
|
||||
{
|
||||
return STR_TOO_HIGH;
|
||||
}
|
||||
|
||||
if (_height > kMaximumLandHeight - 2 && (_style & kTileSlopeMask) != 0)
|
||||
{
|
||||
return STR_TOO_HIGH;
|
||||
}
|
||||
|
||||
if (_height == kMaximumLandHeight - 2 && (_style & kTileSlopeDiagonalFlag))
|
||||
{
|
||||
return STR_TOO_HIGH;
|
||||
}
|
||||
|
||||
return kStringIdNone;
|
||||
}
|
||||
|
||||
MapInvalidateTileFull(_coords);
|
||||
}
|
||||
TileElement* LandSetHeightAction::CheckTreeObstructions() const
|
||||
{
|
||||
for (auto* sceneryElement : TileElementsView<SmallSceneryElement>(_coords))
|
||||
{
|
||||
if (_height > sceneryElement->ClearanceHeight)
|
||||
continue;
|
||||
if (_height + 4 < sceneryElement->BaseHeight)
|
||||
continue;
|
||||
|
||||
int32_t LandSetHeightAction::MapSetLandHeightClearFunc(
|
||||
TileElement** tile_element, [[maybe_unused]] const CoordsXY& coords, [[maybe_unused]] uint8_t flags,
|
||||
[[maybe_unused]] money64* price)
|
||||
{
|
||||
if ((*tile_element)->GetType() == TileElementType::Surface)
|
||||
return 0;
|
||||
auto* sceneryEntry = sceneryElement->GetEntry();
|
||||
if (!sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_IS_TREE))
|
||||
continue;
|
||||
|
||||
if ((*tile_element)->GetType() == TileElementType::SmallScenery)
|
||||
return 0;
|
||||
return sceneryElement->as<TileElement>();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
money64 LandSetHeightAction::GetSmallSceneryRemovalCost() const
|
||||
{
|
||||
money64 cost{ 0 };
|
||||
|
||||
for (auto* sceneryElement : TileElementsView<SmallSceneryElement>(_coords))
|
||||
{
|
||||
if (_height > sceneryElement->ClearanceHeight)
|
||||
continue;
|
||||
if (_height + 4 < sceneryElement->BaseHeight)
|
||||
continue;
|
||||
|
||||
auto* sceneryEntry = sceneryElement->GetEntry();
|
||||
if (sceneryEntry == nullptr)
|
||||
continue;
|
||||
|
||||
cost += sceneryEntry->removal_price;
|
||||
}
|
||||
|
||||
return cost;
|
||||
}
|
||||
|
||||
void LandSetHeightAction::SmallSceneryRemoval() const
|
||||
{
|
||||
TileElement* tileElement = MapGetFirstElementAt(_coords);
|
||||
do
|
||||
{
|
||||
if (tileElement == nullptr)
|
||||
break;
|
||||
if (tileElement->GetType() != TileElementType::SmallScenery)
|
||||
continue;
|
||||
if (_height > tileElement->ClearanceHeight)
|
||||
continue;
|
||||
if (_height + 4 < tileElement->BaseHeight)
|
||||
continue;
|
||||
TileElementRemove(tileElement--);
|
||||
} while (!(tileElement++)->IsLastForTile());
|
||||
}
|
||||
|
||||
StringId LandSetHeightAction::CheckRideSupports() const
|
||||
{
|
||||
for (auto* trackElement : TileElementsView<TrackElement>(_coords))
|
||||
{
|
||||
RideId rideIndex = trackElement->GetRideIndex();
|
||||
|
||||
auto ride = GetRide(rideIndex);
|
||||
if (ride == nullptr)
|
||||
continue;
|
||||
|
||||
const auto* rideEntry = ride->getRideEntry();
|
||||
if (rideEntry == nullptr)
|
||||
continue;
|
||||
|
||||
int32_t maxHeight = rideEntry->max_height;
|
||||
if (maxHeight == 0)
|
||||
{
|
||||
maxHeight = ride->getRideTypeDescriptor().Heights.MaxHeight;
|
||||
}
|
||||
|
||||
int32_t zDelta = trackElement->ClearanceHeight - _height;
|
||||
if (zDelta >= 0 && zDelta / 2 > maxHeight)
|
||||
{
|
||||
return STR_SUPPORTS_CANT_BE_EXTENDED;
|
||||
}
|
||||
}
|
||||
return kStringIdNone;
|
||||
}
|
||||
|
||||
TileElement* LandSetHeightAction::CheckFloatingStructures(TileElement* surfaceElement, uint8_t zCorner) const
|
||||
{
|
||||
if (surfaceElement->AsSurface()->HasTrackThatNeedsWater())
|
||||
{
|
||||
uint32_t waterHeight = surfaceElement->AsSurface()->GetWaterHeight();
|
||||
if (waterHeight != 0)
|
||||
{
|
||||
if (_style & kTileSlopeMask)
|
||||
{
|
||||
zCorner += 2;
|
||||
if (_style & kTileSlopeDiagonalFlag)
|
||||
{
|
||||
zCorner += 2;
|
||||
}
|
||||
}
|
||||
if (zCorner > (waterHeight / kCoordsZStep) - 2)
|
||||
{
|
||||
return ++surfaceElement;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
money64 LandSetHeightAction::GetSurfaceHeightChangeCost(SurfaceElement* surfaceElement) const
|
||||
{
|
||||
money64 cost{ 0 };
|
||||
for (Direction i : kAllDirections)
|
||||
{
|
||||
int32_t cornerHeight = TileElementGetCornerHeight(surfaceElement, i);
|
||||
cornerHeight -= MapGetCornerHeight(_height, _style & kTileSlopeMask, i);
|
||||
cost += 2.50_GBP * abs(cornerHeight);
|
||||
}
|
||||
return cost;
|
||||
}
|
||||
|
||||
void LandSetHeightAction::SetSurfaceHeight(TileElement* surfaceElement) const
|
||||
{
|
||||
surfaceElement->BaseHeight = _height;
|
||||
surfaceElement->ClearanceHeight = _height;
|
||||
surfaceElement->AsSurface()->SetSlope(_style);
|
||||
int32_t waterHeight = surfaceElement->AsSurface()->GetWaterHeight() / kCoordsZStep;
|
||||
if (waterHeight != 0 && waterHeight <= _height)
|
||||
{
|
||||
surfaceElement->AsSurface()->SetWaterHeight(0);
|
||||
}
|
||||
|
||||
MapInvalidateTileFull(_coords);
|
||||
}
|
||||
|
||||
int32_t LandSetHeightAction::MapSetLandHeightClearFunc(
|
||||
TileElement** tile_element, [[maybe_unused]] const CoordsXY& coords, [[maybe_unused]] uint8_t flags,
|
||||
[[maybe_unused]] money64* price)
|
||||
{
|
||||
if ((*tile_element)->GetType() == TileElementType::Surface)
|
||||
return 0;
|
||||
|
||||
if ((*tile_element)->GetType() == TileElementType::SmallScenery)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -11,40 +11,43 @@
|
||||
|
||||
#include "GameAction.h"
|
||||
|
||||
class LandSetHeightAction final : public GameActionBase<GameCommand::SetLandHeight>
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
private:
|
||||
CoordsXY _coords;
|
||||
uint8_t _height{};
|
||||
uint8_t _style{};
|
||||
class LandSetHeightAction final : public GameActionBase<GameCommand::SetLandHeight>
|
||||
{
|
||||
private:
|
||||
CoordsXY _coords;
|
||||
uint8_t _height{};
|
||||
uint8_t _style{};
|
||||
|
||||
public:
|
||||
LandSetHeightAction() = default;
|
||||
LandSetHeightAction(const CoordsXY& coords, uint8_t height, uint8_t style);
|
||||
public:
|
||||
LandSetHeightAction() = default;
|
||||
LandSetHeightAction(const CoordsXY& coords, uint8_t height, uint8_t style);
|
||||
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
|
||||
uint16_t GetActionFlags() const override;
|
||||
uint16_t GetActionFlags() const override;
|
||||
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
OpenRCT2::GameActions::Result Query() const override;
|
||||
OpenRCT2::GameActions::Result Execute() const override;
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
Result Query() const override;
|
||||
Result Execute() const override;
|
||||
|
||||
private:
|
||||
StringId CheckParameters() const;
|
||||
OpenRCT2::TileElement* CheckTreeObstructions() const;
|
||||
money64 GetSmallSceneryRemovalCost() const;
|
||||
void SmallSceneryRemoval() const;
|
||||
StringId CheckRideSupports() const;
|
||||
OpenRCT2::TileElement* CheckFloatingStructures(OpenRCT2::TileElement* surfaceElement, uint8_t zCorner) const;
|
||||
money64 GetSurfaceHeightChangeCost(OpenRCT2::SurfaceElement* surfaceElement) const;
|
||||
void SetSurfaceHeight(OpenRCT2::TileElement* surfaceElement) const;
|
||||
private:
|
||||
StringId CheckParameters() const;
|
||||
TileElement* CheckTreeObstructions() const;
|
||||
money64 GetSmallSceneryRemovalCost() const;
|
||||
void SmallSceneryRemoval() const;
|
||||
StringId CheckRideSupports() const;
|
||||
TileElement* CheckFloatingStructures(TileElement* surfaceElement, uint8_t zCorner) const;
|
||||
money64 GetSurfaceHeightChangeCost(SurfaceElement* surfaceElement) const;
|
||||
void SetSurfaceHeight(TileElement* surfaceElement) const;
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00663CB9
|
||||
*/
|
||||
static int32_t MapSetLandHeightClearFunc(
|
||||
OpenRCT2::TileElement** tile_element, [[maybe_unused]] const CoordsXY& coords, [[maybe_unused]] uint8_t flags,
|
||||
[[maybe_unused]] money64* price);
|
||||
};
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00663CB9
|
||||
*/
|
||||
static int32_t MapSetLandHeightClearFunc(
|
||||
TileElement** tile_element, [[maybe_unused]] const CoordsXY& coords, [[maybe_unused]] uint8_t flags,
|
||||
[[maybe_unused]] money64* price);
|
||||
};
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -26,213 +26,214 @@
|
||||
#include "../world/tile_element/EntranceElement.h"
|
||||
#include "../world/tile_element/SurfaceElement.h"
|
||||
|
||||
using namespace OpenRCT2;
|
||||
using namespace OpenRCT2::Numerics;
|
||||
|
||||
LandSetRightsAction::LandSetRightsAction(const MapRange& range, LandSetRightSetting setting, uint8_t ownership)
|
||||
: _range(range)
|
||||
, _setting(setting)
|
||||
, _ownership(ownership)
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
}
|
||||
using namespace OpenRCT2::Numerics;
|
||||
|
||||
LandSetRightsAction::LandSetRightsAction(const CoordsXY& coord, LandSetRightSetting setting, uint8_t ownership)
|
||||
: _range(coord.x, coord.y, coord.x, coord.y)
|
||||
, _setting(setting)
|
||||
, _ownership(ownership)
|
||||
{
|
||||
}
|
||||
|
||||
void LandSetRightsAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
visitor.Visit(_range);
|
||||
visitor.Visit("setting", _setting);
|
||||
visitor.Visit("ownership", _ownership);
|
||||
}
|
||||
|
||||
uint16_t LandSetRightsAction::GetActionFlags() const
|
||||
{
|
||||
return GameAction::GetActionFlags() | GameActions::Flags::EditorOnly;
|
||||
}
|
||||
|
||||
void LandSetRightsAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_range) << DS_TAG(_setting) << DS_TAG(_ownership);
|
||||
}
|
||||
|
||||
GameActions::Result LandSetRightsAction::Query() const
|
||||
{
|
||||
return QueryExecute(false);
|
||||
}
|
||||
|
||||
GameActions::Result LandSetRightsAction::Execute() const
|
||||
{
|
||||
return QueryExecute(true);
|
||||
}
|
||||
|
||||
GameActions::Result LandSetRightsAction::QueryExecute(bool isExecuting) const
|
||||
{
|
||||
auto res = GameActions::Result();
|
||||
|
||||
auto validRange = ClampRangeWithinMap(_range.Normalise());
|
||||
CoordsXYZ centre{ (validRange.GetLeft() + validRange.GetRight()) / 2 + 16,
|
||||
(validRange.GetTop() + validRange.GetBottom()) / 2 + 16, 0 };
|
||||
centre.z = TileElementHeight(centre);
|
||||
|
||||
res.Position = centre;
|
||||
res.Expenditure = ExpenditureType::landPurchase;
|
||||
|
||||
if (!isInEditorMode() && !getGameState().cheats.sandboxMode)
|
||||
LandSetRightsAction::LandSetRightsAction(const MapRange& range, LandSetRightSetting setting, uint8_t ownership)
|
||||
: _range(range)
|
||||
, _setting(setting)
|
||||
, _ownership(ownership)
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::NotInEditorMode, kStringIdNone, STR_LAND_NOT_FOR_SALE);
|
||||
}
|
||||
|
||||
// Game command modified to accept selection size
|
||||
for (auto y = validRange.GetTop(); y <= validRange.GetBottom(); y += kCoordsXYStep)
|
||||
LandSetRightsAction::LandSetRightsAction(const CoordsXY& coord, LandSetRightSetting setting, uint8_t ownership)
|
||||
: _range(coord.x, coord.y, coord.x, coord.y)
|
||||
, _setting(setting)
|
||||
, _ownership(ownership)
|
||||
{
|
||||
for (auto x = validRange.GetLeft(); x <= validRange.GetRight(); x += kCoordsXYStep)
|
||||
}
|
||||
|
||||
void LandSetRightsAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
visitor.Visit(_range);
|
||||
visitor.Visit("setting", _setting);
|
||||
visitor.Visit("ownership", _ownership);
|
||||
}
|
||||
|
||||
uint16_t LandSetRightsAction::GetActionFlags() const
|
||||
{
|
||||
return GameAction::GetActionFlags() | Flags::EditorOnly;
|
||||
}
|
||||
|
||||
void LandSetRightsAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_range) << DS_TAG(_setting) << DS_TAG(_ownership);
|
||||
}
|
||||
|
||||
Result LandSetRightsAction::Query() const
|
||||
{
|
||||
return QueryExecute(false);
|
||||
}
|
||||
|
||||
Result LandSetRightsAction::Execute() const
|
||||
{
|
||||
return QueryExecute(true);
|
||||
}
|
||||
|
||||
Result LandSetRightsAction::QueryExecute(bool isExecuting) const
|
||||
{
|
||||
auto res = Result();
|
||||
|
||||
auto validRange = ClampRangeWithinMap(_range.Normalise());
|
||||
CoordsXYZ centre{ (validRange.GetLeft() + validRange.GetRight()) / 2 + 16,
|
||||
(validRange.GetTop() + validRange.GetBottom()) / 2 + 16, 0 };
|
||||
centre.z = TileElementHeight(centre);
|
||||
|
||||
res.Position = centre;
|
||||
res.Expenditure = ExpenditureType::landPurchase;
|
||||
|
||||
if (!isInEditorMode() && !getGameState().cheats.sandboxMode)
|
||||
{
|
||||
if (!LocationValid({ x, y }))
|
||||
continue;
|
||||
auto result = MapBuyLandRightsForTile({ x, y }, isExecuting);
|
||||
if (result.Error == GameActions::Status::Ok)
|
||||
return Result(Status::NotInEditorMode, kStringIdNone, STR_LAND_NOT_FOR_SALE);
|
||||
}
|
||||
|
||||
// Game command modified to accept selection size
|
||||
for (auto y = validRange.GetTop(); y <= validRange.GetBottom(); y += kCoordsXYStep)
|
||||
{
|
||||
for (auto x = validRange.GetLeft(); x <= validRange.GetRight(); x += kCoordsXYStep)
|
||||
{
|
||||
res.Cost += result.Cost;
|
||||
if (!LocationValid({ x, y }))
|
||||
continue;
|
||||
auto result = MapBuyLandRightsForTile({ x, y }, isExecuting);
|
||||
if (result.Error == Status::Ok)
|
||||
{
|
||||
res.Cost += result.Cost;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isExecuting)
|
||||
{
|
||||
MapCountRemainingLandRights();
|
||||
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::PlaceItem, centre);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
GameActions::Result LandSetRightsAction::MapBuyLandRightsForTile(const CoordsXY& loc, bool isExecuting) const
|
||||
{
|
||||
SurfaceElement* surfaceElement = MapGetSurfaceElementAt(loc);
|
||||
if (surfaceElement == nullptr)
|
||||
{
|
||||
LOG_ERROR("No surface at x = %d, y = %d", loc.x, loc.y);
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_ERR_INVALID_PARAMETER, STR_ERR_SURFACE_ELEMENT_NOT_FOUND);
|
||||
}
|
||||
|
||||
auto res = GameActions::Result();
|
||||
switch (_setting)
|
||||
{
|
||||
case LandSetRightSetting::UnownLand:
|
||||
if (isExecuting)
|
||||
{
|
||||
surfaceElement->SetOwnership(
|
||||
surfaceElement->GetOwnership() & ~(OWNERSHIP_OWNED | OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED));
|
||||
Park::UpdateFencesAroundTile(loc);
|
||||
}
|
||||
return res;
|
||||
case LandSetRightSetting::UnownConstructionRights:
|
||||
if (isExecuting)
|
||||
{
|
||||
surfaceElement->SetOwnership(surfaceElement->GetOwnership() & ~OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED);
|
||||
uint16_t baseZ = surfaceElement->GetBaseZ();
|
||||
MapInvalidateTile({ loc, baseZ, baseZ + 16 });
|
||||
}
|
||||
return res;
|
||||
case LandSetRightSetting::SetForSale:
|
||||
if (isExecuting)
|
||||
{
|
||||
surfaceElement->SetOwnership(surfaceElement->GetOwnership() | OWNERSHIP_AVAILABLE);
|
||||
uint16_t baseZ = surfaceElement->GetBaseZ();
|
||||
MapInvalidateTile({ loc, baseZ, baseZ + 16 });
|
||||
}
|
||||
return res;
|
||||
case LandSetRightSetting::SetConstructionRightsForSale:
|
||||
if (isExecuting)
|
||||
{
|
||||
surfaceElement->SetOwnership(surfaceElement->GetOwnership() | OWNERSHIP_CONSTRUCTION_RIGHTS_AVAILABLE);
|
||||
uint16_t baseZ = surfaceElement->GetBaseZ();
|
||||
MapInvalidateTile({ loc, baseZ, baseZ + 16 });
|
||||
}
|
||||
return res;
|
||||
case LandSetRightSetting::SetOwnershipWithChecks:
|
||||
if (isExecuting)
|
||||
{
|
||||
if (_ownership == surfaceElement->GetOwnership())
|
||||
{
|
||||
return res;
|
||||
}
|
||||
MapCountRemainingLandRights();
|
||||
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::PlaceItem, centre);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
for (auto* entranceElement : TileElementsView<EntranceElement>(loc))
|
||||
{
|
||||
if (entranceElement->GetEntranceType() != ENTRANCE_TYPE_PARK_ENTRANCE)
|
||||
continue;
|
||||
Result LandSetRightsAction::MapBuyLandRightsForTile(const CoordsXY& loc, bool isExecuting) const
|
||||
{
|
||||
SurfaceElement* surfaceElement = MapGetSurfaceElementAt(loc);
|
||||
if (surfaceElement == nullptr)
|
||||
{
|
||||
LOG_ERROR("No surface at x = %d, y = %d", loc.x, loc.y);
|
||||
return Result(Status::InvalidParameters, STR_ERR_INVALID_PARAMETER, STR_ERR_SURFACE_ELEMENT_NOT_FOUND);
|
||||
}
|
||||
|
||||
// Do not allow ownership of park entrance.
|
||||
if (_ownership == OWNERSHIP_OWNED || _ownership == OWNERSHIP_AVAILABLE)
|
||||
return res;
|
||||
|
||||
// Allow construction rights available / for sale on park entrances on surface.
|
||||
// There is no need to check the height if _ownership is 0 (unowned and no rights available).
|
||||
if (_ownership == OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED || _ownership == OWNERSHIP_CONSTRUCTION_RIGHTS_AVAILABLE)
|
||||
auto res = Result();
|
||||
switch (_setting)
|
||||
{
|
||||
case LandSetRightSetting::UnownLand:
|
||||
if (isExecuting)
|
||||
{
|
||||
if (entranceElement->BaseHeight - 3 > surfaceElement->BaseHeight
|
||||
|| entranceElement->BaseHeight < surfaceElement->BaseHeight)
|
||||
{
|
||||
surfaceElement->SetOwnership(
|
||||
surfaceElement->GetOwnership() & ~(OWNERSHIP_OWNED | OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED));
|
||||
Park::UpdateFencesAroundTile(loc);
|
||||
}
|
||||
return res;
|
||||
case LandSetRightSetting::UnownConstructionRights:
|
||||
if (isExecuting)
|
||||
{
|
||||
surfaceElement->SetOwnership(surfaceElement->GetOwnership() & ~OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED);
|
||||
uint16_t baseZ = surfaceElement->GetBaseZ();
|
||||
MapInvalidateTile({ loc, baseZ, baseZ + 16 });
|
||||
}
|
||||
return res;
|
||||
case LandSetRightSetting::SetForSale:
|
||||
if (isExecuting)
|
||||
{
|
||||
surfaceElement->SetOwnership(surfaceElement->GetOwnership() | OWNERSHIP_AVAILABLE);
|
||||
uint16_t baseZ = surfaceElement->GetBaseZ();
|
||||
MapInvalidateTile({ loc, baseZ, baseZ + 16 });
|
||||
}
|
||||
return res;
|
||||
case LandSetRightSetting::SetConstructionRightsForSale:
|
||||
if (isExecuting)
|
||||
{
|
||||
surfaceElement->SetOwnership(surfaceElement->GetOwnership() | OWNERSHIP_CONSTRUCTION_RIGHTS_AVAILABLE);
|
||||
uint16_t baseZ = surfaceElement->GetBaseZ();
|
||||
MapInvalidateTile({ loc, baseZ, baseZ + 16 });
|
||||
}
|
||||
return res;
|
||||
case LandSetRightSetting::SetOwnershipWithChecks:
|
||||
{
|
||||
if (_ownership == surfaceElement->GetOwnership())
|
||||
{
|
||||
return res;
|
||||
}
|
||||
|
||||
for (auto* entranceElement : TileElementsView<EntranceElement>(loc))
|
||||
{
|
||||
if (entranceElement->GetEntranceType() != ENTRANCE_TYPE_PARK_ENTRANCE)
|
||||
continue;
|
||||
|
||||
// Do not allow ownership of park entrance.
|
||||
if (_ownership == OWNERSHIP_OWNED || _ownership == OWNERSHIP_AVAILABLE)
|
||||
return res;
|
||||
|
||||
// Allow construction rights available / for sale on park entrances on surface.
|
||||
// There is no need to check the height if _ownership is 0 (unowned and no rights available).
|
||||
if (_ownership == OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED
|
||||
|| _ownership == OWNERSHIP_CONSTRUCTION_RIGHTS_AVAILABLE)
|
||||
{
|
||||
if (entranceElement->BaseHeight - 3 > surfaceElement->BaseHeight
|
||||
|| entranceElement->BaseHeight < surfaceElement->BaseHeight)
|
||||
{
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto& gameState = getGameState();
|
||||
const uint8_t currentOwnership = surfaceElement->GetOwnership();
|
||||
auto& gameState = getGameState();
|
||||
const uint8_t currentOwnership = surfaceElement->GetOwnership();
|
||||
|
||||
// Are land rights or construction rights currently owned?
|
||||
if (!(currentOwnership & (OWNERSHIP_OWNED | OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED)))
|
||||
{
|
||||
// Buying land
|
||||
if (!(currentOwnership & OWNERSHIP_OWNED) && (_ownership & OWNERSHIP_OWNED))
|
||||
res.Cost = gameState.scenarioOptions.landPrice;
|
||||
|
||||
// Buying construction rights
|
||||
if (!(currentOwnership & OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED)
|
||||
&& (_ownership & OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED))
|
||||
res.Cost = gameState.scenarioOptions.constructionRightsPrice;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Selling land
|
||||
if ((currentOwnership & OWNERSHIP_OWNED) && !(_ownership & OWNERSHIP_OWNED))
|
||||
res.Cost = -gameState.scenarioOptions.landPrice;
|
||||
|
||||
// Selling construction rights
|
||||
if ((currentOwnership & OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED)
|
||||
&& !(_ownership & OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED))
|
||||
res.Cost = -gameState.scenarioOptions.constructionRightsPrice;
|
||||
}
|
||||
|
||||
if (isExecuting)
|
||||
{
|
||||
if (_ownership != OWNERSHIP_UNOWNED)
|
||||
// Are land rights or construction rights currently owned?
|
||||
if (!(currentOwnership & (OWNERSHIP_OWNED | OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED)))
|
||||
{
|
||||
gameState.peepSpawns.erase(
|
||||
std::remove_if(
|
||||
gameState.peepSpawns.begin(), gameState.peepSpawns.end(),
|
||||
[x = loc.x, y = loc.y](const auto& spawn) {
|
||||
return floor2(spawn.x, 32) == x && floor2(spawn.y, 32) == y;
|
||||
}),
|
||||
gameState.peepSpawns.end());
|
||||
// Buying land
|
||||
if (!(currentOwnership & OWNERSHIP_OWNED) && (_ownership & OWNERSHIP_OWNED))
|
||||
res.Cost = gameState.scenarioOptions.landPrice;
|
||||
|
||||
// Buying construction rights
|
||||
if (!(currentOwnership & OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED)
|
||||
&& (_ownership & OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED))
|
||||
res.Cost = gameState.scenarioOptions.constructionRightsPrice;
|
||||
}
|
||||
surfaceElement->SetOwnership(_ownership);
|
||||
Park::UpdateFencesAroundTile(loc);
|
||||
gMapLandRightsUpdateSuccess = true;
|
||||
else
|
||||
{
|
||||
// Selling land
|
||||
if ((currentOwnership & OWNERSHIP_OWNED) && !(_ownership & OWNERSHIP_OWNED))
|
||||
res.Cost = -gameState.scenarioOptions.landPrice;
|
||||
|
||||
// Selling construction rights
|
||||
if ((currentOwnership & OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED)
|
||||
&& !(_ownership & OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED))
|
||||
res.Cost = -gameState.scenarioOptions.constructionRightsPrice;
|
||||
}
|
||||
|
||||
if (isExecuting)
|
||||
{
|
||||
if (_ownership != OWNERSHIP_UNOWNED)
|
||||
{
|
||||
gameState.peepSpawns.erase(
|
||||
std::remove_if(
|
||||
gameState.peepSpawns.begin(), gameState.peepSpawns.end(),
|
||||
[x = loc.x, y = loc.y](const auto& spawn) {
|
||||
return floor2(spawn.x, 32) == x && floor2(spawn.y, 32) == y;
|
||||
}),
|
||||
gameState.peepSpawns.end());
|
||||
}
|
||||
surfaceElement->SetOwnership(_ownership);
|
||||
Park::UpdateFencesAroundTile(loc);
|
||||
gMapLandRightsUpdateSuccess = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
return res;
|
||||
default:
|
||||
LOG_ERROR("Invalid setting %u to set land rights", _setting);
|
||||
return Result(Status::InvalidParameters, STR_ERR_INVALID_PARAMETER, STR_ERR_VALUE_OUT_OF_RANGE);
|
||||
}
|
||||
default:
|
||||
LOG_ERROR("Invalid setting %u to set land rights", _setting);
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_ERR_INVALID_PARAMETER, STR_ERR_VALUE_OUT_OF_RANGE);
|
||||
}
|
||||
}
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -11,37 +11,40 @@
|
||||
|
||||
#include "GameAction.h"
|
||||
|
||||
enum class LandSetRightSetting : uint8_t
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
UnownLand,
|
||||
UnownConstructionRights,
|
||||
SetForSale,
|
||||
SetConstructionRightsForSale,
|
||||
SetOwnershipWithChecks,
|
||||
Count
|
||||
};
|
||||
enum class LandSetRightSetting : uint8_t
|
||||
{
|
||||
UnownLand,
|
||||
UnownConstructionRights,
|
||||
SetForSale,
|
||||
SetConstructionRightsForSale,
|
||||
SetOwnershipWithChecks,
|
||||
Count
|
||||
};
|
||||
|
||||
class LandSetRightsAction final : public GameActionBase<GameCommand::SetLandOwnership>
|
||||
{
|
||||
private:
|
||||
MapRange _range;
|
||||
LandSetRightSetting _setting{ LandSetRightSetting::Count };
|
||||
uint8_t _ownership{};
|
||||
class LandSetRightsAction final : public GameActionBase<GameCommand::SetLandOwnership>
|
||||
{
|
||||
private:
|
||||
MapRange _range;
|
||||
LandSetRightSetting _setting{ LandSetRightSetting::Count };
|
||||
uint8_t _ownership{};
|
||||
|
||||
public:
|
||||
LandSetRightsAction() = default;
|
||||
LandSetRightsAction(const MapRange& range, LandSetRightSetting setting, uint8_t ownership = 0);
|
||||
LandSetRightsAction(const CoordsXY& coord, LandSetRightSetting setting, uint8_t ownership = 0);
|
||||
public:
|
||||
LandSetRightsAction() = default;
|
||||
LandSetRightsAction(const MapRange& range, LandSetRightSetting setting, uint8_t ownership = 0);
|
||||
LandSetRightsAction(const CoordsXY& coord, LandSetRightSetting setting, uint8_t ownership = 0);
|
||||
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
|
||||
uint16_t GetActionFlags() const override;
|
||||
uint16_t GetActionFlags() const override;
|
||||
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
OpenRCT2::GameActions::Result Query() const override;
|
||||
OpenRCT2::GameActions::Result Execute() const override;
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
Result Query() const override;
|
||||
Result Execute() const override;
|
||||
|
||||
private:
|
||||
OpenRCT2::GameActions::Result QueryExecute(bool isExecuting) const;
|
||||
OpenRCT2::GameActions::Result MapBuyLandRightsForTile(const CoordsXY& loc, bool isExecuting) const;
|
||||
};
|
||||
private:
|
||||
Result QueryExecute(bool isExecuting) const;
|
||||
Result MapBuyLandRightsForTile(const CoordsXY& loc, bool isExecuting) const;
|
||||
};
|
||||
} // namespace OpenRCT2::GameActions
|
||||
File diff suppressed because it is too large.
Load diff
@@ -11,39 +11,41 @@
|
||||
|
||||
#include "GameAction.h"
|
||||
|
||||
class LandSmoothAction final : public GameActionBase<GameCommand::EditLandSmooth>
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
private:
|
||||
CoordsXY _coords;
|
||||
MapRange _range;
|
||||
uint8_t _selectionType{};
|
||||
bool _isLowering{};
|
||||
class LandSmoothAction final : public GameActionBase<GameCommand::EditLandSmooth>
|
||||
{
|
||||
private:
|
||||
CoordsXY _coords;
|
||||
MapRange _range;
|
||||
uint8_t _selectionType{};
|
||||
bool _isLowering{};
|
||||
|
||||
constexpr static StringId kErrorTitles[] = {
|
||||
STR_CANT_LOWER_LAND_HERE,
|
||||
STR_CANT_RAISE_LAND_HERE,
|
||||
constexpr static StringId kErrorTitles[] = {
|
||||
STR_CANT_LOWER_LAND_HERE,
|
||||
STR_CANT_RAISE_LAND_HERE,
|
||||
};
|
||||
|
||||
public:
|
||||
LandSmoothAction() = default;
|
||||
LandSmoothAction(const CoordsXY& coords, MapRange range, uint8_t selectionType, bool isLowering);
|
||||
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
|
||||
uint16_t GetActionFlags() const override;
|
||||
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
Result Query() const override;
|
||||
Result Execute() const override;
|
||||
|
||||
private:
|
||||
Result SmoothLandTile(int32_t direction, bool isExecuting, const CoordsXY& loc, SurfaceElement* surfaceElement) const;
|
||||
money64 SmoothLandRowByEdge(
|
||||
bool isExecuting, const CoordsXY& loc, int32_t expectedLandHeight1, int32_t expectedLandHeight2, int32_t stepX,
|
||||
int32_t stepY, int32_t direction1, int32_t direction2, int32_t checkDirection1, int32_t checkDirection2) const;
|
||||
money64 SmoothLandRowByCorner(
|
||||
bool isExecuting, const CoordsXY& loc, int32_t expectedLandHeight, int32_t stepX, int32_t stepY, int32_t direction,
|
||||
int32_t checkDirection) const;
|
||||
Result SmoothLand(bool isExecuting) const;
|
||||
};
|
||||
|
||||
public:
|
||||
LandSmoothAction() = default;
|
||||
LandSmoothAction(const CoordsXY& coords, MapRange range, uint8_t selectionType, bool isLowering);
|
||||
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
|
||||
uint16_t GetActionFlags() const override;
|
||||
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
OpenRCT2::GameActions::Result Query() const override;
|
||||
OpenRCT2::GameActions::Result Execute() const override;
|
||||
|
||||
private:
|
||||
OpenRCT2::GameActions::Result SmoothLandTile(
|
||||
int32_t direction, bool isExecuting, const CoordsXY& loc, OpenRCT2::SurfaceElement* surfaceElement) const;
|
||||
money64 SmoothLandRowByEdge(
|
||||
bool isExecuting, const CoordsXY& loc, int32_t expectedLandHeight1, int32_t expectedLandHeight2, int32_t stepX,
|
||||
int32_t stepY, int32_t direction1, int32_t direction2, int32_t checkDirection1, int32_t checkDirection2) const;
|
||||
money64 SmoothLandRowByCorner(
|
||||
bool isExecuting, const CoordsXY& loc, int32_t expectedLandHeight, int32_t stepX, int32_t stepY, int32_t direction,
|
||||
int32_t checkDirection) const;
|
||||
OpenRCT2::GameActions::Result SmoothLand(bool isExecuting) const;
|
||||
};
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -28,376 +28,369 @@
|
||||
#include "../world/tile_element/Slope.h"
|
||||
#include "../world/tile_element/SurfaceElement.h"
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
LargeSceneryPlaceAction::LargeSceneryPlaceAction(
|
||||
const CoordsXYZD& loc, ObjectEntryIndex sceneryType, uint8_t primaryColour, uint8_t secondaryColour, uint8_t tertiaryColour)
|
||||
: _loc(loc)
|
||||
, _sceneryType(sceneryType)
|
||||
, _primaryColour(primaryColour)
|
||||
, _secondaryColour(secondaryColour)
|
||||
, _tertiaryColour(tertiaryColour)
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
}
|
||||
|
||||
void LargeSceneryPlaceAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
visitor.Visit(_loc);
|
||||
visitor.Visit("object", _sceneryType);
|
||||
visitor.Visit("primaryColour", _primaryColour);
|
||||
visitor.Visit("secondaryColour", _secondaryColour);
|
||||
visitor.Visit("tertiaryColour", _tertiaryColour);
|
||||
}
|
||||
|
||||
uint16_t LargeSceneryPlaceAction::GetActionFlags() const
|
||||
{
|
||||
return GameAction::GetActionFlags();
|
||||
}
|
||||
|
||||
void LargeSceneryPlaceAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_loc) << DS_TAG(_sceneryType) << DS_TAG(_primaryColour) << DS_TAG(_secondaryColour)
|
||||
<< DS_TAG(_tertiaryColour);
|
||||
}
|
||||
|
||||
GameActions::Result LargeSceneryPlaceAction::Query() const
|
||||
{
|
||||
auto res = GameActions::Result();
|
||||
res.ErrorTitle = STR_CANT_POSITION_THIS_HERE;
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
int16_t surfaceHeight = TileElementHeight(_loc);
|
||||
res.Position.x = _loc.x + 16;
|
||||
res.Position.y = _loc.y + 16;
|
||||
res.Position.z = surfaceHeight;
|
||||
|
||||
auto resultData = LargeSceneryPlaceActionResult{};
|
||||
|
||||
auto& gameState = getGameState();
|
||||
|
||||
money64 supportsCost = 0;
|
||||
|
||||
if (_primaryColour >= COLOUR_COUNT)
|
||||
LargeSceneryPlaceAction::LargeSceneryPlaceAction(
|
||||
const CoordsXYZD& loc, ObjectEntryIndex sceneryType, uint8_t primaryColour, uint8_t secondaryColour,
|
||||
uint8_t tertiaryColour)
|
||||
: _loc(loc)
|
||||
, _sceneryType(sceneryType)
|
||||
, _primaryColour(primaryColour)
|
||||
, _secondaryColour(secondaryColour)
|
||||
, _tertiaryColour(tertiaryColour)
|
||||
{
|
||||
LOG_ERROR("Invalid primary colour %u", _primaryColour);
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_ERR_INVALID_COLOUR);
|
||||
}
|
||||
else if (_secondaryColour >= COLOUR_COUNT)
|
||||
{
|
||||
LOG_ERROR("Invalid secondary colour %u", _secondaryColour);
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_ERR_INVALID_COLOUR);
|
||||
}
|
||||
else if (_tertiaryColour >= COLOUR_COUNT)
|
||||
{
|
||||
LOG_ERROR("Invalid tertiary colour %u", _tertiaryColour);
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_ERR_INVALID_COLOUR);
|
||||
}
|
||||
else if (_sceneryType >= kMaxLargeSceneryObjects)
|
||||
{
|
||||
LOG_ERROR("Invalid sceneryType %u", _sceneryType);
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_ERR_VALUE_OUT_OF_RANGE);
|
||||
}
|
||||
|
||||
auto* sceneryEntry = ObjectManager::GetObjectEntry<LargeSceneryEntry>(_sceneryType);
|
||||
if (sceneryEntry == nullptr)
|
||||
void LargeSceneryPlaceAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
LOG_ERROR("Large scenery entry not found for sceneryType %u", _sceneryType);
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_UNKNOWN_OBJECT_TYPE);
|
||||
visitor.Visit(_loc);
|
||||
visitor.Visit("object", _sceneryType);
|
||||
visitor.Visit("primaryColour", _primaryColour);
|
||||
visitor.Visit("secondaryColour", _secondaryColour);
|
||||
visitor.Visit("tertiaryColour", _tertiaryColour);
|
||||
}
|
||||
|
||||
const auto totalNumTiles = sceneryEntry->tiles.size();
|
||||
int16_t maxHeight = GetMaxSurfaceHeight(sceneryEntry->tiles);
|
||||
|
||||
if (_loc.z != 0)
|
||||
uint16_t LargeSceneryPlaceAction::GetActionFlags() const
|
||||
{
|
||||
maxHeight = _loc.z;
|
||||
return GameAction::GetActionFlags();
|
||||
}
|
||||
|
||||
res.Position.z = maxHeight;
|
||||
|
||||
if (sceneryEntry->scrolling_mode != kScrollingModeNone)
|
||||
void LargeSceneryPlaceAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
if (HasReachedBannerLimit())
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_loc) << DS_TAG(_sceneryType) << DS_TAG(_primaryColour) << DS_TAG(_secondaryColour)
|
||||
<< DS_TAG(_tertiaryColour);
|
||||
}
|
||||
|
||||
Result LargeSceneryPlaceAction::Query() const
|
||||
{
|
||||
auto res = Result();
|
||||
res.ErrorTitle = STR_CANT_POSITION_THIS_HERE;
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
int16_t surfaceHeight = TileElementHeight(_loc);
|
||||
res.Position.x = _loc.x + 16;
|
||||
res.Position.y = _loc.y + 16;
|
||||
res.Position.z = surfaceHeight;
|
||||
|
||||
auto resultData = LargeSceneryPlaceActionResult{};
|
||||
|
||||
auto& gameState = getGameState();
|
||||
|
||||
money64 supportsCost = 0;
|
||||
|
||||
if (_primaryColour >= COLOUR_COUNT)
|
||||
{
|
||||
LOG_ERROR("No free banners available");
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_TOO_MANY_BANNERS_IN_GAME);
|
||||
LOG_ERROR("Invalid primary colour %u", _primaryColour);
|
||||
return Result(Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_ERR_INVALID_COLOUR);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& tile : sceneryEntry->tiles)
|
||||
{
|
||||
auto curTile = CoordsXY{ tile.offset }.Rotate(_loc.direction);
|
||||
|
||||
curTile.x += _loc.x;
|
||||
curTile.y += _loc.y;
|
||||
|
||||
int32_t zLow = tile.offset.z + maxHeight;
|
||||
int32_t zHigh = tile.zClearance + zLow;
|
||||
|
||||
QuarterTile quarterTile = QuarterTile{ tile.corners, 0 }.Rotate(_loc.direction);
|
||||
const auto isTree = (sceneryEntry->flags & LARGE_SCENERY_FLAG_IS_TREE) != 0;
|
||||
auto canBuild = MapCanConstructWithClearAt(
|
||||
{ curTile, zLow, zHigh }, &MapPlaceSceneryClearFunc, quarterTile, GetFlags(), CreateCrossingMode::none, isTree);
|
||||
if (canBuild.Error != GameActions::Status::Ok)
|
||||
else if (_secondaryColour >= COLOUR_COUNT)
|
||||
{
|
||||
canBuild.ErrorTitle = STR_CANT_POSITION_THIS_HERE;
|
||||
return canBuild;
|
||||
LOG_ERROR("Invalid secondary colour %u", _secondaryColour);
|
||||
return Result(Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_ERR_INVALID_COLOUR);
|
||||
}
|
||||
else if (_tertiaryColour >= COLOUR_COUNT)
|
||||
{
|
||||
LOG_ERROR("Invalid tertiary colour %u", _tertiaryColour);
|
||||
return Result(Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_ERR_INVALID_COLOUR);
|
||||
}
|
||||
else if (_sceneryType >= kMaxLargeSceneryObjects)
|
||||
{
|
||||
LOG_ERROR("Invalid sceneryType %u", _sceneryType);
|
||||
return Result(Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_ERR_VALUE_OUT_OF_RANGE);
|
||||
}
|
||||
|
||||
supportsCost += canBuild.Cost;
|
||||
|
||||
const auto clearanceData = canBuild.GetData<ConstructClearResult>();
|
||||
int32_t tempSceneryGroundFlags = clearanceData.GroundFlags & (ELEMENT_IS_ABOVE_GROUND | ELEMENT_IS_UNDERGROUND);
|
||||
if (!gameState.cheats.disableClearanceChecks)
|
||||
auto* sceneryEntry = ObjectManager::GetObjectEntry<LargeSceneryEntry>(_sceneryType);
|
||||
if (sceneryEntry == nullptr)
|
||||
{
|
||||
if ((clearanceData.GroundFlags & ELEMENT_IS_UNDERWATER) || (clearanceData.GroundFlags & ELEMENT_IS_UNDERGROUND))
|
||||
LOG_ERROR("Large scenery entry not found for sceneryType %u", _sceneryType);
|
||||
return Result(Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_UNKNOWN_OBJECT_TYPE);
|
||||
}
|
||||
|
||||
const auto totalNumTiles = sceneryEntry->tiles.size();
|
||||
int16_t maxHeight = GetMaxSurfaceHeight(sceneryEntry->tiles);
|
||||
|
||||
if (_loc.z != 0)
|
||||
{
|
||||
maxHeight = _loc.z;
|
||||
}
|
||||
|
||||
res.Position.z = maxHeight;
|
||||
|
||||
if (sceneryEntry->scrolling_mode != kScrollingModeNone)
|
||||
{
|
||||
if (HasReachedBannerLimit())
|
||||
{
|
||||
return GameActions::Result(
|
||||
GameActions::Status::Disallowed, STR_CANT_POSITION_THIS_HERE, STR_CANT_BUILD_THIS_UNDERWATER);
|
||||
}
|
||||
if (resultData.GroundFlags && !(resultData.GroundFlags & tempSceneryGroundFlags))
|
||||
{
|
||||
return GameActions::Result(
|
||||
GameActions::Status::Disallowed, STR_CANT_POSITION_THIS_HERE,
|
||||
STR_CANT_BUILD_PARTLY_ABOVE_AND_PARTLY_BELOW_GROUND);
|
||||
LOG_ERROR("No free banners available");
|
||||
return Result(Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_TOO_MANY_BANNERS_IN_GAME);
|
||||
}
|
||||
}
|
||||
|
||||
resultData.GroundFlags = tempSceneryGroundFlags;
|
||||
|
||||
if (!LocationValid(curTile) || MapIsEdge(curTile))
|
||||
for (auto& tile : sceneryEntry->tiles)
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::Disallowed, STR_CANT_POSITION_THIS_HERE, STR_OFF_EDGE_OF_MAP);
|
||||
auto curTile = CoordsXY{ tile.offset }.Rotate(_loc.direction);
|
||||
|
||||
curTile.x += _loc.x;
|
||||
curTile.y += _loc.y;
|
||||
|
||||
int32_t zLow = tile.offset.z + maxHeight;
|
||||
int32_t zHigh = tile.zClearance + zLow;
|
||||
|
||||
QuarterTile quarterTile = QuarterTile{ tile.corners, 0 }.Rotate(_loc.direction);
|
||||
const auto isTree = (sceneryEntry->flags & LARGE_SCENERY_FLAG_IS_TREE) != 0;
|
||||
auto canBuild = MapCanConstructWithClearAt(
|
||||
{ curTile, zLow, zHigh }, &MapPlaceSceneryClearFunc, quarterTile, GetFlags(), CreateCrossingMode::none, isTree);
|
||||
if (canBuild.Error != Status::Ok)
|
||||
{
|
||||
canBuild.ErrorTitle = STR_CANT_POSITION_THIS_HERE;
|
||||
return canBuild;
|
||||
}
|
||||
|
||||
supportsCost += canBuild.Cost;
|
||||
|
||||
const auto clearanceData = canBuild.GetData<ConstructClearResult>();
|
||||
int32_t tempSceneryGroundFlags = clearanceData.GroundFlags & (ELEMENT_IS_ABOVE_GROUND | ELEMENT_IS_UNDERGROUND);
|
||||
if (!gameState.cheats.disableClearanceChecks)
|
||||
{
|
||||
if ((clearanceData.GroundFlags & ELEMENT_IS_UNDERWATER) || (clearanceData.GroundFlags & ELEMENT_IS_UNDERGROUND))
|
||||
{
|
||||
return Result(Status::Disallowed, STR_CANT_POSITION_THIS_HERE, STR_CANT_BUILD_THIS_UNDERWATER);
|
||||
}
|
||||
if (resultData.GroundFlags && !(resultData.GroundFlags & tempSceneryGroundFlags))
|
||||
{
|
||||
return Result(
|
||||
Status::Disallowed, STR_CANT_POSITION_THIS_HERE, STR_CANT_BUILD_PARTLY_ABOVE_AND_PARTLY_BELOW_GROUND);
|
||||
}
|
||||
}
|
||||
|
||||
resultData.GroundFlags = tempSceneryGroundFlags;
|
||||
|
||||
if (!LocationValid(curTile) || MapIsEdge(curTile))
|
||||
{
|
||||
return Result(Status::Disallowed, STR_CANT_POSITION_THIS_HERE, STR_OFF_EDGE_OF_MAP);
|
||||
}
|
||||
|
||||
if (gLegacyScene != LegacyScene::scenarioEditor && !MapIsLocationOwned({ curTile, zLow })
|
||||
&& !gameState.cheats.sandboxMode)
|
||||
{
|
||||
return Result(Status::Disallowed, STR_CANT_POSITION_THIS_HERE, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
}
|
||||
}
|
||||
|
||||
if (gLegacyScene != LegacyScene::scenarioEditor && !MapIsLocationOwned({ curTile, zLow })
|
||||
&& !gameState.cheats.sandboxMode)
|
||||
if (!CheckMapCapacity(sceneryEntry->tiles, totalNumTiles))
|
||||
{
|
||||
return GameActions::Result(
|
||||
GameActions::Status::Disallowed, STR_CANT_POSITION_THIS_HERE, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
}
|
||||
}
|
||||
|
||||
if (!CheckMapCapacity(sceneryEntry->tiles, totalNumTiles))
|
||||
{
|
||||
LOG_ERROR("No free map elements available");
|
||||
return GameActions::Result(
|
||||
GameActions::Status::NoFreeElements, STR_CANT_POSITION_THIS_HERE, STR_TILE_ELEMENT_LIMIT_REACHED);
|
||||
}
|
||||
|
||||
// Force ride construction to recheck area
|
||||
_currentTrackSelectionFlags.set(TrackSelectionFlag::recheck);
|
||||
|
||||
res.Cost = sceneryEntry->price + supportsCost;
|
||||
res.SetData(std::move(resultData));
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
GameActions::Result LargeSceneryPlaceAction::Execute() const
|
||||
{
|
||||
auto res = GameActions::Result();
|
||||
res.ErrorTitle = STR_CANT_POSITION_THIS_HERE;
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
|
||||
int16_t surfaceHeight = TileElementHeight(_loc);
|
||||
res.Position.x = _loc.x + 16;
|
||||
res.Position.y = _loc.y + 16;
|
||||
res.Position.z = surfaceHeight;
|
||||
|
||||
auto resultData = LargeSceneryPlaceActionResult{};
|
||||
|
||||
money64 supportsCost = 0;
|
||||
|
||||
auto* sceneryEntry = ObjectManager::GetObjectEntry<LargeSceneryEntry>(_sceneryType);
|
||||
if (sceneryEntry == nullptr)
|
||||
{
|
||||
LOG_ERROR("Large scenery entry not found for sceneryType = %u", _sceneryType);
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_UNKNOWN_OBJECT_TYPE);
|
||||
}
|
||||
|
||||
if (sceneryEntry->tiles.empty())
|
||||
{
|
||||
LOG_ERROR("Invalid large scenery object, sceneryType = %u", _sceneryType);
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, kStringIdNone);
|
||||
}
|
||||
|
||||
int16_t maxHeight = GetMaxSurfaceHeight(sceneryEntry->tiles);
|
||||
|
||||
if (_loc.z != 0)
|
||||
{
|
||||
maxHeight = _loc.z;
|
||||
}
|
||||
|
||||
res.Position.z = maxHeight;
|
||||
|
||||
// Allocate banner
|
||||
Banner* banner = nullptr;
|
||||
if (sceneryEntry->scrolling_mode != kScrollingModeNone)
|
||||
{
|
||||
banner = CreateBanner();
|
||||
if (banner == nullptr)
|
||||
{
|
||||
LOG_ERROR("No free banners available");
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_TOO_MANY_BANNERS_IN_GAME);
|
||||
LOG_ERROR("No free map elements available");
|
||||
return Result(Status::NoFreeElements, STR_CANT_POSITION_THIS_HERE, STR_TILE_ELEMENT_LIMIT_REACHED);
|
||||
}
|
||||
|
||||
banner->text = {};
|
||||
banner->colour = 2;
|
||||
banner->textColour = TextColour::white;
|
||||
banner->flags = { BannerFlag::isLargeScenery };
|
||||
banner->type = 0;
|
||||
banner->position = TileCoordsXY(_loc);
|
||||
// Force ride construction to recheck area
|
||||
_currentTrackSelectionFlags.set(TrackSelectionFlag::recheck);
|
||||
|
||||
RideId rideIndex = BannerGetClosestRideIndex({ _loc, maxHeight });
|
||||
if (!rideIndex.IsNull())
|
||||
{
|
||||
banner->rideIndex = rideIndex;
|
||||
banner->flags.set(BannerFlag::linkedToRide);
|
||||
}
|
||||
res.Cost = sceneryEntry->price + supportsCost;
|
||||
res.SetData(std::move(resultData));
|
||||
|
||||
resultData.bannerId = banner->id;
|
||||
return res;
|
||||
}
|
||||
|
||||
for (auto& tile : sceneryEntry->tiles)
|
||||
Result LargeSceneryPlaceAction::Execute() const
|
||||
{
|
||||
auto curTile = CoordsXY{ tile.offset }.Rotate(_loc.direction);
|
||||
auto res = Result();
|
||||
res.ErrorTitle = STR_CANT_POSITION_THIS_HERE;
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
|
||||
curTile.x += _loc.x;
|
||||
curTile.y += _loc.y;
|
||||
int16_t surfaceHeight = TileElementHeight(_loc);
|
||||
res.Position.x = _loc.x + 16;
|
||||
res.Position.y = _loc.y + 16;
|
||||
res.Position.z = surfaceHeight;
|
||||
|
||||
int32_t zLow = tile.offset.z + maxHeight;
|
||||
int32_t zHigh = tile.zClearance + zLow;
|
||||
auto resultData = LargeSceneryPlaceActionResult{};
|
||||
|
||||
QuarterTile quarterTile = QuarterTile{ tile.corners, 0 }.Rotate(_loc.direction);
|
||||
const auto isTree = (sceneryEntry->flags & LARGE_SCENERY_FLAG_IS_TREE) != 0;
|
||||
auto canBuild = MapCanConstructWithClearAt(
|
||||
{ curTile, zLow, zHigh }, &MapPlaceSceneryClearFunc, quarterTile, GetFlags(), CreateCrossingMode::none, isTree);
|
||||
if (canBuild.Error != GameActions::Status::Ok)
|
||||
money64 supportsCost = 0;
|
||||
|
||||
auto* sceneryEntry = ObjectManager::GetObjectEntry<LargeSceneryEntry>(_sceneryType);
|
||||
if (sceneryEntry == nullptr)
|
||||
{
|
||||
LOG_ERROR("Large scenery entry not found for sceneryType = %u", _sceneryType);
|
||||
return Result(Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_UNKNOWN_OBJECT_TYPE);
|
||||
}
|
||||
|
||||
if (sceneryEntry->tiles.empty())
|
||||
{
|
||||
LOG_ERROR("Invalid large scenery object, sceneryType = %u", _sceneryType);
|
||||
return Result(Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, kStringIdNone);
|
||||
}
|
||||
|
||||
int16_t maxHeight = GetMaxSurfaceHeight(sceneryEntry->tiles);
|
||||
|
||||
if (_loc.z != 0)
|
||||
{
|
||||
maxHeight = _loc.z;
|
||||
}
|
||||
|
||||
res.Position.z = maxHeight;
|
||||
|
||||
// Allocate banner
|
||||
Banner* banner = nullptr;
|
||||
if (sceneryEntry->scrolling_mode != kScrollingModeNone)
|
||||
{
|
||||
banner = CreateBanner();
|
||||
if (banner == nullptr)
|
||||
{
|
||||
LOG_ERROR("No free banners available");
|
||||
return Result(Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_TOO_MANY_BANNERS_IN_GAME);
|
||||
}
|
||||
|
||||
banner->text = {};
|
||||
banner->colour = 2;
|
||||
banner->textColour = TextColour::white;
|
||||
banner->flags = { BannerFlag::isLargeScenery };
|
||||
banner->type = 0;
|
||||
banner->position = TileCoordsXY(_loc);
|
||||
|
||||
RideId rideIndex = BannerGetClosestRideIndex({ _loc, maxHeight });
|
||||
if (!rideIndex.IsNull())
|
||||
{
|
||||
banner->rideIndex = rideIndex;
|
||||
banner->flags.set(BannerFlag::linkedToRide);
|
||||
}
|
||||
|
||||
resultData.bannerId = banner->id;
|
||||
}
|
||||
|
||||
for (auto& tile : sceneryEntry->tiles)
|
||||
{
|
||||
auto curTile = CoordsXY{ tile.offset }.Rotate(_loc.direction);
|
||||
|
||||
curTile.x += _loc.x;
|
||||
curTile.y += _loc.y;
|
||||
|
||||
int32_t zLow = tile.offset.z + maxHeight;
|
||||
int32_t zHigh = tile.zClearance + zLow;
|
||||
|
||||
QuarterTile quarterTile = QuarterTile{ tile.corners, 0 }.Rotate(_loc.direction);
|
||||
const auto isTree = (sceneryEntry->flags & LARGE_SCENERY_FLAG_IS_TREE) != 0;
|
||||
auto canBuild = MapCanConstructWithClearAt(
|
||||
{ curTile, zLow, zHigh }, &MapPlaceSceneryClearFunc, quarterTile, GetFlags(), CreateCrossingMode::none, isTree);
|
||||
if (canBuild.Error != Status::Ok)
|
||||
{
|
||||
if (banner != nullptr)
|
||||
{
|
||||
DeleteBanner(banner->id);
|
||||
}
|
||||
canBuild.ErrorTitle = STR_CANT_POSITION_THIS_HERE;
|
||||
return canBuild;
|
||||
}
|
||||
|
||||
supportsCost += canBuild.Cost;
|
||||
|
||||
const auto clearanceData = canBuild.GetData<ConstructClearResult>();
|
||||
resultData.GroundFlags = clearanceData.GroundFlags & (ELEMENT_IS_ABOVE_GROUND | ELEMENT_IS_UNDERGROUND);
|
||||
|
||||
if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST))
|
||||
{
|
||||
FootpathRemoveLitter({ curTile, zLow });
|
||||
if (!getGameState().cheats.disableClearanceChecks)
|
||||
{
|
||||
WallRemoveAt({ curTile, zLow, zHigh });
|
||||
}
|
||||
}
|
||||
|
||||
auto* newSceneryElement = TileElementInsert<LargeSceneryElement>(
|
||||
CoordsXYZ{ curTile.x, curTile.y, zLow }, quarterTile.GetBaseQuarterOccupied());
|
||||
Guard::Assert(newSceneryElement != nullptr);
|
||||
newSceneryElement->SetClearanceZ(zHigh);
|
||||
|
||||
SetNewLargeSceneryElement(*newSceneryElement, tile.index);
|
||||
if (banner != nullptr)
|
||||
{
|
||||
DeleteBanner(banner->id);
|
||||
newSceneryElement->SetBannerIndex(banner->id);
|
||||
}
|
||||
canBuild.ErrorTitle = STR_CANT_POSITION_THIS_HERE;
|
||||
return canBuild;
|
||||
}
|
||||
|
||||
supportsCost += canBuild.Cost;
|
||||
MapAnimations::MarkTileForInvalidation(TileCoordsXY(curTile));
|
||||
MapInvalidateTileFull(curTile);
|
||||
|
||||
const auto clearanceData = canBuild.GetData<ConstructClearResult>();
|
||||
resultData.GroundFlags = clearanceData.GroundFlags & (ELEMENT_IS_ABOVE_GROUND | ELEMENT_IS_UNDERGROUND);
|
||||
|
||||
if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST))
|
||||
{
|
||||
FootpathRemoveLitter({ curTile, zLow });
|
||||
if (!getGameState().cheats.disableClearanceChecks)
|
||||
if (tile.index == 0)
|
||||
{
|
||||
WallRemoveAt({ curTile, zLow, zHigh });
|
||||
resultData.firstTileHeight = zLow;
|
||||
}
|
||||
}
|
||||
|
||||
auto* newSceneryElement = TileElementInsert<LargeSceneryElement>(
|
||||
CoordsXYZ{ curTile.x, curTile.y, zLow }, quarterTile.GetBaseQuarterOccupied());
|
||||
Guard::Assert(newSceneryElement != nullptr);
|
||||
newSceneryElement->SetClearanceZ(zHigh);
|
||||
// Force ride construction to recheck area
|
||||
_currentTrackSelectionFlags.set(TrackSelectionFlag::recheck);
|
||||
|
||||
SetNewLargeSceneryElement(*newSceneryElement, tile.index);
|
||||
if (banner != nullptr)
|
||||
{
|
||||
newSceneryElement->SetBannerIndex(banner->id);
|
||||
}
|
||||
res.Cost = sceneryEntry->price + supportsCost;
|
||||
res.SetData(std::move(resultData));
|
||||
|
||||
MapAnimations::MarkTileForInvalidation(TileCoordsXY(curTile));
|
||||
MapInvalidateTileFull(curTile);
|
||||
|
||||
if (tile.index == 0)
|
||||
{
|
||||
resultData.firstTileHeight = zLow;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
// Force ride construction to recheck area
|
||||
_currentTrackSelectionFlags.set(TrackSelectionFlag::recheck);
|
||||
|
||||
res.Cost = sceneryEntry->price + supportsCost;
|
||||
res.SetData(std::move(resultData));
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool LargeSceneryPlaceAction::CheckMapCapacity(std::span<const LargeSceneryTile> tiles, size_t numTiles) const
|
||||
{
|
||||
for (auto& tile : tiles)
|
||||
bool LargeSceneryPlaceAction::CheckMapCapacity(std::span<const LargeSceneryTile> tiles, size_t numTiles) const
|
||||
{
|
||||
auto curTile = CoordsXY{ tile.offset }.Rotate(_loc.direction);
|
||||
|
||||
curTile.x += _loc.x;
|
||||
curTile.y += _loc.y;
|
||||
if (!MapCheckCapacityAndReorganise(curTile, numTiles))
|
||||
for (auto& tile : tiles)
|
||||
{
|
||||
return false;
|
||||
auto curTile = CoordsXY{ tile.offset }.Rotate(_loc.direction);
|
||||
|
||||
curTile.x += _loc.x;
|
||||
curTile.y += _loc.y;
|
||||
if (!MapCheckCapacityAndReorganise(curTile, numTiles))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int16_t LargeSceneryPlaceAction::GetMaxSurfaceHeight(std::span<const LargeSceneryTile> tiles) const
|
||||
{
|
||||
int16_t maxHeight = -1;
|
||||
for (auto& tile : tiles)
|
||||
int16_t LargeSceneryPlaceAction::GetMaxSurfaceHeight(std::span<const LargeSceneryTile> tiles) const
|
||||
{
|
||||
auto curTile = CoordsXY{ tile.offset }.Rotate(_loc.direction);
|
||||
|
||||
curTile.x += _loc.x;
|
||||
curTile.y += _loc.y;
|
||||
|
||||
if (!MapIsLocationValid(curTile))
|
||||
int16_t maxHeight = -1;
|
||||
for (auto& tile : tiles)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
auto curTile = CoordsXY{ tile.offset }.Rotate(_loc.direction);
|
||||
|
||||
auto* surfaceElement = MapGetSurfaceElementAt(curTile);
|
||||
if (surfaceElement == nullptr)
|
||||
continue;
|
||||
curTile.x += _loc.x;
|
||||
curTile.y += _loc.y;
|
||||
|
||||
int32_t baseZ = surfaceElement->GetBaseZ();
|
||||
int32_t slope = surfaceElement->GetSlope();
|
||||
if (!MapIsLocationValid(curTile))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((slope & kTileSlopeRaisedCornersMask) != kTileSlopeFlat)
|
||||
{
|
||||
baseZ += kLandHeightStep;
|
||||
if (slope & kTileSlopeDiagonalFlag)
|
||||
auto* surfaceElement = MapGetSurfaceElementAt(curTile);
|
||||
if (surfaceElement == nullptr)
|
||||
continue;
|
||||
|
||||
int32_t baseZ = surfaceElement->GetBaseZ();
|
||||
int32_t slope = surfaceElement->GetSlope();
|
||||
|
||||
if ((slope & kTileSlopeRaisedCornersMask) != kTileSlopeFlat)
|
||||
{
|
||||
baseZ += kLandHeightStep;
|
||||
if (slope & kTileSlopeDiagonalFlag)
|
||||
{
|
||||
baseZ += kLandHeightStep;
|
||||
}
|
||||
}
|
||||
|
||||
if (baseZ > maxHeight)
|
||||
{
|
||||
maxHeight = baseZ;
|
||||
}
|
||||
}
|
||||
return maxHeight;
|
||||
}
|
||||
|
||||
if (baseZ > maxHeight)
|
||||
void LargeSceneryPlaceAction::SetNewLargeSceneryElement(LargeSceneryElement& sceneryElement, uint8_t tileNum) const
|
||||
{
|
||||
sceneryElement.SetDirection(_loc.direction);
|
||||
sceneryElement.SetEntryIndex(_sceneryType);
|
||||
sceneryElement.SetSequenceIndex(tileNum);
|
||||
sceneryElement.SetPrimaryColour(_primaryColour);
|
||||
sceneryElement.SetSecondaryColour(_secondaryColour);
|
||||
sceneryElement.SetTertiaryColour(_tertiaryColour);
|
||||
|
||||
if (GetFlags() & GAME_COMMAND_FLAG_GHOST)
|
||||
{
|
||||
maxHeight = baseZ;
|
||||
sceneryElement.SetGhost(true);
|
||||
}
|
||||
}
|
||||
return maxHeight;
|
||||
}
|
||||
|
||||
void LargeSceneryPlaceAction::SetNewLargeSceneryElement(LargeSceneryElement& sceneryElement, uint8_t tileNum) const
|
||||
{
|
||||
sceneryElement.SetDirection(_loc.direction);
|
||||
sceneryElement.SetEntryIndex(_sceneryType);
|
||||
sceneryElement.SetSequenceIndex(tileNum);
|
||||
sceneryElement.SetPrimaryColour(_primaryColour);
|
||||
sceneryElement.SetSecondaryColour(_secondaryColour);
|
||||
sceneryElement.SetTertiaryColour(_tertiaryColour);
|
||||
|
||||
if (GetFlags() & GAME_COMMAND_FLAG_GHOST)
|
||||
{
|
||||
sceneryElement.SetGhost(true);
|
||||
}
|
||||
}
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -11,45 +11,48 @@
|
||||
|
||||
#include "GameAction.h"
|
||||
|
||||
struct LargeSceneryPlaceActionResult
|
||||
{
|
||||
uint8_t GroundFlags{ 0 };
|
||||
int32_t firstTileHeight{ 0 };
|
||||
BannerIndex bannerId = BannerIndex::GetNull();
|
||||
};
|
||||
|
||||
namespace OpenRCT2
|
||||
{
|
||||
struct LargeSceneryTile;
|
||||
struct LargeSceneryElement;
|
||||
} // namespace OpenRCT2
|
||||
|
||||
class LargeSceneryPlaceAction final : public GameActionBase<GameCommand::PlaceLargeScenery>
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
private:
|
||||
CoordsXYZD _loc;
|
||||
OpenRCT2::ObjectEntryIndex _sceneryType{ OpenRCT2::kObjectEntryIndexNull };
|
||||
uint8_t _primaryColour{};
|
||||
uint8_t _secondaryColour{};
|
||||
uint8_t _tertiaryColour{};
|
||||
struct LargeSceneryPlaceActionResult
|
||||
{
|
||||
uint8_t GroundFlags{ 0 };
|
||||
int32_t firstTileHeight{ 0 };
|
||||
BannerIndex bannerId = BannerIndex::GetNull();
|
||||
};
|
||||
|
||||
public:
|
||||
LargeSceneryPlaceAction() = default;
|
||||
class LargeSceneryPlaceAction final : public GameActionBase<GameCommand::PlaceLargeScenery>
|
||||
{
|
||||
private:
|
||||
CoordsXYZD _loc;
|
||||
ObjectEntryIndex _sceneryType{ kObjectEntryIndexNull };
|
||||
uint8_t _primaryColour{};
|
||||
uint8_t _secondaryColour{};
|
||||
uint8_t _tertiaryColour{};
|
||||
|
||||
LargeSceneryPlaceAction(
|
||||
const CoordsXYZD& loc, OpenRCT2::ObjectEntryIndex sceneryType, uint8_t primaryColour, uint8_t secondaryColour,
|
||||
uint8_t tertiaryColour);
|
||||
public:
|
||||
LargeSceneryPlaceAction() = default;
|
||||
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
LargeSceneryPlaceAction(
|
||||
const CoordsXYZD& loc, ObjectEntryIndex sceneryType, uint8_t primaryColour, uint8_t secondaryColour,
|
||||
uint8_t tertiaryColour);
|
||||
|
||||
uint16_t GetActionFlags() const override;
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
OpenRCT2::GameActions::Result Query() const override;
|
||||
OpenRCT2::GameActions::Result Execute() const override;
|
||||
uint16_t GetActionFlags() const override;
|
||||
|
||||
private:
|
||||
bool CheckMapCapacity(std::span<const OpenRCT2::LargeSceneryTile> tiles, size_t numTiles) const;
|
||||
int16_t GetMaxSurfaceHeight(std::span<const OpenRCT2::LargeSceneryTile> tiles) const;
|
||||
void SetNewLargeSceneryElement(OpenRCT2::LargeSceneryElement& sceneryElement, uint8_t tileNum) const;
|
||||
};
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
Result Query() const override;
|
||||
Result Execute() const override;
|
||||
|
||||
private:
|
||||
bool CheckMapCapacity(std::span<const LargeSceneryTile> tiles, size_t numTiles) const;
|
||||
int16_t GetMaxSurfaceHeight(std::span<const LargeSceneryTile> tiles) const;
|
||||
void SetNewLargeSceneryElement(LargeSceneryElement& sceneryElement, uint8_t tileNum) const;
|
||||
};
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -22,197 +22,196 @@
|
||||
#include "../world/TileElementsView.h"
|
||||
#include "../world/tile_element/LargeSceneryElement.h"
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
LargeSceneryRemoveAction::LargeSceneryRemoveAction(const CoordsXYZD& location, uint16_t tileIndex)
|
||||
: _loc(location)
|
||||
, _tileIndex(tileIndex)
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
}
|
||||
|
||||
void LargeSceneryRemoveAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
visitor.Visit(_loc);
|
||||
visitor.Visit("tileIndex", _tileIndex);
|
||||
}
|
||||
|
||||
uint16_t LargeSceneryRemoveAction::GetActionFlags() const
|
||||
{
|
||||
return GameAction::GetActionFlags();
|
||||
}
|
||||
|
||||
void LargeSceneryRemoveAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_loc) << DS_TAG(_tileIndex);
|
||||
}
|
||||
|
||||
GameActions::Result LargeSceneryRemoveAction::Query() const
|
||||
{
|
||||
auto res = GameActions::Result();
|
||||
|
||||
const uint32_t flags = GetFlags();
|
||||
|
||||
res.Position.x = _loc.x + 16;
|
||||
res.Position.y = _loc.y + 16;
|
||||
res.Position.z = _loc.z;
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
res.Cost = 0;
|
||||
|
||||
TileElement* tileElement = FindLargeSceneryElement(_loc, _tileIndex);
|
||||
if (tileElement == nullptr)
|
||||
LargeSceneryRemoveAction::LargeSceneryRemoveAction(const CoordsXYZD& location, uint16_t tileIndex)
|
||||
: _loc(location)
|
||||
, _tileIndex(tileIndex)
|
||||
{
|
||||
LOG_ERROR("No large scenery element to remove at x = %d, y = %d", _loc.x, _loc.y);
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS);
|
||||
}
|
||||
|
||||
auto* sceneryEntry = tileElement->AsLargeScenery()->GetEntry();
|
||||
// If we have a bugged scenery entry, do not touch the tile element.
|
||||
if (sceneryEntry == nullptr)
|
||||
void LargeSceneryRemoveAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
LOG_WARNING("Scenery entry at x = %d, y = %d not removed because it is an unknown object type", _loc.x, _loc.y);
|
||||
return GameActions::Result(GameActions::Status::Unknown, STR_CANT_REMOVE_THIS, STR_UNKNOWN_OBJECT_TYPE);
|
||||
visitor.Visit(_loc);
|
||||
visitor.Visit("tileIndex", _tileIndex);
|
||||
}
|
||||
|
||||
auto rotatedOffsets = CoordsXYZ{ CoordsXY{ sceneryEntry->tiles[_tileIndex].offset }.Rotate(_loc.direction),
|
||||
sceneryEntry->tiles[_tileIndex].offset.z };
|
||||
|
||||
auto firstTile = CoordsXYZ{ _loc.x, _loc.y, _loc.z } - rotatedOffsets;
|
||||
|
||||
bool calculate_cost = true;
|
||||
for (auto& tile : sceneryEntry->tiles)
|
||||
uint16_t LargeSceneryRemoveAction::GetActionFlags() const
|
||||
{
|
||||
auto currentTileRotatedOffset = CoordsXYZ{ CoordsXY{ tile.offset }.Rotate(_loc.direction), tile.offset.z };
|
||||
return GameAction::GetActionFlags();
|
||||
}
|
||||
|
||||
auto currentTile = CoordsXYZ{ firstTile.x, firstTile.y, firstTile.z } + currentTileRotatedOffset;
|
||||
void LargeSceneryRemoveAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
if (gLegacyScene != LegacyScene::scenarioEditor && !getGameState().cheats.sandboxMode)
|
||||
stream << DS_TAG(_loc) << DS_TAG(_tileIndex);
|
||||
}
|
||||
|
||||
Result LargeSceneryRemoveAction::Query() const
|
||||
{
|
||||
auto res = Result();
|
||||
|
||||
const uint32_t flags = GetFlags();
|
||||
|
||||
res.Position.x = _loc.x + 16;
|
||||
res.Position.y = _loc.y + 16;
|
||||
res.Position.z = _loc.z;
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
res.Cost = 0;
|
||||
|
||||
TileElement* tileElement = FindLargeSceneryElement(_loc, _tileIndex);
|
||||
if (tileElement == nullptr)
|
||||
{
|
||||
if (getGameState().park.flags & PARK_FLAGS_FORBID_TREE_REMOVAL)
|
||||
LOG_ERROR("No large scenery element to remove at x = %d, y = %d", _loc.x, _loc.y);
|
||||
return Result(Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS);
|
||||
}
|
||||
|
||||
auto* sceneryEntry = tileElement->AsLargeScenery()->GetEntry();
|
||||
// If we have a bugged scenery entry, do not touch the tile element.
|
||||
if (sceneryEntry == nullptr)
|
||||
{
|
||||
LOG_WARNING("Scenery entry at x = %d, y = %d not removed because it is an unknown object type", _loc.x, _loc.y);
|
||||
return Result(Status::Unknown, STR_CANT_REMOVE_THIS, STR_UNKNOWN_OBJECT_TYPE);
|
||||
}
|
||||
|
||||
auto rotatedOffsets = CoordsXYZ{ CoordsXY{ sceneryEntry->tiles[_tileIndex].offset }.Rotate(_loc.direction),
|
||||
sceneryEntry->tiles[_tileIndex].offset.z };
|
||||
|
||||
auto firstTile = CoordsXYZ{ _loc.x, _loc.y, _loc.z } - rotatedOffsets;
|
||||
|
||||
bool calculate_cost = true;
|
||||
for (auto& tile : sceneryEntry->tiles)
|
||||
{
|
||||
auto currentTileRotatedOffset = CoordsXYZ{ CoordsXY{ tile.offset }.Rotate(_loc.direction), tile.offset.z };
|
||||
|
||||
auto currentTile = CoordsXYZ{ firstTile.x, firstTile.y, firstTile.z } + currentTileRotatedOffset;
|
||||
|
||||
if (gLegacyScene != LegacyScene::scenarioEditor && !getGameState().cheats.sandboxMode)
|
||||
{
|
||||
if (sceneryEntry->HasFlag(LARGE_SCENERY_FLAG_IS_TREE))
|
||||
if (getGameState().park.flags & PARK_FLAGS_FORBID_TREE_REMOVAL)
|
||||
{
|
||||
res.Error = GameActions::Status::NoClearance;
|
||||
res.ErrorTitle = STR_CANT_REMOVE_THIS;
|
||||
res.ErrorMessage = STR_FORBIDDEN_BY_THE_LOCAL_AUTHORITY;
|
||||
return res;
|
||||
if (sceneryEntry->HasFlag(LARGE_SCENERY_FLAG_IS_TREE))
|
||||
{
|
||||
res.Error = Status::NoClearance;
|
||||
res.ErrorTitle = STR_CANT_REMOVE_THIS;
|
||||
res.ErrorMessage = STR_FORBIDDEN_BY_THE_LOCAL_AUTHORITY;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
if (!MapIsLocationOwned({ currentTile.x, currentTile.y, currentTile.z }))
|
||||
{
|
||||
return Result(Status::NoClearance, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
}
|
||||
}
|
||||
|
||||
if (!MapIsLocationOwned({ currentTile.x, currentTile.y, currentTile.z }))
|
||||
if (!LocationValid(currentTile))
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::NoClearance, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
return Result(Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_OFF_EDGE_OF_MAP);
|
||||
}
|
||||
// Prevent duplicate costs when using the clear scenery tool that overlaps multiple large
|
||||
// scenery tile elements.
|
||||
if (flags & GAME_COMMAND_FLAG_TRACK_DESIGN)
|
||||
{
|
||||
if (tileElement->AsLargeScenery()->IsAccounted())
|
||||
calculate_cost = false;
|
||||
|
||||
// Sets the flag to prevent this being counted in additional calls
|
||||
tileElement->AsLargeScenery()->SetIsAccounted(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (!LocationValid(currentTile))
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_OFF_EDGE_OF_MAP);
|
||||
}
|
||||
// Prevent duplicate costs when using the clear scenery tool that overlaps multiple large
|
||||
// scenery tile elements.
|
||||
if (flags & GAME_COMMAND_FLAG_TRACK_DESIGN)
|
||||
{
|
||||
if (tileElement->AsLargeScenery()->IsAccounted())
|
||||
calculate_cost = false;
|
||||
if (calculate_cost)
|
||||
res.Cost = sceneryEntry->removal_price;
|
||||
|
||||
// Sets the flag to prevent this being counted in additional calls
|
||||
tileElement->AsLargeScenery()->SetIsAccounted(true);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
if (calculate_cost)
|
||||
Result LargeSceneryRemoveAction::Execute() const
|
||||
{
|
||||
auto res = Result();
|
||||
|
||||
res.Position.x = _loc.x + 16;
|
||||
res.Position.y = _loc.y + 16;
|
||||
res.Position.z = _loc.z;
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
res.Cost = 0;
|
||||
|
||||
TileElement* tileElement = FindLargeSceneryElement(_loc, _tileIndex);
|
||||
if (tileElement == nullptr)
|
||||
{
|
||||
LOG_ERROR("No large scenery element to remove at %d, y = %d", _loc.x, _loc.y);
|
||||
return Result(Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS);
|
||||
}
|
||||
|
||||
auto* sceneryEntry = tileElement->AsLargeScenery()->GetEntry();
|
||||
// If we have a bugged scenery entry, do not touch the tile element.
|
||||
if (sceneryEntry == nullptr)
|
||||
{
|
||||
LOG_WARNING("Scenery entry at x = %d, y = %d not removed because it is an unknown object type", _loc.x, _loc.y);
|
||||
return Result(Status::Unknown, STR_CANT_REMOVE_THIS, kStringIdNone);
|
||||
}
|
||||
|
||||
tileElement->RemoveBannerEntry();
|
||||
|
||||
auto rotatedFirstTile = CoordsXYZ{ CoordsXY{ sceneryEntry->tiles[_tileIndex].offset }.Rotate(_loc.direction),
|
||||
sceneryEntry->tiles[_tileIndex].offset.z };
|
||||
|
||||
auto firstTile = CoordsXYZ{ _loc.x, _loc.y, _loc.z } - rotatedFirstTile;
|
||||
|
||||
for (auto& tile : sceneryEntry->tiles)
|
||||
{
|
||||
auto rotatedCurrentTile = CoordsXYZ{ CoordsXY{ tile.offset }.Rotate(_loc.direction), tile.offset.z };
|
||||
|
||||
auto currentTile = CoordsXYZ{ firstTile.x, firstTile.y, firstTile.z } + rotatedCurrentTile;
|
||||
|
||||
if (gLegacyScene != LegacyScene::scenarioEditor && !getGameState().cheats.sandboxMode)
|
||||
{
|
||||
if (!MapIsLocationOwned({ currentTile.x, currentTile.y, currentTile.z }))
|
||||
{
|
||||
return Result(Status::NoClearance, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
}
|
||||
}
|
||||
|
||||
auto* sceneryElement = FindLargeSceneryElement(currentTile, tile.index);
|
||||
if (sceneryElement == nullptr)
|
||||
{
|
||||
LOG_ERROR("Tile not found when trying to remove element!");
|
||||
}
|
||||
else
|
||||
{
|
||||
MapInvalidateTileFull(currentTile);
|
||||
TileElementRemove(sceneryElement);
|
||||
}
|
||||
}
|
||||
|
||||
res.Cost = sceneryEntry->removal_price;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
GameActions::Result LargeSceneryRemoveAction::Execute() const
|
||||
{
|
||||
auto res = GameActions::Result();
|
||||
|
||||
res.Position.x = _loc.x + 16;
|
||||
res.Position.y = _loc.y + 16;
|
||||
res.Position.z = _loc.z;
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
res.Cost = 0;
|
||||
|
||||
TileElement* tileElement = FindLargeSceneryElement(_loc, _tileIndex);
|
||||
if (tileElement == nullptr)
|
||||
{
|
||||
LOG_ERROR("No large scenery element to remove at %d, y = %d", _loc.x, _loc.y);
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS);
|
||||
return res;
|
||||
}
|
||||
|
||||
auto* sceneryEntry = tileElement->AsLargeScenery()->GetEntry();
|
||||
// If we have a bugged scenery entry, do not touch the tile element.
|
||||
if (sceneryEntry == nullptr)
|
||||
TileElement* LargeSceneryRemoveAction::FindLargeSceneryElement(const CoordsXYZ& pos, int32_t sequenceIndex) const
|
||||
{
|
||||
LOG_WARNING("Scenery entry at x = %d, y = %d not removed because it is an unknown object type", _loc.x, _loc.y);
|
||||
return GameActions::Result(GameActions::Status::Unknown, STR_CANT_REMOVE_THIS, kStringIdNone);
|
||||
}
|
||||
|
||||
tileElement->RemoveBannerEntry();
|
||||
|
||||
auto rotatedFirstTile = CoordsXYZ{ CoordsXY{ sceneryEntry->tiles[_tileIndex].offset }.Rotate(_loc.direction),
|
||||
sceneryEntry->tiles[_tileIndex].offset.z };
|
||||
|
||||
auto firstTile = CoordsXYZ{ _loc.x, _loc.y, _loc.z } - rotatedFirstTile;
|
||||
|
||||
for (auto& tile : sceneryEntry->tiles)
|
||||
{
|
||||
auto rotatedCurrentTile = CoordsXYZ{ CoordsXY{ tile.offset }.Rotate(_loc.direction), tile.offset.z };
|
||||
|
||||
auto currentTile = CoordsXYZ{ firstTile.x, firstTile.y, firstTile.z } + rotatedCurrentTile;
|
||||
|
||||
if (gLegacyScene != LegacyScene::scenarioEditor && !getGameState().cheats.sandboxMode)
|
||||
const bool isGhost = GetFlags() & GAME_COMMAND_FLAG_GHOST;
|
||||
for (auto* sceneryElement : TileElementsView<LargeSceneryElement>(pos))
|
||||
{
|
||||
if (!MapIsLocationOwned({ currentTile.x, currentTile.y, currentTile.z }))
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::NoClearance, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
}
|
||||
// If we are removing ghost elements
|
||||
if (isGhost && sceneryElement->IsGhost() == false)
|
||||
continue;
|
||||
|
||||
if (sceneryElement->GetDirection() != _loc.direction)
|
||||
continue;
|
||||
|
||||
if (sceneryElement->GetSequenceIndex() != sequenceIndex)
|
||||
continue;
|
||||
|
||||
if (sceneryElement->GetBaseZ() != pos.z)
|
||||
continue;
|
||||
|
||||
return sceneryElement->as<TileElement>();
|
||||
}
|
||||
|
||||
auto* sceneryElement = FindLargeSceneryElement(currentTile, tile.index);
|
||||
if (sceneryElement == nullptr)
|
||||
{
|
||||
LOG_ERROR("Tile not found when trying to remove element!");
|
||||
}
|
||||
else
|
||||
{
|
||||
MapInvalidateTileFull(currentTile);
|
||||
TileElementRemove(sceneryElement);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
res.Cost = sceneryEntry->removal_price;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
TileElement* LargeSceneryRemoveAction::FindLargeSceneryElement(const CoordsXYZ& pos, int32_t sequenceIndex) const
|
||||
{
|
||||
const bool isGhost = GetFlags() & GAME_COMMAND_FLAG_GHOST;
|
||||
for (auto* sceneryElement : TileElementsView<LargeSceneryElement>(pos))
|
||||
{
|
||||
// If we are removing ghost elements
|
||||
if (isGhost && sceneryElement->IsGhost() == false)
|
||||
continue;
|
||||
|
||||
if (sceneryElement->GetDirection() != _loc.direction)
|
||||
continue;
|
||||
|
||||
if (sceneryElement->GetSequenceIndex() != sequenceIndex)
|
||||
continue;
|
||||
|
||||
if (sceneryElement->GetBaseZ() != pos.z)
|
||||
continue;
|
||||
|
||||
return sceneryElement->as<TileElement>();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -11,24 +11,27 @@
|
||||
|
||||
#include "GameAction.h"
|
||||
|
||||
class LargeSceneryRemoveAction final : public GameActionBase<GameCommand::RemoveLargeScenery>
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
private:
|
||||
CoordsXYZD _loc;
|
||||
uint16_t _tileIndex{};
|
||||
class LargeSceneryRemoveAction final : public GameActionBase<GameCommand::RemoveLargeScenery>
|
||||
{
|
||||
private:
|
||||
CoordsXYZD _loc;
|
||||
uint16_t _tileIndex{};
|
||||
|
||||
public:
|
||||
LargeSceneryRemoveAction() = default;
|
||||
LargeSceneryRemoveAction(const CoordsXYZD& location, uint16_t tileIndex);
|
||||
public:
|
||||
LargeSceneryRemoveAction() = default;
|
||||
LargeSceneryRemoveAction(const CoordsXYZD& location, uint16_t tileIndex);
|
||||
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
|
||||
uint16_t GetActionFlags() const override;
|
||||
uint16_t GetActionFlags() const override;
|
||||
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
OpenRCT2::GameActions::Result Query() const override;
|
||||
OpenRCT2::GameActions::Result Execute() const override;
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
Result Query() const override;
|
||||
Result Execute() const override;
|
||||
|
||||
private:
|
||||
OpenRCT2::TileElement* FindLargeSceneryElement(const CoordsXYZ& pos, int32_t sequenceIndex) const;
|
||||
};
|
||||
private:
|
||||
TileElement* FindLargeSceneryElement(const CoordsXYZ& pos, int32_t sequenceIndex) const;
|
||||
};
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -17,146 +17,147 @@
|
||||
#include "../world/Scenery.h"
|
||||
#include "../world/tile_element/LargeSceneryElement.h"
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
LargeScenerySetColourAction::LargeScenerySetColourAction(
|
||||
const CoordsXYZD& loc, uint8_t tileIndex, uint8_t primaryColour, uint8_t secondaryColour, uint8_t tertiaryColour)
|
||||
: _loc(loc)
|
||||
, _tileIndex(tileIndex)
|
||||
, _primaryColour(primaryColour)
|
||||
, _secondaryColour(secondaryColour)
|
||||
, _tertiaryColour(tertiaryColour)
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
}
|
||||
|
||||
void LargeScenerySetColourAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
visitor.Visit(_loc);
|
||||
visitor.Visit("tileIndex", _tileIndex);
|
||||
visitor.Visit("primaryColour", _primaryColour);
|
||||
visitor.Visit("secondaryColour", _secondaryColour);
|
||||
visitor.Visit("tertiaryColour", _tertiaryColour);
|
||||
}
|
||||
|
||||
uint16_t LargeScenerySetColourAction::GetActionFlags() const
|
||||
{
|
||||
return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused;
|
||||
}
|
||||
|
||||
void LargeScenerySetColourAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_loc) << DS_TAG(_tileIndex) << DS_TAG(_primaryColour) << DS_TAG(_secondaryColour)
|
||||
<< DS_TAG(_tertiaryColour);
|
||||
}
|
||||
|
||||
GameActions::Result LargeScenerySetColourAction::Query() const
|
||||
{
|
||||
return QueryExecute(false);
|
||||
}
|
||||
|
||||
GameActions::Result LargeScenerySetColourAction::Execute() const
|
||||
{
|
||||
return QueryExecute(true);
|
||||
}
|
||||
|
||||
GameActions::Result LargeScenerySetColourAction::QueryExecute(bool isExecuting) const
|
||||
{
|
||||
auto res = GameActions::Result();
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
res.Position.x = _loc.x + 16;
|
||||
res.Position.y = _loc.y + 16;
|
||||
res.Position.z = TileElementHeight(_loc);
|
||||
res.ErrorTitle = STR_CANT_REPAINT_THIS;
|
||||
|
||||
auto mapSizeMax = GetMapSizeMaxXY();
|
||||
if (_loc.x < 0 || _loc.y < 0 || _loc.x > mapSizeMax.x || _loc.y > mapSizeMax.y)
|
||||
LargeScenerySetColourAction::LargeScenerySetColourAction(
|
||||
const CoordsXYZD& loc, uint8_t tileIndex, uint8_t primaryColour, uint8_t secondaryColour, uint8_t tertiaryColour)
|
||||
: _loc(loc)
|
||||
, _tileIndex(tileIndex)
|
||||
, _primaryColour(primaryColour)
|
||||
, _secondaryColour(secondaryColour)
|
||||
, _tertiaryColour(tertiaryColour)
|
||||
{
|
||||
LOG_ERROR("Invalid x / y coordinates: x = %d, y = %d", _loc.x, _loc.y);
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_REPAINT_THIS, STR_ERR_VALUE_OUT_OF_RANGE);
|
||||
}
|
||||
|
||||
if (_primaryColour >= COLOUR_COUNT)
|
||||
void LargeScenerySetColourAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
LOG_ERROR("Invalid primary colour %u", _primaryColour);
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_REPAINT_THIS, STR_ERR_INVALID_COLOUR);
|
||||
}
|
||||
else if (_secondaryColour >= COLOUR_COUNT)
|
||||
{
|
||||
LOG_ERROR("Invalid secondary colour %u", _secondaryColour);
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_REPAINT_THIS, STR_ERR_INVALID_COLOUR);
|
||||
}
|
||||
else if (_tertiaryColour >= COLOUR_COUNT)
|
||||
{
|
||||
LOG_ERROR("Invalid tertiary colour %u", _tertiaryColour);
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_REPAINT_THIS, STR_ERR_INVALID_COLOUR);
|
||||
visitor.Visit(_loc);
|
||||
visitor.Visit("tileIndex", _tileIndex);
|
||||
visitor.Visit("primaryColour", _primaryColour);
|
||||
visitor.Visit("secondaryColour", _secondaryColour);
|
||||
visitor.Visit("tertiaryColour", _tertiaryColour);
|
||||
}
|
||||
|
||||
auto largeElement = MapGetLargeScenerySegment(_loc, _tileIndex);
|
||||
|
||||
if (largeElement == nullptr)
|
||||
uint16_t LargeScenerySetColourAction::GetActionFlags() const
|
||||
{
|
||||
LOG_ERROR(
|
||||
"Could not find large scenery at: x = %d, y = %d, z = %d, direction = %d, tileIndex = %u", _loc.x, _loc.y, _loc.z,
|
||||
_loc.direction, _tileIndex);
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_REPAINT_THIS, kStringIdNone);
|
||||
return GameAction::GetActionFlags() | Flags::AllowWhilePaused;
|
||||
}
|
||||
|
||||
if ((GetFlags() & GAME_COMMAND_FLAG_GHOST) && !(largeElement->IsGhost()))
|
||||
void LargeScenerySetColourAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
return res;
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_loc) << DS_TAG(_tileIndex) << DS_TAG(_primaryColour) << DS_TAG(_secondaryColour)
|
||||
<< DS_TAG(_tertiaryColour);
|
||||
}
|
||||
|
||||
auto* sceneryEntry = largeElement->GetEntry();
|
||||
|
||||
if (sceneryEntry == nullptr)
|
||||
Result LargeScenerySetColourAction::Query() const
|
||||
{
|
||||
LOG_ERROR("Scenery element doesn't have scenery entry");
|
||||
return GameActions::Result(GameActions::Status::Unknown, STR_CANT_REPAINT_THIS, kStringIdNone);
|
||||
return QueryExecute(false);
|
||||
}
|
||||
// Work out the base tile coordinates (Tile with index 0)
|
||||
auto rotatedBaseCoordsOffset = CoordsXYZ{ CoordsXY{ sceneryEntry->tiles[_tileIndex].offset }.Rotate(_loc.direction),
|
||||
sceneryEntry->tiles[_tileIndex].offset.z };
|
||||
|
||||
auto baseTile = CoordsXYZ{ _loc.x, _loc.y, _loc.z } - rotatedBaseCoordsOffset;
|
||||
|
||||
for (auto& tile : sceneryEntry->tiles)
|
||||
Result LargeScenerySetColourAction::Execute() const
|
||||
{
|
||||
// Work out the current tile coordinates
|
||||
auto rotatedTileCoords = CoordsXYZ{ CoordsXY{ tile.offset }.Rotate(_loc.direction), tile.offset.z };
|
||||
auto currentTile = CoordsXYZ{ baseTile.x, baseTile.y, baseTile.z } + rotatedTileCoords;
|
||||
return QueryExecute(true);
|
||||
}
|
||||
|
||||
if (gLegacyScene != LegacyScene::scenarioEditor && !getGameState().cheats.sandboxMode)
|
||||
Result LargeScenerySetColourAction::QueryExecute(bool isExecuting) const
|
||||
{
|
||||
auto res = Result();
|
||||
res.Expenditure = ExpenditureType::landscaping;
|
||||
res.Position.x = _loc.x + 16;
|
||||
res.Position.y = _loc.y + 16;
|
||||
res.Position.z = TileElementHeight(_loc);
|
||||
res.ErrorTitle = STR_CANT_REPAINT_THIS;
|
||||
|
||||
auto mapSizeMax = GetMapSizeMaxXY();
|
||||
if (_loc.x < 0 || _loc.y < 0 || _loc.x > mapSizeMax.x || _loc.y > mapSizeMax.y)
|
||||
{
|
||||
if (!MapIsLocationOwned(currentTile))
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::NotOwned, STR_CANT_REPAINT_THIS, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
}
|
||||
LOG_ERROR("Invalid x / y coordinates: x = %d, y = %d", _loc.x, _loc.y);
|
||||
return Result(Status::InvalidParameters, STR_CANT_REPAINT_THIS, STR_ERR_VALUE_OUT_OF_RANGE);
|
||||
}
|
||||
|
||||
if (!LocationValid(currentTile))
|
||||
if (_primaryColour >= COLOUR_COUNT)
|
||||
{
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_REPAINT_THIS, STR_OFF_EDGE_OF_MAP);
|
||||
LOG_ERROR("Invalid primary colour %u", _primaryColour);
|
||||
return Result(Status::InvalidParameters, STR_CANT_REPAINT_THIS, STR_ERR_INVALID_COLOUR);
|
||||
}
|
||||
else if (_secondaryColour >= COLOUR_COUNT)
|
||||
{
|
||||
LOG_ERROR("Invalid secondary colour %u", _secondaryColour);
|
||||
return Result(Status::InvalidParameters, STR_CANT_REPAINT_THIS, STR_ERR_INVALID_COLOUR);
|
||||
}
|
||||
else if (_tertiaryColour >= COLOUR_COUNT)
|
||||
{
|
||||
LOG_ERROR("Invalid tertiary colour %u", _tertiaryColour);
|
||||
return Result(Status::InvalidParameters, STR_CANT_REPAINT_THIS, STR_ERR_INVALID_COLOUR);
|
||||
}
|
||||
|
||||
auto tileElement = MapGetLargeScenerySegment({ currentTile.x, currentTile.y, _loc.z, _loc.direction }, tile.index);
|
||||
auto largeElement = MapGetLargeScenerySegment(_loc, _tileIndex);
|
||||
|
||||
if (tileElement == nullptr)
|
||||
if (largeElement == nullptr)
|
||||
{
|
||||
LOG_ERROR(
|
||||
"Large scenery element not found at: x = %d, y = %d, z = %d, direction = %d", _loc.x, _loc.y, _loc.z,
|
||||
_loc.direction);
|
||||
return GameActions::Result(GameActions::Status::Unknown, STR_CANT_REPAINT_THIS, kStringIdNone);
|
||||
"Could not find large scenery at: x = %d, y = %d, z = %d, direction = %d, tileIndex = %u", _loc.x, _loc.y,
|
||||
_loc.z, _loc.direction, _tileIndex);
|
||||
return Result(Status::InvalidParameters, STR_CANT_REPAINT_THIS, kStringIdNone);
|
||||
}
|
||||
if (isExecuting)
|
||||
{
|
||||
tileElement->SetPrimaryColour(_primaryColour);
|
||||
tileElement->SetSecondaryColour(_secondaryColour);
|
||||
tileElement->SetTertiaryColour(_tertiaryColour);
|
||||
|
||||
MapInvalidateTileFull(currentTile);
|
||||
if ((GetFlags() & GAME_COMMAND_FLAG_GHOST) && !(largeElement->IsGhost()))
|
||||
{
|
||||
return res;
|
||||
}
|
||||
|
||||
auto* sceneryEntry = largeElement->GetEntry();
|
||||
|
||||
if (sceneryEntry == nullptr)
|
||||
{
|
||||
LOG_ERROR("Scenery element doesn't have scenery entry");
|
||||
return Result(Status::Unknown, STR_CANT_REPAINT_THIS, kStringIdNone);
|
||||
}
|
||||
// Work out the base tile coordinates (Tile with index 0)
|
||||
auto rotatedBaseCoordsOffset = CoordsXYZ{ CoordsXY{ sceneryEntry->tiles[_tileIndex].offset }.Rotate(_loc.direction),
|
||||
sceneryEntry->tiles[_tileIndex].offset.z };
|
||||
|
||||
auto baseTile = CoordsXYZ{ _loc.x, _loc.y, _loc.z } - rotatedBaseCoordsOffset;
|
||||
|
||||
for (auto& tile : sceneryEntry->tiles)
|
||||
{
|
||||
// Work out the current tile coordinates
|
||||
auto rotatedTileCoords = CoordsXYZ{ CoordsXY{ tile.offset }.Rotate(_loc.direction), tile.offset.z };
|
||||
auto currentTile = CoordsXYZ{ baseTile.x, baseTile.y, baseTile.z } + rotatedTileCoords;
|
||||
|
||||
if (gLegacyScene != LegacyScene::scenarioEditor && !getGameState().cheats.sandboxMode)
|
||||
{
|
||||
if (!MapIsLocationOwned(currentTile))
|
||||
{
|
||||
return Result(Status::NotOwned, STR_CANT_REPAINT_THIS, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
}
|
||||
}
|
||||
|
||||
if (!LocationValid(currentTile))
|
||||
{
|
||||
return Result(Status::InvalidParameters, STR_CANT_REPAINT_THIS, STR_OFF_EDGE_OF_MAP);
|
||||
}
|
||||
|
||||
auto tileElement = MapGetLargeScenerySegment({ currentTile.x, currentTile.y, _loc.z, _loc.direction }, tile.index);
|
||||
|
||||
if (tileElement == nullptr)
|
||||
{
|
||||
LOG_ERROR(
|
||||
"Large scenery element not found at: x = %d, y = %d, z = %d, direction = %d", _loc.x, _loc.y, _loc.z,
|
||||
_loc.direction);
|
||||
return Result(Status::Unknown, STR_CANT_REPAINT_THIS, kStringIdNone);
|
||||
}
|
||||
if (isExecuting)
|
||||
{
|
||||
tileElement->SetPrimaryColour(_primaryColour);
|
||||
tileElement->SetSecondaryColour(_secondaryColour);
|
||||
tileElement->SetTertiaryColour(_tertiaryColour);
|
||||
|
||||
MapInvalidateTileFull(currentTile);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -11,28 +11,31 @@
|
||||
|
||||
#include "GameAction.h"
|
||||
|
||||
class LargeScenerySetColourAction final : public GameActionBase<GameCommand::SetLargeSceneryColour>
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
private:
|
||||
CoordsXYZD _loc;
|
||||
uint8_t _tileIndex{};
|
||||
uint8_t _primaryColour{};
|
||||
uint8_t _secondaryColour{};
|
||||
uint8_t _tertiaryColour{};
|
||||
class LargeScenerySetColourAction final : public GameActionBase<GameCommand::SetLargeSceneryColour>
|
||||
{
|
||||
private:
|
||||
CoordsXYZD _loc;
|
||||
uint8_t _tileIndex{};
|
||||
uint8_t _primaryColour{};
|
||||
uint8_t _secondaryColour{};
|
||||
uint8_t _tertiaryColour{};
|
||||
|
||||
public:
|
||||
LargeScenerySetColourAction() = default;
|
||||
LargeScenerySetColourAction(
|
||||
const CoordsXYZD& loc, uint8_t tileIndex, uint8_t primaryColour, uint8_t secondaryColour, uint8_t tertiaryColour);
|
||||
public:
|
||||
LargeScenerySetColourAction() = default;
|
||||
LargeScenerySetColourAction(
|
||||
const CoordsXYZD& loc, uint8_t tileIndex, uint8_t primaryColour, uint8_t secondaryColour, uint8_t tertiaryColour);
|
||||
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
|
||||
uint16_t GetActionFlags() const override;
|
||||
uint16_t GetActionFlags() const override;
|
||||
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
OpenRCT2::GameActions::Result Query() const override;
|
||||
OpenRCT2::GameActions::Result Execute() const override;
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
Result Query() const override;
|
||||
Result Execute() const override;
|
||||
|
||||
private:
|
||||
OpenRCT2::GameActions::Result QueryExecute(bool isExecuting) const;
|
||||
};
|
||||
private:
|
||||
Result QueryExecute(bool isExecuting) const;
|
||||
};
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -13,55 +13,56 @@
|
||||
#include "../OpenRCT2.h"
|
||||
#include "../ui/WindowManager.h"
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
LoadOrQuitAction::LoadOrQuitAction(LoadOrQuitModes mode, PromptMode savePromptMode)
|
||||
: _mode(mode)
|
||||
, _savePromptMode(savePromptMode)
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
}
|
||||
|
||||
void LoadOrQuitAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
visitor.Visit("mode", _mode);
|
||||
visitor.Visit("savePromptMode", _savePromptMode);
|
||||
}
|
||||
|
||||
uint16_t LoadOrQuitAction::GetActionFlags() const
|
||||
{
|
||||
return GameAction::GetActionFlags() | GameActions::Flags::ClientOnly | GameActions::Flags::AllowWhilePaused;
|
||||
}
|
||||
|
||||
void LoadOrQuitAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_mode) << DS_TAG(_savePromptMode);
|
||||
}
|
||||
|
||||
GameActions::Result LoadOrQuitAction::Query() const
|
||||
{
|
||||
return GameActions::Result();
|
||||
}
|
||||
|
||||
GameActions::Result LoadOrQuitAction::Execute() const
|
||||
{
|
||||
auto mode = static_cast<LoadOrQuitModes>(_mode);
|
||||
switch (mode)
|
||||
LoadOrQuitAction::LoadOrQuitAction(LoadOrQuitModes mode, PromptMode savePromptMode)
|
||||
: _mode(mode)
|
||||
, _savePromptMode(savePromptMode)
|
||||
{
|
||||
case LoadOrQuitModes::OpenSavePrompt:
|
||||
gSavePromptMode = _savePromptMode;
|
||||
ContextOpenWindow(WindowClass::SavePrompt);
|
||||
break;
|
||||
case LoadOrQuitModes::CloseSavePrompt:
|
||||
{
|
||||
auto* windowMgr = Ui::GetWindowManager();
|
||||
windowMgr->CloseByClass(WindowClass::SavePrompt);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
GameLoadOrQuitNoSavePrompt();
|
||||
break;
|
||||
}
|
||||
return GameActions::Result();
|
||||
}
|
||||
|
||||
void LoadOrQuitAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
visitor.Visit("mode", _mode);
|
||||
visitor.Visit("savePromptMode", _savePromptMode);
|
||||
}
|
||||
|
||||
uint16_t LoadOrQuitAction::GetActionFlags() const
|
||||
{
|
||||
return GameAction::GetActionFlags() | Flags::ClientOnly | Flags::AllowWhilePaused;
|
||||
}
|
||||
|
||||
void LoadOrQuitAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_mode) << DS_TAG(_savePromptMode);
|
||||
}
|
||||
|
||||
Result LoadOrQuitAction::Query() const
|
||||
{
|
||||
return Result();
|
||||
}
|
||||
|
||||
Result LoadOrQuitAction::Execute() const
|
||||
{
|
||||
auto mode = static_cast<LoadOrQuitModes>(_mode);
|
||||
switch (mode)
|
||||
{
|
||||
case LoadOrQuitModes::OpenSavePrompt:
|
||||
gSavePromptMode = _savePromptMode;
|
||||
ContextOpenWindow(WindowClass::SavePrompt);
|
||||
break;
|
||||
case LoadOrQuitModes::CloseSavePrompt:
|
||||
{
|
||||
auto* windowMgr = Ui::GetWindowManager();
|
||||
windowMgr->CloseByClass(WindowClass::SavePrompt);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
GameLoadOrQuitNoSavePrompt();
|
||||
break;
|
||||
}
|
||||
return Result();
|
||||
}
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -12,27 +12,30 @@
|
||||
#include "../interface/Window.h"
|
||||
#include "GameAction.h"
|
||||
|
||||
enum class LoadOrQuitModes : uint8_t
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
OpenSavePrompt,
|
||||
CloseSavePrompt
|
||||
};
|
||||
enum class LoadOrQuitModes : uint8_t
|
||||
{
|
||||
OpenSavePrompt,
|
||||
CloseSavePrompt
|
||||
};
|
||||
|
||||
class LoadOrQuitAction final : public GameActionBase<GameCommand::LoadOrQuit>
|
||||
{
|
||||
private:
|
||||
LoadOrQuitModes _mode{};
|
||||
PromptMode _savePromptMode{ PromptMode::saveBeforeLoad };
|
||||
class LoadOrQuitAction final : public GameActionBase<GameCommand::LoadOrQuit>
|
||||
{
|
||||
private:
|
||||
LoadOrQuitModes _mode{};
|
||||
PromptMode _savePromptMode{ PromptMode::saveBeforeLoad };
|
||||
|
||||
public:
|
||||
LoadOrQuitAction() = default;
|
||||
LoadOrQuitAction(LoadOrQuitModes mode, PromptMode savePromptMode = PromptMode::saveBeforeLoad);
|
||||
public:
|
||||
LoadOrQuitAction() = default;
|
||||
LoadOrQuitAction(LoadOrQuitModes mode, PromptMode savePromptMode = PromptMode::saveBeforeLoad);
|
||||
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
|
||||
uint16_t GetActionFlags() const override;
|
||||
uint16_t GetActionFlags() const override;
|
||||
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
OpenRCT2::GameActions::Result Query() const override;
|
||||
OpenRCT2::GameActions::Result Execute() const override;
|
||||
};
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
Result Query() const override;
|
||||
Result Execute() const override;
|
||||
};
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -17,85 +17,84 @@
|
||||
#include "../windows/Intent.h"
|
||||
#include "../world/Park.h"
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
MapChangeSizeAction::MapChangeSizeAction(const TileCoordsXY& targetSize)
|
||||
: MapChangeSizeAction(targetSize, TileCoordsXY())
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
}
|
||||
|
||||
MapChangeSizeAction::MapChangeSizeAction(const TileCoordsXY& targetSize, const TileCoordsXY& shift)
|
||||
: _targetSize(targetSize)
|
||||
, _shift(shift)
|
||||
{
|
||||
}
|
||||
|
||||
uint16_t MapChangeSizeAction::GetActionFlags() const
|
||||
{
|
||||
return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused;
|
||||
}
|
||||
|
||||
void MapChangeSizeAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
stream << DS_TAG(_targetSize);
|
||||
stream << DS_TAG(_shift);
|
||||
}
|
||||
|
||||
GameActions::Result MapChangeSizeAction::Query() const
|
||||
{
|
||||
if (_targetSize.x > kMaximumMapSizeTechnical || _targetSize.y > kMaximumMapSizeTechnical)
|
||||
MapChangeSizeAction::MapChangeSizeAction(const TileCoordsXY& targetSize)
|
||||
: MapChangeSizeAction(targetSize, TileCoordsXY())
|
||||
{
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_INCREASE_MAP_SIZE_ANY_FURTHER, STR_ERR_VALUE_OUT_OF_RANGE);
|
||||
}
|
||||
if (_targetSize.x < kMinimumMapSizeTechnical || _targetSize.y < kMinimumMapSizeTechnical)
|
||||
{
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_DECREASE_MAP_SIZE_ANY_FURTHER, STR_ERR_VALUE_OUT_OF_RANGE);
|
||||
}
|
||||
return GameActions::Result();
|
||||
}
|
||||
|
||||
GameActions::Result MapChangeSizeAction::Execute() const
|
||||
{
|
||||
auto& gameState = getGameState();
|
||||
// Expand map
|
||||
while (_targetSize.x > gameState.mapSize.x)
|
||||
{
|
||||
gameState.mapSize.x++;
|
||||
MapExtendBoundarySurfaceX();
|
||||
}
|
||||
while (_targetSize.y > gameState.mapSize.y)
|
||||
{
|
||||
gameState.mapSize.y++;
|
||||
MapExtendBoundarySurfaceY();
|
||||
}
|
||||
|
||||
// Shift the map (allows increasing the map at the 0,0 position
|
||||
ShiftMap(_shift);
|
||||
|
||||
// Shrink map
|
||||
if (_targetSize.x < gameState.mapSize.x || _targetSize.y < gameState.mapSize.y)
|
||||
MapChangeSizeAction::MapChangeSizeAction(const TileCoordsXY& targetSize, const TileCoordsXY& shift)
|
||||
: _targetSize(targetSize)
|
||||
, _shift(shift)
|
||||
{
|
||||
gameState.mapSize = _targetSize;
|
||||
MapRemoveOutOfRangeElements();
|
||||
}
|
||||
|
||||
auto* ctx = OpenRCT2::GetContext();
|
||||
auto& uiContext = ctx->GetUiContext();
|
||||
auto* windowManager = uiContext.GetWindowManager();
|
||||
OpenRCT2::Park::UpdateSize(gameState);
|
||||
uint16_t MapChangeSizeAction::GetActionFlags() const
|
||||
{
|
||||
return GameAction::GetActionFlags() | Flags::AllowWhilePaused;
|
||||
}
|
||||
|
||||
windowManager->BroadcastIntent(Intent(INTENT_ACTION_MAP));
|
||||
GfxInvalidateScreen();
|
||||
return GameActions::Result();
|
||||
}
|
||||
void MapChangeSizeAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
stream << DS_TAG(_targetSize);
|
||||
stream << DS_TAG(_shift);
|
||||
}
|
||||
|
||||
void MapChangeSizeAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
visitor.Visit("targetSizeX", _targetSize.x);
|
||||
visitor.Visit("targetSizeY", _targetSize.y);
|
||||
visitor.Visit("shiftX", _shift.x);
|
||||
visitor.Visit("shiftY", _shift.y);
|
||||
}
|
||||
Result MapChangeSizeAction::Query() const
|
||||
{
|
||||
if (_targetSize.x > kMaximumMapSizeTechnical || _targetSize.y > kMaximumMapSizeTechnical)
|
||||
{
|
||||
return Result(Status::InvalidParameters, STR_CANT_INCREASE_MAP_SIZE_ANY_FURTHER, STR_ERR_VALUE_OUT_OF_RANGE);
|
||||
}
|
||||
if (_targetSize.x < kMinimumMapSizeTechnical || _targetSize.y < kMinimumMapSizeTechnical)
|
||||
{
|
||||
return Result(Status::InvalidParameters, STR_CANT_DECREASE_MAP_SIZE_ANY_FURTHER, STR_ERR_VALUE_OUT_OF_RANGE);
|
||||
}
|
||||
return Result();
|
||||
}
|
||||
|
||||
Result MapChangeSizeAction::Execute() const
|
||||
{
|
||||
auto& gameState = getGameState();
|
||||
// Expand map
|
||||
while (_targetSize.x > gameState.mapSize.x)
|
||||
{
|
||||
gameState.mapSize.x++;
|
||||
MapExtendBoundarySurfaceX();
|
||||
}
|
||||
while (_targetSize.y > gameState.mapSize.y)
|
||||
{
|
||||
gameState.mapSize.y++;
|
||||
MapExtendBoundarySurfaceY();
|
||||
}
|
||||
|
||||
// Shift the map (allows increasing the map at the 0,0 position
|
||||
ShiftMap(_shift);
|
||||
|
||||
// Shrink map
|
||||
if (_targetSize.x < gameState.mapSize.x || _targetSize.y < gameState.mapSize.y)
|
||||
{
|
||||
gameState.mapSize = _targetSize;
|
||||
MapRemoveOutOfRangeElements();
|
||||
}
|
||||
|
||||
auto* ctx = OpenRCT2::GetContext();
|
||||
auto& uiContext = ctx->GetUiContext();
|
||||
auto* windowManager = uiContext.GetWindowManager();
|
||||
Park::UpdateSize(gameState);
|
||||
|
||||
windowManager->BroadcastIntent(Intent(INTENT_ACTION_MAP));
|
||||
GfxInvalidateScreen();
|
||||
return Result();
|
||||
}
|
||||
|
||||
void MapChangeSizeAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
visitor.Visit("targetSizeX", _targetSize.x);
|
||||
visitor.Visit("targetSizeY", _targetSize.y);
|
||||
visitor.Visit("shiftX", _shift.x);
|
||||
visitor.Visit("shiftY", _shift.y);
|
||||
}
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -12,21 +12,24 @@
|
||||
#include "../world/Map.h"
|
||||
#include "GameAction.h"
|
||||
|
||||
class MapChangeSizeAction final : public GameActionBase<GameCommand::ChangeMapSize>
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
public:
|
||||
MapChangeSizeAction() = default;
|
||||
MapChangeSizeAction(const TileCoordsXY& targetSize);
|
||||
MapChangeSizeAction(const TileCoordsXY& targetSize, const TileCoordsXY& shift);
|
||||
class MapChangeSizeAction final : public GameActionBase<GameCommand::ChangeMapSize>
|
||||
{
|
||||
public:
|
||||
MapChangeSizeAction() = default;
|
||||
MapChangeSizeAction(const TileCoordsXY& targetSize);
|
||||
MapChangeSizeAction(const TileCoordsXY& targetSize, const TileCoordsXY& shift);
|
||||
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
uint16_t GetActionFlags() const override;
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
uint16_t GetActionFlags() const override;
|
||||
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
OpenRCT2::GameActions::Result Query() const override;
|
||||
OpenRCT2::GameActions::Result Execute() const override;
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
Result Query() const override;
|
||||
Result Execute() const override;
|
||||
|
||||
private:
|
||||
TileCoordsXY _targetSize;
|
||||
TileCoordsXY _shift;
|
||||
};
|
||||
private:
|
||||
TileCoordsXY _targetSize;
|
||||
TileCoordsXY _shift;
|
||||
};
|
||||
} // namespace OpenRCT2::GameActions
|
||||
@@ -20,187 +20,188 @@
|
||||
#include "../world/tile_element/SurfaceElement.h"
|
||||
#include "../world/tile_element/TrackElement.h"
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
using namespace OpenRCT2::TrackMetaData;
|
||||
|
||||
MazePlaceTrackAction::MazePlaceTrackAction(const CoordsXYZ& location, RideId rideIndex, uint16_t mazeEntry)
|
||||
: _loc(location)
|
||||
, _rideIndex(rideIndex)
|
||||
, _mazeEntry(mazeEntry)
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
}
|
||||
using namespace OpenRCT2::TrackMetaData;
|
||||
|
||||
void MazePlaceTrackAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
visitor.Visit(_loc);
|
||||
visitor.Visit("ride", _rideIndex);
|
||||
visitor.Visit("mazeEntry", _mazeEntry);
|
||||
}
|
||||
|
||||
void MazePlaceTrackAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
stream << DS_TAG(_loc) << DS_TAG(_rideIndex) << DS_TAG(_mazeEntry);
|
||||
}
|
||||
|
||||
GameActions::Result MazePlaceTrackAction::Query() const
|
||||
{
|
||||
auto res = GameActions::Result();
|
||||
|
||||
res.Position = _loc + CoordsXYZ{ 8, 8, 0 };
|
||||
res.Expenditure = ExpenditureType::rideConstruction;
|
||||
res.ErrorTitle = STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE;
|
||||
if ((_loc.z & 0xF) != 0)
|
||||
MazePlaceTrackAction::MazePlaceTrackAction(const CoordsXYZ& location, RideId rideIndex, uint16_t mazeEntry)
|
||||
: _loc(location)
|
||||
, _rideIndex(rideIndex)
|
||||
, _mazeEntry(mazeEntry)
|
||||
{
|
||||
res.Error = GameActions::Status::Unknown;
|
||||
res.ErrorMessage = STR_INVALID_HEIGHT;
|
||||
return res;
|
||||
}
|
||||
|
||||
if (!LocationValid(_loc))
|
||||
void MazePlaceTrackAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
res.Error = GameActions::Status::InvalidParameters;
|
||||
res.ErrorMessage = STR_OFF_EDGE_OF_MAP;
|
||||
return res;
|
||||
}
|
||||
auto& gameState = getGameState();
|
||||
if (!MapIsLocationOwned(_loc) && !gameState.cheats.sandboxMode)
|
||||
{
|
||||
res.Error = GameActions::Status::NotOwned;
|
||||
res.ErrorMessage = STR_LAND_NOT_OWNED_BY_PARK;
|
||||
return res;
|
||||
visitor.Visit(_loc);
|
||||
visitor.Visit("ride", _rideIndex);
|
||||
visitor.Visit("mazeEntry", _mazeEntry);
|
||||
}
|
||||
|
||||
if (!MapCheckCapacityAndReorganise(_loc))
|
||||
void MazePlaceTrackAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
res.Error = GameActions::Status::NoFreeElements;
|
||||
res.ErrorMessage = STR_TILE_ELEMENT_LIMIT_REACHED;
|
||||
return res;
|
||||
}
|
||||
auto surfaceElement = MapGetSurfaceElementAt(_loc);
|
||||
if (surfaceElement == nullptr)
|
||||
{
|
||||
res.Error = GameActions::Status::Unknown;
|
||||
res.ErrorMessage = STR_INVALID_SELECTION_OF_OBJECTS;
|
||||
return res;
|
||||
GameAction::Serialise(stream);
|
||||
stream << DS_TAG(_loc) << DS_TAG(_rideIndex) << DS_TAG(_mazeEntry);
|
||||
}
|
||||
|
||||
auto baseHeight = _loc.z;
|
||||
auto clearanceHeight = _loc.z + kMazeClearanceHeight;
|
||||
|
||||
auto heightDifference = baseHeight - surfaceElement->GetBaseZ();
|
||||
if (heightDifference >= 0 && !gameState.cheats.disableSupportLimits)
|
||||
Result MazePlaceTrackAction::Query() const
|
||||
{
|
||||
heightDifference /= kCoordsZPerTinyZ;
|
||||
auto res = Result();
|
||||
|
||||
auto* ride = GetRide(_rideIndex);
|
||||
const auto& rtd = ride->getRideTypeDescriptor();
|
||||
if (heightDifference > rtd.Heights.MaxHeight)
|
||||
res.Position = _loc + CoordsXYZ{ 8, 8, 0 };
|
||||
res.Expenditure = ExpenditureType::rideConstruction;
|
||||
res.ErrorTitle = STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE;
|
||||
if ((_loc.z & 0xF) != 0)
|
||||
{
|
||||
res.Error = GameActions::Status::TooHigh;
|
||||
res.ErrorMessage = STR_TOO_HIGH_FOR_SUPPORTS;
|
||||
res.Error = Status::Unknown;
|
||||
res.ErrorMessage = STR_INVALID_HEIGHT;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
auto canBuild = MapCanConstructWithClearAt(
|
||||
{ _loc.ToTileStart(), baseHeight, clearanceHeight }, &MapPlaceNonSceneryClearFunc, { 0b1111, 0 }, GetFlags());
|
||||
if (canBuild.Error != GameActions::Status::Ok)
|
||||
{
|
||||
canBuild.ErrorTitle = STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE;
|
||||
return canBuild;
|
||||
}
|
||||
if (!LocationValid(_loc))
|
||||
{
|
||||
res.Error = Status::InvalidParameters;
|
||||
res.ErrorMessage = STR_OFF_EDGE_OF_MAP;
|
||||
return res;
|
||||
}
|
||||
auto& gameState = getGameState();
|
||||
if (!MapIsLocationOwned(_loc) && !gameState.cheats.sandboxMode)
|
||||
{
|
||||
res.Error = Status::NotOwned;
|
||||
res.ErrorMessage = STR_LAND_NOT_OWNED_BY_PARK;
|
||||
return res;
|
||||
}
|
||||
|
||||
if (!MapCheckCapacityAndReorganise(_loc))
|
||||
{
|
||||
res.Error = Status::NoFreeElements;
|
||||
res.ErrorMessage = STR_TILE_ELEMENT_LIMIT_REACHED;
|
||||
return res;
|
||||
}
|
||||
auto surfaceElement = MapGetSurfaceElementAt(_loc);
|
||||
if (surfaceElement == nullptr)
|
||||
{
|
||||
res.Error = Status::Unknown;
|
||||
res.ErrorMessage = STR_INVALID_SELECTION_OF_OBJECTS;
|
||||
return res;
|
||||
}
|
||||
|
||||
auto baseHeight = _loc.z;
|
||||
auto clearanceHeight = _loc.z + kMazeClearanceHeight;
|
||||
|
||||
auto heightDifference = baseHeight - surfaceElement->GetBaseZ();
|
||||
if (heightDifference >= 0 && !gameState.cheats.disableSupportLimits)
|
||||
{
|
||||
heightDifference /= kCoordsZPerTinyZ;
|
||||
|
||||
auto* ride = GetRide(_rideIndex);
|
||||
const auto& rtd = ride->getRideTypeDescriptor();
|
||||
if (heightDifference > rtd.Heights.MaxHeight)
|
||||
{
|
||||
res.Error = Status::TooHigh;
|
||||
res.ErrorMessage = STR_TOO_HIGH_FOR_SUPPORTS;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
auto canBuild = MapCanConstructWithClearAt(
|
||||
{ _loc.ToTileStart(), baseHeight, clearanceHeight }, &MapPlaceNonSceneryClearFunc, { 0b1111, 0 }, GetFlags());
|
||||
if (canBuild.Error != Status::Ok)
|
||||
{
|
||||
canBuild.ErrorTitle = STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE;
|
||||
return canBuild;
|
||||
}
|
||||
|
||||
const auto clearanceData = canBuild.GetData<ConstructClearResult>();
|
||||
if (clearanceData.GroundFlags & ELEMENT_IS_UNDERWATER)
|
||||
{
|
||||
res.Error = Status::NoClearance;
|
||||
res.ErrorMessage = STR_RIDE_CANT_BUILD_THIS_UNDERWATER;
|
||||
return res;
|
||||
}
|
||||
|
||||
if (clearanceData.GroundFlags & ELEMENT_IS_UNDERGROUND)
|
||||
{
|
||||
res.Error = Status::NoClearance;
|
||||
res.ErrorMessage = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND;
|
||||
return res;
|
||||
}
|
||||
|
||||
auto ride = GetRide(_rideIndex);
|
||||
if (ride == nullptr || ride->type == kRideTypeNull)
|
||||
{
|
||||
LOG_ERROR("Ride not found for rideIndex %u", _rideIndex);
|
||||
res.Error = Status::InvalidParameters;
|
||||
res.ErrorMessage = STR_ERR_RIDE_NOT_FOUND;
|
||||
return res;
|
||||
}
|
||||
|
||||
res.Cost = MazeCalculateCost(canBuild.Cost, *ride, _loc);
|
||||
|
||||
const auto clearanceData = canBuild.GetData<ConstructClearResult>();
|
||||
if (clearanceData.GroundFlags & ELEMENT_IS_UNDERWATER)
|
||||
{
|
||||
res.Error = GameActions::Status::NoClearance;
|
||||
res.ErrorMessage = STR_RIDE_CANT_BUILD_THIS_UNDERWATER;
|
||||
return res;
|
||||
}
|
||||
|
||||
if (clearanceData.GroundFlags & ELEMENT_IS_UNDERGROUND)
|
||||
Result MazePlaceTrackAction::Execute() const
|
||||
{
|
||||
res.Error = GameActions::Status::NoClearance;
|
||||
res.ErrorMessage = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND;
|
||||
auto res = Result();
|
||||
|
||||
res.Position = _loc + CoordsXYZ{ 8, 8, 0 };
|
||||
res.Expenditure = ExpenditureType::rideConstruction;
|
||||
res.ErrorTitle = STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE;
|
||||
|
||||
auto ride = GetRide(_rideIndex);
|
||||
if (ride == nullptr)
|
||||
{
|
||||
LOG_ERROR("Ride not found for rideIndex %u", _rideIndex);
|
||||
res.Error = Status::InvalidParameters;
|
||||
res.ErrorMessage = STR_ERR_RIDE_NOT_FOUND;
|
||||
return res;
|
||||
}
|
||||
|
||||
uint32_t flags = GetFlags();
|
||||
if (!(flags & GAME_COMMAND_FLAG_GHOST))
|
||||
{
|
||||
FootpathRemoveLitter(_loc);
|
||||
WallRemoveAt({ _loc.ToTileStart(), _loc.z, _loc.z + 32 });
|
||||
}
|
||||
|
||||
auto baseHeight = _loc.z;
|
||||
auto clearanceHeight = _loc.z + kMazeClearanceHeight;
|
||||
|
||||
auto canBuild = MapCanConstructWithClearAt(
|
||||
{ _loc.ToTileStart(), baseHeight, clearanceHeight }, &MapPlaceNonSceneryClearFunc, { 0b1111, 0 },
|
||||
GetFlags() | GAME_COMMAND_FLAG_APPLY);
|
||||
if (canBuild.Error != Status::Ok)
|
||||
{
|
||||
canBuild.ErrorTitle = STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE;
|
||||
return canBuild;
|
||||
}
|
||||
|
||||
res.Cost = MazeCalculateCost(canBuild.Cost, *ride, _loc);
|
||||
|
||||
auto startLoc = _loc.ToTileStart();
|
||||
|
||||
auto* trackElement = TileElementInsert<TrackElement>(_loc, 0b1111);
|
||||
Guard::Assert(trackElement != nullptr);
|
||||
|
||||
trackElement->SetClearanceZ(clearanceHeight);
|
||||
trackElement->SetTrackType(TrackElemType::Maze);
|
||||
trackElement->SetRideType(ride->type);
|
||||
trackElement->SetRideIndex(_rideIndex);
|
||||
trackElement->SetMazeEntry(_mazeEntry);
|
||||
trackElement->SetGhost(flags & GAME_COMMAND_FLAG_GHOST);
|
||||
|
||||
MapInvalidateTileFull(startLoc);
|
||||
|
||||
ride->mazeTiles++;
|
||||
ride->getStation().SetBaseZ(trackElement->GetBaseZ());
|
||||
ride->getStation().Start = { 0, 0 };
|
||||
|
||||
if (ride->mazeTiles == 1)
|
||||
{
|
||||
ride->overallView = startLoc;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
auto ride = GetRide(_rideIndex);
|
||||
if (ride == nullptr || ride->type == kRideTypeNull)
|
||||
{
|
||||
LOG_ERROR("Ride not found for rideIndex %u", _rideIndex);
|
||||
res.Error = GameActions::Status::InvalidParameters;
|
||||
res.ErrorMessage = STR_ERR_RIDE_NOT_FOUND;
|
||||
return res;
|
||||
}
|
||||
|
||||
res.Cost = MazeCalculateCost(canBuild.Cost, *ride, _loc);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
GameActions::Result MazePlaceTrackAction::Execute() const
|
||||
{
|
||||
auto res = GameActions::Result();
|
||||
|
||||
res.Position = _loc + CoordsXYZ{ 8, 8, 0 };
|
||||
res.Expenditure = ExpenditureType::rideConstruction;
|
||||
res.ErrorTitle = STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE;
|
||||
|
||||
auto ride = GetRide(_rideIndex);
|
||||
if (ride == nullptr)
|
||||
{
|
||||
LOG_ERROR("Ride not found for rideIndex %u", _rideIndex);
|
||||
res.Error = GameActions::Status::InvalidParameters;
|
||||
res.ErrorMessage = STR_ERR_RIDE_NOT_FOUND;
|
||||
return res;
|
||||
}
|
||||
|
||||
uint32_t flags = GetFlags();
|
||||
if (!(flags & GAME_COMMAND_FLAG_GHOST))
|
||||
{
|
||||
FootpathRemoveLitter(_loc);
|
||||
WallRemoveAt({ _loc.ToTileStart(), _loc.z, _loc.z + 32 });
|
||||
}
|
||||
|
||||
auto baseHeight = _loc.z;
|
||||
auto clearanceHeight = _loc.z + kMazeClearanceHeight;
|
||||
|
||||
auto canBuild = MapCanConstructWithClearAt(
|
||||
{ _loc.ToTileStart(), baseHeight, clearanceHeight }, &MapPlaceNonSceneryClearFunc, { 0b1111, 0 },
|
||||
GetFlags() | GAME_COMMAND_FLAG_APPLY);
|
||||
if (canBuild.Error != GameActions::Status::Ok)
|
||||
{
|
||||
canBuild.ErrorTitle = STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE;
|
||||
return canBuild;
|
||||
}
|
||||
|
||||
res.Cost = MazeCalculateCost(canBuild.Cost, *ride, _loc);
|
||||
|
||||
auto startLoc = _loc.ToTileStart();
|
||||
|
||||
auto* trackElement = TileElementInsert<TrackElement>(_loc, 0b1111);
|
||||
Guard::Assert(trackElement != nullptr);
|
||||
|
||||
trackElement->SetClearanceZ(clearanceHeight);
|
||||
trackElement->SetTrackType(TrackElemType::Maze);
|
||||
trackElement->SetRideType(ride->type);
|
||||
trackElement->SetRideIndex(_rideIndex);
|
||||
trackElement->SetMazeEntry(_mazeEntry);
|
||||
trackElement->SetGhost(flags & GAME_COMMAND_FLAG_GHOST);
|
||||
|
||||
MapInvalidateTileFull(startLoc);
|
||||
|
||||
ride->mazeTiles++;
|
||||
ride->getStation().SetBaseZ(trackElement->GetBaseZ());
|
||||
ride->getStation().Start = { 0, 0 };
|
||||
|
||||
if (ride->mazeTiles == 1)
|
||||
{
|
||||
ride->overallView = startLoc;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
} // namespace OpenRCT2::GameActions
|
||||
Loaded 100 of 229 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user