Fix #20747: handle staff speed permanency/serialization/apply for new staff (#20756)

This commit is contained in:
KawkMob 2023-11-12 12:06:51 +01:00 committed by GitHub
parent d6a481b066
commit 135c8b9f9b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 49 additions and 14 deletions

View file

@ -12,6 +12,7 @@
- Fix: [#20356] Cannot set tertiary colour on small scenery. - Fix: [#20356] Cannot set tertiary colour on small scenery.
- Fix: [#20679] Android: game crashes at launch. - Fix: [#20679] Android: game crashes at launch.
- Fix: [#20737] Spent money in player window underflows when getting refunds. - Fix: [#20737] Spent money in player window underflows when getting refunds.
- Fix: [#20747] Staff speed cheat not applying to newly hired staff, UI not showing the current applied speed.
- Fix: [#20778] [Plugin] Incorrect target api when executing custom actions. - Fix: [#20778] [Plugin] Incorrect target api when executing custom actions.
- Fix: [#20807] Tertiary colour not copied with small scenery. - Fix: [#20807] Tertiary colour not copied with small scenery.
- Fix: [#20964] Crash when player connects to server with a group assigned that no longer exists. - Fix: [#20964] Crash when player connects to server with a group assigned that no longer exists.

View file

@ -45,8 +45,8 @@ enum
static StringId _staffSpeedNames[] = static StringId _staffSpeedNames[] =
{ {
STR_FROZEN,
STR_NORMAL, STR_NORMAL,
STR_FROZEN,
STR_FAST, STR_FAST,
}; };
@ -361,7 +361,6 @@ class CheatsWindow final : public Window
private: private:
char _moneySpinnerText[MONEY_STRING_MAXLENGTH]{}; char _moneySpinnerText[MONEY_STRING_MAXLENGTH]{};
money64 _moneySpinnerValue = CHEATS_MONEY_DEFAULT; money64 _moneySpinnerValue = CHEATS_MONEY_DEFAULT;
int32_t _selectedStaffSpeed = 1;
int32_t _parkRatingSpinnerValue{}; int32_t _parkRatingSpinnerValue{};
int32_t _yearSpinnerValue = 1; int32_t _yearSpinnerValue = 1;
int32_t _monthSpinnerValue = 1; int32_t _monthSpinnerValue = 1;
@ -509,7 +508,7 @@ public:
// Current weather // Current weather
window_cheats_misc_widgets[WIDX_WEATHER].text = WeatherTypes[EnumValue(gClimateCurrent.Weather)]; window_cheats_misc_widgets[WIDX_WEATHER].text = WeatherTypes[EnumValue(gClimateCurrent.Weather)];
// Staff speed // Staff speed
window_cheats_misc_widgets[WIDX_STAFF_SPEED].text = _staffSpeedNames[_selectedStaffSpeed]; window_cheats_misc_widgets[WIDX_STAFF_SPEED].text = _staffSpeedNames[EnumValue(gCheatsSelectedStaffSpeed)];
if (gScreenFlags & SCREEN_FLAGS_EDITOR) if (gScreenFlags & SCREEN_FLAGS_EDITOR)
{ {
@ -851,7 +850,7 @@ private:
WindowDropdownShowTextCustomWidth( WindowDropdownShowTextCustomWidth(
{ windowPos.x + dropdownWidget->left, windowPos.y + dropdownWidget->top }, dropdownWidget->height() + 1, { windowPos.x + dropdownWidget->left, windowPos.y + dropdownWidget->top }, dropdownWidget->height() + 1,
colours[1], 0, Dropdown::Flag::StayOpen, 3, dropdownWidget->width() - 3); colours[1], 0, Dropdown::Flag::StayOpen, 3, dropdownWidget->width() - 3);
Dropdown::SetChecked(_selectedStaffSpeed, true); Dropdown::SetChecked(EnumValue(gCheatsSelectedStaffSpeed), true);
} }
} }
} }
@ -934,18 +933,24 @@ private:
} }
if (widgetIndex == WIDX_STAFF_SPEED_DROPDOWN_BUTTON) if (widgetIndex == WIDX_STAFF_SPEED_DROPDOWN_BUTTON)
{ {
int32_t speed = CHEATS_STAFF_FAST_SPEED; int32_t speed = CHEATS_STAFF_NORMAL_SPEED;
switch (dropdownIndex) switch (dropdownIndex)
{ {
case 0: case 0:
gCheatsSelectedStaffSpeed = StaffSpeedCheat::None;
speed = CHEATS_STAFF_NORMAL_SPEED;
break;
case 1:
gCheatsSelectedStaffSpeed = StaffSpeedCheat::Frozen;
speed = CHEATS_STAFF_FREEZE_SPEED; speed = CHEATS_STAFF_FREEZE_SPEED;
break; break;
case 1:
speed = CHEATS_STAFF_NORMAL_SPEED;
}
case 2:
gCheatsSelectedStaffSpeed = StaffSpeedCheat::Fast;
speed = CHEATS_STAFF_FAST_SPEED;
}
CheatsSet(CheatType::SetStaffSpeed, speed); CheatsSet(CheatType::SetStaffSpeed, speed);
_selectedStaffSpeed = dropdownIndex;
} }
} }

View file

