mirror of https://github.com/OpenRCT2/OpenRCT2.git
Refactor result passing of TrackPlaceAction
This commit is contained in:
parent
2d78a5efc3
commit
e06f9c3ee7
|
@ -1664,8 +1664,8 @@ static void window_ride_construction_dropdown(rct_window* w, rct_widgetindex wid
|
|||
_currentTrackCurve = trackPiece | RideConstructionSpecialPieceSelected;
|
||||
window_ride_construction_update_active_elements();
|
||||
}
|
||||
static void RideConstructPlacedForwardGameActionCallback(const GameAction* ga, const TrackPlaceActionResult* result);
|
||||
static void RideConstructPlacedBackwardGameActionCallback(const GameAction* ga, const TrackPlaceActionResult* result);
|
||||
static void RideConstructPlacedForwardGameActionCallback(const GameAction* ga, const GameActions::Result* result);
|
||||
static void RideConstructPlacedBackwardGameActionCallback(const GameAction* ga, const GameActions::Result* result);
|
||||
static void CloseConstructWindowOnCompletion(Ride* ride);
|
||||
|
||||
static void CloseConstructWindowOnCompletion(Ride* ride)
|
||||
|
@ -1687,7 +1687,7 @@ static void CloseConstructWindowOnCompletion(Ride* ride)
|
|||
}
|
||||
}
|
||||
|
||||
static void RideConstructPlacedForwardGameActionCallback(const GameAction* ga, const TrackPlaceActionResult* result)
|
||||
static void RideConstructPlacedForwardGameActionCallback(const GameAction* ga, const GameActions::Result* result)
|
||||
{
|
||||
if (result->Error != GameActions::Status::Ok)
|
||||
{
|
||||
|
@ -1732,7 +1732,7 @@ static void RideConstructPlacedForwardGameActionCallback(const GameAction* ga, c
|
|||
CloseConstructWindowOnCompletion(ride);
|
||||
}
|
||||
|
||||
static void RideConstructPlacedBackwardGameActionCallback(const GameAction* ga, const TrackPlaceActionResult* result)
|
||||
static void RideConstructPlacedBackwardGameActionCallback(const GameAction* ga, const GameActions::Result* result)
|
||||
{
|
||||
if (result->Error != GameActions::Status::Ok)
|
||||
{
|
||||
|
@ -1833,8 +1833,8 @@ static void window_ride_construction_construct(rct_window* w)
|
|||
_currentTrackSelectionFlags |= TRACK_SELECTION_FLAG_TRACK_PLACE_ACTION_QUEUED;
|
||||
}
|
||||
|
||||
auto tpar = dynamic_cast<TrackPlaceActionResult*>(res.get());
|
||||
if (tpar != nullptr && tpar->GroundFlags & ELEMENT_IS_UNDERGROUND)
|
||||
const auto resultData = res->GetData<TrackPlaceActionResult>();
|
||||
if (resultData.GroundFlags & ELEMENT_IS_UNDERGROUND)
|
||||
{
|
||||
viewport_set_visibility(1);
|
||||
}
|
||||
|
|
|
@ -21,25 +21,6 @@
|
|||
#include "RideSetSettingAction.h"
|
||||
|
||||
using namespace OpenRCT2::TrackMetaData;
|
||||
TrackPlaceActionResult::TrackPlaceActionResult()
|
||||
: GameActions::Result(GameActions::Status::Ok, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE)
|
||||
{
|
||||
}
|
||||
|
||||
TrackPlaceActionResult::TrackPlaceActionResult(GameActions::Status error)
|
||||
: GameActions::Result(error, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE)
|
||||
{
|
||||
}
|
||||
|
||||
TrackPlaceActionResult::TrackPlaceActionResult(GameActions::Status error, rct_string_id message)
|
||||
: GameActions::Result(error, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, message)
|
||||
{
|
||||
}
|
||||
|
||||
TrackPlaceActionResult::TrackPlaceActionResult(GameActions::Status error, rct_string_id message, uint8_t* args)
|
||||
: GameActions::Result(error, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, message, args)
|
||||
{
|
||||
}
|
||||
|
||||
TrackPlaceAction::TrackPlaceAction(
|
||||
NetworkRideId_t rideIndex, int32_t trackType, const CoordsXYZD& origin, int32_t brakeSpeed, int32_t colour,
|
||||
|
@ -87,42 +68,44 @@ GameActions::Result::Ptr TrackPlaceAction::Query() const
|
|||
if (ride == nullptr)
|
||||
{
|
||||
log_warning("Invalid ride for track placement, rideIndex = %d", EnumValue(_rideIndex));
|
||||
return std::make_unique<TrackPlaceActionResult>(GameActions::Status::InvalidParameters, STR_NONE);
|
||||
return MakeResult(GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_NONE);
|
||||
}
|
||||
rct_ride_entry* rideEntry = get_ride_entry(ride->subtype);
|
||||
if (rideEntry == nullptr)
|
||||
{
|
||||
log_warning("Invalid ride subtype for track placement, rideIndex = %d", EnumValue(_rideIndex));
|
||||
return std::make_unique<TrackPlaceActionResult>(GameActions::Status::InvalidParameters, STR_NONE);
|
||||
return MakeResult(GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_NONE);
|
||||
}
|
||||
|
||||
if (!direction_valid(_origin.direction))
|
||||
{
|
||||
log_warning("Invalid direction for track placement, direction = %d", _origin.direction);
|
||||
return std::make_unique<TrackPlaceActionResult>(GameActions::Status::InvalidParameters, STR_NONE);
|
||||
return MakeResult(GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_NONE);
|
||||
}
|
||||
|
||||
auto res = std::make_unique<TrackPlaceActionResult>();
|
||||
auto res = MakeResult();
|
||||
res->Expenditure = ExpenditureType::RideConstruction;
|
||||
res->Position.x = _origin.x + 16;
|
||||
res->Position.y = _origin.y + 16;
|
||||
res->Position.z = _origin.z;
|
||||
|
||||
res->GroundFlags = 0;
|
||||
auto resultData = TrackPlaceActionResult{};
|
||||
|
||||
uint32_t rideTypeFlags = ride->GetRideTypeDescriptor().Flags;
|
||||
|
||||
if ((ride->lifecycle_flags & RIDE_LIFECYCLE_INDESTRUCTIBLE_TRACK) && _trackType == TrackElemType::EndStation)
|
||||
{
|
||||
return std::make_unique<TrackPlaceActionResult>(GameActions::Status::Disallowed, STR_NOT_ALLOWED_TO_MODIFY_STATION);
|
||||
return MakeResult(
|
||||
GameActions::Status::Disallowed, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_NOT_ALLOWED_TO_MODIFY_STATION);
|
||||
}
|
||||
|
||||
if (!(GetActionFlags() & GameActions::Flags::AllowWhilePaused))
|
||||
{
|
||||
if (game_is_paused() && !gCheatsBuildInPauseMode)
|
||||
{
|
||||
return std::make_unique<TrackPlaceActionResult>(
|
||||
GameActions::Status::Disallowed, STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED);
|
||||
return MakeResult(
|
||||
GameActions::Status::Disallowed, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE,
|
||||
STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -132,16 +115,18 @@ GameActions::Result::Ptr TrackPlaceAction::Query() const
|
|||
{
|
||||
if (ride->lifecycle_flags & RIDE_LIFECYCLE_ON_RIDE_PHOTO)
|
||||
{
|
||||
return std::make_unique<TrackPlaceActionResult>(
|
||||
GameActions::Status::Disallowed, STR_ONLY_ONE_ON_RIDE_PHOTO_PER_RIDE);
|
||||
return MakeResult(
|
||||
GameActions::Status::Disallowed, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE,
|
||||
STR_ONLY_ONE_ON_RIDE_PHOTO_PER_RIDE);
|
||||
}
|
||||
}
|
||||
else if (_trackType == TrackElemType::CableLiftHill)
|
||||
{
|
||||
if (ride->lifecycle_flags & RIDE_LIFECYCLE_CABLE_LIFT_HILL_COMPONENT_USED)
|
||||
{
|
||||
return std::make_unique<TrackPlaceActionResult>(
|
||||
GameActions::Status::Disallowed, STR_ONLY_ONE_CABLE_LIFT_HILL_PER_RIDE);
|
||||
return MakeResult(
|
||||
GameActions::Status::Disallowed, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE,
|
||||
STR_ONLY_ONE_CABLE_LIFT_HILL_PER_RIDE);
|
||||
}
|
||||
}
|
||||
// Backwards steep lift hills are allowed, even on roller coasters that do not support forwards steep lift hills.
|
||||
|
@ -151,7 +136,9 @@ GameActions::Result::Ptr TrackPlaceAction::Query() const
|
|||
const auto& ted = GetTrackElementDescriptor(_trackType);
|
||||
if (ted.Flags & TRACK_ELEM_FLAG_IS_STEEP_UP)
|
||||
{
|
||||
return std::make_unique<TrackPlaceActionResult>(GameActions::Status::Disallowed, STR_TOO_STEEP_FOR_LIFT_HILL);
|
||||
return MakeResult(
|
||||
GameActions::Status::Disallowed, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE,
|
||||
STR_TOO_STEEP_FOR_LIFT_HILL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -168,7 +155,8 @@ GameActions::Result::Ptr TrackPlaceAction::Query() const
|
|||
|
||||
if (!LocationValid(tileCoords) || (!map_is_location_owned(tileCoords) && !gCheatsSandboxMode))
|
||||
{
|
||||
return std::make_unique<TrackPlaceActionResult>(GameActions::Status::Disallowed, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
return MakeResult(
|
||||
GameActions::Status::Disallowed, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
}
|
||||
numElements++;
|
||||
}
|
||||
|
@ -176,7 +164,9 @@ GameActions::Result::Ptr TrackPlaceAction::Query() const
|
|||
if (!CheckMapCapacity(numElements))
|
||||
{
|
||||
log_warning("Not enough free map elements to place track.");
|
||||
return std::make_unique<TrackPlaceActionResult>(GameActions::Status::NoFreeElements, STR_TILE_ELEMENT_LIMIT_REACHED);
|
||||
return MakeResult(
|
||||
GameActions::Status::NoFreeElements, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE,
|
||||
STR_TILE_ELEMENT_LIMIT_REACHED);
|
||||
}
|
||||
|
||||
if (!gCheatsAllowTrackPlaceInvalidHeights)
|
||||
|
@ -185,16 +175,18 @@ GameActions::Result::Ptr TrackPlaceAction::Query() const
|
|||
{
|
||||
if ((_origin.z & 0x0F) != 8)
|
||||
{
|
||||
return std::make_unique<TrackPlaceActionResult>(
|
||||
GameActions::Status::InvalidParameters, STR_CONSTRUCTION_ERR_UNKNOWN);
|
||||
return MakeResult(
|
||||
GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE,
|
||||
STR_CONSTRUCTION_ERR_UNKNOWN);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((_origin.z & 0x0F) != 0)
|
||||
{
|
||||
return std::make_unique<TrackPlaceActionResult>(
|
||||
GameActions::Status::InvalidParameters, STR_CONSTRUCTION_ERR_UNKNOWN);
|
||||
return MakeResult(
|
||||
GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE,
|
||||
STR_CONSTRUCTION_ERR_UNKNOWN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -210,7 +202,8 @@ GameActions::Result::Ptr TrackPlaceAction::Query() const
|
|||
|
||||
if (mapLoc.z < 16)
|
||||
{
|
||||
return std::make_unique<TrackPlaceActionResult>(GameActions::Status::InvalidParameters, STR_TOO_LOW);
|
||||
return MakeResult(
|
||||
GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_TOO_LOW);
|
||||
}
|
||||
|
||||
int32_t baseZ = floor2(mapLoc.z, COORDS_Z_STEP);
|
||||
|
@ -230,7 +223,8 @@ GameActions::Result::Ptr TrackPlaceAction::Query() const
|
|||
|
||||
if (clearanceZ > MAX_TRACK_HEIGHT)
|
||||
{
|
||||
return std::make_unique<TrackPlaceActionResult>(GameActions::Status::InvalidParameters, STR_TOO_HIGH);
|
||||
return MakeResult(
|
||||
GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_TOO_HIGH);
|
||||
}
|
||||
|
||||
uint8_t crossingMode = (ride->GetRideTypeDescriptor().HasFlag(RIDE_TYPE_FLAG_SUPPORTS_LEVEL_CROSSINGS)
|
||||
|
@ -257,19 +251,21 @@ GameActions::Result::Ptr TrackPlaceAction::Query() const
|
|||
}
|
||||
|
||||
uint8_t mapGroundFlags = canBuild->GroundFlags & (ELEMENT_IS_ABOVE_GROUND | ELEMENT_IS_UNDERGROUND);
|
||||
if (res->GroundFlags != 0 && (res->GroundFlags & mapGroundFlags) == 0)
|
||||
if (resultData.GroundFlags != 0 && (resultData.GroundFlags & mapGroundFlags) == 0)
|
||||
{
|
||||
return std::make_unique<TrackPlaceActionResult>(
|
||||
GameActions::Status::Disallowed, STR_CANT_BUILD_PARTLY_ABOVE_AND_PARTLY_BELOW_GROUND);
|
||||
return MakeResult(
|
||||
GameActions::Status::Disallowed, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE,
|
||||
STR_CANT_BUILD_PARTLY_ABOVE_AND_PARTLY_BELOW_GROUND);
|
||||
}
|
||||
|
||||
res->GroundFlags = mapGroundFlags;
|
||||
resultData.GroundFlags = mapGroundFlags;
|
||||
if (ted.Flags & TRACK_ELEM_FLAG_ONLY_ABOVE_GROUND)
|
||||
{
|
||||
if (res->GroundFlags & ELEMENT_IS_UNDERGROUND)
|
||||
if (resultData.GroundFlags & ELEMENT_IS_UNDERGROUND)
|
||||
{
|
||||
return std::make_unique<TrackPlaceActionResult>(
|
||||
GameActions::Status::Disallowed, STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND);
|
||||
return MakeResult(
|
||||
GameActions::Status::Disallowed, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE,
|
||||
STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -277,34 +273,40 @@ GameActions::Result::Ptr TrackPlaceAction::Query() const
|
|||
{ // No element has this flag
|
||||
if (canBuild->GroundFlags & ELEMENT_IS_UNDERWATER)
|
||||
{
|
||||
return std::make_unique<TrackPlaceActionResult>(
|
||||
GameActions::Status::Disallowed, STR_CAN_ONLY_BUILD_THIS_UNDERWATER);
|
||||
return MakeResult(
|
||||
GameActions::Status::Disallowed, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE,
|
||||
STR_CAN_ONLY_BUILD_THIS_UNDERWATER);
|
||||
}
|
||||
}
|
||||
|
||||
if (canBuild->GroundFlags & ELEMENT_IS_UNDERWATER && !gCheatsDisableClearanceChecks)
|
||||
{
|
||||
return std::make_unique<TrackPlaceActionResult>(
|
||||
GameActions::Status::Disallowed, STR_RIDE_CANT_BUILD_THIS_UNDERWATER);
|
||||
return MakeResult(
|
||||
GameActions::Status::Disallowed, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE,
|
||||
STR_RIDE_CANT_BUILD_THIS_UNDERWATER);
|
||||
}
|
||||
|
||||
if ((rideTypeFlags & RIDE_TYPE_FLAG_TRACK_MUST_BE_ON_WATER) && !_trackDesignDrawingPreview)
|
||||
{
|
||||
auto surfaceElement = map_get_surface_element_at(mapLoc);
|
||||
if (surfaceElement == nullptr)
|
||||
return std::make_unique<TrackPlaceActionResult>(GameActions::Status::Unknown, STR_NONE);
|
||||
{
|
||||
return MakeResult(GameActions::Status::Unknown, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_NONE);
|
||||
}
|
||||
|
||||
auto waterHeight = surfaceElement->GetWaterHeight();
|
||||
if (waterHeight == 0)
|
||||
{
|
||||
return std::make_unique<TrackPlaceActionResult>(
|
||||
GameActions::Status::Disallowed, STR_CAN_ONLY_BUILD_THIS_ON_WATER);
|
||||
return MakeResult(
|
||||
GameActions::Status::Disallowed, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE,
|
||||
STR_CAN_ONLY_BUILD_THIS_ON_WATER);
|
||||
}
|
||||
|
||||
if (waterHeight != baseZ)
|
||||
{
|
||||
return std::make_unique<TrackPlaceActionResult>(
|
||||
GameActions::Status::Disallowed, STR_CAN_ONLY_BUILD_THIS_ON_WATER);
|
||||
return MakeResult(
|
||||
GameActions::Status::Disallowed, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE,
|
||||
STR_CAN_ONLY_BUILD_THIS_ON_WATER);
|
||||
}
|
||||
waterHeight -= LAND_HEIGHT_STEP;
|
||||
if (waterHeight == surfaceElement->GetBaseZ())
|
||||
|
@ -313,8 +315,9 @@ GameActions::Result::Ptr TrackPlaceAction::Query() const
|
|||
if (slope == TILE_ELEMENT_SLOPE_W_CORNER_DN || slope == TILE_ELEMENT_SLOPE_S_CORNER_DN
|
||||
|| slope == TILE_ELEMENT_SLOPE_E_CORNER_DN || slope == TILE_ELEMENT_SLOPE_N_CORNER_DN)
|
||||
{
|
||||
return std::make_unique<TrackPlaceActionResult>(
|
||||
GameActions::Status::Disallowed, STR_CAN_ONLY_BUILD_THIS_ON_WATER);
|
||||
return MakeResult(
|
||||
GameActions::Status::Disallowed, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE,
|
||||
STR_CAN_ONLY_BUILD_THIS_ON_WATER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -324,14 +327,17 @@ GameActions::Result::Ptr TrackPlaceAction::Query() const
|
|||
{
|
||||
if (!track_add_station_element({ mapLoc, baseZ, _origin.direction }, _rideIndex, 0, _fromTrackDesign))
|
||||
{
|
||||
return std::make_unique<TrackPlaceActionResult>(GameActions::Status::Unknown, gGameCommandErrorText);
|
||||
return MakeResult(
|
||||
GameActions::Status::Unknown, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, gGameCommandErrorText);
|
||||
}
|
||||
}
|
||||
|
||||
// 6c5648 12 push
|
||||
auto surfaceElement = map_get_surface_element_at(mapLoc);
|
||||
if (surfaceElement == nullptr)
|
||||
return std::make_unique<TrackPlaceActionResult>(GameActions::Status::Unknown, STR_NONE);
|
||||
{
|
||||
return MakeResult(GameActions::Status::Unknown, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_NONE);
|
||||
}
|
||||
|
||||
if (!gCheatsDisableSupportLimits)
|
||||
{
|
||||
|
@ -353,7 +359,9 @@ GameActions::Result::Ptr TrackPlaceAction::Query() const
|
|||
ride_height /= COORDS_Z_PER_TINY_Z;
|
||||
if (ride_height > maxHeight && !_trackDesignDrawingPreview)
|
||||
{
|
||||
return std::make_unique<TrackPlaceActionResult>(GameActions::Status::Disallowed, STR_TOO_HIGH_FOR_SUPPORTS);
|
||||
return MakeResult(
|
||||
GameActions::Status::Disallowed, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE,
|
||||
STR_TOO_HIGH_FOR_SUPPORTS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -372,6 +380,8 @@ GameActions::Result::Ptr TrackPlaceAction::Query() const
|
|||
|
||||
price >>= 16;
|
||||
res->Cost = cost + ((price / 2) * 10);
|
||||
res->SetData(std::move(resultData));
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -381,23 +391,23 @@ GameActions::Result::Ptr TrackPlaceAction::Execute() const
|
|||
if (ride == nullptr)
|
||||
{
|
||||
log_warning("Invalid ride for track placement, rideIndex = %d", EnumValue(_rideIndex));
|
||||
return std::make_unique<TrackPlaceActionResult>(GameActions::Status::InvalidParameters);
|
||||
return MakeResult(GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_NONE);
|
||||
}
|
||||
|
||||
rct_ride_entry* rideEntry = get_ride_entry(ride->subtype);
|
||||
if (rideEntry == nullptr)
|
||||
{
|
||||
log_warning("Invalid ride subtype for track placement, rideIndex = %d", EnumValue(_rideIndex));
|
||||
return std::make_unique<TrackPlaceActionResult>(GameActions::Status::InvalidParameters);
|
||||
return MakeResult(GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_NONE);
|
||||
}
|
||||
|
||||
auto res = std::make_unique<TrackPlaceActionResult>();
|
||||
auto res = MakeResult();
|
||||
res->Expenditure = ExpenditureType::RideConstruction;
|
||||
res->Position.x = _origin.x + 16;
|
||||
res->Position.y = _origin.y + 16;
|
||||
res->Position.z = _origin.z;
|
||||
|
||||
res->GroundFlags = 0;
|
||||
auto resultData = TrackPlaceActionResult{};
|
||||
|
||||
uint32_t rideTypeFlags = ride->GetRideTypeDescriptor().Flags;
|
||||
|
||||
|
@ -466,18 +476,21 @@ GameActions::Result::Ptr TrackPlaceAction::Execute() const
|
|||
}
|
||||
|
||||
uint8_t mapGroundFlags = canBuild->GroundFlags & (ELEMENT_IS_ABOVE_GROUND | ELEMENT_IS_UNDERGROUND);
|
||||
if (res->GroundFlags != 0 && (res->GroundFlags & mapGroundFlags) == 0)
|
||||
if (resultData.GroundFlags != 0 && (resultData.GroundFlags & mapGroundFlags) == 0)
|
||||
{
|
||||
return std::make_unique<TrackPlaceActionResult>(
|
||||
GameActions::Status::Disallowed, STR_CANT_BUILD_PARTLY_ABOVE_AND_PARTLY_BELOW_GROUND);
|
||||
return MakeResult(
|
||||
GameActions::Status::Disallowed, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE,
|
||||
STR_CANT_BUILD_PARTLY_ABOVE_AND_PARTLY_BELOW_GROUND);
|
||||
}
|
||||
|
||||
res->GroundFlags = mapGroundFlags;
|
||||
resultData.GroundFlags = mapGroundFlags;
|
||||
|
||||
// 6c5648 12 push
|
||||
auto surfaceElement = map_get_surface_element_at(mapLoc);
|
||||
if (surfaceElement == nullptr)
|
||||
return std::make_unique<TrackPlaceActionResult>(GameActions::Status::Unknown, STR_NONE);
|
||||
{
|
||||
return MakeResult(GameActions::Status::Unknown, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_NONE);
|
||||
}
|
||||
|
||||
int32_t supportHeight = baseZ - surfaceElement->GetBaseZ();
|
||||
if (supportHeight < 0)
|
||||
|
@ -552,7 +565,9 @@ GameActions::Result::Ptr TrackPlaceAction::Execute() const
|
|||
if (trackElement == nullptr)
|
||||
{
|
||||
log_warning("Cannot create track element for ride = %d", EnumValue(_rideIndex));
|
||||
return std::make_unique<TrackPlaceActionResult>(GameActions::Status::NoFreeElements);
|
||||
return MakeResult(
|
||||
GameActions::Status::NoFreeElements, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE,
|
||||
STR_TILE_ELEMENT_LIMIT_REACHED);
|
||||
}
|
||||
|
||||
trackElement->SetClearanceZ(clearanceZ);
|
||||
|
@ -659,6 +674,8 @@ GameActions::Result::Ptr TrackPlaceAction::Execute() const
|
|||
|
||||
price >>= 16;
|
||||
res->Cost = cost + ((price / 2) * 10);
|
||||
res->SetData(std::move(resultData));
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,18 +11,12 @@
|
|||
|
||||
#include "GameAction.h"
|
||||
|
||||
class TrackPlaceActionResult final : public GameActions::Result
|
||||
struct TrackPlaceActionResult
|
||||
{
|
||||
public:
|
||||
TrackPlaceActionResult();
|
||||
TrackPlaceActionResult(GameActions::Status error);
|
||||
TrackPlaceActionResult(GameActions::Status error, rct_string_id message);
|
||||
TrackPlaceActionResult(GameActions::Status error, rct_string_id message, uint8_t* args);
|
||||
|
||||
uint8_t GroundFlags{ 0 };
|
||||
};
|
||||
|
||||
DEFINE_GAME_ACTION(TrackPlaceAction, GameCommand::PlaceTrack, TrackPlaceActionResult)
|
||||
DEFINE_GAME_ACTION(TrackPlaceAction, GameCommand::PlaceTrack, GameActions::Result)
|
||||
{
|
||||
private:
|
||||
NetworkRideId_t _rideIndex{ RIDE_ID_NULL };
|
||||
|
|
|
@ -51,13 +51,12 @@ money32 place_provisional_track_piece(
|
|||
if (ride == nullptr)
|
||||
return MONEY32_UNDEFINED;
|
||||
|
||||
money32 result;
|
||||
ride_construction_remove_ghosts();
|
||||
if (ride->type == RIDE_TYPE_MAZE)
|
||||
{
|
||||
int32_t flags = GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND
|
||||
| GAME_COMMAND_FLAG_GHOST; // 105
|
||||
result = maze_set_track(trackPos.x, trackPos.y, trackPos.z, flags, true, 0, rideIndex, GC_SET_MAZE_TRACK_BUILD);
|
||||
auto result = maze_set_track(trackPos.x, trackPos.y, trackPos.z, flags, true, 0, rideIndex, GC_SET_MAZE_TRACK_BUILD);
|
||||
if (result == MONEY32_UNDEFINED)
|
||||
return result;
|
||||
|
||||
|
@ -84,10 +83,8 @@ money32 place_provisional_track_piece(
|
|||
trackPlaceAction.SetFlags(GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND | GAME_COMMAND_FLAG_GHOST);
|
||||
// This command must not be sent over the network
|
||||
auto res = GameActions::Execute(&trackPlaceAction);
|
||||
auto tpar = dynamic_cast<TrackPlaceActionResult*>(res.get());
|
||||
result = ((tpar == nullptr) || (res->Error == GameActions::Status::Ok)) ? res->Cost : MONEY32_UNDEFINED;
|
||||
if (result == MONEY32_UNDEFINED)
|
||||
return result;
|
||||
if (res->Error != GameActions::Status::Ok)
|
||||
return MONEY32_UNDEFINED;
|
||||
|
||||
int16_t z_begin, z_end;
|
||||
const auto& ted = GetTrackElementDescriptor(trackType);
|
||||
|
@ -104,10 +101,9 @@ money32 place_provisional_track_piece(
|
|||
|
||||
_unkF440C5 = { trackPos.x, trackPos.y, trackPos.z + z_begin, static_cast<Direction>(trackDirection) };
|
||||
_currentTrackSelectionFlags |= TRACK_SELECTION_FLAG_TRACK;
|
||||
if (tpar != nullptr)
|
||||
{
|
||||
viewport_set_visibility((tpar->GroundFlags & ELEMENT_IS_UNDERGROUND) ? 1 : 3);
|
||||
}
|
||||
|
||||
const auto resultData = res->GetData<TrackPlaceActionResult>();
|
||||
viewport_set_visibility((resultData.GroundFlags & ELEMENT_IS_UNDERGROUND) ? 1 : 3);
|
||||
if (_currentTrackSlopeEnd != 0)
|
||||
viewport_set_visibility(2);
|
||||
|
||||
|
@ -120,7 +116,7 @@ money32 place_provisional_track_piece(
|
|||
virtual_floor_set_height(trackPos.z - z_begin + z_end);
|
||||
}
|
||||
|
||||
return result;
|
||||
return res->Cost;
|
||||
}
|
||||
|
||||
static std::tuple<bool, track_type_t> window_ride_construction_update_state_get_track_element()
|
||||
|
|
Loading…
Reference in New Issue