mirror of https://github.com/OpenRCT2/OpenRCT2.git
Merge pull request #7543 from AaronVanGeffen/refactor/park
Create new Park class
This commit is contained in:
commit
d44d727fac
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
#include "title/TitleScreen.h"
|
||||
#include "title/TitleSequenceManager.h"
|
||||
#include "ui/WindowManager.h"
|
||||
#include "world/Park.h"
|
||||
#include "Version.h"
|
||||
|
||||
#include "audio/audio.h"
|
||||
|
@ -104,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;
|
||||
|
@ -164,6 +166,11 @@ namespace OpenRCT2
|
|||
return _uiContext;
|
||||
}
|
||||
|
||||
Park * GetPark() override
|
||||
{
|
||||
return _park.get();
|
||||
}
|
||||
|
||||
std::shared_ptr<IPlatformEnvironment> GetPlatformEnvironment() override
|
||||
{
|
||||
return _env;
|
||||
|
@ -444,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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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();
|
||||
|
@ -250,8 +253,8 @@ void scenario_success_submit_name(const char *name)
|
|||
static void scenario_entrance_fee_too_high_check()
|
||||
{
|
||||
uint16 x = 0, y = 0;
|
||||
money16 totalRideValue = gTotalRideValueForMoney;
|
||||
money16 max_fee = totalRideValue + (totalRideValue / 2);
|
||||
money16 totalRideValueForMoney = gTotalRideValueForMoney;
|
||||
money16 max_fee = totalRideValueForMoney + (totalRideValueForMoney / 2);
|
||||
|
||||
if ((gParkFlags & PARK_FLAGS_PARK_OPEN) && park_get_entrance_fee() > max_fee) {
|
||||
for (sint32 i = 0; i < MAX_PARK_ENTRANCES && gParkEntrances[i].x != LOCATION_NULL; i++) {
|
||||
|
@ -345,8 +348,6 @@ static void scenario_week_update()
|
|||
break;
|
||||
}
|
||||
}
|
||||
park_update_histories();
|
||||
park_calculate_size();
|
||||
}
|
||||
|
||||
static void scenario_fortnight_update()
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -14,10 +14,11 @@
|
|||
*****************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
#ifndef _PARK_H_
|
||||
#define _PARK_H_
|
||||
#pragma once
|
||||
|
||||
#include "../common.h"
|
||||
#include "../ride/Ride.h"
|
||||
#include "Map.h"
|
||||
|
||||
#define DECRYPT_MONEY(money) ((money32)rol32((money) ^ 0xF4EC9621, 13))
|
||||
#define ENCRYPT_MONEY(money) ((money32)(ror32((money), 13) ^ 0xF4EC9621))
|
||||
|
@ -49,6 +50,46 @@ enum : uint32
|
|||
PARK_FLAGS_UNLOCK_ALL_PRICES = (1u << 31), // OpenRCT2 only!
|
||||
};
|
||||
|
||||
struct rct_peep;
|
||||
struct rct_ride;
|
||||
|
||||
namespace OpenRCT2
|
||||
{
|
||||
class Park final
|
||||
{
|
||||
public:
|
||||
bool IsOpen() const;
|
||||
|
||||
uint16 GetParkRating() const;
|
||||
money32 GetParkValue() const;
|
||||
money32 GetCompanyValue() const;
|
||||
|
||||
void Initialise();
|
||||
void Update();
|
||||
|
||||
sint32 CalculateParkSize() const;
|
||||
sint32 CalculateParkRating() const;
|
||||
money32 CalculateParkValue() const;
|
||||
money32 CalculateCompanyValue() const;
|
||||
static uint8 CalculateGuestInitialHappiness(uint8 percentage);
|
||||
|
||||
rct_peep * GenerateGuest();
|
||||
|
||||
void ResetHistories();
|
||||
void UpdateHistories();
|
||||
|
||||
private:
|
||||
money32 CalculateRideValue(const Ride * ride) const;
|
||||
money16 CalculateTotalRideValueForMoney() const;
|
||||
uint32 CalculateSuggestedMaxGuests() const;
|
||||
uint32 CalculateGuestGenerationProbability() const;
|
||||
|
||||
void GenerateGuests();
|
||||
rct_peep * GenerateGuestFromCampaign(sint32 campaign);
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
BUY_LAND_RIGHTS_FLAG_BUY_LAND,
|
||||
|
@ -86,17 +127,10 @@ 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 park_update();
|
||||
void park_update_histories();
|
||||
void update_park_fences(sint32 x, sint32 y);
|
||||
void update_park_fences_around_tile(sint32 x, sint32 y);
|
||||
|
||||
|
@ -117,5 +151,3 @@ money16 park_get_entrance_fee();
|
|||
|
||||
bool park_ride_prices_unlocked();
|
||||
bool park_entry_price_unlocked();
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue