mirror of https://github.com/OpenRCT2/OpenRCT2.git
Turn Park into struct
This commit is contained in:
parent
7b072808ee
commit
4f3b7aa8a9
|
@ -134,8 +134,8 @@ static InteractionInfo ViewportInteractionGetItemLeft(const ScreenCoordsXY& scre
|
|||
break;
|
||||
case ViewportInteractionItem::ParkEntrance:
|
||||
{
|
||||
auto& park = GetGameState().Park;
|
||||
auto parkName = park.Name.c_str();
|
||||
auto& gameState = GetGameState();
|
||||
auto parkName = gameState.Park.Name.c_str();
|
||||
|
||||
auto ft = Formatter();
|
||||
ft.Add<StringId>(STR_STRING);
|
||||
|
|
|
@ -662,9 +662,9 @@ static uint64_t window_editor_objective_options_page_hold_down_widgets[] = {
|
|||
{
|
||||
case WIDX_PARK_NAME:
|
||||
{
|
||||
auto& park = OpenRCT2::GetGameState().Park;
|
||||
WindowTextInputRawOpen(
|
||||
this, WIDX_PARK_NAME, STR_PARK_NAME, STR_ENTER_PARK_NAME, {}, park.Name.c_str(), ParkNameMaxLength);
|
||||
this, WIDX_PARK_NAME, STR_PARK_NAME, STR_ENTER_PARK_NAME, {}, gameState.Park.Name.c_str(),
|
||||
ParkNameMaxLength);
|
||||
break;
|
||||
}
|
||||
case WIDX_SCENARIO_NAME:
|
||||
|
@ -794,8 +794,7 @@ static uint64_t window_editor_objective_options_page_hold_down_widgets[] = {
|
|||
|
||||
if (gameState.ScenarioName.empty())
|
||||
{
|
||||
auto& park = OpenRCT2::GetGameState().Park;
|
||||
gameState.ScenarioName = park.Name;
|
||||
gameState.ScenarioName = gameState.Park.Name;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -972,8 +971,7 @@ static uint64_t window_editor_objective_options_page_hold_down_widgets[] = {
|
|||
widthToSet = widgets[WIDX_PARK_NAME].left - 16;
|
||||
|
||||
{
|
||||
auto& park = OpenRCT2::GetGameState().Park;
|
||||
auto parkName = park.Name.c_str();
|
||||
auto parkName = OpenRCT2::GetGameState().Park.Name.c_str();
|
||||
|
||||
ft = Formatter();
|
||||
ft.Add<StringId>(STR_STRING);
|
||||
|
|
|
@ -870,8 +870,7 @@ static Widget _windowFinancesResearchWidgets[] =
|
|||
break;
|
||||
default:
|
||||
{
|
||||
auto& park = OpenRCT2::GetGameState().Park;
|
||||
auto parkName = park.Name.c_str();
|
||||
auto parkName = OpenRCT2::GetGameState().Park.Name.c_str();
|
||||
ft.Add<StringId>(STR_STRING);
|
||||
ft.Add<const char*>(parkName);
|
||||
}
|
||||
|
|
|
@ -1629,8 +1629,7 @@ static_assert(_guestWindowPageWidgets.size() == WINDOW_GUEST_PAGE_COUNT);
|
|||
|
||||
std::pair<StringId, Formatter> InventoryFormatItem(Guest& guest, ShopItem item) const
|
||||
{
|
||||
auto& park = OpenRCT2::GetGameState().Park;
|
||||
auto parkName = park.Name.c_str();
|
||||
auto parkName = OpenRCT2::GetGameState().Park.Name.c_str();
|
||||
|
||||
// Default arguments
|
||||
auto ft = Formatter();
|
||||
|
|
|
@ -458,8 +458,7 @@ static Widget window_loadsave_widgets[] =
|
|||
}
|
||||
else
|
||||
{
|
||||
auto& park = OpenRCT2::GetGameState().Park;
|
||||
auto buffer = park.Name;
|
||||
auto buffer = OpenRCT2::GetGameState().Park.Name;
|
||||
if (buffer.empty())
|
||||
{
|
||||
buffer = LanguageGetString(STR_UNNAMED_PARK);
|
||||
|
|
|
@ -402,8 +402,7 @@ static constexpr WindowParkAward _parkAwards[] = {
|
|||
|
||||
void PrepareWindowTitleText()
|
||||
{
|
||||
auto& park = OpenRCT2::GetGameState().Park;
|
||||
auto parkName = park.Name.c_str();
|
||||
auto parkName = OpenRCT2::GetGameState().Park.Name.c_str();
|
||||
|
||||
auto ft = Formatter::Common();
|
||||
ft.Add<StringId>(STR_STRING);
|
||||
|
@ -456,7 +455,7 @@ static constexpr WindowParkAward _parkAwards[] = {
|
|||
WindowDropdownShowText(
|
||||
{ windowPos.x + widget.left, windowPos.y + widget.top }, widget.height() + 1, colours[1], 0, 2);
|
||||
|
||||
if (ParkIsOpen())
|
||||
if (GetGameState().Park.IsOpen())
|
||||
{
|
||||
gDropdownDefaultIndex = 0;
|
||||
Dropdown::SetChecked(1, true);
|
||||
|
@ -512,18 +511,18 @@ static constexpr WindowParkAward _parkAwards[] = {
|
|||
|
||||
// Set open / close park button state
|
||||
{
|
||||
auto& park = OpenRCT2::GetGameState().Park;
|
||||
auto parkName = park.Name.c_str();
|
||||
auto parkName = OpenRCT2::GetGameState().Park.Name.c_str();
|
||||
|
||||
auto ft = Formatter::Common();
|
||||
ft.Add<StringId>(STR_STRING);
|
||||
ft.Add<const char*>(parkName);
|
||||
}
|
||||
widgets[WIDX_OPEN_OR_CLOSE].image = ImageId(ParkIsOpen() ? SPR_OPEN : SPR_CLOSED);
|
||||
const auto closeLightImage = SPR_G2_RCT1_CLOSE_BUTTON_0 + !ParkIsOpen() * 2
|
||||
const bool parkIsOpen = gameState.Park.IsOpen();
|
||||
widgets[WIDX_OPEN_OR_CLOSE].image = ImageId(parkIsOpen ? SPR_OPEN : SPR_CLOSED);
|
||||
const auto closeLightImage = SPR_G2_RCT1_CLOSE_BUTTON_0 + !parkIsOpen * 2
|
||||
+ WidgetIsPressed(*this, WIDX_CLOSE_LIGHT);
|
||||
widgets[WIDX_CLOSE_LIGHT].image = ImageId(closeLightImage);
|
||||
const auto openLightImage = SPR_G2_RCT1_OPEN_BUTTON_0 + ParkIsOpen() * 2 + WidgetIsPressed(*this, WIDX_OPEN_LIGHT);
|
||||
const auto openLightImage = SPR_G2_RCT1_OPEN_BUTTON_0 + parkIsOpen * 2 + WidgetIsPressed(*this, WIDX_OPEN_LIGHT);
|
||||
widgets[WIDX_OPEN_LIGHT].image = ImageId(openLightImage);
|
||||
|
||||
// Only allow closing of park for guest / rating objective
|
||||
|
@ -605,7 +604,7 @@ static constexpr WindowParkAward _parkAwards[] = {
|
|||
|
||||
// Draw park closed / open label
|
||||
auto ft = Formatter();
|
||||
ft.Add<StringId>(ParkIsOpen() ? STR_PARK_OPEN : STR_PARK_CLOSED);
|
||||
ft.Add<StringId>(GetGameState().Park.IsOpen() ? STR_PARK_OPEN : STR_PARK_CLOSED);
|
||||
|
||||
auto* labelWidget = &widgets[WIDX_STATUS];
|
||||
DrawTextEllipsised(
|
||||
|
|
|
@ -499,13 +499,13 @@ namespace Editor
|
|||
*/
|
||||
ResultWithMessage CheckPark()
|
||||
{
|
||||
int32_t parkSize = ParkCalculateSize();
|
||||
auto& gameState = GetGameState();
|
||||
int32_t parkSize = ParkUpdateSize(gameState);
|
||||
if (parkSize == 0)
|
||||
{
|
||||
return { false, STR_PARK_MUST_OWN_SOME_LAND };
|
||||
}
|
||||
|
||||
const auto& gameState = GetGameState();
|
||||
if (gameState.ParkEntrances.empty())
|
||||
{
|
||||
return { false, STR_NO_PARK_ENTRANCES };
|
||||
|
|
|
@ -70,7 +70,7 @@ namespace OpenRCT2
|
|||
gameState.CurrentTicks = 0;
|
||||
|
||||
MapInit(mapSize);
|
||||
gameState.Park.Initialise();
|
||||
ParkInitialise(gameState);
|
||||
FinanceInit();
|
||||
BannerInit(gameState);
|
||||
RideInitAll();
|
||||
|
@ -344,7 +344,7 @@ namespace OpenRCT2
|
|||
|
||||
if (!(gScreenFlags & SCREEN_FLAGS_EDITOR))
|
||||
{
|
||||
gameState.Park.Update(gameState.Date);
|
||||
ParkUpdate(gameState, gameState.Date);
|
||||
}
|
||||
|
||||
ResearchUpdate();
|
||||
|
|
|
@ -34,11 +34,12 @@
|
|||
|
||||
namespace OpenRCT2
|
||||
{
|
||||
class Park;
|
||||
struct Park;
|
||||
|
||||
struct GameState_t
|
||||
{
|
||||
::OpenRCT2::Park Park{};
|
||||
std::string PluginStorage;
|
||||
uint32_t CurrentTicks{};
|
||||
::OpenRCT2::Date Date;
|
||||
uint64_t ParkFlags;
|
||||
|
|
|
@ -222,7 +222,7 @@ GameActions::Result CheatSetAction::Execute() const
|
|||
GetGameState().Cheats.NeverendingMarketing = _param1 != 0;
|
||||
break;
|
||||
case CheatType::OpenClosePark:
|
||||
ParkSetOpen(!ParkIsOpen());
|
||||
ParkSetOpen(!GetGameState().Park.IsOpen());
|
||||
break;
|
||||
case CheatType::HaveFun:
|
||||
gameState.ScenarioObjective.Type = OBJECTIVE_HAVE_FUN;
|
||||
|
@ -607,10 +607,9 @@ void CheatSetAction::ClearLoan() const
|
|||
|
||||
void CheatSetAction::GenerateGuests(int32_t count) const
|
||||
{
|
||||
auto& park = OpenRCT2::GetGameState().Park;
|
||||
for (int32_t i = 0; i < count; i++)
|
||||
{
|
||||
park.GenerateGuest();
|
||||
GenerateGuest();
|
||||
}
|
||||
WindowInvalidateByClass(WindowClass::BottomToolbar);
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ GameActions::Result MapChangeSizeAction::Execute() const
|
|||
auto* ctx = OpenRCT2::GetContext();
|
||||
auto uiContext = ctx->GetUiContext();
|
||||
auto* windowManager = uiContext->GetWindowManager();
|
||||
ParkCalculateSize();
|
||||
ParkUpdateSize(gameState);
|
||||
|
||||
windowManager->BroadcastIntent(Intent(INTENT_ACTION_MAP));
|
||||
GfxInvalidateScreen();
|
||||
|
|
|
@ -156,7 +156,7 @@ GameActions::Result RideDemolishAction::DemolishRide(Ride& ride) const
|
|||
}
|
||||
|
||||
ride.Delete();
|
||||
GetGameState().ParkValue = GetGameState().Park.CalculateParkValue();
|
||||
GetGameState().ParkValue = CalculateParkValue();
|
||||
|
||||
// Close windows related to the demolished ride
|
||||
WindowCloseByNumber(WindowClass::RideConstruction, rideId.ToUnderlying());
|
||||
|
|
|
@ -649,29 +649,29 @@ namespace OpenRCT2
|
|||
|
||||
void ReadWritePluginStorageChunk(GameState_t& gameState, OrcaStream& os)
|
||||
{
|
||||
auto& park = gameState.Park;
|
||||
if (os.GetMode() == OrcaStream::Mode::WRITING)
|
||||
{
|
||||
#ifdef ENABLE_SCRIPTING
|
||||
// Dump the plugin storage to JSON (stored in park)
|
||||
auto& scriptEngine = GetContext()->GetScriptEngine();
|
||||
park.PluginStorage = scriptEngine.GetParkStorageAsJSON();
|
||||
gameState.PluginStorage = scriptEngine.GetParkStorageAsJSON();
|
||||
#endif
|
||||
if (park.PluginStorage.empty() || park.PluginStorage == "{}")
|
||||
if (gameState.PluginStorage.empty() || gameState.PluginStorage == "{}")
|
||||
{
|
||||
// Don't write the chunk if there is no plugin storage
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
os.ReadWriteChunk(
|
||||
ParkFileChunkType::PLUGIN_STORAGE, [&park](OrcaStream::ChunkStream& cs) { cs.ReadWrite(park.PluginStorage); });
|
||||
os.ReadWriteChunk(ParkFileChunkType::PLUGIN_STORAGE, [&gameState](OrcaStream::ChunkStream& cs) {
|
||||
cs.ReadWrite(gameState.PluginStorage);
|
||||
});
|
||||
|
||||
if (os.GetMode() == OrcaStream::Mode::READING)
|
||||
{
|
||||
#ifdef ENABLE_SCRIPTING
|
||||
auto& scriptEngine = GetContext()->GetScriptEngine();
|
||||
scriptEngine.SetParkStorageFromJSON(park.PluginStorage);
|
||||
scriptEngine.SetParkStorageFromJSON(gameState.PluginStorage);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -275,8 +275,7 @@ namespace RCT1
|
|||
{
|
||||
// Use the ratio between the old and new park value to calcute the ratio to
|
||||
// use for the park value history and the goal.
|
||||
auto& park = GetGameState().Park;
|
||||
_parkValueConversionFactor = (park.CalculateParkValue() * 10) / _s4.ParkValue;
|
||||
_parkValueConversionFactor = (CalculateParkValue() * 10) / _s4.ParkValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2149,8 +2148,7 @@ namespace RCT1
|
|||
// Park rating
|
||||
gameState.ParkRating = _s4.ParkRating;
|
||||
|
||||
auto& park = OpenRCT2::GetGameState().Park;
|
||||
park.ResetHistories();
|
||||
ResetParkHistories(gameState);
|
||||
std::copy(std::begin(_s4.ParkRatingHistory), std::end(_s4.ParkRatingHistory), gameState.ParkRatingHistory);
|
||||
for (size_t i = 0; i < std::size(_s4.GuestsInParkHistory); i++)
|
||||
{
|
||||
|
|
|
@ -307,8 +307,7 @@ namespace RCT2
|
|||
|
||||
gameState.ParkRating = _s6.ParkRating;
|
||||
|
||||
auto& park = OpenRCT2::GetGameState().Park;
|
||||
park.ResetHistories();
|
||||
ResetParkHistories(gameState);
|
||||
std::copy(std::begin(_s6.ParkRatingHistory), std::end(_s6.ParkRatingHistory), gameState.ParkRatingHistory);
|
||||
for (size_t i = 0; i < std::size(_s6.GuestsInParkHistory); i++)
|
||||
{
|
||||
|
@ -504,7 +503,7 @@ namespace RCT2
|
|||
ConvertScenarioStringsToUTF8(gameState);
|
||||
DetermineRideEntranceAndExitLocations();
|
||||
|
||||
park.Name = GetUserString(_s6.ParkName);
|
||||
gameState.Park.Name = GetUserString(_s6.ParkName);
|
||||
|
||||
FixLandOwnership();
|
||||
FixWater();
|
||||
|
|
|
@ -100,10 +100,9 @@ void ScenarioReset(GameState_t& gameState)
|
|||
ScenerySetDefaultPlacementConfiguration();
|
||||
News::InitQueue();
|
||||
|
||||
auto& park = GetGameState().Park;
|
||||
gameState.ParkRating = park.CalculateParkRating();
|
||||
gameState.ParkValue = park.CalculateParkValue();
|
||||
gameState.CompanyValue = park.CalculateCompanyValue();
|
||||
gameState.ParkRating = CalculateParkRating();
|
||||
gameState.ParkValue = CalculateParkValue();
|
||||
gameState.CompanyValue = CalculateCompanyValue();
|
||||
gameState.HistoricalProfit = gameState.InitialCash - gameState.BankLoan;
|
||||
gameState.Cash = gameState.InitialCash;
|
||||
|
||||
|
@ -120,7 +119,7 @@ void ScenarioReset(GameState_t& gameState)
|
|||
}
|
||||
if (localisedStringIds[1] != STR_NONE)
|
||||
{
|
||||
park.Name = LanguageGetString(localisedStringIds[1]);
|
||||
gameState.Park.Name = LanguageGetString(localisedStringIds[1]);
|
||||
}
|
||||
if (localisedStringIds[2] != STR_NONE)
|
||||
{
|
||||
|
@ -132,7 +131,7 @@ void ScenarioReset(GameState_t& gameState)
|
|||
// Set the last saved game path
|
||||
auto env = GetContext()->GetPlatformEnvironment();
|
||||
auto savePath = env->GetDirectoryPath(DIRBASE::USER, DIRID::SAVE);
|
||||
gScenarioSavePath = Path::Combine(savePath, park.Name + u8".park");
|
||||
gScenarioSavePath = Path::Combine(savePath, gameState.Park.Name + u8".park");
|
||||
|
||||
gameState.CurrentExpenditure = 0;
|
||||
gameState.CurrentProfit = 0;
|
||||
|
@ -145,13 +144,13 @@ void ScenarioReset(GameState_t& gameState)
|
|||
gameState.ScenarioCompletedCompanyValue = kMoney64Undefined;
|
||||
gameState.ScenarioCompletedBy = "?";
|
||||
|
||||
park.ResetHistories();
|
||||
ResetParkHistories(gameState);
|
||||
FinanceResetHistory();
|
||||
AwardReset();
|
||||
ResetAllRideBuildDates();
|
||||
ResetDate();
|
||||
Duck::RemoveAll();
|
||||
ParkCalculateSize();
|
||||
ParkUpdateSize(gameState);
|
||||
MapCountRemainingLandRights();
|
||||
Staff::ResetStats();
|
||||
|
||||
|
|
|
@ -50,6 +50,14 @@ using namespace OpenRCT2;
|
|||
// If this value is more than or equal to 0, the park rating is forced to this value. Used for cheat
|
||||
static int32_t _forcedParkRating = -1;
|
||||
|
||||
static money64 calculateRideValue(const Ride& ride);
|
||||
static money64 calculateTotalRideValueForMoney();
|
||||
static uint32_t calculateSuggestedMaxGuests();
|
||||
static uint32_t calculateGuestGenerationProbability();
|
||||
|
||||
static void generateGuests(GameState_t& gameState);
|
||||
static Guest* generateGuestFromCampaign(int32_t campaign);
|
||||
|
||||
/**
|
||||
* Choose a random peep spawn and iterates through until defined spawn is found.
|
||||
*/
|
||||
|
@ -152,8 +160,7 @@ void ParkUpdateFencesAroundTile(const CoordsXY& coords)
|
|||
void ParkSetForcedRating(int32_t rating)
|
||||
{
|
||||
_forcedParkRating = rating;
|
||||
auto& park = GetGameState().Park;
|
||||
GetGameState().ParkRating = park.CalculateParkRating();
|
||||
GetGameState().ParkRating = CalculateParkRating();
|
||||
auto intent = Intent(INTENT_ACTION_UPDATE_PARK_RATING);
|
||||
ContextBroadcastIntent(&intent);
|
||||
}
|
||||
|
@ -210,27 +217,10 @@ bool Park::IsOpen() const
|
|||
return (GetGameState().ParkFlags & PARK_FLAGS_PARK_OPEN) != 0;
|
||||
}
|
||||
|
||||
uint16_t Park::GetParkRating() const
|
||||
void ParkInitialise(GameState_t& gameState)
|
||||
{
|
||||
return GetGameState().ParkRating;
|
||||
}
|
||||
|
||||
money64 Park::GetParkValue() const
|
||||
{
|
||||
return GetGameState().ParkValue;
|
||||
}
|
||||
|
||||
money64 Park::GetCompanyValue() const
|
||||
{
|
||||
return GetGameState().CompanyValue;
|
||||
}
|
||||
|
||||
void Park::Initialise()
|
||||
{
|
||||
auto& gameState = GetGameState();
|
||||
|
||||
Name = LanguageGetString(STR_UNNAMED_PARK);
|
||||
PluginStorage = {};
|
||||
gameState.Park.Name = LanguageGetString(STR_UNNAMED_PARK);
|
||||
gameState.PluginStorage = {};
|
||||
gameState.StaffHandymanColour = COLOUR_BRIGHT_RED;
|
||||
gameState.StaffMechanicColour = COLOUR_LIGHT_BLUE;
|
||||
gameState.StaffSecurityColour = COLOUR_YELLOW;
|
||||
|
@ -272,7 +262,7 @@ void Park::Initialise()
|
|||
gameState.LandPrice = 90.00_GBP;
|
||||
gameState.ConstructionRightsPrice = 40.00_GBP;
|
||||
gameState.ParkFlags = PARK_FLAGS_NO_MONEY | PARK_FLAGS_SHOW_REAL_GUEST_NAMES;
|
||||
ResetHistories();
|
||||
ResetParkHistories(gameState);
|
||||
FinanceResetHistory();
|
||||
AwardReset();
|
||||
|
||||
|
@ -280,17 +270,16 @@ void Park::Initialise()
|
|||
gameState.ScenarioDetails = String::ToStd(LanguageGetString(STR_NO_DETAILS_YET));
|
||||
}
|
||||
|
||||
void Park::Update(const Date& date)
|
||||
void ParkUpdate(GameState_t& gameState, const Date& date)
|
||||
{
|
||||
PROFILED_FUNCTION();
|
||||
|
||||
// Every new week
|
||||
if (date.IsWeekStart())
|
||||
{
|
||||
UpdateHistories();
|
||||
UpdateParkHistories(gameState);
|
||||
}
|
||||
|
||||
auto& gameState = GetGameState();
|
||||
const auto currentTicks = gameState.CurrentTicks;
|
||||
|
||||
// Every ~13 seconds
|
||||
|
@ -299,9 +288,9 @@ void Park::Update(const Date& date)
|
|||
gameState.ParkRating = CalculateParkRating();
|
||||
gameState.ParkValue = CalculateParkValue();
|
||||
gameState.CompanyValue = CalculateCompanyValue();
|
||||
gameState.TotalRideValueForMoney = CalculateTotalRideValueForMoney();
|
||||
gameState.SuggestedGuestMaximum = CalculateSuggestedMaxGuests();
|
||||
gameState.GuestGenerationProbability = CalculateGuestGenerationProbability();
|
||||
gameState.TotalRideValueForMoney = calculateTotalRideValueForMoney();
|
||||
gameState.SuggestedGuestMaximum = calculateSuggestedMaxGuests();
|
||||
gameState.GuestGenerationProbability = calculateGuestGenerationProbability();
|
||||
|
||||
WindowInvalidateByClass(WindowClass::Finances);
|
||||
auto intent = Intent(INTENT_ACTION_UPDATE_PARK_RATING);
|
||||
|
@ -315,10 +304,10 @@ void Park::Update(const Date& date)
|
|||
WindowInvalidateByClass(WindowClass::ParkInformation);
|
||||
}
|
||||
|
||||
GenerateGuests();
|
||||
generateGuests(gameState);
|
||||
}
|
||||
|
||||
uint32_t Park::CalculateParkSize() const
|
||||
uint32_t CalculateParkSize()
|
||||
{
|
||||
uint32_t tiles = 0;
|
||||
TileElementIterator it;
|
||||
|
@ -344,7 +333,7 @@ uint32_t Park::CalculateParkSize() const
|
|||
return tiles;
|
||||
}
|
||||
|
||||
int32_t Park::CalculateParkRating() const
|
||||
int32_t CalculateParkRating()
|
||||
{
|
||||
if (_forcedParkRating >= 0)
|
||||
{
|
||||
|
@ -461,13 +450,13 @@ int32_t Park::CalculateParkRating() const
|
|||
return result;
|
||||
}
|
||||
|
||||
money64 Park::CalculateParkValue() const
|
||||
money64 CalculateParkValue()
|
||||
{
|
||||
// Sum ride values
|
||||
money64 result = 0;
|
||||
for (const auto& ride : GetRideManager())
|
||||
{
|
||||
result += CalculateRideValue(ride);
|
||||
result += calculateRideValue(ride);
|
||||
}
|
||||
|
||||
// +7.00 per guest
|
||||
|
@ -476,7 +465,7 @@ money64 Park::CalculateParkValue() const
|
|||
return result;
|
||||
}
|
||||
|
||||
money64 Park::CalculateRideValue(const Ride& ride) const
|
||||
static money64 calculateRideValue(const Ride& ride)
|
||||
{
|
||||
money64 result = 0;
|
||||
if (ride.value != RIDE_VALUE_UNDEFINED)
|
||||
|
@ -487,7 +476,7 @@ money64 Park::CalculateRideValue(const Ride& ride) const
|
|||
return result;
|
||||
}
|
||||
|
||||
money64 Park::CalculateCompanyValue() const
|
||||
money64 CalculateCompanyValue()
|
||||
{
|
||||
const auto& gameState = GetGameState();
|
||||
|
||||
|
@ -499,7 +488,7 @@ money64 Park::CalculateCompanyValue() const
|
|||
return result;
|
||||
}
|
||||
|
||||
money64 Park::CalculateTotalRideValueForMoney() const
|
||||
static money64 calculateTotalRideValueForMoney()
|
||||
{
|
||||
money64 totalRideValue = 0;
|
||||
bool ridePricesUnlocked = ParkRidePricesUnlocked() && !(GetGameState().ParkFlags & PARK_FLAGS_NO_MONEY);
|
||||
|
@ -529,7 +518,7 @@ money64 Park::CalculateTotalRideValueForMoney() const
|
|||
return totalRideValue;
|
||||
}
|
||||
|
||||
uint32_t Park::CalculateSuggestedMaxGuests() const
|
||||
static uint32_t calculateSuggestedMaxGuests()
|
||||
{
|
||||
uint32_t suggestedMaxGuests = 0;
|
||||
uint32_t difficultGenerationBonus = 0;
|
||||
|
@ -577,7 +566,7 @@ uint32_t Park::CalculateSuggestedMaxGuests() const
|
|||
return suggestedMaxGuests;
|
||||
}
|
||||
|
||||
uint32_t Park::CalculateGuestGenerationProbability() const
|
||||
static uint32_t calculateGuestGenerationProbability()
|
||||
{
|
||||
auto& gameState = GetGameState();
|
||||
|
||||
|
@ -631,7 +620,7 @@ uint32_t Park::CalculateGuestGenerationProbability() const
|
|||
return probability;
|
||||
}
|
||||
|
||||
uint8_t Park::CalculateGuestInitialHappiness(uint8_t percentage)
|
||||
uint8_t CalculateGuestInitialHappiness(uint8_t percentage)
|
||||
{
|
||||
percentage = std::clamp<uint8_t>(percentage, 15, 98);
|
||||
|
||||
|
@ -653,10 +642,8 @@ uint8_t Park::CalculateGuestInitialHappiness(uint8_t percentage)
|
|||
return 40;
|
||||
}
|
||||
|
||||
void Park::GenerateGuests()
|
||||
static void generateGuests(GameState_t& gameState)
|
||||
{
|
||||
auto& gameState = GetGameState();
|
||||
|
||||
// Generate a new guest for some probability
|
||||
if (static_cast<int32_t>(ScenarioRand() & 0xFFFF) < gameState.GuestGenerationProbability)
|
||||
{
|
||||
|
@ -675,12 +662,12 @@ void Park::GenerateGuests()
|
|||
auto random = ScenarioRandMax(std::numeric_limits<uint16_t>::max());
|
||||
if (random < probability)
|
||||
{
|
||||
GenerateGuestFromCampaign(campaign.Type);
|
||||
generateGuestFromCampaign(campaign.Type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Guest* Park::GenerateGuestFromCampaign(int32_t campaign)
|
||||
static Guest* generateGuestFromCampaign(int32_t campaign)
|
||||
{
|
||||
auto peep = GenerateGuest();
|
||||
if (peep != nullptr)
|
||||
|
@ -690,7 +677,7 @@ Guest* Park::GenerateGuestFromCampaign(int32_t campaign)
|
|||
return peep;
|
||||
}
|
||||
|
||||
Guest* Park::GenerateGuest()
|
||||
Guest* GenerateGuest()
|
||||
{
|
||||
Guest* peep = nullptr;
|
||||
const auto spawn = GetRandomPeepSpawn();
|
||||
|
@ -721,16 +708,14 @@ template<typename T, size_t TSize> static void HistoryPushRecord(T history[TSize
|
|||
history[0] = newItem;
|
||||
}
|
||||
|
||||
void Park::ResetHistories()
|
||||
void ResetParkHistories(GameState_t& gameState)
|
||||
{
|
||||
auto& gameState = GetGameState();
|
||||
std::fill(std::begin(gameState.ParkRatingHistory), std::end(gameState.ParkRatingHistory), ParkRatingHistoryUndefined);
|
||||
std::fill(std::begin(gameState.GuestsInParkHistory), std::end(gameState.GuestsInParkHistory), GuestsInParkHistoryUndefined);
|
||||
}
|
||||
|
||||
void Park::UpdateHistories()
|
||||
void UpdateParkHistories(GameState_t& gameState)
|
||||
{
|
||||
auto& gameState = GetGameState();
|
||||
uint8_t guestChangeModifier = 1;
|
||||
int32_t changeInGuestsInPark = static_cast<int32_t>(gameState.NumGuestsInPark)
|
||||
- static_cast<int32_t>(gameState.NumGuestsInParkLastWeek);
|
||||
|
@ -774,15 +759,9 @@ void Park::UpdateHistories()
|
|||
WindowInvalidateByClass(WindowClass::Finances);
|
||||
}
|
||||
|
||||
int32_t ParkIsOpen()
|
||||
uint32_t ParkUpdateSize(GameState_t& gameState)
|
||||
{
|
||||
return GetGameState().Park.IsOpen();
|
||||
}
|
||||
|
||||
uint32_t ParkCalculateSize()
|
||||
{
|
||||
auto& gameState = GetGameState();
|
||||
auto tiles = GetGameState().Park.CalculateParkSize();
|
||||
auto tiles = CalculateParkSize();
|
||||
if (tiles != gameState.ParkSize)
|
||||
{
|
||||
gameState.ParkSize = tiles;
|
||||
|
@ -790,8 +769,3 @@ uint32_t ParkCalculateSize()
|
|||
}
|
||||
return tiles;
|
||||
}
|
||||
|
||||
uint8_t CalculateGuestInitialHappiness(uint8_t percentage)
|
||||
{
|
||||
return Park::CalculateGuestInitialHappiness(percentage);
|
||||
}
|
||||
|
|
|
@ -47,57 +47,35 @@ enum : uint32_t
|
|||
};
|
||||
|
||||
struct Guest;
|
||||
struct rct_ride;
|
||||
|
||||
namespace OpenRCT2
|
||||
{
|
||||
struct Date;
|
||||
|
||||
class Park final
|
||||
struct Park final
|
||||
{
|
||||
public:
|
||||
std::string Name;
|
||||
std::string PluginStorage;
|
||||
|
||||
Park() = default;
|
||||
Park(const Park&) = delete;
|
||||
|
||||
bool IsOpen() const;
|
||||
|
||||
uint16_t GetParkRating() const;
|
||||
money64 GetParkValue() const;
|
||||
money64 GetCompanyValue() const;
|
||||
|
||||
void Initialise();
|
||||
void Update(const Date& date);
|
||||
|
||||
uint32_t CalculateParkSize() const;
|
||||
int32_t CalculateParkRating() const;
|
||||
money64 CalculateParkValue() const;
|
||||
money64 CalculateCompanyValue() const;
|
||||
static uint8_t CalculateGuestInitialHappiness(uint8_t percentage);
|
||||
|
||||
Guest* GenerateGuest();
|
||||
|
||||
void ResetHistories();
|
||||
void UpdateHistories();
|
||||
|
||||
private:
|
||||
money64 CalculateRideValue(const Ride& ride) const;
|
||||
money64 CalculateTotalRideValueForMoney() const;
|
||||
uint32_t CalculateSuggestedMaxGuests() const;
|
||||
uint32_t CalculateGuestGenerationProbability() const;
|
||||
|
||||
void GenerateGuests();
|
||||
Guest* GenerateGuestFromCampaign(int32_t campaign);
|
||||
};
|
||||
} // namespace OpenRCT2
|
||||
|
||||
void ParkInitialise(OpenRCT2::GameState_t& gameState);
|
||||
void ParkUpdate(OpenRCT2::GameState_t& gameState, const OpenRCT2::Date& date);
|
||||
|
||||
uint32_t CalculateParkSize();
|
||||
int32_t CalculateParkRating();
|
||||
money64 CalculateParkValue();
|
||||
money64 CalculateCompanyValue();
|
||||
|
||||
Guest* GenerateGuest();
|
||||
|
||||
void ResetParkHistories(OpenRCT2::GameState_t& gameState);
|
||||
void UpdateParkHistories(OpenRCT2::GameState_t& gameState);
|
||||
void ParkSetForcedRating(int32_t rating);
|
||||
int32_t ParkGetForcedRating();
|
||||
|
||||
int32_t ParkIsOpen();
|
||||
uint32_t ParkCalculateSize();
|
||||
uint32_t ParkUpdateSize(OpenRCT2::GameState_t& gameState);
|
||||
|
||||
void ParkUpdateFences(const CoordsXY& coords);
|
||||
void ParkUpdateFencesAroundTile(const CoordsXY& coords);
|
||||
|
|
Loading…
Reference in New Issue