@ -55,6 +55,7 @@ bool gCheatsAllowTrackPlaceInvalidHeights = false;
bool gCheatsAllowRegularPathAsQueue = false; bool gCheatsAllowRegularPathAsQueue = false;
bool gCheatsAllowSpecialColourSchemes = false; bool gCheatsAllowSpecialColourSchemes = false;
bool gCheatsMakeAllDestructible = false; bool gCheatsMakeAllDestructible = false;
StaffSpeedCheat gCheatsSelectedStaffSpeed = StaffSpeedCheat::None;
void CheatsReset() void CheatsReset()
{ {
@ -83,6 +84,7 @@ void CheatsReset()
gCheatsAllowRegularPathAsQueue = false; gCheatsAllowRegularPathAsQueue = false;
gCheatsAllowSpecialColourSchemes = false; gCheatsAllowSpecialColourSchemes = false;
gCheatsMakeAllDestructible = false; gCheatsMakeAllDestructible = false;
gCheatsSelectedStaffSpeed = StaffSpeedCheat::None;
} }
void CheatsSet(CheatType cheatType, int64_t param1 /* = 0*/, int64_t param2 /* = 0*/) void CheatsSet(CheatType cheatType, int64_t param1 /* = 0*/, int64_t param2 /* = 0*/)
@ -134,6 +136,7 @@ void CheatsSerialise(DataSerialiser& ds)
CheatEntrySerialise(ds, CheatType::AllowRegularPathAsQueue, gCheatsAllowRegularPathAsQueue, count); CheatEntrySerialise(ds, CheatType::AllowRegularPathAsQueue, gCheatsAllowRegularPathAsQueue, count);
CheatEntrySerialise(ds, CheatType::AllowSpecialColourSchemes, gCheatsAllowSpecialColourSchemes, count); CheatEntrySerialise(ds, CheatType::AllowSpecialColourSchemes, gCheatsAllowSpecialColourSchemes, count);
CheatEntrySerialise(ds, CheatType::MakeDestructible, gCheatsMakeAllDestructible, count); CheatEntrySerialise(ds, CheatType::MakeDestructible, gCheatsMakeAllDestructible, count);
CheatEntrySerialise(ds, CheatType::SetStaffSpeed, gCheatsSelectedStaffSpeed, count);
// Remember current position and update count. // Remember current position and update count.
uint64_t endOffset = stream.GetPosition(); uint64_t endOffset = stream.GetPosition();
@ -235,6 +238,9 @@ void CheatsSerialise(DataSerialiser& ds)
case CheatType::MakeDestructible: case CheatType::MakeDestructible:
ds << gCheatsMakeAllDestructible; ds << gCheatsMakeAllDestructible;
break; break;
case CheatType::SetStaffSpeed:
ds << gCheatsSelectedStaffSpeed;
break;
default: default:
break; break;
} }

View file

@ -11,6 +11,13 @@
#include "common.h" #include "common.h"
enum class StaffSpeedCheat
{
None,
Frozen,
Fast,
};
extern bool gCheatsSandboxMode; extern bool gCheatsSandboxMode;
extern bool gCheatsDisableClearanceChecks; extern bool gCheatsDisableClearanceChecks;
extern bool gCheatsDisableSupportLimits; extern bool gCheatsDisableSupportLimits;
@ -36,6 +43,7 @@ extern bool gCheatsAllowTrackPlaceInvalidHeights;
extern bool gCheatsAllowRegularPathAsQueue; extern bool gCheatsAllowRegularPathAsQueue;
extern bool gCheatsAllowSpecialColourSchemes; extern bool gCheatsAllowSpecialColourSchemes;
extern bool gCheatsMakeAllDestructible; extern bool gCheatsMakeAllDestructible;
extern StaffSpeedCheat gCheatsSelectedStaffSpeed;
enum class CheatType : int32_t enum class CheatType : int32_t
{ {

View file

@ -201,10 +201,25 @@ GameActions::Result StaffHireNewAction::QueryExecute(bool execute) const
newPeep->TrousersColour = colour; newPeep->TrousersColour = colour;
// Staff energy determines their walking speed // Staff energy determines their walking speed
newPeep->Energy = 0x60; switch (gCheatsSelectedStaffSpeed)
newPeep->EnergyTarget = 0x60; {
newPeep->StaffMowingTimeout = 0; case StaffSpeedCheat::None:
newPeep->Energy = CHEATS_STAFF_NORMAL_SPEED;
newPeep->EnergyTarget = CHEATS_STAFF_NORMAL_SPEED;
break;
case StaffSpeedCheat::Frozen:
newPeep->Energy = CHEATS_STAFF_FREEZE_SPEED;
newPeep->EnergyTarget = CHEATS_STAFF_FREEZE_SPEED;
break;
case StaffSpeedCheat::Fast:
newPeep->Energy = CHEATS_STAFF_FAST_SPEED;
newPeep->EnergyTarget = CHEATS_STAFF_FAST_SPEED;
break;
}
newPeep->StaffMowingTimeout = 0;
newPeep->PatrolInfo = nullptr; newPeep->PatrolInfo = nullptr;
res.SetData(StaffHireNewActionResult{ newPeep->Id }); res.SetData(StaffHireNewActionResult{ newPeep->Id });

View file

@ -9,10 +9,10 @@ struct ObjectRepositoryItem;
namespace OpenRCT2 namespace OpenRCT2
{ {
// Current version that is saved. // Current version that is saved.
constexpr uint32_t PARK_FILE_CURRENT_VERSION = 32; constexpr uint32_t PARK_FILE_CURRENT_VERSION = 33;
// The minimum version that is forwards compatible with the current version. // The minimum version that is forwards compatible with the current version.
constexpr uint32_t PARK_FILE_MIN_VERSION = 32; constexpr uint32_t PARK_FILE_MIN_VERSION = 33;
// The minimum version that is backwards compatible with the current version. // The minimum version that is backwards compatible with the current version.
// If this is increased beyond 0, uncomment the checks in ParkFile.cpp and Context.cpp! // If this is increased beyond 0, uncomment the checks in ParkFile.cpp and Context.cpp!