mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-10 09:32:29 +01:00
Modify TrackPlaceAction to handle ride type parameter (#15980)
* Modify TrackPlaceAction to handle ride type parameter * Update network and plugin version * Update replays
This commit is contained in:
@@ -65,9 +65,9 @@ set(OBJECTS_VERSION "1.2.2")
|
||||
set(OBJECTS_URL "https://github.com/OpenRCT2/objects/releases/download/v${OBJECTS_VERSION}/objects.zip")
|
||||
set(OBJECTS_SHA1 "a808fd47e9bc35d105dc371428a55888e6a86860")
|
||||
|
||||
set(REPLAYS_VERSION "0.0.59")
|
||||
set(REPLAYS_VERSION "0.0.60")
|
||||
set(REPLAYS_URL "https://github.com/OpenRCT2/replays/releases/download/v${REPLAYS_VERSION}/replays.zip")
|
||||
set(REPLAYS_SHA1 "B2230B07F966A3CFFA5297C7B03ED7DD68FC9D2D")
|
||||
set(REPLAYS_SHA1 "1EB460BB3C71BD21CCBE778BEF1E8CD593241A18")
|
||||
|
||||
option(FORCE32 "Force 32-bit build. It will add `-m32` to compiler flags.")
|
||||
option(WITH_TESTS "Build tests")
|
||||
|
||||
@@ -48,8 +48,8 @@
|
||||
<TitleSequencesSha1>304d13a126c15bf2c86ff13b81a2f2cc1856ac8d</TitleSequencesSha1>
|
||||
<ObjectsUrl>https://github.com/OpenRCT2/objects/releases/download/v1.2.2/objects.zip</ObjectsUrl>
|
||||
<ObjectsSha1>a808fd47e9bc35d105dc371428a55888e6a86860</ObjectsSha1>
|
||||
<ReplaysUrl>https://github.com/OpenRCT2/replays/releases/download/v0.0.59/replays.zip</ReplaysUrl>
|
||||
<ReplaysSha1>B2230B07F966A3CFFA5297C7B03ED7DD68FC9D2D</ReplaysSha1>
|
||||
<ReplaysUrl>https://github.com/OpenRCT2/replays/releases/download/v0.0.60/replays.zip</ReplaysUrl>
|
||||
<ReplaysSha1>1EB460BB3C71BD21CCBE778BEF1E8CD593241A18</ReplaysSha1>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1791,9 +1791,13 @@ static void WindowRideConstructionConstruct(rct_window* w)
|
||||
return;
|
||||
}
|
||||
|
||||
auto* ride = get_ride(rideIndex);
|
||||
if (ride == nullptr)
|
||||
return;
|
||||
|
||||
auto trackPlaceAction = TrackPlaceAction(
|
||||
rideIndex, trackType, { trackPos, static_cast<uint8_t>(trackDirection) }, (properties)&0xFF, (properties >> 8) & 0x0F,
|
||||
(properties >> 12) & 0x0F, liftHillAndAlternativeState, false);
|
||||
rideIndex, trackType, ride->type, { trackPos, static_cast<uint8_t>(trackDirection) }, (properties)&0xFF,
|
||||
(properties >> 8) & 0x0F, (properties >> 12) & 0x0F, liftHillAndAlternativeState, false);
|
||||
if (_rideConstructionState == RideConstructionState::Back)
|
||||
{
|
||||
trackPlaceAction.SetCallback(RideConstructPlacedBackwardGameActionCallback);
|
||||
|
||||
@@ -24,10 +24,11 @@
|
||||
using namespace OpenRCT2::TrackMetaData;
|
||||
|
||||
TrackPlaceAction::TrackPlaceAction(
|
||||
NetworkRideId_t rideIndex, int32_t trackType, const CoordsXYZD& origin, int32_t brakeSpeed, int32_t colour,
|
||||
int32_t seatRotation, int32_t liftHillAndAlternativeState, bool fromTrackDesign)
|
||||
NetworkRideId_t rideIndex, int32_t trackType, ride_type_t rideType, const CoordsXYZD& origin, int32_t brakeSpeed,
|
||||
int32_t colour, int32_t seatRotation, int32_t liftHillAndAlternativeState, bool fromTrackDesign)
|
||||
: _rideIndex(rideIndex)
|
||||
, _trackType(trackType)
|
||||
, _rideType(rideType)
|
||||
, _origin(origin)
|
||||
, _brakeSpeed(brakeSpeed)
|
||||
, _colour(colour)
|
||||
@@ -43,6 +44,7 @@ void TrackPlaceAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
visitor.Visit(_origin);
|
||||
visitor.Visit("ride", _rideIndex);
|
||||
visitor.Visit("trackType", _trackType);
|
||||
visitor.Visit("rideType", _rideType);
|
||||
visitor.Visit("brakeSpeed", _brakeSpeed);
|
||||
visitor.Visit("colour", _colour);
|
||||
visitor.Visit("seatRotation", _seatRotation);
|
||||
@@ -59,8 +61,8 @@ void TrackPlaceAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_rideIndex) << DS_TAG(_trackType) << DS_TAG(_origin) << DS_TAG(_brakeSpeed) << DS_TAG(_colour)
|
||||
<< DS_TAG(_seatRotation) << DS_TAG(_trackPlaceFlags);
|
||||
stream << DS_TAG(_rideIndex) << DS_TAG(_trackType) << DS_TAG(_rideType) << DS_TAG(_origin) << DS_TAG(_brakeSpeed)
|
||||
<< DS_TAG(_colour) << DS_TAG(_seatRotation) << DS_TAG(_trackPlaceFlags);
|
||||
}
|
||||
|
||||
GameActions::Result TrackPlaceAction::Query() const
|
||||
@@ -87,6 +89,19 @@ GameActions::Result TrackPlaceAction::Query() const
|
||||
GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_NONE);
|
||||
}
|
||||
|
||||
if (_rideType != ride->type && !gCheatsAllowArbitraryRideTypeChanges)
|
||||
{
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_NONE);
|
||||
}
|
||||
|
||||
if (_rideType > RIDE_TYPE_COUNT)
|
||||
{
|
||||
log_warning("Invalid ride type for track placement, rideType = %d", _rideType);
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_NONE);
|
||||
}
|
||||
|
||||
auto res = GameActions::Result();
|
||||
res.Expenditure = ExpenditureType::RideConstruction;
|
||||
res.Position.x = _origin.x + 16;
|
||||
@@ -585,7 +600,7 @@ GameActions::Result TrackPlaceAction::Execute() const
|
||||
trackElement->SetSequenceIndex(trackBlock->index);
|
||||
trackElement->SetRideIndex(_rideIndex);
|
||||
trackElement->SetTrackType(_trackType);
|
||||
trackElement->SetRideType(ride->type);
|
||||
trackElement->SetRideType(_rideType);
|
||||
trackElement->SetGhost(GetFlags() & GAME_COMMAND_FLAG_GHOST);
|
||||
|
||||
switch (_trackType)
|
||||
|
||||
@@ -21,6 +21,7 @@ class TrackPlaceAction final : public GameActionBase<GameCommand::PlaceTrack>
|
||||
private:
|
||||
NetworkRideId_t _rideIndex{ RIDE_ID_NULL };
|
||||
int32_t _trackType{};
|
||||
ride_type_t _rideType{};
|
||||
CoordsXYZD _origin;
|
||||
int32_t _brakeSpeed{};
|
||||
int32_t _colour{};
|
||||
@@ -31,8 +32,8 @@ private:
|
||||
public:
|
||||
TrackPlaceAction() = default;
|
||||
TrackPlaceAction(
|
||||
NetworkRideId_t rideIndex, int32_t trackType, const CoordsXYZD& origin, int32_t brakeSpeed, int32_t colour,
|
||||
int32_t seatRotation, int32_t liftHillAndAlternativeState, bool fromTrackDesign);
|
||||
NetworkRideId_t rideIndex, int32_t trackType, ride_type_t rideType, const CoordsXYZD& origin, int32_t brakeSpeed,
|
||||
int32_t colour, int32_t seatRotation, int32_t liftHillAndAlternativeState, bool fromTrackDesign);
|
||||
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
// This string specifies which version of network stream current build uses.
|
||||
// It is used for making sure only compatible builds get connected, even within
|
||||
// single OpenRCT2 version.
|
||||
#define NETWORK_STREAM_VERSION "2"
|
||||
#define NETWORK_STREAM_VERSION "3"
|
||||
#define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION
|
||||
|
||||
static Peep* _pickup_peep = nullptr;
|
||||
|
||||
@@ -1631,8 +1631,8 @@ static GameActions::Result TrackDesignPlaceRide(TrackDesignState& tds, TrackDesi
|
||||
}
|
||||
|
||||
auto trackPlaceAction = TrackPlaceAction(
|
||||
_currentRideIndex, trackType, { newCoords, tempZ, static_cast<uint8_t>(rotation) }, brakeSpeed, trackColour,
|
||||
seatRotation, liftHillAndAlternativeState, true);
|
||||
_currentRideIndex, trackType, ride->type, { newCoords, tempZ, static_cast<uint8_t>(rotation) }, brakeSpeed,
|
||||
trackColour, seatRotation, liftHillAndAlternativeState, true);
|
||||
trackPlaceAction.SetFlags(flags);
|
||||
|
||||
auto res = flags & GAME_COMMAND_FLAG_APPLY ? GameActions::ExecuteNested(&trackPlaceAction)
|
||||
|
||||
@@ -79,7 +79,8 @@ money32 place_provisional_track_piece(
|
||||
}
|
||||
|
||||
auto trackPlaceAction = TrackPlaceAction(
|
||||
rideIndex, trackType, { trackPos, static_cast<uint8_t>(trackDirection) }, 0, 0, 0, liftHillAndAlternativeState, false);
|
||||
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);
|
||||
// This command must not be sent over the network
|
||||
auto res = GameActions::Execute(&trackPlaceAction);
|
||||
|
||||
Reference in New Issue
Block a user