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:
@@ -30,6 +30,8 @@
|
|||||||
#include "world/Sprite.h"
|
#include "world/Sprite.h"
|
||||||
#include "world/Surface.h"
|
#include "world/Surface.h"
|
||||||
|
|
||||||
|
using namespace OpenRCT2;
|
||||||
|
|
||||||
bool gCheatsSandboxMode = false;
|
bool gCheatsSandboxMode = false;
|
||||||
bool gCheatsDisableClearanceChecks = false;
|
bool gCheatsDisableClearanceChecks = false;
|
||||||
bool gCheatsDisableSupportLimits = false;
|
bool gCheatsDisableSupportLimits = false;
|
||||||
@@ -267,8 +269,9 @@ static void cheat_clear_loan()
|
|||||||
|
|
||||||
static void cheat_generate_guests(sint32 count)
|
static void cheat_generate_guests(sint32 count)
|
||||||
{
|
{
|
||||||
|
auto park = GetContext()->GetPark();
|
||||||
for (sint32 i = 0; i < count; i++)
|
for (sint32 i = 0; i < count; i++)
|
||||||
park_generate_new_guest();
|
park->GenerateGuest();
|
||||||
|
|
||||||
window_invalidate_by_class(WC_BOTTOM_TOOLBAR);
|
window_invalidate_by_class(WC_BOTTOM_TOOLBAR);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,8 @@
|
|||||||
#include "GameAction.h"
|
#include "GameAction.h"
|
||||||
#include "MazeSetTrackAction.hpp"
|
#include "MazeSetTrackAction.hpp"
|
||||||
|
|
||||||
|
using namespace OpenRCT2;
|
||||||
|
|
||||||
struct RideDemolishAction : public GameActionBase<GAME_COMMAND_DEMOLISH_RIDE, GameActionResult>
|
struct RideDemolishAction : public GameActionBase<GAME_COMMAND_DEMOLISH_RIDE, GameActionResult>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@@ -190,7 +192,7 @@ public:
|
|||||||
|
|
||||||
user_string_free(ride->name);
|
user_string_free(ride->name);
|
||||||
ride->type = RIDE_TYPE_NULL;
|
ride->type = RIDE_TYPE_NULL;
|
||||||
gParkValue = calculate_park_value();
|
gParkValue = GetContext()->GetPark()->CalculateCompanyValue();
|
||||||
|
|
||||||
auto res = std::make_unique<GameActionResult>();
|
auto res = std::make_unique<GameActionResult>();
|
||||||
res->ExpenditureType = RCT_EXPENDITURE_TYPE_RIDE_CONSTRUCTION;
|
res->ExpenditureType = RCT_EXPENDITURE_TYPE_RIDE_CONSTRUCTION;
|
||||||
|
|||||||
@@ -66,6 +66,8 @@
|
|||||||
#include "../world/SmallScenery.h"
|
#include "../world/SmallScenery.h"
|
||||||
#include "../world/Surface.h"
|
#include "../world/Surface.h"
|
||||||
|
|
||||||
|
using namespace OpenRCT2;
|
||||||
|
|
||||||
static uint8 GetPathType(rct_tile_element * tileElement);
|
static uint8 GetPathType(rct_tile_element * tileElement);
|
||||||
static sint32 GetWallType(rct_tile_element * tileElement, sint32 edge);
|
static sint32 GetWallType(rct_tile_element * tileElement, sint32 edge);
|
||||||
static uint8 GetWallColour(rct_tile_element * tileElement);
|
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 the ratio between the old and new park value to calcute the ratio to
|
||||||
// use for the park value history and the goal.
|
// 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
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -90,6 +90,8 @@ char gScenarioFileName[MAX_PATH];
|
|||||||
static sint32 scenario_create_ducks();
|
static sint32 scenario_create_ducks();
|
||||||
static void scenario_objective_check();
|
static void scenario_objective_check();
|
||||||
|
|
||||||
|
using namespace OpenRCT2;
|
||||||
|
|
||||||
void scenario_begin()
|
void scenario_begin()
|
||||||
{
|
{
|
||||||
game_load_init();
|
game_load_init();
|
||||||
@@ -108,9 +110,10 @@ void scenario_begin()
|
|||||||
if (gScenarioObjectiveType != OBJECTIVE_NONE && !gLoadKeepWindowsOpen)
|
if (gScenarioObjectiveType != OBJECTIVE_NONE && !gLoadKeepWindowsOpen)
|
||||||
context_open_window_view(WV_PARK_OBJECTIVE);
|
context_open_window_view(WV_PARK_OBJECTIVE);
|
||||||
|
|
||||||
gParkRating = calculate_park_rating();
|
auto park = GetContext()->GetPark();
|
||||||
gParkValue = calculate_park_value();
|
gParkRating = park->CalculateParkRating();
|
||||||
gCompanyValue = calculate_company_value();
|
gParkValue = park->CalculateParkValue();
|
||||||
|
gCompanyValue = park->CalculateCompanyValue();
|
||||||
gHistoricalProfit = gInitialCash - gBankLoan;
|
gHistoricalProfit = gInitialCash - gBankLoan;
|
||||||
gCash = gInitialCash;
|
gCash = gInitialCash;
|
||||||
|
|
||||||
@@ -169,7 +172,7 @@ void scenario_begin()
|
|||||||
gTotalAdmissions = 0;
|
gTotalAdmissions = 0;
|
||||||
gTotalIncomeFromAdmissions = 0;
|
gTotalIncomeFromAdmissions = 0;
|
||||||
safe_strcpy(gScenarioCompletedBy, "?", sizeof(gScenarioCompletedBy));
|
safe_strcpy(gScenarioCompletedBy, "?", sizeof(gScenarioCompletedBy));
|
||||||
park_reset_history();
|
park->ResetHistories();
|
||||||
finance_reset_history();
|
finance_reset_history();
|
||||||
award_reset();
|
award_reset();
|
||||||
reset_all_ride_build_dates();
|
reset_all_ride_build_dates();
|
||||||
|
|||||||
@@ -44,6 +44,8 @@
|
|||||||
#include "Sprite.h"
|
#include "Sprite.h"
|
||||||
#include "Surface.h"
|
#include "Surface.h"
|
||||||
|
|
||||||
|
using namespace OpenRCT2;
|
||||||
|
|
||||||
rct_string_id gParkName;
|
rct_string_id gParkName;
|
||||||
uint32 gParkNameArgs;
|
uint32 gParkNameArgs;
|
||||||
uint32 gParkFlags;
|
uint32 gParkFlags;
|
||||||
@@ -442,7 +444,8 @@ void game_command_buy_land_rights(
|
|||||||
void set_forced_park_rating(sint32 rating)
|
void set_forced_park_rating(sint32 rating)
|
||||||
{
|
{
|
||||||
_forcedParkRating = rating;
|
_forcedParkRating = rating;
|
||||||
gParkRating = calculate_park_rating();
|
auto park = GetContext()->GetPark();
|
||||||
|
gParkRating = park->CalculateParkRating();
|
||||||
auto intent = Intent(INTENT_ACTION_UPDATE_PARK_RATING);
|
auto intent = Intent(INTENT_ACTION_UPDATE_PARK_RATING);
|
||||||
context_broadcast_intent(&intent);
|
context_broadcast_intent(&intent);
|
||||||
}
|
}
|
||||||
@@ -491,8 +494,6 @@ bool park_entry_price_unlocked()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
using namespace OpenRCT2;
|
|
||||||
|
|
||||||
bool Park::IsOpen() const
|
bool Park::IsOpen() const
|
||||||
{
|
{
|
||||||
return (gParkFlags & PARK_FLAGS_PARK_OPEN) != 0;
|
return (gParkFlags & PARK_FLAGS_PARK_OPEN) != 0;
|
||||||
@@ -938,7 +939,7 @@ void Park::GenerateGuests()
|
|||||||
bool difficultGeneration = (gParkFlags & PARK_FLAGS_DIFFICULT_GUEST_GENERATION) != 0;
|
bool difficultGeneration = (gParkFlags & PARK_FLAGS_DIFFICULT_GUEST_GENERATION) != 0;
|
||||||
if (!difficultGeneration || _suggestedGuestMaximum + 150 >= gNumGuestsInPark)
|
if (!difficultGeneration || _suggestedGuestMaximum + 150 >= gNumGuestsInPark)
|
||||||
{
|
{
|
||||||
park_generate_new_guest();
|
GenerateGuest();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1027,7 +1028,7 @@ void Park::UpdateHistories()
|
|||||||
gNumGuestsInParkLastWeek = gNumGuestsInPark;
|
gNumGuestsInParkLastWeek = gNumGuestsInPark;
|
||||||
|
|
||||||
// Update park rating, guests in park and current cash history
|
// 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<uint8, 32>(gGuestsInParkHistory, std::min<uint16>(gNumGuestsInPark, 5000) / 20);
|
||||||
HistoryPushRecord<money32, 128>(gCashHistory, finance_get_current_cash() - gBankLoan);
|
HistoryPushRecord<money32, 128>(gCashHistory, finance_get_current_cash() - gBankLoan);
|
||||||
|
|
||||||
@@ -1077,31 +1078,6 @@ sint32 park_calculate_size()
|
|||||||
return tiles;
|
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)
|
uint8 calculate_guest_initial_happiness(uint8 percentage)
|
||||||
{
|
{
|
||||||
return Park::CalculateGuestInitialHappiness(percentage);
|
return Park::CalculateGuestInitialHappiness(percentage);
|
||||||
|
|||||||
@@ -127,14 +127,9 @@ sint32 get_forced_park_rating();
|
|||||||
|
|
||||||
sint32 park_is_open();
|
sint32 park_is_open();
|
||||||
void park_init();
|
void park_init();
|
||||||
void park_reset_history();
|
|
||||||
sint32 park_calculate_size();
|
sint32 park_calculate_size();
|
||||||
|
|
||||||
sint32 calculate_park_rating();
|
|
||||||
money32 calculate_park_value();
|
|
||||||
money32 calculate_company_value();
|
|
||||||
void reset_park_entry();
|
void reset_park_entry();
|
||||||
rct_peep * park_generate_new_guest();
|
|
||||||
|
|
||||||
void update_park_fences(sint32 x, sint32 y);
|
void update_park_fences(sint32 x, sint32 y);
|
||||||
void update_park_fences_around_tile(sint32 x, sint32 y);
|
void update_park_fences_around_tile(sint32 x, sint32 y);
|
||||||
|
|||||||
Reference in New Issue
Block a user