1 /***************************************************************************** 2 * Copyright (c) 2014-2020 OpenRCT2 developers 3 * 4 * For a complete list of all authors, please refer to contributors.md 5 * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 6 * 7 * OpenRCT2 is licensed under the GNU General Public License version 3. 8 *****************************************************************************/ 9 10 #pragma once 11 12 #include "../common.h" 13 #include "../core/Random.hpp" 14 #include "../management/Finance.h" 15 #include "../management/Research.h" 16 #include "../object/Object.h" 17 #include "../ride/Ride.h" 18 #include "../ride/RideRatings.h" 19 #include "../world/Banner.h" 20 #include "../world/Climate.h" 21 #include "../world/EntityList.h" 22 #include "../world/Map.h" 23 #include "../world/MapAnimation.h" 24 25 using random_engine_t = Random::Rct2::Engine; 26 27 enum 28 { 29 SCENARIO_FLAGS_VISIBLE = (1 << 0), 30 SCENARIO_FLAGS_COMPLETED = (1 << 1), 31 SCENARIO_FLAGS_SIXFLAGS = (1 << 2) 32 }; 33 34 enum 35 { 36 S6_TYPE_SAVEDGAME, 37 S6_TYPE_SCENARIO 38 }; 39 40 #define S6_RCT2_VERSION 120001 41 #define S6_MAGIC_NUMBER 0x00031144 42 43 enum SCENARIO_CATEGORY 44 { 45 // RCT2 categories (keep order) 46 SCENARIO_CATEGORY_BEGINNER, 47 SCENARIO_CATEGORY_CHALLENGING, 48 SCENARIO_CATEGORY_EXPERT, 49 SCENARIO_CATEGORY_REAL, 50 SCENARIO_CATEGORY_OTHER, 51 52 // OpenRCT2 categories 53 SCENARIO_CATEGORY_DLC, 54 SCENARIO_CATEGORY_BUILD_YOUR_OWN, 55 56 SCENARIO_CATEGORY_COUNT 57 }; 58 59 enum 60 { 61 OBJECTIVE_NONE, 62 OBJECTIVE_GUESTS_BY, 63 OBJECTIVE_PARK_VALUE_BY, 64 OBJECTIVE_HAVE_FUN, 65 OBJECTIVE_BUILD_THE_BEST, 66 OBJECTIVE_10_ROLLERCOASTERS, 67 OBJECTIVE_GUESTS_AND_RATING, 68 OBJECTIVE_MONTHLY_RIDE_INCOME, 69 OBJECTIVE_10_ROLLERCOASTERS_LENGTH, 70 OBJECTIVE_FINISH_5_ROLLERCOASTERS, 71 OBJECTIVE_REPAY_LOAN_AND_PARK_VALUE, 72 OBJECTIVE_MONTHLY_FOOD_INCOME, 73 74 OBJECTIVE_COUNT 75 }; 76 77 bool ObjectiveNeedsMoney(const uint8_t objective); 78 79 enum class ObjectiveStatus : uint8_t 80 { 81 Undecided, 82 Success, 83 Failure, 84 }; 85 86 struct Objective 87 { 88 uint8_t Type; 89 uint8_t Year; 90 union 91 { 92 uint16_t NumGuests; 93 rct_string_id RideId; 94 uint16_t MinimumLength; // For the "Build 10 coasters of minimum length" objective. 95 }; 96 union 97 { 98 money64 Currency; 99 uint16_t MinimumExcitement; // For the "Finish 5 coaster with a minimum excitement rating" objective. 100 }; 101 NeedsMoneyObjective102 bool NeedsMoney() const 103 { 104 return ObjectiveNeedsMoney(Type); 105 } 106 IsValidObjective107 bool IsValid(bool useMoney, bool canAskMoneyForRides) const 108 { 109 const bool objectiveAllowedByMoneyUsage = useMoney || !NeedsMoney(); 110 // This objective can only work if the player can ask money for rides. 111 const bool objectiveAllowedByPaymentSettings = (Type != OBJECTIVE_MONTHLY_RIDE_INCOME) || canAskMoneyForRides; 112 return objectiveAllowedByMoneyUsage && objectiveAllowedByPaymentSettings; 113 } 114 115 ObjectiveStatus Check() const; 116 117 private: 118 ObjectiveStatus CheckGuestsBy() const; 119 ObjectiveStatus CheckParkValueBy() const; 120 ObjectiveStatus Check10RollerCoasters() const; 121 ObjectiveStatus CheckGuestsAndRating() const; 122 ObjectiveStatus CheckMonthlyRideIncome() const; 123 ObjectiveStatus Check10RollerCoastersLength() const; 124 ObjectiveStatus CheckFinish5RollerCoasters() const; 125 ObjectiveStatus CheckRepayLoanAndParkValue() const; 126 ObjectiveStatus CheckMonthlyFoodIncome() const; 127 }; 128 129 enum 130 { 131 SCENARIO_SELECT_MODE_DIFFICULTY, 132 SCENARIO_SELECT_MODE_ORIGIN, 133 }; 134 135 enum 136 { 137 AUTOSAVE_EVERY_MINUTE, 138 AUTOSAVE_EVERY_5MINUTES, 139 AUTOSAVE_EVERY_15MINUTES, 140 AUTOSAVE_EVERY_30MINUTES, 141 AUTOSAVE_EVERY_HOUR, 142 AUTOSAVE_NEVER 143 }; 144 145 #define AUTOSAVE_PAUSE 0 146 #define DEFAULT_NUM_AUTOSAVES_TO_KEEP 10 147 148 static constexpr money64 COMPANY_VALUE_ON_FAILED_OBJECTIVE = 0x8000000000000001; 149 150 extern const rct_string_id ScenarioCategoryStringIds[SCENARIO_CATEGORY_COUNT]; 151 152 extern random_engine_t gScenarioRand; 153 154 extern Objective gScenarioObjective; 155 extern bool gAllowEarlyCompletionInNetworkPlay; 156 extern uint16_t gScenarioParkRatingWarningDays; 157 extern money64 gScenarioCompletedCompanyValue; 158 extern money64 gScenarioCompanyValueRecord; 159 160 extern SCENARIO_CATEGORY gScenarioCategory; 161 extern std::string gScenarioName; 162 extern std::string gScenarioDetails; 163 extern std::string gScenarioCompletedBy; 164 extern std::string gScenarioSavePath; 165 extern char gScenarioExpansionPacks[3256]; 166 extern bool gFirstTimeSaving; 167 extern uint16_t gSavedAge; 168 extern uint32_t gLastAutoSaveUpdate; 169 170 extern char gScenarioFileName[260]; 171 172 void load_from_sc6(const char* path); 173 void scenario_begin(); 174 void scenario_update(); 175 bool scenario_create_ducks(); 176 bool AllowEarlyCompletion(); 177 178 const random_engine_t::state_type& scenario_rand_state(); 179 void scenario_rand_seed(random_engine_t::result_type s0, random_engine_t::result_type s1); 180 random_engine_t::result_type scenario_rand(); 181 uint32_t scenario_rand_max(uint32_t max); 182 183 bool scenario_prepare_for_save(); 184 int32_t scenario_save(const utf8* path, int32_t flags); 185 void scenario_failure(); 186 void scenario_success(); 187 void scenario_success_submit_name(const char* name); 188 void scenario_autosave_check(); 189