mirror of https://github.com/OpenRCT2/OpenRCT2.git
Close #17955: Make ratings setting networked and freeze them
This commit is contained in:
parent
8d08c13fa6
commit
c1149895fa
|
@ -21,6 +21,7 @@
|
|||
- Improved: [#17868] [Plugin] You can now change active tab of a custom window programmatically.
|
||||
- Improved: [#17909] Track elements that are not supported by any train are now hidden by default.
|
||||
- Improved: [#17924] Improved performance when loading JSON object images from a .DAT file.
|
||||
- Improved: [#17955] Modifying ratings via in-game console is now multiplayer-safe and also freezes the ratings.
|
||||
- Change: [#9104] Calculate maze support costs.
|
||||
- Change: [#17319] Giant screenshots are now cropped to the horizontal view-clipping selection.
|
||||
- Change: [#17499] Update error text when using vehicle incompatible with TD6 and add error when using incompatible track elements.
|
||||
|
|
|
@ -102,6 +102,7 @@ enum class GameCommand : int32_t
|
|||
SetDate, // GA
|
||||
Custom, // GA
|
||||
ChangeMapSize,
|
||||
FreezeRideRating,
|
||||
Count,
|
||||
};
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
#include "RideDemolishAction.h"
|
||||
#include "RideEntranceExitPlaceAction.h"
|
||||
#include "RideEntranceExitRemoveAction.h"
|
||||
#include "RideFreezeRatingAction.h"
|
||||
#include "RideSetAppearanceAction.h"
|
||||
#include "RideSetColourSchemeAction.h"
|
||||
#include "RideSetNameAction.h"
|
||||
|
@ -159,6 +160,7 @@ namespace GameActions
|
|||
REGISTER_ACTION(RideSetNameAction);
|
||||
REGISTER_ACTION(RideSetPriceAction);
|
||||
REGISTER_ACTION(RideSetStatusAction);
|
||||
REGISTER_ACTION(RideFreezeRatingAction);
|
||||
REGISTER_ACTION(RideSetAppearanceAction);
|
||||
REGISTER_ACTION(RideSetVehicleAction);
|
||||
REGISTER_ACTION(RideSetSettingAction);
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
/*****************************************************************************
|
||||
* Copyright (c) 2014-2022 OpenRCT2 developers
|
||||
*
|
||||
* For a complete list of all authors, please refer to contributors.md
|
||||
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
||||
*
|
||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "RideFreezeRatingAction.h"
|
||||
|
||||
RideFreezeRatingAction::RideFreezeRatingAction(RideId rideIndex, RideRatingType type, ride_rating value)
|
||||
: _rideIndex(rideIndex)
|
||||
, _type(type)
|
||||
, _value(value)
|
||||
{
|
||||
}
|
||||
|
||||
void RideFreezeRatingAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
stream << DS_TAG(_rideIndex) << DS_TAG(_type) << DS_TAG(_value);
|
||||
}
|
||||
|
||||
GameActions::Result RideFreezeRatingAction::Query() const
|
||||
{
|
||||
auto ride = get_ride(_rideIndex);
|
||||
if (ride == nullptr)
|
||||
{
|
||||
log_warning("Invalid game command, ride_id = %u", _rideIndex.ToUnderlying());
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_NONE, STR_NONE);
|
||||
}
|
||||
|
||||
if (_value <= 0)
|
||||
{
|
||||
log_warning("Rating value must be positive", _rideIndex.ToUnderlying());
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_NONE, STR_NONE);
|
||||
}
|
||||
|
||||
return GameActions::Result();
|
||||
}
|
||||
|
||||
GameActions::Result RideFreezeRatingAction::Execute() const
|
||||
{
|
||||
auto ride = get_ride(_rideIndex);
|
||||
|
||||
switch (_type)
|
||||
{
|
||||
case RideRatingType::Excitement:
|
||||
ride->excitement = _value;
|
||||
break;
|
||||
case RideRatingType::Intensity:
|
||||
ride->intensity = _value;
|
||||
break;
|
||||
case RideRatingType::Nausea:
|
||||
ride->nausea = _value;
|
||||
break;
|
||||
}
|
||||
|
||||
ride->lifecycle_flags |= RIDE_LIFECYCLE_FIXED_RATINGS;
|
||||
|
||||
window_invalidate_by_number(WindowClass::Ride, _rideIndex.ToUnderlying());
|
||||
|
||||
auto res = GameActions::Result();
|
||||
return res;
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/*****************************************************************************
|
||||
* Copyright (c) 2014-2022 OpenRCT2 developers
|
||||
*
|
||||
* For a complete list of all authors, please refer to contributors.md
|
||||
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
||||
*
|
||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "GameAction.h"
|
||||
|
||||
enum class RideRatingType : uint8_t
|
||||
{
|
||||
Excitement,
|
||||
Intensity,
|
||||
Nausea,
|
||||
};
|
||||
//
|
||||
class RideFreezeRatingAction final : public GameActionBase<GameCommand::FreezeRideRating>
|
||||
{
|
||||
private:
|
||||
RideId _rideIndex{ RideId::GetNull() };
|
||||
RideRatingType _type{};
|
||||
ride_rating _value{};
|
||||
|
||||
public:
|
||||
RideFreezeRatingAction() = default;
|
||||
RideFreezeRatingAction(RideId rideIndex, RideRatingType type, ride_rating value);
|
||||
|
||||
void Serialise(DataSerialiser& stream) override;
|
||||
GameActions::Result Query() const override;
|
||||
GameActions::Result Execute() const override;
|
||||
};
|
|
@ -18,6 +18,7 @@
|
|||
#include "../Version.h"
|
||||
#include "../actions/ClimateSetAction.h"
|
||||
#include "../actions/ParkSetParameterAction.h"
|
||||
#include "../actions/RideFreezeRatingAction.h"
|
||||
#include "../actions/RideSetPriceAction.h"
|
||||
#include "../actions/RideSetSettingAction.h"
|
||||
#include "../actions/ScenarioSetSettingAction.h"
|
||||
|
@ -299,7 +300,8 @@ static int32_t cc_rides(InteractiveConsole& console, const arguments_t& argv)
|
|||
}
|
||||
else
|
||||
{
|
||||
auto ride = get_ride(RideId::FromUnderlying(ride_index));
|
||||
auto rideIndex = RideId::FromUnderlying(ride_index);
|
||||
auto ride = get_ride(rideIndex);
|
||||
if (excitement <= 0)
|
||||
{
|
||||
console.WriteFormatLine("Excitement value must be strictly positive");
|
||||
|
@ -310,7 +312,8 @@ static int32_t cc_rides(InteractiveConsole& console, const arguments_t& argv)
|
|||
}
|
||||
else
|
||||
{
|
||||
ride->excitement = excitement;
|
||||
auto rideAction = RideFreezeRatingAction(rideIndex, RideRatingType::Excitement, excitement);
|
||||
GameActions::Execute(&rideAction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -330,7 +333,8 @@ static int32_t cc_rides(InteractiveConsole& console, const arguments_t& argv)
|
|||
}
|
||||
else
|
||||
{
|
||||
auto ride = get_ride(RideId::FromUnderlying(ride_index));
|
||||
auto rideIndex = RideId::FromUnderlying(ride_index);
|
||||
auto ride = get_ride(rideIndex);
|
||||
if (intensity <= 0)
|
||||
{
|
||||
console.WriteFormatLine("Intensity value must be strictly positive");
|
||||
|
@ -341,7 +345,8 @@ static int32_t cc_rides(InteractiveConsole& console, const arguments_t& argv)
|
|||
}
|
||||
else
|
||||
{
|
||||
ride->intensity = intensity;
|
||||
auto rideAction = RideFreezeRatingAction(rideIndex, RideRatingType::Intensity, intensity);
|
||||
GameActions::Execute(&rideAction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -361,7 +366,8 @@ static int32_t cc_rides(InteractiveConsole& console, const arguments_t& argv)
|
|||
}
|
||||
else
|
||||
{
|
||||
auto ride = get_ride(RideId::FromUnderlying(ride_index));
|
||||
auto rideIndex = RideId::FromUnderlying(ride_index);
|
||||
auto ride = get_ride(rideIndex);
|
||||
if (nausea <= 0)
|
||||
{
|
||||
console.WriteFormatLine("Nausea value must be strictly positive");
|
||||
|
@ -372,7 +378,8 @@ static int32_t cc_rides(InteractiveConsole& console, const arguments_t& argv)
|
|||
}
|
||||
else
|
||||
{
|
||||
ride->nausea = nausea;
|
||||
auto rideAction = RideFreezeRatingAction(rideIndex, RideRatingType::Nausea, nausea);
|
||||
GameActions::Execute(&rideAction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,6 +111,7 @@
|
|||
<ClInclude Include="actions\RideDemolishAction.h" />
|
||||
<ClInclude Include="actions\RideEntranceExitPlaceAction.h" />
|
||||
<ClInclude Include="actions\RideEntranceExitRemoveAction.h" />
|
||||
<ClInclude Include="actions\RideFreezeRatingAction.h" />
|
||||
<ClInclude Include="actions\RideSetAppearanceAction.h" />
|
||||
<ClInclude Include="actions\RideSetColourSchemeAction.h" />
|
||||
<ClInclude Include="actions\RideSetNameAction.h" />
|
||||
|
@ -606,6 +607,7 @@
|
|||
<ClCompile Include="actions\RideDemolishAction.cpp" />
|
||||
<ClCompile Include="actions\RideEntranceExitPlaceAction.cpp" />
|
||||
<ClCompile Include="actions\RideEntranceExitRemoveAction.cpp" />
|
||||
<ClCompile Include="actions\RideFreezeRatingAction.cpp" />
|
||||
<ClCompile Include="actions\RideSetAppearanceAction.cpp" />
|
||||
<ClCompile Include="actions\RideSetColourSchemeAction.cpp" />
|
||||
<ClCompile Include="actions\RideSetNameAction.cpp" />
|
||||
|
|
|
@ -237,6 +237,7 @@ const std::array<NetworkAction, static_cast<size_t>(NetworkPermission::Count)> N
|
|||
{
|
||||
GameCommand::Cheat,
|
||||
GameCommand::SetDate,
|
||||
GameCommand::FreezeRideRating,
|
||||
},
|
||||
},
|
||||
NetworkAction{
|
||||
|
|
|
@ -1310,6 +1310,7 @@ const static EnumMap<GameCommand> ActionNameToType = {
|
|||
{ "ridedemolish", GameCommand::DemolishRide },
|
||||
{ "rideentranceexitplace", GameCommand::PlaceRideEntranceOrExit },
|
||||
{ "rideentranceexitremove", GameCommand::RemoveRideEntranceOrExit },
|
||||
{ "ridefreezerating", GameCommand::FreezeRideRating },
|
||||
{ "ridesetappearance", GameCommand::SetRideAppearance },
|
||||
{ "ridesetcolourscheme", GameCommand::SetColourScheme },
|
||||
{ "ridesetname", GameCommand::SetRideName },
|
||||
|
|
Loading…
Reference in New Issue