1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-20 13:33:02 +01:00

Return date and park by reference from game state

This commit is contained in:
Ted John
2018-05-30 13:06:39 +01:00
parent 1e7560e7da
commit 9d617958cf
8 changed files with 25 additions and 20 deletions

View File

@@ -270,10 +270,11 @@ static void cheat_clear_loan()
static void cheat_generate_guests(sint32 count)
{
auto park = GetContext()->GetGameState()->GetPark();
auto& park = GetContext()->GetGameState()->GetPark();
for (sint32 i = 0; i < count; i++)
park->GenerateGuest();
{
park.GenerateGuest();
}
window_invalidate_by_class(WC_BOTTOM_TOOLBAR);
}

View File

@@ -34,9 +34,10 @@ namespace OpenRCT2
public:
GameState();
GameState(const GameState&) = delete;
Date * GetDate() { return &_date; }
Park * GetPark() { return _park.get(); }
Date& GetDate() { return _date; }
Park& GetPark() { return *_park; }
void InitAll(sint32 mapSize);
void Update();

View File

@@ -235,7 +235,7 @@ private:
user_string_free(ride->name);
ride->type = RIDE_TYPE_NULL;
gParkValue = GetContext()->GetGameState()->GetPark()->CalculateParkValue();
gParkValue = GetContext()->GetGameState()->GetPark().CalculateParkValue();
auto res = std::make_unique<GameActionResult>();
res->ExpenditureType = RCT_EXPENDITURE_TYPE_RIDE_CONSTRUCTION;

View File

@@ -284,8 +284,8 @@ public:
{
// 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 = GetContext()->GetGameState()->GetPark();
_parkValueConversionFactor = (park->CalculateParkValue() * 10) / _s4.park_value;
auto& park = GetContext()->GetGameState()->GetPark();
_parkValueConversionFactor = (park.CalculateParkValue() * 10) / _s4.park_value;
}
else
{

View File

@@ -111,10 +111,10 @@ void scenario_begin()
if (gScenarioObjectiveType != OBJECTIVE_NONE && !gLoadKeepWindowsOpen)
context_open_window_view(WV_PARK_OBJECTIVE);
auto park = GetContext()->GetGameState()->GetPark();
gParkRating = park->CalculateParkRating();
gParkValue = park->CalculateParkValue();
gCompanyValue = park->CalculateCompanyValue();
auto& park = GetContext()->GetGameState()->GetPark();
gParkRating = park.CalculateParkRating();
gParkValue = park.CalculateParkValue();
gCompanyValue = park.CalculateCompanyValue();
gHistoricalProfit = gInitialCash - gBankLoan;
gCash = gInitialCash;
@@ -173,7 +173,7 @@ void scenario_begin()
gTotalAdmissions = 0;
gTotalIncomeFromAdmissions = 0;
safe_strcpy(gScenarioCompletedBy, "?", sizeof(gScenarioCompletedBy));
park->ResetHistories();
park.ResetHistories();
finance_reset_history();
award_reset();
reset_all_ride_build_dates();

View File

@@ -446,8 +446,8 @@ void game_command_buy_land_rights(
void set_forced_park_rating(sint32 rating)
{
_forcedParkRating = rating;
auto park = GetContext()->GetGameState()->GetPark();
gParkRating = park->CalculateParkRating();
auto& park = GetContext()->GetGameState()->GetPark();
gParkRating = park.CalculateParkRating();
auto intent = Intent(INTENT_ACTION_UPDATE_PARK_RATING);
context_broadcast_intent(&intent);
}
@@ -1058,12 +1058,12 @@ void Park::UpdateHistories()
sint32 park_is_open()
{
return GetContext()->GetGameState()->GetPark()->IsOpen();
return GetContext()->GetGameState()->GetPark().IsOpen();
}
sint32 park_calculate_size()
{
auto tiles = GetContext()->GetGameState()->GetPark()->CalculateParkSize();
auto tiles = GetContext()->GetGameState()->GetPark().CalculateParkSize();
if (tiles != gParkSize)
{
gParkSize = tiles;

View File

@@ -60,6 +60,9 @@ namespace OpenRCT2
class Park final
{
public:
Park() = default;
Park(const Park&) = delete;
bool IsOpen() const;
uint16 GetParkRating() const;