mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-22 14:24:33 +01:00
Refactor RideCreateAction to pass entrance object explicitly
This commit is contained in:
@@ -64,7 +64,7 @@ void ride_construct_new(RideSelection listItem)
|
||||
int32_t colour1 = ride_get_random_colour_preset_index(listItem.Type);
|
||||
int32_t colour2 = ride_get_unused_preset_vehicle_colour(rideEntryIndex);
|
||||
|
||||
auto gameAction = RideCreateAction(listItem.Type, listItem.EntryIndex, colour1, colour2);
|
||||
auto gameAction = RideCreateAction(listItem.Type, listItem.EntryIndex, colour1, colour2, gLastEntranceStyle);
|
||||
|
||||
gameAction.SetCallback([](const GameAction* ga, const GameActions::Result* result) {
|
||||
if (result->Error != GameActions::Status::Ok)
|
||||
|
||||
@@ -27,9 +27,11 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
RideCreateAction::RideCreateAction(int32_t rideType, ObjectEntryIndex subType, int32_t colour1, int32_t colour2)
|
||||
RideCreateAction::RideCreateAction(
|
||||
int32_t rideType, ObjectEntryIndex subType, int32_t colour1, int32_t colour2, ObjectEntryIndex entranceObjectIndex)
|
||||
: _rideType(rideType)
|
||||
, _subType(subType)
|
||||
, _entranceObjectIndex(entranceObjectIndex)
|
||||
, _colour1(colour1)
|
||||
, _colour2(colour2)
|
||||
{
|
||||
@@ -39,6 +41,7 @@ void RideCreateAction::AcceptParameters(GameActionParameterVisitor& visitor)
|
||||
{
|
||||
visitor.Visit("rideType", _rideType);
|
||||
visitor.Visit("rideObject", _subType);
|
||||
visitor.Visit("entranceObject", _entranceObjectIndex);
|
||||
visitor.Visit("colour1", _colour1);
|
||||
visitor.Visit("colour2", _colour2);
|
||||
}
|
||||
@@ -62,7 +65,7 @@ void RideCreateAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_rideType) << DS_TAG(_subType) << DS_TAG(_colour1) << DS_TAG(_colour2);
|
||||
stream << DS_TAG(_rideType) << DS_TAG(_subType) << DS_TAG(_entranceObjectIndex) << DS_TAG(_colour1) << DS_TAG(_colour2);
|
||||
}
|
||||
|
||||
GameActions::Result RideCreateAction::Query() const
|
||||
@@ -293,7 +296,7 @@ GameActions::Result RideCreateAction::Execute() const
|
||||
ride->entrance_style = OBJECT_ENTRY_INDEX_NULL;
|
||||
if (rtd.HasFlag(RIDE_TYPE_FLAG_HAS_ENTRANCE_EXIT))
|
||||
{
|
||||
ride->entrance_style = gLastEntranceStyle;
|
||||
ride->entrance_style = _entranceObjectIndex;
|
||||
}
|
||||
|
||||
ride->num_block_brakes = 0;
|
||||
|
||||
@@ -16,12 +16,14 @@ class RideCreateAction final : public GameActionBase<GameCommand::CreateRide>
|
||||
private:
|
||||
ObjectEntryIndex _rideType{ OBJECT_ENTRY_INDEX_NULL };
|
||||
ObjectEntryIndex _subType{ OBJECT_ENTRY_INDEX_NULL };
|
||||
ObjectEntryIndex _entranceObjectIndex{ OBJECT_ENTRY_INDEX_NULL };
|
||||
uint8_t _colour1{ 0xFF };
|
||||
uint8_t _colour2{ 0xFF };
|
||||
|
||||
public:
|
||||
RideCreateAction() = default;
|
||||
RideCreateAction(int32_t rideType, ObjectEntryIndex subType, int32_t colour1, int32_t colour2);
|
||||
RideCreateAction(
|
||||
int32_t rideType, ObjectEntryIndex subType, int32_t colour1, int32_t colour2, ObjectEntryIndex entranceStyleIndex);
|
||||
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ GameActions::Result TrackDesignAction::Query() const
|
||||
}
|
||||
|
||||
// Colours do not matter as will be overwritten
|
||||
auto rideCreateAction = RideCreateAction(_td.type, entryIndex, 0, 0);
|
||||
auto rideCreateAction = RideCreateAction(_td.type, entryIndex, 0, 0, gLastEntranceStyle);
|
||||
rideCreateAction.SetFlags(GetFlags());
|
||||
auto r = GameActions::ExecuteNested(&rideCreateAction);
|
||||
if (r.Error != GameActions::Status::Ok)
|
||||
@@ -148,7 +148,7 @@ GameActions::Result TrackDesignAction::Execute() const
|
||||
}
|
||||
|
||||
// Colours do not matter as will be overwritten
|
||||
auto rideCreateAction = RideCreateAction(_td.type, entryIndex, 0, 0);
|
||||
auto rideCreateAction = RideCreateAction(_td.type, entryIndex, 0, 0, gLastEntranceStyle);
|
||||
rideCreateAction.SetFlags(GetFlags());
|
||||
auto r = GameActions::ExecuteNested(&rideCreateAction);
|
||||
if (r.Error != GameActions::Status::Ok)
|
||||
|
||||
@@ -1920,7 +1920,7 @@ int32_t TrackDesignGetZPlacement(TrackDesign* td6, Ride* ride, const CoordsXYZ&
|
||||
static money32 TrackDesignCreateRide(int32_t type, int32_t subType, int32_t flags, ride_id_t* outRideIndex)
|
||||
{
|
||||
// Don't set colours as will be set correctly later.
|
||||
auto gameAction = RideCreateAction(type, subType, 0, 0);
|
||||
auto gameAction = RideCreateAction(type, subType, 0, 0, gLastEntranceStyle);
|
||||
gameAction.SetFlags(flags);
|
||||
|
||||
auto res = GameActions::ExecuteNested(&gameAction);
|
||||
|
||||
Reference in New Issue
Block a user