Register the ride set appearance action to prevent server crash (#8691)

* Register the ride set appearance action to prevent server crash

* Bump network version

* Copy the type back when deserialising

This should really be fixed by adding RideSetAppearanceType to the dataserialiser

* Switch the types to prevent possible serialiser issues
This commit is contained in:
Duncan 2019-02-07 19:53:09 +00:00 committed by GitHub
parent 3be6137fde
commit d03bd95598
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 7 deletions

View File

@ -57,6 +57,7 @@ namespace GameActions
Register<RideSetColourSchemeAction>();
Register<RideSetNameAction>();
Register<RideSetStatusAction>();
Register<RideSetAppearanceAction>();
Register<SetParkEntranceFeeAction>();
Register<SignSetNameAction>();
Register<SignSetStyleAction>();

View File

@ -39,7 +39,7 @@ DEFINE_GAME_ACTION(RideSetAppearanceAction, GAME_COMMAND_SET_RIDE_APPEARANCE, Ga
{
private:
NetworkRideId_t _rideIndex{ -1 };
RideSetAppearanceType _type;
uint8_t _type;
uint8_t _value;
uint32_t _index;
@ -49,7 +49,7 @@ public:
}
RideSetAppearanceAction(ride_id_t rideIndex, RideSetAppearanceType type, uint8_t value, uint32_t index)
: _rideIndex(rideIndex)
, _type(type)
, _type(static_cast<uint8_t>(type))
, _value(value)
, _index(index)
{
@ -63,8 +63,7 @@ public:
void Serialise(DataSerialiser & stream) override
{
GameAction::Serialise(stream);
auto type = static_cast<uint8_t>(_type);
stream << DS_TAG(_rideIndex) << DS_TAG(type) << DS_TAG(_value) << DS_TAG(_index);
stream << DS_TAG(_rideIndex) << DS_TAG(_type) << DS_TAG(_value) << DS_TAG(_index);
}
GameActionResult::Ptr Query() const override
@ -82,7 +81,7 @@ public:
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_NONE);
}
switch (_type)
switch (static_cast<RideSetAppearanceType>(_type))
{
case RideSetAppearanceType::TrackColourMain:
case RideSetAppearanceType::TrackColourAdditional:
@ -122,7 +121,7 @@ public:
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_NONE);
}
switch (_type)
switch (static_cast<RideSetAppearanceType>(_type))
{
case RideSetAppearanceType::TrackColourMain:
ride->track_colour[_index].main = _value;

View File

@ -30,7 +30,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 "30"
#define NETWORK_STREAM_VERSION "31"
#define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION
static rct_peep* _pickup_peep = nullptr;