1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-10 09:32:29 +01:00

Make remove_park_fences multiplayer-safe

This commit is contained in:
Gymnasiast
2023-10-28 21:21:13 +02:00
parent e24b59e939
commit 6d87e3e56d
7 changed files with 30 additions and 12 deletions

View File

@@ -3695,6 +3695,7 @@ STR_6589 :Show window buttons on the left
STR_6590 :Show the window buttons (e.g. to close the window) on the left of the title bar instead of on the right.
STR_6591 :Staff member is currently fixing a ride and cant be fired.
STR_6592 :Staff member is currently inspecting a ride and cant be fired.
STR_6593 :Remove park fences
#############
# Scenarios #

View File

@@ -342,6 +342,8 @@ const char* CheatsGetName(CheatType cheatType)
return LanguageGetString(STR_CHEAT_ALLOW_PATH_AS_QUEUE);
case CheatType::AllowSpecialColourSchemes:
return LanguageGetString(STR_CHEAT_ALLOW_SPECIAL_COLOUR_SCHEMES);
case CheatType::RemoveParkFences:
return LanguageGetString(STR_CHEAT_REMOVE_PARK_FENCES);
default:
return "Unknown Cheat";
}

View File

@@ -91,6 +91,7 @@ enum class CheatType : int32_t
NoCapOnQueueLengthDummy, // Removed; this dummy exists only for deserialisation parks that had it saved
AllowRegularPathAsQueue,
AllowSpecialColourSchemes,
RemoveParkFences,
Count,
};

View File

@@ -248,6 +248,9 @@ GameActions::Result CheatSetAction::Execute() const
case CheatType::AllowSpecialColourSchemes:
gCheatsAllowSpecialColourSchemes = static_cast<bool>(_param1);
break;
case CheatType::RemoveParkFences:
RemoveParkFences();
break;
default:
{
LOG_ERROR("Unabled cheat: %d", _cheatType.id);
@@ -395,6 +398,8 @@ ParametersRange CheatSetAction::GetParameterRange(CheatType cheatType) const
case CheatType::NoCapOnQueueLengthDummy:
[[fallthrough]];
case CheatType::RemoveLitter:
[[fallthrough]];
case CheatType::RemoveParkFences:
return { { 0, 0 }, { 0, 0 } };
case CheatType::Count:
break;
@@ -786,3 +791,19 @@ void CheatSetAction::CreateDucks(int count) const
}
}
}
void CheatSetAction::RemoveParkFences() const
{
TileElementIterator it;
TileElementIteratorBegin(&it);
do
{
if (it.element->GetType() == TileElementType::Surface)
{
// Remove all park fence flags
it.element->AsSurface()->SetParkFences(0);
}
} while (TileElementIteratorNext(&it));
GfxInvalidateScreen();
}

View File

@@ -54,4 +54,5 @@ private:
void OwnAllLand() const;
void ParkSetOpen(bool isOpen) const;
void CreateDucks(int count) const;
void RemoveParkFences() const;
};

View File

@@ -1396,18 +1396,8 @@ static int32_t ConsoleCommandRemoveFloatingObjects(InteractiveConsole& console,
static int32_t ConsoleCommandRemoveParkFences(InteractiveConsole& console, [[maybe_unused]] const arguments_t& argv)
{
TileElementIterator it;
TileElementIteratorBegin(&it);
do
{
if (it.element->GetType() == TileElementType::Surface)
{
// Remove all park fence flags
it.element->AsSurface()->SetParkFences(0);
}
} while (TileElementIteratorNext(&it));
GfxInvalidateScreen();
auto action = CheatSetAction(CheatType::RemoveParkFences);
GameActions::Execute(&action);
console.WriteFormatLine("Park fences have been removed.");
return 0;

View File

@@ -4000,6 +4000,8 @@ enum : uint16_t
STR_CANT_FIRE_STAFF_FIXING = 6591,
STR_CANT_FIRE_STAFF_INSPECTING = 6592,
STR_CHEAT_REMOVE_PARK_FENCES = 6593,
// Have to include resource strings (from scenarios and objects) for the time being now that language is partially working
/* MAX_STR_COUNT = 32768 */ // MAX_STR_COUNT - upper limit for number of strings, not the current count strings
};