1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-23 15:52:55 +01:00

Refactor procedural park methods into Park calls.

This commit is contained in:
Aaron van Geffen
2018-05-19 20:14:52 +02:00
parent c211ac5a7b
commit bfa5bf6ecc
6 changed files with 24 additions and 42 deletions

View File

@@ -30,6 +30,8 @@
#include "world/Sprite.h"
#include "world/Surface.h"
using namespace OpenRCT2;
bool gCheatsSandboxMode = false;
bool gCheatsDisableClearanceChecks = false;
bool gCheatsDisableSupportLimits = false;
@@ -267,8 +269,9 @@ static void cheat_clear_loan()
static void cheat_generate_guests(sint32 count)
{
auto park = GetContext()->GetPark();
for (sint32 i = 0; i < count; i++)
park_generate_new_guest();
park->GenerateGuest();
window_invalidate_by_class(WC_BOTTOM_TOOLBAR);
}

View File

@@ -31,6 +31,8 @@
#include "GameAction.h"
#include "MazeSetTrackAction.hpp"
using namespace OpenRCT2;
struct RideDemolishAction : public GameActionBase<GAME_COMMAND_DEMOLISH_RIDE, GameActionResult>
{
private:
@@ -190,7 +192,7 @@ public:
user_string_free(ride->name);
ride->type = RIDE_TYPE_NULL;
gParkValue = calculate_park_value();
gParkValue = GetContext()->GetPark()->CalculateCompanyValue();
auto res = std::make_unique<GameActionResult>();
res->ExpenditureType = RCT_EXPENDITURE_TYPE_RIDE_CONSTRUCTION;

View File

@@ -66,6 +66,8 @@
#include "../world/SmallScenery.h"
#include "../world/Surface.h"
using namespace OpenRCT2;
static uint8 GetPathType(rct_tile_element * tileElement);
static sint32 GetWallType(rct_tile_element * tileElement, sint32 edge);
static uint8 GetWallColour(rct_tile_element * tileElement);
@@ -316,7 +318,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.
_parkValueConversionFactor = (calculate_park_value() * 10) / _s4.park_value;
auto park = GetContext()->GetPark();
_parkValueConversionFactor = (park->CalculateParkValue() * 10) / _s4.park_value;
}
else
{

View File

@@ -90,6 +90,8 @@ char gScenarioFileName[MAX_PATH];
static sint32 scenario_create_ducks();
static void scenario_objective_check();
using namespace OpenRCT2;
void scenario_begin()
{
game_load_init();
@@ -108,9 +110,10 @@ void scenario_begin()
if (gScenarioObjectiveType != OBJECTIVE_NONE && !gLoadKeepWindowsOpen)
context_open_window_view(WV_PARK_OBJECTIVE);
gParkRating = calculate_park_rating();
gParkValue = calculate_park_value();
gCompanyValue = calculate_company_value();
auto park = GetContext()->GetPark();
gParkRating = park->CalculateParkRating();
gParkValue = park->CalculateParkValue();
gCompanyValue = park->CalculateCompanyValue();
gHistoricalProfit = gInitialCash - gBankLoan;
gCash = gInitialCash;
@@ -169,7 +172,7 @@ void scenario_begin()
gTotalAdmissions = 0;
gTotalIncomeFromAdmissions = 0;
safe_strcpy(gScenarioCompletedBy, "?", sizeof(gScenarioCompletedBy));
park_reset_history();
park->ResetHistories();
finance_reset_history();
award_reset();
reset_all_ride_build_dates();

View File

@@ -44,6 +44,8 @@
#include "Sprite.h"
#include "Surface.h"
using namespace OpenRCT2;
rct_string_id gParkName;
uint32 gParkNameArgs;
uint32 gParkFlags;
@@ -442,7 +444,8 @@ void game_command_buy_land_rights(
void set_forced_park_rating(sint32 rating)
{
_forcedParkRating = rating;
gParkRating = calculate_park_rating();
auto park = GetContext()->GetPark();
gParkRating = park->CalculateParkRating();
auto intent = Intent(INTENT_ACTION_UPDATE_PARK_RATING);
context_broadcast_intent(&intent);
}
@@ -491,8 +494,6 @@ bool park_entry_price_unlocked()
return false;
}
using namespace OpenRCT2;
bool Park::IsOpen() const
{
return (gParkFlags & PARK_FLAGS_PARK_OPEN) != 0;
@@ -938,7 +939,7 @@ void Park::GenerateGuests()
bool difficultGeneration = (gParkFlags & PARK_FLAGS_DIFFICULT_GUEST_GENERATION) != 0;
if (!difficultGeneration || _suggestedGuestMaximum + 150 >= gNumGuestsInPark)
{
park_generate_new_guest();
GenerateGuest();
}
}
@@ -1027,7 +1028,7 @@ void Park::UpdateHistories()
gNumGuestsInParkLastWeek = gNumGuestsInPark;
// Update park rating, guests in park and current cash history
HistoryPushRecord<uint8, 32>(gParkRatingHistory, calculate_park_rating() / 4);
HistoryPushRecord<uint8, 32>(gParkRatingHistory, CalculateParkRating() / 4);
HistoryPushRecord<uint8, 32>(gGuestsInParkHistory, std::min<uint16>(gNumGuestsInPark, 5000) / 20);
HistoryPushRecord<money32, 128>(gCashHistory, finance_get_current_cash() - gBankLoan);
@@ -1077,31 +1078,6 @@ sint32 park_calculate_size()
return tiles;
}
sint32 calculate_park_rating()
{
return GetContext()->GetPark()->CalculateParkRating();
}
money32 calculate_park_value()
{
return GetContext()->GetPark()->CalculateParkValue();
}
money32 calculate_company_value()
{
return GetContext()->GetPark()->CalculateCompanyValue();
}
rct_peep * park_generate_new_guest()
{
return GetContext()->GetPark()->GenerateGuest();
}
void park_reset_history()
{
GetContext()->GetPark()->ResetHistories();
}
uint8 calculate_guest_initial_happiness(uint8 percentage)
{
return Park::CalculateGuestInitialHappiness(percentage);

View File

@@ -127,14 +127,9 @@ sint32 get_forced_park_rating();
sint32 park_is_open();
void park_init();
void park_reset_history();
sint32 park_calculate_size();
sint32 calculate_park_rating();
money32 calculate_park_value();
money32 calculate_company_value();
void reset_park_entry();
rct_peep * park_generate_new_guest();
void update_park_fences(sint32 x, sint32 y);
void update_park_fences_around_tile(sint32 x, sint32 y);