From d03bd955983b33979d68df71465c14ff0f91af58 Mon Sep 17 00:00:00 2001 From: Duncan Date: Thu, 7 Feb 2019 19:53:09 +0000 Subject: [PATCH] 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 --- src/openrct2/actions/GameActionRegistration.cpp | 1 + src/openrct2/actions/RideSetAppearanceAction.hpp | 11 +++++------ src/openrct2/network/Network.cpp | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/openrct2/actions/GameActionRegistration.cpp b/src/openrct2/actions/GameActionRegistration.cpp index ebb86ecb49..0f113b9faa 100644 --- a/src/openrct2/actions/GameActionRegistration.cpp +++ b/src/openrct2/actions/GameActionRegistration.cpp @@ -57,6 +57,7 @@ namespace GameActions Register(); Register(); Register(); + Register(); Register(); Register(); Register(); diff --git a/src/openrct2/actions/RideSetAppearanceAction.hpp b/src/openrct2/actions/RideSetAppearanceAction.hpp index 2e5d428a26..8e8e2cd36b 100644 --- a/src/openrct2/actions/RideSetAppearanceAction.hpp +++ b/src/openrct2/actions/RideSetAppearanceAction.hpp @@ -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(type)) , _value(value) , _index(index) { @@ -63,8 +63,7 @@ public: void Serialise(DataSerialiser & stream) override { GameAction::Serialise(stream); - auto type = static_cast(_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(GA_ERROR::INVALID_PARAMETERS, STR_NONE); } - switch (_type) + switch (static_cast(_type)) { case RideSetAppearanceType::TrackColourMain: case RideSetAppearanceType::TrackColourAdditional: @@ -122,7 +121,7 @@ public: return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_NONE); } - switch (_type) + switch (static_cast(_type)) { case RideSetAppearanceType::TrackColourMain: ride->track_colour[_index].main = _value; diff --git a/src/openrct2/network/Network.cpp b/src/openrct2/network/Network.cpp index 11486c9cd1..e450016247 100644 --- a/src/openrct2/network/Network.cpp +++ b/src/openrct2/network/Network.cpp @@ -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;