mirror of https://github.com/OpenRCT2/OpenRCT2.git
Move park_update into Park class.
Co-authored-by: Aaron van Geffen <aaron@aaronweb.net>
This commit is contained in:
parent
0d6cde2cdb
commit
721dc00778
|
@ -105,6 +105,7 @@ namespace OpenRCT2
|
|||
|
||||
// Game states
|
||||
std::unique_ptr<TitleScreen> _titleScreen;
|
||||
std::unique_ptr<Park> _park;
|
||||
|
||||
sint32 _drawingEngineType = DRAWING_ENGINE_SOFTWARE;
|
||||
std::unique_ptr<IDrawingEngine> _drawingEngine;
|
||||
|
@ -165,6 +166,11 @@ namespace OpenRCT2
|
|||
return _uiContext;
|
||||
}
|
||||
|
||||
Park * GetPark() override
|
||||
{
|
||||
return _park.get();
|
||||
}
|
||||
|
||||
std::shared_ptr<IPlatformEnvironment> GetPlatformEnvironment() override
|
||||
{
|
||||
return _env;
|
||||
|
@ -445,6 +451,7 @@ namespace OpenRCT2
|
|||
game_init_all(150);
|
||||
|
||||
_titleScreen = std::make_unique<TitleScreen>();
|
||||
_park = std::make_unique<Park>();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ enum
|
|||
namespace OpenRCT2
|
||||
{
|
||||
interface IPlatformEnvironment;
|
||||
class Park;
|
||||
|
||||
namespace Audio
|
||||
{
|
||||
|
@ -101,6 +102,7 @@ namespace OpenRCT2
|
|||
|
||||
virtual std::shared_ptr<Audio::IAudioContext> GetAudioContext() abstract;
|
||||
virtual std::shared_ptr<Ui::IUiContext> GetUiContext() abstract;
|
||||
virtual Park * GetPark() abstract;
|
||||
virtual std::shared_ptr<IPlatformEnvironment> GetPlatformEnvironment() abstract;
|
||||
virtual Localisation::LocalisationService& GetLocalisationService() abstract;
|
||||
virtual std::shared_ptr<IObjectManager> GetObjectManager() abstract;
|
||||
|
|
|
@ -111,6 +111,8 @@ rct_string_id gGameCommandErrorText;
|
|||
uint8 gErrorType;
|
||||
rct_string_id gErrorStringId;
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
sint32 game_command_callback_get_index(GAME_COMMAND_CALLBACK_POINTER * callback)
|
||||
{
|
||||
for (uint32 i = 0; i < Util::CountOf(game_command_callback_table); i++)
|
||||
|
@ -489,7 +491,7 @@ void game_logic_update()
|
|||
vehicle_update_all();
|
||||
sprite_misc_update_all();
|
||||
ride_update_all();
|
||||
park_update();
|
||||
GetContext()->GetPark()->Update();
|
||||
research_update();
|
||||
ride_ratings_update_all();
|
||||
ride_measurements_update();
|
||||
|
|
|
@ -545,30 +545,6 @@ static void park_generate_new_guests()
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006674F7
|
||||
*/
|
||||
void park_update()
|
||||
{
|
||||
if (gScreenFlags & (SCREEN_FLAGS_SCENARIO_EDITOR | SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))
|
||||
return;
|
||||
|
||||
// Every 5 seconds approximately
|
||||
if (gCurrentTicks % 512 == 0) {
|
||||
gParkRating = calculate_park_rating();
|
||||
gParkValue = calculate_park_value();
|
||||
gCompanyValue = calculate_company_value();
|
||||
window_invalidate_by_class(WC_FINANCES);
|
||||
_guestGenerationProbability = park_calculate_guest_generation_probability();
|
||||
auto intent = Intent(INTENT_ACTION_UPDATE_PARK_RATING);
|
||||
context_broadcast_intent(&intent);
|
||||
}
|
||||
|
||||
// Generate new guests
|
||||
park_generate_new_guests();
|
||||
}
|
||||
|
||||
uint8 calculate_guest_initial_happiness(uint8 percentage) {
|
||||
if (percentage < 15) {
|
||||
// There is a minimum of 15% happiness
|
||||
|
@ -1039,6 +1015,21 @@ bool park_entry_price_unlocked()
|
|||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
static Park * _singleton = nullptr;
|
||||
|
||||
Park::Park()
|
||||
{
|
||||
_singleton = this;
|
||||
}
|
||||
|
||||
Park::~Park()
|
||||
{
|
||||
if (_singleton == this)
|
||||
{
|
||||
_singleton = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
uint16 Park::GetParkRating() const
|
||||
{
|
||||
return gParkRating;
|
||||
|
@ -1056,7 +1047,19 @@ money32 Park::GetCompanyValue() const
|
|||
|
||||
void Park::Update()
|
||||
{
|
||||
park_update();
|
||||
// Every 5 seconds approximately
|
||||
if (gCurrentTicks % 512 == 0)
|
||||
{
|
||||
gParkRating = CalculateParkRating();
|
||||
gParkValue = CalculateParkValue();
|
||||
gCompanyValue = CalculateCompanyValue();
|
||||
_guestGenerationProbability = park_calculate_guest_generation_probability();
|
||||
window_invalidate_by_class(WC_FINANCES);
|
||||
auto intent = Intent(INTENT_ACTION_UPDATE_PARK_RATING);
|
||||
context_broadcast_intent(&intent);
|
||||
}
|
||||
|
||||
park_generate_new_guests();
|
||||
}
|
||||
|
||||
sint32 Park::CalculateParkRating() const
|
||||
|
|
|
@ -54,6 +54,9 @@ namespace OpenRCT2
|
|||
class Park final
|
||||
{
|
||||
public:
|
||||
Park();
|
||||
~Park();
|
||||
|
||||
uint16 GetParkRating() const;
|
||||
money32 GetParkValue() const;
|
||||
money32 GetCompanyValue() const;
|
||||
|
@ -113,7 +116,6 @@ money32 calculate_company_value();
|
|||
void reset_park_entry();
|
||||
rct_peep * park_generate_new_guest();
|
||||
|
||||
void park_update();
|
||||
void park_update_histories();
|
||||
void update_park_fences(sint32 x, sint32 y);
|
||||
void update_park_fences_around_tile(sint32 x, sint32 y);
|
||||
|
|
Loading…
Reference in New Issue