diff --git a/src/openrct2/management/Award.cpp b/src/openrct2/management/Award.cpp index acadfafb6d..f17fd7639e 100644 --- a/src/openrct2/management/Award.cpp +++ b/src/openrct2/management/Award.cpp @@ -7,6 +7,8 @@ * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ +#include "Award.h" + #include "../config/Config.h" #include "../core/Util.hpp" #include "../interface/Window.h" @@ -15,14 +17,12 @@ #include "../ride/Ride.h" #include "../scenario/Scenario.h" #include "../world/Park.h" -#include "Award.h" #include "NewsItem.h" #define NEGATIVE 0 #define POSITIVE 1 -static constexpr const uint8_t AwardPositiveMap[] = -{ +static constexpr const uint8_t AwardPositiveMap[] = { NEGATIVE, // PARK_AWARD_MOST_UNTIDY POSITIVE, // PARK_AWARD_MOST_TIDY POSITIVE, // PARK_AWARD_BEST_ROLLERCOASTERS @@ -42,8 +42,7 @@ static constexpr const uint8_t AwardPositiveMap[] = POSITIVE, // PARK_AWARD_BEST_GENTLE_RIDES }; -static constexpr const rct_string_id AwardNewsStrings[] = -{ +static constexpr const rct_string_id AwardNewsStrings[] = { STR_NEWS_ITEM_AWARD_MOST_UNTIDY, STR_NEWS_ITEM_MOST_TIDY, STR_NEWS_ITEM_BEST_ROLLERCOASTERS, @@ -76,7 +75,7 @@ bool award_is_positive(int32_t type) static bool award_is_deserved_most_untidy(int32_t activeAwardTypes) { uint16_t spriteIndex; - rct_peep * peep; + rct_peep* peep; int32_t negativeCount; if (activeAwardTypes & (1 << PARK_AWARD_MOST_BEAUTIFUL)) @@ -87,7 +86,7 @@ static bool award_is_deserved_most_untidy(int32_t activeAwardTypes) return false; negativeCount = 0; - FOR_ALL_GUESTS(spriteIndex, peep) + FOR_ALL_GUESTS (spriteIndex, peep) { if (peep->outside_of_park != 0) continue; @@ -95,9 +94,9 @@ static bool award_is_deserved_most_untidy(int32_t activeAwardTypes) if (peep->thoughts[0].freshness > 5) continue; - if (peep->thoughts[0].type == PEEP_THOUGHT_TYPE_BAD_LITTER || - peep->thoughts[0].type == PEEP_THOUGHT_TYPE_PATH_DISGUSTING || - peep->thoughts[0].type == PEEP_THOUGHT_TYPE_VANDALISM) + if (peep->thoughts[0].type == PEEP_THOUGHT_TYPE_BAD_LITTER + || peep->thoughts[0].type == PEEP_THOUGHT_TYPE_PATH_DISGUSTING + || peep->thoughts[0].type == PEEP_THOUGHT_TYPE_VANDALISM) { negativeCount++; } @@ -110,7 +109,7 @@ static bool award_is_deserved_most_untidy(int32_t activeAwardTypes) static bool award_is_deserved_most_tidy(int32_t activeAwardTypes) { uint16_t spriteIndex; - rct_peep * peep; + rct_peep* peep; int32_t positiveCount; int32_t negativeCount; @@ -121,7 +120,7 @@ static bool award_is_deserved_most_tidy(int32_t activeAwardTypes) positiveCount = 0; negativeCount = 0; - FOR_ALL_GUESTS(spriteIndex, peep) + FOR_ALL_GUESTS (spriteIndex, peep) { if (peep->outside_of_park != 0) continue; @@ -132,10 +131,9 @@ static bool award_is_deserved_most_tidy(int32_t activeAwardTypes) if (peep->thoughts[0].type == PEEP_THOUGHT_TYPE_VERY_CLEAN) positiveCount++; - if (peep->thoughts[0].type == PEEP_THOUGHT_TYPE_BAD_LITTER || - peep->thoughts[0].type == PEEP_THOUGHT_TYPE_PATH_DISGUSTING || - peep->thoughts[0].type == PEEP_THOUGHT_TYPE_VANDALISM - ) + if (peep->thoughts[0].type == PEEP_THOUGHT_TYPE_BAD_LITTER + || peep->thoughts[0].type == PEEP_THOUGHT_TYPE_PATH_DISGUSTING + || peep->thoughts[0].type == PEEP_THOUGHT_TYPE_VANDALISM) { negativeCount++; } @@ -148,11 +146,11 @@ static bool award_is_deserved_most_tidy(int32_t activeAwardTypes) static bool award_is_deserved_best_rollercoasters([[maybe_unused]] int32_t activeAwardTypes) { int32_t i, rollerCoasters; - Ride * ride; - rct_ride_entry * rideEntry; + Ride* ride; + rct_ride_entry* rideEntry; rollerCoasters = 0; - FOR_ALL_RIDES(i, ride) + FOR_ALL_RIDES (i, ride) { rideEntry = get_ride_entry(ride->subtype); if (rideEntry == nullptr) @@ -201,7 +199,7 @@ static bool award_is_deserved_best_value(int32_t activeAwardTypes) static bool award_is_deserved_most_beautiful(int32_t activeAwardTypes) { uint16_t spriteIndex; - rct_peep * peep; + rct_peep* peep; int32_t positiveCount; int32_t negativeCount; @@ -212,7 +210,7 @@ static bool award_is_deserved_most_beautiful(int32_t activeAwardTypes) positiveCount = 0; negativeCount = 0; - FOR_ALL_GUESTS(spriteIndex, peep) + FOR_ALL_GUESTS (spriteIndex, peep) { if (peep->outside_of_park != 0) continue; @@ -223,9 +221,9 @@ static bool award_is_deserved_most_beautiful(int32_t activeAwardTypes) if (peep->thoughts[0].type == PEEP_THOUGHT_TYPE_SCENERY) positiveCount++; - if (peep->thoughts[0].type == PEEP_THOUGHT_TYPE_BAD_LITTER || - peep->thoughts[0].type == PEEP_THOUGHT_TYPE_PATH_DISGUSTING || - peep->thoughts[0].type == PEEP_THOUGHT_TYPE_VANDALISM) + if (peep->thoughts[0].type == PEEP_THOUGHT_TYPE_BAD_LITTER + || peep->thoughts[0].type == PEEP_THOUGHT_TYPE_PATH_DISGUSTING + || peep->thoughts[0].type == PEEP_THOUGHT_TYPE_VANDALISM) { negativeCount++; } @@ -255,11 +253,11 @@ static bool award_is_deserved_safest([[maybe_unused]] int32_t activeAwardTypes) { int32_t i, peepsWhoDislikeVandalism; uint16_t spriteIndex; - rct_peep * peep; - Ride * ride; + rct_peep* peep; + Ride* ride; peepsWhoDislikeVandalism = 0; - FOR_ALL_GUESTS(spriteIndex, peep) + FOR_ALL_GUESTS (spriteIndex, peep) { if (peep->outside_of_park != 0) continue; @@ -271,7 +269,7 @@ static bool award_is_deserved_safest([[maybe_unused]] int32_t activeAwardTypes) return false; // Check for rides that have crashed maybe? - FOR_ALL_RIDES(i, ride) + FOR_ALL_RIDES (i, ride) { if (ride->last_crash_type != RIDE_CRASH_TYPE_NONE) return false; @@ -284,17 +282,17 @@ static bool award_is_deserved_safest([[maybe_unused]] int32_t activeAwardTypes) static bool award_is_deserved_best_staff(int32_t activeAwardTypes) { uint16_t spriteIndex; - rct_peep * peep; + rct_peep* peep; int32_t peepCount, staffCount; int32_t staffTypeFlags; if (activeAwardTypes & (1 << PARK_AWARD_MOST_UNTIDY)) return false; - peepCount = 0; - staffCount = 0; + peepCount = 0; + staffCount = 0; staffTypeFlags = 0; - FOR_ALL_PEEPS(spriteIndex, peep) + FOR_ALL_PEEPS (spriteIndex, peep) { if (peep->type == PEEP_TYPE_STAFF) { @@ -308,7 +306,6 @@ static bool award_is_deserved_best_staff(int32_t activeAwardTypes) } return ((staffTypeFlags & 0xF) && staffCount >= 20 && staffCount >= peepCount / 32); - } /** At least 7 shops, 4 unique, one shop per 128 guests and no more than 12 hungry guests. */ @@ -316,18 +313,18 @@ static bool award_is_deserved_best_food(int32_t activeAwardTypes) { int32_t i, hungryPeeps, shops, uniqueShops; uint64_t shopTypes; - Ride * ride; - rct_ride_entry * rideEntry; + Ride* ride; + rct_ride_entry* rideEntry; uint16_t spriteIndex; - rct_peep * peep; + rct_peep* peep; if (activeAwardTypes & (1 << PARK_AWARD_WORST_FOOD)) return false; - shops = 0; + shops = 0; uniqueShops = 0; - shopTypes = 0; - FOR_ALL_RIDES(i, ride) + shopTypes = 0; + FOR_ALL_RIDES (i, ride) { if (ride->status != RIDE_STATUS_OPEN) continue; @@ -352,7 +349,7 @@ static bool award_is_deserved_best_food(int32_t activeAwardTypes) // Count hungry peeps hungryPeeps = 0; - FOR_ALL_GUESTS(spriteIndex, peep) + FOR_ALL_GUESTS (spriteIndex, peep) { if (peep->outside_of_park != 0) continue; @@ -369,18 +366,18 @@ static bool award_is_deserved_worst_food(int32_t activeAwardTypes) { int32_t i, hungryPeeps, shops, uniqueShops; uint64_t shopTypes; - Ride * ride; - rct_ride_entry * rideEntry; + Ride* ride; + rct_ride_entry* rideEntry; uint16_t spriteIndex; - rct_peep * peep; + rct_peep* peep; if (activeAwardTypes & (1 << PARK_AWARD_BEST_FOOD)) return false; - shops = 0; + shops = 0; uniqueShops = 0; - shopTypes = 0; - FOR_ALL_RIDES(i, ride) + shopTypes = 0; + FOR_ALL_RIDES (i, ride) { if (ride->status != RIDE_STATUS_OPEN) continue; @@ -405,7 +402,7 @@ static bool award_is_deserved_worst_food(int32_t activeAwardTypes) // Count hungry peeps hungryPeeps = 0; - FOR_ALL_GUESTS(spriteIndex, peep) + FOR_ALL_GUESTS (spriteIndex, peep) { if (peep->outside_of_park != 0) continue; @@ -421,13 +418,13 @@ static bool award_is_deserved_worst_food(int32_t activeAwardTypes) static bool award_is_deserved_best_restrooms([[maybe_unused]] int32_t activeAwardTypes) { uint32_t i, numRestrooms, guestsWhoNeedRestroom; - Ride * ride; + Ride* ride; uint16_t spriteIndex; - rct_peep * peep; + rct_peep* peep; // Count open restrooms numRestrooms = 0; - FOR_ALL_RIDES(i, ride) + FOR_ALL_RIDES (i, ride) { if (ride->type == RIDE_TYPE_TOILETS && ride->status == RIDE_STATUS_OPEN) numRestrooms++; @@ -443,7 +440,7 @@ static bool award_is_deserved_best_restrooms([[maybe_unused]] int32_t activeAwar // Count number of guests who are thinking they need the restroom guestsWhoNeedRestroom = 0; - FOR_ALL_GUESTS(spriteIndex, peep) + FOR_ALL_GUESTS (spriteIndex, peep) { if (peep->outside_of_park != 0) continue; @@ -459,7 +456,7 @@ static bool award_is_deserved_best_restrooms([[maybe_unused]] int32_t activeAwar static bool award_is_deserved_most_disappointing(int32_t activeAwardTypes) { uint32_t i, countedRides, disappointingRides; - Ride * ride; + Ride* ride; if (activeAwardTypes & (1 << PARK_AWARD_BEST_VALUE)) return false; @@ -467,10 +464,10 @@ static bool award_is_deserved_most_disappointing(int32_t activeAwardTypes) return false; // Count the number of disappointing rides - countedRides = 0; + countedRides = 0; disappointingRides = 0; - FOR_ALL_RIDES(i, ride) + FOR_ALL_RIDES (i, ride) { if (ride->excitement == RIDE_RATING_UNDEFINED || ride->popularity == 0xFF) continue; @@ -490,11 +487,11 @@ static bool award_is_deserved_most_disappointing(int32_t activeAwardTypes) static bool award_is_deserved_best_water_rides([[maybe_unused]] int32_t activeAwardTypes) { int32_t i, waterRides; - Ride * ride; - rct_ride_entry * rideEntry; + Ride* ride; + rct_ride_entry* rideEntry; waterRides = 0; - FOR_ALL_RIDES(i, ride) + FOR_ALL_RIDES (i, ride) { rideEntry = get_ride_entry(ride->subtype); if (rideEntry == nullptr) @@ -522,13 +519,13 @@ static bool award_is_deserved_best_water_rides([[maybe_unused]] int32_t activeAw static bool award_is_deserved_best_custom_designed_rides(int32_t activeAwardTypes) { int32_t i, customDesignedRides; - Ride * ride; + Ride* ride; if (activeAwardTypes & (1 << PARK_AWARD_MOST_DISAPPOINTING)) return false; customDesignedRides = 0; - FOR_ALL_RIDES(i, ride) + FOR_ALL_RIDES (i, ride) { if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_HAS_TRACK)) continue; @@ -546,20 +543,21 @@ static bool award_is_deserved_best_custom_designed_rides(int32_t activeAwardType } /** At least 5 colourful rides and more than half of the rides are colourful. */ -static constexpr const uint8_t dazzling_ride_colours[] = {COLOUR_BRIGHT_PURPLE, COLOUR_BRIGHT_GREEN, COLOUR_LIGHT_ORANGE, COLOUR_BRIGHT_PINK}; +static constexpr const uint8_t dazzling_ride_colours[] + = { COLOUR_BRIGHT_PURPLE, COLOUR_BRIGHT_GREEN, COLOUR_LIGHT_ORANGE, COLOUR_BRIGHT_PINK }; static bool award_is_deserved_most_dazzling_ride_colours(int32_t activeAwardTypes) { int32_t i, countedRides, colourfulRides; - Ride * ride; + Ride* ride; uint8_t mainTrackColour; if (activeAwardTypes & (1 << PARK_AWARD_MOST_DISAPPOINTING)) return false; - countedRides = 0; + countedRides = 0; colourfulRides = 0; - FOR_ALL_RIDES(i, ride) + FOR_ALL_RIDES (i, ride) { if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_HAS_TRACK)) continue; @@ -585,17 +583,18 @@ static bool award_is_deserved_most_confusing_layout([[maybe_unused]] int32_t act { uint32_t peepsCounted, peepsLost; uint16_t spriteIndex; - rct_peep * peep; + rct_peep* peep; peepsCounted = 0; - peepsLost = 0; - FOR_ALL_GUESTS(spriteIndex, peep) + peepsLost = 0; + FOR_ALL_GUESTS (spriteIndex, peep) { if (peep->outside_of_park != 0) continue; peepsCounted++; - if (peep->thoughts[0].freshness <= 5 && (peep->thoughts[0].type == PEEP_THOUGHT_TYPE_LOST || peep->thoughts[0].type == PEEP_THOUGHT_TYPE_CANT_FIND)) + if (peep->thoughts[0].freshness <= 5 + && (peep->thoughts[0].type == PEEP_THOUGHT_TYPE_LOST || peep->thoughts[0].type == PEEP_THOUGHT_TYPE_CANT_FIND)) peepsLost++; } @@ -606,11 +605,11 @@ static bool award_is_deserved_most_confusing_layout([[maybe_unused]] int32_t act static bool award_is_deserved_best_gentle_rides([[maybe_unused]] int32_t activeAwardTypes) { int32_t i, gentleRides; - Ride * ride; - rct_ride_entry * rideEntry; + Ride* ride; + rct_ride_entry* rideEntry; gentleRides = 0; - FOR_ALL_RIDES(i, ride) + FOR_ALL_RIDES (i, ride) { rideEntry = get_ride_entry(ride->subtype); if (rideEntry == nullptr) @@ -636,26 +635,23 @@ static bool award_is_deserved_best_gentle_rides([[maybe_unused]] int32_t activeA using award_deserved_check = bool (*)(int32_t); -static constexpr const award_deserved_check _awardChecks[] = -{ - award_is_deserved_most_untidy, - award_is_deserved_most_tidy, - award_is_deserved_best_rollercoasters, - award_is_deserved_best_value, - award_is_deserved_most_beautiful, - award_is_deserved_worst_value, - award_is_deserved_safest, - award_is_deserved_best_staff, - award_is_deserved_best_food, - award_is_deserved_worst_food, - award_is_deserved_best_restrooms, - award_is_deserved_most_disappointing, - award_is_deserved_best_water_rides, - award_is_deserved_best_custom_designed_rides, - award_is_deserved_most_dazzling_ride_colours, - award_is_deserved_most_confusing_layout, - award_is_deserved_best_gentle_rides -}; +static constexpr const award_deserved_check _awardChecks[] = { award_is_deserved_most_untidy, + award_is_deserved_most_tidy, + award_is_deserved_best_rollercoasters, + award_is_deserved_best_value, + award_is_deserved_most_beautiful, + award_is_deserved_worst_value, + award_is_deserved_safest, + award_is_deserved_best_staff, + award_is_deserved_best_food, + award_is_deserved_worst_food, + award_is_deserved_best_restrooms, + award_is_deserved_most_disappointing, + award_is_deserved_best_water_rides, + award_is_deserved_best_custom_designed_rides, + award_is_deserved_most_dazzling_ride_colours, + award_is_deserved_most_confusing_layout, + award_is_deserved_best_gentle_rides }; static bool award_is_deserved(int32_t awardType, int32_t activeAwardTypes) { @@ -666,7 +662,7 @@ static bool award_is_deserved(int32_t awardType, int32_t activeAwardTypes) void award_reset() { - for (auto &award : gCurrentAwards) + for (auto& award : gCurrentAwards) { award.Time = 0; award.Type = 0; @@ -683,9 +679,9 @@ void award_update_all() if (gParkFlags & PARK_FLAGS_PARK_OPEN) { // Set active award types as flags - int32_t activeAwardTypes = 0; - int32_t freeAwardEntryIndex = -1; - for (int32_t i = 0; i < MAX_AWARDS; i++) + int32_t activeAwardTypes = 0; + int32_t freeAwardEntryIndex = -1; + for (int32_t i = 0; i < MAX_AWARDS; i++) { if (gCurrentAwards[i].Time != 0) activeAwardTypes |= (1 << gCurrentAwards[i].Type); @@ -701,8 +697,7 @@ void award_update_all() do { awardType = (((scenario_rand() & 0xFF) * 17) >> 8) & 0xFF; - } - while (activeAwardTypes & (1 << awardType)); + } while (activeAwardTypes & (1 << awardType)); // Check if award is deserved if (award_is_deserved(awardType, activeAwardTypes)) @@ -720,7 +715,7 @@ void award_update_all() } // Decrease award times - for (auto &award : gCurrentAwards) + for (auto& award : gCurrentAwards) { if (award.Time != 0) if (--award.Time == 0) diff --git a/src/openrct2/management/Finance.cpp b/src/openrct2/management/Finance.cpp index ae688bfd62..5f4f7315a6 100644 --- a/src/openrct2/management/Finance.cpp +++ b/src/openrct2/management/Finance.cpp @@ -7,6 +7,9 @@ * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ +#include "Finance.h" + +#include "../Context.h" #include "../Game.h" #include "../interface/Window.h" #include "../localisation/Date.h" @@ -16,46 +19,42 @@ #include "../ride/Ride.h" #include "../scenario/Scenario.h" #include "../util/Util.h" +#include "../windows/Intent.h" #include "../world/Park.h" #include "../world/Sprite.h" -#include "Finance.h" -#include "../Context.h" -#include "../windows/Intent.h" /** * Monthly staff wages * * rct2: 0x00992A00 */ -const money32 wage_table[STAFF_TYPE_COUNT] = -{ - MONEY(50, 00), // Handyman - MONEY(80, 00), // Mechanic - MONEY(60, 00), // Security guard - MONEY(55, 00) // Entertainer +const money32 wage_table[STAFF_TYPE_COUNT] = { + MONEY(50, 00), // Handyman + MONEY(80, 00), // Mechanic + MONEY(60, 00), // Security guard + MONEY(55, 00) // Entertainer }; // Monthly research funding costs -const money32 research_cost_table[RESEARCH_FUNDING_COUNT] = -{ - MONEY(0, 00), // No funding - MONEY(100, 00), // Minimum funding - MONEY(200, 00), // Normal funding - MONEY(400, 00) // Maximum funding +const money32 research_cost_table[RESEARCH_FUNDING_COUNT] = { + MONEY(0, 00), // No funding + MONEY(100, 00), // Minimum funding + MONEY(200, 00), // Normal funding + MONEY(400, 00) // Maximum funding }; -static constexpr const int32_t dword_988E60[RCT_EXPENDITURE_TYPE_COUNT] = {1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0}; +static constexpr const int32_t dword_988E60[RCT_EXPENDITURE_TYPE_COUNT] = { 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0 }; money32 gInitialCash; money32 gCash; money32 gBankLoan; -uint8_t gBankLoanInterestRate; +uint8_t gBankLoanInterestRate; money32 gMaxBankLoan; money32 gCurrentExpenditure; money32 gCurrentProfit; money32 gHistoricalProfit; money32 gWeeklyProfitAverageDividend; -uint16_t gWeeklyProfitAverageDivisor; +uint16_t gWeeklyProfitAverageDivisor; money32 gCashHistory[FINANCE_GRAPH_SIZE]; money32 gWeeklyProfitHistory[FINANCE_GRAPH_SIZE]; money32 gParkValueHistory[FINANCE_GRAPH_SIZE]; @@ -71,7 +70,7 @@ uint8_t gCommandExpenditureType; */ void finance_payment(money32 amount, rct_expenditure_type type) { - //overflow check + // overflow check gCash = add_clamp_money32(gCash, -amount); gExpenditureTable[0][type] -= amount; @@ -91,7 +90,7 @@ void finance_payment(money32 amount, rct_expenditure_type type) */ void finance_pay_wages() { - rct_peep * peep; + rct_peep* peep; uint16_t spriteIndex; if (gParkFlags & PARK_FLAGS_NO_MONEY) @@ -99,16 +98,16 @@ void finance_pay_wages() return; } - FOR_ALL_STAFF(spriteIndex, peep) + FOR_ALL_STAFF (spriteIndex, peep) { finance_payment(wage_table[peep->staff_type] / 4, RCT_EXPENDITURE_TYPE_WAGES); } } /** -* Pays the current research level's cost. -* rct2: 0x00684DA5 -**/ + * Pays the current research level's cost. + * rct2: 0x00684DA5 + **/ void finance_pay_research() { uint8_t level; @@ -130,8 +129,8 @@ void finance_pay_interest() { // This variable uses the 64-bit type as the computation below can involve multiplying very large numbers // that will overflow money32 if the loan is greater than (1 << 31) / (5 * current_interest_rate) - money64 current_loan = gBankLoan; - uint8_t current_interest_rate = gBankLoanInterestRate; + money64 current_loan = gBankLoan; + uint8_t current_interest_rate = gBankLoanInterestRate; money32 interest_to_pay; if (gParkFlags & PARK_FLAGS_NO_MONEY) @@ -151,9 +150,9 @@ void finance_pay_interest() void finance_pay_ride_upkeep() { int32_t i; - Ride * ride; + Ride* ride; - FOR_ALL_RIDES(i, ride) + FOR_ALL_RIDES (i, ride) { if (!(ride->lifecycle_flags & RIDE_LIFECYCLE_EVER_BEEN_OPENED)) { @@ -182,16 +181,16 @@ void finance_reset_history() { for (int32_t i = 0; i < FINANCE_GRAPH_SIZE; i++) { - gCashHistory[i] = MONEY32_UNDEFINED; + gCashHistory[i] = MONEY32_UNDEFINED; gWeeklyProfitHistory[i] = MONEY32_UNDEFINED; - gParkValueHistory[i] = MONEY32_UNDEFINED; + gParkValueHistory[i] = MONEY32_UNDEFINED; } } /** -* -* rct2: 0x0069DEFB -*/ + * + * rct2: 0x0069DEFB + */ void finance_init() { // It only initialises the first month @@ -201,35 +200,35 @@ void finance_init() } gCurrentExpenditure = 0; - gCurrentProfit = 0; + gCurrentProfit = 0; gWeeklyProfitAverageDividend = 0; - gWeeklyProfitAverageDivisor = 0; + gWeeklyProfitAverageDivisor = 0; gInitialCash = MONEY(10000, 00); // Cheat detection - gCash = MONEY(10000, 00); - gBankLoan = MONEY(10000, 00); - gMaxBankLoan = MONEY(20000, 00); + gCash = MONEY(10000, 00); + gBankLoan = MONEY(10000, 00); + gMaxBankLoan = MONEY(20000, 00); gHistoricalProfit = 0; - gBankLoanInterestRate = 10; - gParkValue = 0; - gCompanyValue = 0; + gBankLoanInterestRate = 10; + gParkValue = 0; + gCompanyValue = 0; gScenarioCompletedCompanyValue = MONEY32_UNDEFINED; - gTotalAdmissions = 0; - gTotalIncomeFromAdmissions = 0; + gTotalAdmissions = 0; + gTotalIncomeFromAdmissions = 0; safe_strcpy(gScenarioCompletedBy, "?", sizeof(gScenarioCompletedBy)); } /** -* -* rct2: 0x0069E79A -*/ + * + * rct2: 0x0069E79A + */ void finance_update_daily_profit() { - gCurrentProfit = 7 * gCurrentExpenditure; + gCurrentProfit = 7 * gCurrentExpenditure; gCurrentExpenditure = 0; // Reset daily expenditure money32 current_profit = 0; @@ -238,9 +237,9 @@ void finance_update_daily_profit() { // Staff costs uint16_t sprite_index; - rct_peep * peep; + rct_peep* peep; - FOR_ALL_STAFF(sprite_index, peep) + FOR_ALL_STAFF (sprite_index, peep) { current_profit -= wage_table[peep->staff_type]; } @@ -254,9 +253,9 @@ void finance_update_daily_profit() current_profit -= current_loan / 600; // Ride costs - Ride * ride; + Ride* ride; int32_t i; - FOR_ALL_RIDES(i, ride) + FOR_ALL_RIDES (i, ride) { if (ride->status != RIDE_STATUS_CLOSED && ride->upkeep_cost != MONEY16_UNDEFINED) { @@ -350,7 +349,7 @@ money32 finance_get_last_month_shop_profit() money32 profit = 0; if (gDateMonthsElapsed != 0) { - money32 * lastMonthExpenditure = gExpenditureTable[1]; + money32* lastMonthExpenditure = gExpenditureTable[1]; profit += lastMonthExpenditure[RCT_EXPENDITURE_TYPE_SHOP_SHOP_SALES]; profit += lastMonthExpenditure[RCT_EXPENDITURE_TYPE_SHOP_STOCK]; diff --git a/src/openrct2/management/Finance.h b/src/openrct2/management/Finance.h index 58fdf87683..ef131b5f26 100644 --- a/src/openrct2/management/Finance.h +++ b/src/openrct2/management/Finance.h @@ -15,7 +15,8 @@ using rct_expenditure_type = int32_t; -enum { +enum +{ RCT_EXPENDITURE_TYPE_RIDE_CONSTRUCTION, RCT_EXPENDITURE_TYPE_RIDE_RUNNING_COSTS, RCT_EXPENDITURE_TYPE_LAND_PURCHASE, diff --git a/src/openrct2/management/Marketing.cpp b/src/openrct2/management/Marketing.cpp index 1b8f306b46..1ad88e6c3b 100644 --- a/src/openrct2/management/Marketing.cpp +++ b/src/openrct2/management/Marketing.cpp @@ -7,31 +7,31 @@ * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ +#include "Marketing.h" + +#include "../Cheats.h" +#include "../Game.h" #include "../config/Config.h" #include "../core/Util.hpp" -#include "../Game.h" #include "../interface/Window.h" #include "../localisation/Localisation.h" #include "../ride/Ride.h" #include "../ride/RideData.h" #include "../ride/ShopItem.h" #include "../world/Park.h" -#include "../Cheats.h" #include "Finance.h" -#include "Marketing.h" #include "NewsItem.h" -const money16 AdvertisingCampaignPricePerWeek[] = -{ - MONEY(50, 00), // PARK_ENTRY_FREE - MONEY(50, 00), // RIDE_FREE - MONEY(50, 00), // PARK_ENTRY_HALF_PRICE - MONEY(50, 00), // FOOD_OR_DRINK_FREE - MONEY(350, 00), // PARK - MONEY(200, 00) // RIDE +const money16 AdvertisingCampaignPricePerWeek[] = { + MONEY(50, 00), // PARK_ENTRY_FREE + MONEY(50, 00), // RIDE_FREE + MONEY(50, 00), // PARK_ENTRY_HALF_PRICE + MONEY(50, 00), // FOOD_OR_DRINK_FREE + MONEY(350, 00), // PARK + MONEY(200, 00) // RIDE }; -static constexpr const int32_t AdvertisingCampaignGuestGenerationProbabilities[] = {400, 300, 200, 200, 250, 200}; +static constexpr const int32_t AdvertisingCampaignGuestGenerationProbabilities[] = { 400, 300, 200, 200, 250, 200 }; uint8_t gMarketingCampaignDaysLeft[20]; uint8_t gMarketingCampaignRideIndex[22]; @@ -39,24 +39,24 @@ uint8_t gMarketingCampaignRideIndex[22]; int32_t marketing_get_campaign_guest_generation_probability(int32_t campaign) { int32_t probability = AdvertisingCampaignGuestGenerationProbabilities[campaign]; - Ride * ride; + Ride* ride; // Lower probability of guest generation if price was already low switch (campaign) { - case ADVERTISING_CAMPAIGN_PARK_ENTRY_FREE: - if (park_get_entrance_fee() < 4) - probability /= 8; - break; - case ADVERTISING_CAMPAIGN_PARK_ENTRY_HALF_PRICE: - if (park_get_entrance_fee() < 6) - probability /= 8; - break; - case ADVERTISING_CAMPAIGN_RIDE_FREE: - ride = get_ride(gMarketingCampaignRideIndex[campaign]); - if (ride->price < 3) - probability /= 8; - break; + case ADVERTISING_CAMPAIGN_PARK_ENTRY_FREE: + if (park_get_entrance_fee() < 4) + probability /= 8; + break; + case ADVERTISING_CAMPAIGN_PARK_ENTRY_HALF_PRICE: + if (park_get_entrance_fee() < 6) + probability /= 8; + break; + case ADVERTISING_CAMPAIGN_RIDE_FREE: + ride = get_ride(gMarketingCampaignRideIndex[campaign]); + if (ride->price < 3) + probability /= 8; + break; } return probability; @@ -93,7 +93,7 @@ void marketing_update() // This sets the string parameters for the marketing types that have an argument. if (campaign == ADVERTISING_CAMPAIGN_RIDE_FREE || campaign == ADVERTISING_CAMPAIGN_RIDE) { - Ride * ride = get_ride(campaignItem); + Ride* ride = get_ride(campaignItem); set_format_arg(0, rct_string_id, ride->name); set_format_arg(2, uint32_t, ride->name_arguments); } @@ -109,89 +109,87 @@ void marketing_update() } } -void marketing_set_guest_campaign(rct_peep * peep, int32_t campaign) +void marketing_set_guest_campaign(rct_peep* peep, int32_t campaign) { switch (campaign) { - case ADVERTISING_CAMPAIGN_PARK_ENTRY_FREE: - peep->item_standard_flags |= PEEP_ITEM_VOUCHER; - peep->voucher_type = VOUCHER_TYPE_PARK_ENTRY_FREE; - break; - case ADVERTISING_CAMPAIGN_RIDE_FREE: - peep->item_standard_flags |= PEEP_ITEM_VOUCHER; - peep->voucher_type = VOUCHER_TYPE_RIDE_FREE; - peep->voucher_arguments = gMarketingCampaignRideIndex[campaign]; - peep->guest_heading_to_ride_id = gMarketingCampaignRideIndex[campaign]; - peep->peep_is_lost_countdown = 240; - break; - case ADVERTISING_CAMPAIGN_PARK_ENTRY_HALF_PRICE: - peep->item_standard_flags |= PEEP_ITEM_VOUCHER; - peep->voucher_type = VOUCHER_TYPE_PARK_ENTRY_HALF_PRICE; - break; - case ADVERTISING_CAMPAIGN_FOOD_OR_DRINK_FREE: - peep->item_standard_flags |= PEEP_ITEM_VOUCHER; - peep->voucher_type = VOUCHER_TYPE_FOOD_OR_DRINK_FREE; - peep->voucher_arguments = gMarketingCampaignRideIndex[campaign]; - break; - case ADVERTISING_CAMPAIGN_PARK: - break; - case ADVERTISING_CAMPAIGN_RIDE: - peep->guest_heading_to_ride_id = gMarketingCampaignRideIndex[campaign]; - peep->peep_is_lost_countdown = 240; - break; + case ADVERTISING_CAMPAIGN_PARK_ENTRY_FREE: + peep->item_standard_flags |= PEEP_ITEM_VOUCHER; + peep->voucher_type = VOUCHER_TYPE_PARK_ENTRY_FREE; + break; + case ADVERTISING_CAMPAIGN_RIDE_FREE: + peep->item_standard_flags |= PEEP_ITEM_VOUCHER; + peep->voucher_type = VOUCHER_TYPE_RIDE_FREE; + peep->voucher_arguments = gMarketingCampaignRideIndex[campaign]; + peep->guest_heading_to_ride_id = gMarketingCampaignRideIndex[campaign]; + peep->peep_is_lost_countdown = 240; + break; + case ADVERTISING_CAMPAIGN_PARK_ENTRY_HALF_PRICE: + peep->item_standard_flags |= PEEP_ITEM_VOUCHER; + peep->voucher_type = VOUCHER_TYPE_PARK_ENTRY_HALF_PRICE; + break; + case ADVERTISING_CAMPAIGN_FOOD_OR_DRINK_FREE: + peep->item_standard_flags |= PEEP_ITEM_VOUCHER; + peep->voucher_type = VOUCHER_TYPE_FOOD_OR_DRINK_FREE; + peep->voucher_arguments = gMarketingCampaignRideIndex[campaign]; + break; + case ADVERTISING_CAMPAIGN_PARK: + break; + case ADVERTISING_CAMPAIGN_RIDE: + peep->guest_heading_to_ride_id = gMarketingCampaignRideIndex[campaign]; + peep->peep_is_lost_countdown = 240; + break; } } bool marketing_is_campaign_type_applicable(int32_t campaignType) { - int32_t i; - Ride * ride; - rct_ride_entry * rideEntry; + int32_t i; + Ride* ride; + rct_ride_entry* rideEntry; switch (campaignType) { - case ADVERTISING_CAMPAIGN_PARK_ENTRY_FREE: - case ADVERTISING_CAMPAIGN_PARK_ENTRY_HALF_PRICE: - if (!park_entry_price_unlocked()) - return false; - return true; + case ADVERTISING_CAMPAIGN_PARK_ENTRY_FREE: + case ADVERTISING_CAMPAIGN_PARK_ENTRY_HALF_PRICE: + if (!park_entry_price_unlocked()) + return false; + return true; - case ADVERTISING_CAMPAIGN_RIDE_FREE: - if (!park_ride_prices_unlocked()) + case ADVERTISING_CAMPAIGN_RIDE_FREE: + if (!park_ride_prices_unlocked()) + return false; + + // fall-through + case ADVERTISING_CAMPAIGN_RIDE: + // Check if any rides exist + FOR_ALL_RIDES (i, ride) + { + if (gRideClassifications[ride->type] == RIDE_CLASS_RIDE) + { + return true; + } + } return false; - // fall-through - case ADVERTISING_CAMPAIGN_RIDE: - // Check if any rides exist - FOR_ALL_RIDES(i, ride) - { - if (gRideClassifications[ride->type] == RIDE_CLASS_RIDE) + case ADVERTISING_CAMPAIGN_FOOD_OR_DRINK_FREE: + // Check if any food or drink stalls exist + FOR_ALL_RIDES (i, ride) { - return true; + rideEntry = get_ride_entry(ride->subtype); + if (rideEntry == nullptr) + { + continue; + } + if (shop_item_is_food_or_drink(rideEntry->shop_item) + || shop_item_is_food_or_drink(rideEntry->shop_item_secondary)) + { + return true; + } } - } - return false; + return false; - case ADVERTISING_CAMPAIGN_FOOD_OR_DRINK_FREE: - // Check if any food or drink stalls exist - FOR_ALL_RIDES(i, ride) - { - rideEntry = get_ride_entry(ride->subtype); - if (rideEntry == nullptr) - { - continue; - } - if ( - shop_item_is_food_or_drink(rideEntry->shop_item) || - shop_item_is_food_or_drink(rideEntry->shop_item_secondary) - ) - { - return true; - } - } - return false; - - default: - return true; + default: + return true; } } diff --git a/src/openrct2/management/Marketing.h b/src/openrct2/management/Marketing.h index 19ff5b5bc0..b2aab4d2ac 100644 --- a/src/openrct2/management/Marketing.h +++ b/src/openrct2/management/Marketing.h @@ -9,11 +9,12 @@ #pragma once -#include "../common.h" #include "../Cheats.h" +#include "../common.h" #include "../peep/Peep.h" -enum { +enum +{ ADVERTISING_CAMPAIGN_PARK_ENTRY_FREE, ADVERTISING_CAMPAIGN_RIDE_FREE, ADVERTISING_CAMPAIGN_PARK_ENTRY_HALF_PRICE, @@ -23,14 +24,16 @@ enum { ADVERTISING_CAMPAIGN_COUNT }; -enum{ +enum +{ VOUCHER_TYPE_PARK_ENTRY_FREE, VOUCHER_TYPE_RIDE_FREE, VOUCHER_TYPE_PARK_ENTRY_HALF_PRICE, VOUCHER_TYPE_FOOD_OR_DRINK_FREE, }; -enum { +enum +{ CAMPAIGN_ACTIVE_FLAG = (1 << 7) }; @@ -40,5 +43,5 @@ extern uint8_t gMarketingCampaignRideIndex[22]; int32_t marketing_get_campaign_guest_generation_probability(int32_t campaign); void marketing_update(); -void marketing_set_guest_campaign(rct_peep *peep, int32_t campaign); +void marketing_set_guest_campaign(rct_peep* peep, int32_t campaign); bool marketing_is_campaign_type_applicable(int32_t campaignType); diff --git a/src/openrct2/management/NewsItem.cpp b/src/openrct2/management/NewsItem.cpp index 898f3e62cc..ba962652ab 100644 --- a/src/openrct2/management/NewsItem.cpp +++ b/src/openrct2/management/NewsItem.cpp @@ -7,26 +7,26 @@ * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ -#include "../audio/audio.h" +#include "NewsItem.h" + #include "../Context.h" -#include "../core/Util.hpp" #include "../Input.h" +#include "../OpenRCT2.h" +#include "../audio/audio.h" +#include "../core/Util.hpp" #include "../interface/Window.h" #include "../localisation/Date.h" #include "../localisation/Localisation.h" #include "../management/Research.h" -#include "../OpenRCT2.h" #include "../ride/Ride.h" #include "../util/Util.h" #include "../windows/Intent.h" #include "../world/Sprite.h" -#include "NewsItem.h" NewsItem gNewsItems[MAX_NEWS_ITEMS]; /** rct2: 0x0097BE7C */ -const uint8_t news_type_properties[] = -{ +const uint8_t news_type_properties[] = { 0, // NEWS_ITEM_NULL NEWS_TYPE_HAS_LOCATION | NEWS_TYPE_HAS_SUBJECT, // NEWS_ITEM_RIDE NEWS_TYPE_HAS_LOCATION | NEWS_TYPE_HAS_SUBJECT, // NEWS_ITEM_PEEP_ON_RIDE @@ -51,7 +51,7 @@ bool news_item_is_valid_idx(int32_t index) return true; } -NewsItem * news_item_get(int32_t index) +NewsItem* news_item_get(int32_t index) { if (news_item_is_valid_idx(index)) { @@ -65,7 +65,7 @@ NewsItem * news_item_get(int32_t index) bool news_item_is_empty(int32_t index) { - NewsItem * news = news_item_get(index); + NewsItem* news = news_item_get(index); return news != nullptr && news->Type == NEWS_ITEM_NULL; } @@ -80,11 +80,11 @@ bool news_item_is_queue_empty() */ void news_item_init_queue() { - news_item_get(0)->Type = NEWS_ITEM_NULL; + news_item_get(0)->Type = NEWS_ITEM_NULL; news_item_get(11)->Type = NEWS_ITEM_NULL; // Throttles for warning types (PEEP_*_WARNING) - for (auto &warningThrottle : gPeepWarningThrottle) + for (auto& warningThrottle : gPeepWarningThrottle) { warningThrottle = 0; } @@ -108,10 +108,7 @@ static void news_item_tick_current() static bool news_item_is_current_old() { int32_t remove_time = 320; - if (!news_item_is_empty(5) && - !news_item_is_empty(4) && - !news_item_is_empty(3) && - !news_item_is_empty(2)) + if (!news_item_is_empty(5) && !news_item_is_empty(4) && !news_item_is_empty(3) && !news_item_is_empty(2)) { remove_time = 256; } @@ -147,7 +144,7 @@ void news_item_update_current() void news_item_close_current() { int32_t i; - NewsItem * newsItems = gNewsItems; + NewsItem* newsItems = gNewsItems; // Check if there is a current message if (news_item_is_queue_empty()) @@ -181,12 +178,11 @@ void news_item_close_current() static void news_item_shift_history_up() { const int32_t history_idx = 11; - NewsItem * history_start = news_item_get(history_idx); + NewsItem* history_start = news_item_get(history_idx); const size_t count = sizeof(NewsItem) * (MAX_NEWS_ITEMS - 1 - history_idx); memmove(history_start, history_start + 1, count); } - /** * Finds a spare history slot or replaces an existing one if there are no spare * slots available. @@ -211,76 +207,75 @@ static int32_t news_item_get_new_history_slot() * * rct2: 0x0066BA74 */ -void news_item_get_subject_location(int32_t type, int32_t subject, int32_t * x, int32_t * y, int32_t * z) +void news_item_get_subject_location(int32_t type, int32_t subject, int32_t* x, int32_t* y, int32_t* z) { - Ride * ride; - rct_peep * peep; - rct_vehicle * vehicle; + Ride* ride; + rct_peep* peep; + rct_vehicle* vehicle; switch (type) { - case NEWS_ITEM_RIDE: - ride = get_ride(subject); - if (ride->overall_view.xy == RCT_XY8_UNDEFINED) - { + case NEWS_ITEM_RIDE: + ride = get_ride(subject); + if (ride->overall_view.xy == RCT_XY8_UNDEFINED) + { + *x = LOCATION_NULL; + break; + } + *x = ride->overall_view.x * 32 + 16; + *y = ride->overall_view.y * 32 + 16; + *z = tile_element_height(*x, *y); + break; + case NEWS_ITEM_PEEP_ON_RIDE: + peep = GET_PEEP(subject); + *x = peep->x; + *y = peep->y; + *z = peep->z; + if (*x != LOCATION_NULL) + break; + + if (peep->state != 3 && peep->state != 7) + { + *x = LOCATION_NULL; + break; + } + + // Find which ride peep is on + ride = get_ride(peep->current_ride); + if (!(ride->lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK)) + { + *x = LOCATION_NULL; + break; + } + + // Find the first car of the train peep is on + vehicle = &(get_sprite(ride->vehicles[peep->current_train])->vehicle); + // Find the actual car peep is on + for (int32_t i = 0; i < peep->current_car; i++) + { + vehicle = &(get_sprite(vehicle->next_vehicle_on_train)->vehicle); + } + *x = vehicle->x; + *y = vehicle->y; + *z = vehicle->z; + break; + case NEWS_ITEM_PEEP: + peep = GET_PEEP(subject); + *x = peep->x; + *y = peep->y; + *z = peep->z; + break; + case NEWS_ITEM_BLANK: + *x = subject; + *y = subject >> 16; + *z = tile_element_height(*x, *y); + break; + default: *x = LOCATION_NULL; break; - } - *x = ride->overall_view.x * 32 + 16; - *y = ride->overall_view.y * 32 + 16; - *z = tile_element_height(*x, *y); - break; - case NEWS_ITEM_PEEP_ON_RIDE: - peep = GET_PEEP(subject); - *x = peep->x; - *y = peep->y; - *z = peep->z; - if (*x != LOCATION_NULL) - break; - - if (peep->state != 3 && peep->state != 7) - { - *x = LOCATION_NULL; - break; - } - - // Find which ride peep is on - ride = get_ride(peep->current_ride); - if (!(ride->lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK)) - { - *x = LOCATION_NULL; - break; - } - - // Find the first car of the train peep is on - vehicle = &(get_sprite(ride->vehicles[peep->current_train])->vehicle); - // Find the actual car peep is on - for (int32_t i = 0; i < peep->current_car; i++) - { - vehicle = &(get_sprite(vehicle->next_vehicle_on_train)->vehicle); - } - *x = vehicle->x; - *y = vehicle->y; - *z = vehicle->z; - break; - case NEWS_ITEM_PEEP: - peep = GET_PEEP(subject); - *x = peep->x; - *y = peep->y; - *z = peep->z; - break; - case NEWS_ITEM_BLANK: - *x = subject; - *y = subject >> 16; - *z = tile_element_height(*x, *y); - break; - default: - *x = LOCATION_NULL; - break; } } - /** * * rct2: 0x0066DF55 @@ -288,16 +283,16 @@ void news_item_get_subject_location(int32_t type, int32_t subject, int32_t * x, void news_item_add_to_queue(uint8_t type, rct_string_id string_id, uint32_t assoc) { utf8 buffer[256]; - void * args = gCommonFormatArgs; + void* args = gCommonFormatArgs; // overflows possible? format_string(buffer, 256, string_id, args); news_item_add_to_queue_raw(type, buffer, assoc); } -void news_item_add_to_queue_raw(uint8_t type, const utf8 * text, uint32_t assoc) +void news_item_add_to_queue_raw(uint8_t type, const utf8* text, uint32_t assoc) { - NewsItem * newsItem = gNewsItems; + NewsItem* newsItem = gNewsItems; // Find first open slot while (newsItem->Type != NEWS_ITEM_NULL) @@ -309,12 +304,12 @@ void news_item_add_to_queue_raw(uint8_t type, const utf8 * text, uint32_t assoc) } // Now we have found an item slot to place the new news in - newsItem->Type = type; - newsItem->Flags = 0; - newsItem->Assoc = assoc; - newsItem->Ticks = 0; + newsItem->Type = type; + newsItem->Flags = 0; + newsItem->Assoc = assoc; + newsItem->Ticks = 0; newsItem->MonthYear = gDateMonthsElapsed; - newsItem->Day = ((days_in_month[date_get_month(newsItem->MonthYear)] * gDateMonthTicks) >> 16) + 1; + newsItem->Day = ((days_in_month[date_get_month(newsItem->MonthYear)] * gDateMonthTicks) >> 16) + 1; safe_strcpy(newsItem->Text, text, sizeof(newsItem->Text)); // Blatant disregard for what happens on the last element. @@ -331,76 +326,76 @@ void news_item_add_to_queue_raw(uint8_t type, const utf8 * text, uint32_t assoc) */ void news_item_open_subject(int32_t type, int32_t subject) { - rct_peep * peep; - rct_window * window; + rct_peep* peep; + rct_window* window; switch (type) { - case NEWS_ITEM_RIDE: - { - auto intent = Intent(WC_RIDE); - intent.putExtra(INTENT_EXTRA_RIDE_ID, subject); - context_open_intent(&intent); - break; - } - case NEWS_ITEM_PEEP_ON_RIDE: - case NEWS_ITEM_PEEP: - { - peep = GET_PEEP(subject); - - auto intent = Intent(WC_PEEP); - intent.putExtra(INTENT_EXTRA_PEEP, peep); - context_open_intent(&intent); - break; - } - case NEWS_ITEM_MONEY: - context_open_window(WC_FINANCES); - break; - case NEWS_ITEM_RESEARCH: - if (subject >= RESEARCH_ENTRY_RIDE_MASK) + case NEWS_ITEM_RIDE: { - auto intent = Intent(INTENT_ACTION_NEW_RIDE_OF_TYPE); - intent.putExtra(INTENT_EXTRA_RIDE_TYPE, subject >> 8); - intent.putExtra(INTENT_EXTRA_RIDE_ENTRY_INDEX, subject & 0xFF); + auto intent = Intent(WC_RIDE); + intent.putExtra(INTENT_EXTRA_RIDE_ID, subject); context_open_intent(&intent); break; } - - // Check if window is already open - window = window_bring_to_front_by_class(WC_SCENERY); - if (window == nullptr) + case NEWS_ITEM_PEEP_ON_RIDE: + case NEWS_ITEM_PEEP: { - window = window_find_by_class(WC_TOP_TOOLBAR); - if (window != nullptr) + peep = GET_PEEP(subject); + + auto intent = Intent(WC_PEEP); + intent.putExtra(INTENT_EXTRA_PEEP, peep); + context_open_intent(&intent); + break; + } + case NEWS_ITEM_MONEY: + context_open_window(WC_FINANCES); + break; + case NEWS_ITEM_RESEARCH: + if (subject >= RESEARCH_ENTRY_RIDE_MASK) { - window_invalidate(window); - if (!tool_set(window, WC_TOP_TOOLBAR__WIDX_SCENERY, TOOL_ARROW)) + auto intent = Intent(INTENT_ACTION_NEW_RIDE_OF_TYPE); + intent.putExtra(INTENT_EXTRA_RIDE_TYPE, subject >> 8); + intent.putExtra(INTENT_EXTRA_RIDE_ENTRY_INDEX, subject & 0xFF); + context_open_intent(&intent); + break; + } + + // Check if window is already open + window = window_bring_to_front_by_class(WC_SCENERY); + if (window == nullptr) + { + window = window_find_by_class(WC_TOP_TOOLBAR); + if (window != nullptr) { - input_set_flag(INPUT_FLAG_6, true); - context_open_window(WC_SCENERY); + window_invalidate(window); + if (!tool_set(window, WC_TOP_TOOLBAR__WIDX_SCENERY, TOOL_ARROW)) + { + input_set_flag(INPUT_FLAG_6, true); + context_open_window(WC_SCENERY); + } } } - } - // Switch to new scenery tab - window = window_find_by_class(WC_SCENERY); - if (window != nullptr) - window_event_mouse_down_call(window, WC_SCENERY__WIDX_SCENERY_TAB_1 + subject); - break; - case NEWS_ITEM_PEEPS: - { - auto intent = Intent(WC_GUEST_LIST); - intent.putExtra(INTENT_EXTRA_GUEST_LIST_FILTER, GLFT_GUESTS_THINKING_X); - intent.putExtra(INTENT_EXTRA_RIDE_ID, subject); - context_open_intent(&intent); - break; - } - case NEWS_ITEM_AWARD: - context_open_window_view(WV_PARK_AWARDS); - break; - case NEWS_ITEM_GRAPH: - context_open_window_view(WV_PARK_RATING); - break; + // Switch to new scenery tab + window = window_find_by_class(WC_SCENERY); + if (window != nullptr) + window_event_mouse_down_call(window, WC_SCENERY__WIDX_SCENERY_TAB_1 + subject); + break; + case NEWS_ITEM_PEEPS: + { + auto intent = Intent(WC_GUEST_LIST); + intent.putExtra(INTENT_EXTRA_GUEST_LIST_FILTER, GLFT_GUESTS_THINKING_X); + intent.putExtra(INTENT_EXTRA_RIDE_ID, subject); + context_open_intent(&intent); + break; + } + case NEWS_ITEM_AWARD: + context_open_window_view(WV_PARK_AWARDS); + break; + case NEWS_ITEM_GRAPH: + context_open_window_view(WV_PARK_RATING); + break; } } @@ -415,7 +410,7 @@ void news_item_disable_news(uint8_t type, uint32_t assoc) { if (!news_item_is_empty(i)) { - NewsItem * const newsItem = news_item_get(i); + NewsItem* const newsItem = news_item_get(i); if (type == newsItem->Type && assoc == newsItem->Assoc) { newsItem->Flags |= NEWS_FLAG_HAS_BUTTON; @@ -436,7 +431,7 @@ void news_item_disable_news(uint8_t type, uint32_t assoc) { if (!news_item_is_empty(i)) { - NewsItem * const newsItem = news_item_get(i); + NewsItem* const newsItem = news_item_get(i); if (type == newsItem->Type && assoc == newsItem->Assoc) { newsItem->Flags |= NEWS_FLAG_HAS_BUTTON; @@ -450,9 +445,9 @@ void news_item_disable_news(uint8_t type, uint32_t assoc) } } -void news_item_add_to_queue_custom(NewsItem * newNewsItem) +void news_item_add_to_queue_custom(NewsItem* newNewsItem) { - NewsItem * newsItem = gNewsItems; + NewsItem* newsItem = gNewsItems; // Find first open slot while (newsItem->Type != NEWS_ITEM_NULL) diff --git a/src/openrct2/management/NewsItem.h b/src/openrct2/management/NewsItem.h index 4d59c2eadd..de80cc2ce6 100644 --- a/src/openrct2/management/NewsItem.h +++ b/src/openrct2/management/NewsItem.h @@ -28,7 +28,7 @@ enum enum { NEWS_TYPE_HAS_LOCATION = 1, - NEWS_TYPE_HAS_SUBJECT = 2, + NEWS_TYPE_HAS_SUBJECT = 2, }; enum @@ -41,13 +41,13 @@ enum */ struct NewsItem { - uint8_t Type; - uint8_t Flags; + uint8_t Type; + uint8_t Flags; uint32_t Assoc; uint16_t Ticks; uint16_t MonthYear; - uint8_t Day; - utf8 Text[256]; + uint8_t Day; + utf8 Text[256]; }; #define MAX_NEWS_ITEMS 61 @@ -61,21 +61,20 @@ void news_item_init_queue(); void news_item_update_current(); void news_item_close_current(); -void news_item_get_subject_location(int32_t type, int32_t subject, int32_t * x, int32_t * y, int32_t * z); +void news_item_get_subject_location(int32_t type, int32_t subject, int32_t* x, int32_t* y, int32_t* z); void news_item_add_to_queue(uint8_t type, rct_string_id string_id, uint32_t assoc); -void news_item_add_to_queue_raw(uint8_t type, const utf8 * text, uint32_t assoc); +void news_item_add_to_queue_raw(uint8_t type, const utf8* text, uint32_t assoc); void news_item_open_subject(int32_t type, int32_t subject); void news_item_disable_news(uint8_t type, uint32_t assoc); -NewsItem * news_item_get(int32_t index); +NewsItem* news_item_get(int32_t index); bool news_item_is_empty(int32_t index); bool news_item_is_queue_empty(); bool news_item_is_valid_idx(int32_t index); -void news_item_add_to_queue_custom(NewsItem * newNewsItem); - +void news_item_add_to_queue_custom(NewsItem* newNewsItem); diff --git a/src/openrct2/management/Research.cpp b/src/openrct2/management/Research.cpp index 9dc6ba330d..3f540370d6 100644 --- a/src/openrct2/management/Research.cpp +++ b/src/openrct2/management/Research.cpp @@ -7,41 +7,43 @@ * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ -#include +#include "Research.h" + +#include "../Game.h" +#include "../OpenRCT2.h" #include "../actions/ParkSetResearchFundingAction.hpp" #include "../config/Config.h" #include "../core/Guard.hpp" +#include "../core/Memory.hpp" #include "../core/Util.hpp" -#include "../Game.h" #include "../interface/Window.h" #include "../localisation/Date.h" #include "../localisation/Localisation.h" #include "../localisation/StringIds.h" #include "../object/ObjectList.h" -#include "../OpenRCT2.h" -#include "../scenario/Scenario.h" #include "../rct1/RCT1.h" #include "../ride/Ride.h" #include "../ride/RideData.h" #include "../ride/RideGroupManager.h" #include "../ride/TrackData.h" +#include "../scenario/Scenario.h" +#include "../util/Util.h" #include "../world/Park.h" #include "../world/Scenery.h" -#include "NewsItem.h" #include "Finance.h" -#include "Research.h" -#include "../core/Memory.hpp" -#include "../util/Util.h" +#include "NewsItem.h" -static constexpr const int32_t _researchRate[] = {0, 160, 250, 400}; +#include -uint8_t gResearchFundingLevel; -uint8_t gResearchPriorities; +static constexpr const int32_t _researchRate[] = { 0, 160, 250, 400 }; + +uint8_t gResearchFundingLevel; +uint8_t gResearchPriorities; uint16_t gResearchProgress; -uint8_t gResearchProgressStage; +uint8_t gResearchProgressStage; rct_research_item gResearchLastItem; -uint8_t gResearchExpectedMonth; -uint8_t gResearchExpectedDay; +uint8_t gResearchExpectedMonth; +uint8_t gResearchExpectedDay; rct_research_item gResearchNextItem; // 0x01358844[500] @@ -56,8 +58,6 @@ static bool _researchedSceneryItems[MAX_RESEARCHED_SCENERY_ITEMS]; bool gSilentResearch = false; - - /** * * rct2: 0x006671AD, part of 0x00667132 @@ -76,8 +76,9 @@ void research_reset_items() void research_update_uncompleted_types() { int32_t uncompletedResearchTypes = 0; - rct_research_item * researchItem = gResearchItems; - while (researchItem++->rawValue != RESEARCHED_ITEMS_SEPARATOR); + rct_research_item* researchItem = gResearchItems; + while (researchItem++->rawValue != RESEARCHED_ITEMS_SEPARATOR) + ; for (; researchItem->rawValue != RESEARCHED_ITEMS_END; researchItem++) { @@ -103,14 +104,14 @@ static void research_calculate_expected_date() progressRemaining -= gResearchProgress; int32_t daysRemaining = (progressRemaining / _researchRate[gResearchFundingLevel]) * 128; - int32_t expectedDay = gDateMonthTicks + (daysRemaining & 0xFFFF); - int32_t dayQuotient = expectedDay / 0x10000; + int32_t expectedDay = gDateMonthTicks + (daysRemaining & 0xFFFF); + int32_t dayQuotient = expectedDay / 0x10000; int32_t dayRemainder = expectedDay % 0x10000; int32_t expectedMonth = date_get_month(gDateMonthsElapsed + dayQuotient + (daysRemaining >> 16)); expectedDay = (dayRemainder * days_in_month[expectedMonth]) >> 16; - gResearchExpectedDay = expectedDay; + gResearchExpectedDay = expectedDay; gResearchExpectedMonth = expectedMonth; } } @@ -127,7 +128,7 @@ static void research_invalidate_related_windows() */ static void research_next_design() { - rct_research_item * firstUnresearchedItem, * researchItem, tmp; + rct_research_item *firstUnresearchedItem, *researchItem, tmp; int32_t ignoreActiveResearchTypes; // Skip already researched items @@ -138,7 +139,7 @@ static void research_next_design() } ignoreActiveResearchTypes = 0; - researchItem = firstUnresearchedItem; + researchItem = firstUnresearchedItem; for (;;) { researchItem++; @@ -147,12 +148,12 @@ static void research_next_design() if (!ignoreActiveResearchTypes) { ignoreActiveResearchTypes = 1; - researchItem = firstUnresearchedItem; + researchItem = firstUnresearchedItem; continue; } else { - gResearchProgress = 0; + gResearchProgress = 0; gResearchProgressStage = RESEARCH_STAGE_FINISHED_ALL; research_invalidate_related_windows(); // Reset funding to 0 if no more rides. @@ -167,19 +168,18 @@ static void research_next_design() } } - gResearchNextItem = *researchItem; - gResearchProgress = 0; + gResearchNextItem = *researchItem; + gResearchProgress = 0; gResearchProgressStage = RESEARCH_STAGE_DESIGNING; // Bubble research item up until it is above the researched items separator do { tmp = *researchItem; - *researchItem = *(researchItem - 1); + *researchItem = *(researchItem - 1); *(researchItem - 1) = tmp; researchItem--; - } - while ((researchItem + 1)->rawValue != RESEARCHED_ITEMS_SEPARATOR); + } while ((researchItem + 1)->rawValue != RESEARCHED_ITEMS_SEPARATOR); research_invalidate_related_windows(); } @@ -188,7 +188,7 @@ static void research_next_design() * * rct2: 0x006848D4 */ -void research_finish_item(rct_research_item * researchItem) +void research_finish_item(rct_research_item* researchItem) { gResearchLastItem = *researchItem; research_invalidate_related_windows(); @@ -198,18 +198,18 @@ void research_finish_item(rct_research_item * researchItem) // Ride uint32_t base_ride_type = researchItem->baseRideType; int32_t rideEntryIndex = researchItem->entryIndex; - rct_ride_entry * rideEntry = get_ride_entry(rideEntryIndex); + rct_ride_entry* rideEntry = get_ride_entry(rideEntryIndex); if (rideEntry != nullptr && base_ride_type != RIDE_TYPE_NULL) { bool ride_group_was_invented_before = false; - bool ride_type_was_invented_before = ride_type_is_invented(base_ride_type); + bool ride_type_was_invented_before = ride_type_is_invented(base_ride_type); rct_string_id availabilityString; // Determine if the ride group this entry belongs to was invented before. if (RideGroupManager::RideTypeHasRideGroups(base_ride_type)) { - const RideGroup * rideGroup = RideGroupManager::GetRideGroup(base_ride_type, rideEntry); + const RideGroup* rideGroup = RideGroupManager::GetRideGroup(base_ride_type, rideEntry); if (rideGroup->IsInvented()) { @@ -218,18 +218,19 @@ void research_finish_item(rct_research_item * researchItem) } ride_type_set_invented(base_ride_type); - openrct2_assert(base_ride_type < Util::CountOf(RideTypePossibleTrackConfigurations), - "Invalid base_ride_type = %d", base_ride_type); + openrct2_assert( + base_ride_type < Util::CountOf(RideTypePossibleTrackConfigurations), + "Invalid base_ride_type = %d", + base_ride_type); ride_entry_set_invented(rideEntryIndex); bool seenRideEntry[MAX_RIDE_OBJECTS]; - rct_research_item * researchItem2 = gResearchItems; + rct_research_item* researchItem2 = gResearchItems; for (; researchItem2->rawValue != RESEARCHED_ITEMS_END; researchItem2++) { - if (researchItem2->rawValue != RESEARCHED_ITEMS_SEPARATOR && - researchItem2->type == RESEARCH_ENTRY_TYPE_RIDE) + if (researchItem2->rawValue != RESEARCHED_ITEMS_SEPARATOR && researchItem2->type == RESEARCH_ENTRY_TYPE_RIDE) { uint8_t index = researchItem2->entryIndex; seenRideEntry[index] = true; @@ -242,7 +243,7 @@ void research_finish_item(rct_research_item * researchItem) { if (!seenRideEntry[i]) { - rct_ride_entry * rideEntry2 = get_ride_entry(i); + rct_ride_entry* rideEntry2 = get_ride_entry(i); if (rideEntry2 != nullptr) { for (uint8_t j = 0; j < MAX_RIDE_TYPES_PER_RIDE_ENTRY; j++) @@ -264,8 +265,9 @@ void research_finish_item(rct_research_item * researchItem) set_format_arg(0, rct_string_id, rideEntry->naming.name); } // If a vehicle is the first to be invented for its ride group, show the ride group name. - else if (!ride_type_was_invented_before || - (RideGroupManager::RideTypeHasRideGroups(base_ride_type) && !ride_group_was_invented_before)) + else if ( + !ride_type_was_invented_before + || (RideGroupManager::RideTypeHasRideGroups(base_ride_type) && !ride_group_was_invented_before)) { rct_ride_name naming = get_ride_naming(base_ride_type, rideEntry); availabilityString = STR_NEWS_ITEM_RESEARCH_NEW_RIDE_AVAILABLE; @@ -296,7 +298,7 @@ void research_finish_item(rct_research_item * researchItem) else { // Scenery - rct_scenery_group_entry * sceneryGroupEntry = get_scenery_group_entry(researchItem->entryIndex); + rct_scenery_group_entry* sceneryGroupEntry = get_scenery_group_entry(researchItem->entryIndex); if (sceneryGroupEntry != nullptr) { scenery_group_set_invented(researchItem->entryIndex); @@ -307,7 +309,8 @@ void research_finish_item(rct_research_item * researchItem) { if (gConfigNotifications.ride_researched) { - news_item_add_to_queue(NEWS_ITEM_RESEARCH, STR_NEWS_ITEM_RESEARCH_NEW_SCENERY_SET_AVAILABLE, researchItem->rawValue); + news_item_add_to_queue( + NEWS_ITEM_RESEARCH, STR_NEWS_ITEM_RESEARCH_NEW_SCENERY_SET_AVAILABLE, researchItem->rawValue); } } @@ -336,11 +339,11 @@ void research_update() return; } - if ((gParkFlags & PARK_FLAGS_NO_MONEY) && gResearchFundingLevel == RESEARCH_FUNDING_NONE) + if ((gParkFlags & PARK_FLAGS_NO_MONEY) && gResearchFundingLevel == RESEARCH_FUNDING_NONE) { researchLevel = RESEARCH_FUNDING_NORMAL; - } - else + } + else { researchLevel = gResearchFundingLevel; } @@ -355,35 +358,37 @@ void research_update() { switch (gResearchProgressStage) { - case RESEARCH_STAGE_INITIAL_RESEARCH: - research_next_design(); - research_calculate_expected_date(); - break; - case RESEARCH_STAGE_DESIGNING: - gResearchProgress = 0; - gResearchProgressStage = RESEARCH_STAGE_COMPLETING_DESIGN; - research_calculate_expected_date(); - research_invalidate_related_windows(); - break; - case RESEARCH_STAGE_COMPLETING_DESIGN: - research_finish_item(&gResearchNextItem); - gResearchProgress = 0; - gResearchProgressStage = RESEARCH_STAGE_INITIAL_RESEARCH; - research_calculate_expected_date(); - research_update_uncompleted_types(); - research_invalidate_related_windows(); - break; - case RESEARCH_STAGE_FINISHED_ALL: - gResearchFundingLevel = RESEARCH_FUNDING_NONE; - break; + case RESEARCH_STAGE_INITIAL_RESEARCH: + research_next_design(); + research_calculate_expected_date(); + break; + case RESEARCH_STAGE_DESIGNING: + gResearchProgress = 0; + gResearchProgressStage = RESEARCH_STAGE_COMPLETING_DESIGN; + research_calculate_expected_date(); + research_invalidate_related_windows(); + break; + case RESEARCH_STAGE_COMPLETING_DESIGN: + research_finish_item(&gResearchNextItem); + gResearchProgress = 0; + gResearchProgressStage = RESEARCH_STAGE_INITIAL_RESEARCH; + research_calculate_expected_date(); + research_update_uncompleted_types(); + research_invalidate_related_windows(); + break; + case RESEARCH_STAGE_FINISHED_ALL: + gResearchFundingLevel = RESEARCH_FUNDING_NONE; + break; } } } void research_process_random_items() { - rct_research_item * research = gResearchItems; - for (; research->rawValue != RESEARCHED_ITEMS_END; research++) { } + rct_research_item* research = gResearchItems; + for (; research->rawValue != RESEARCHED_ITEMS_END; research++) + { + } research++; for (; research->rawValue != RESEARCHED_ITEMS_END_2; research += 2) @@ -393,9 +398,9 @@ void research_process_random_items() continue; } - rct_research_item * edx = nullptr; - rct_research_item * ebp = nullptr; - rct_research_item * inner_research = gResearchItems; + rct_research_item* edx = nullptr; + rct_research_item* ebp = nullptr; + rct_research_item* inner_research = gResearchItems; do { if (research->rawValue == inner_research->rawValue) @@ -406,8 +411,7 @@ void research_process_random_items() { ebp = inner_research; } - } - while ((inner_research++)->rawValue != RESEARCHED_ITEMS_END); + } while ((inner_research++)->rawValue != RESEARCHED_ITEMS_END); assert(edx != nullptr); edx->rawValue = research->rawValue; assert(ebp != nullptr); @@ -434,15 +438,14 @@ void research_reset_current_item() set_all_scenery_items_invented(); set_all_scenery_groups_not_invented(); - - for (rct_research_item * research = gResearchItems; research->rawValue != RESEARCHED_ITEMS_SEPARATOR; research++) + for (rct_research_item* research = gResearchItems; research->rawValue != RESEARCHED_ITEMS_SEPARATOR; research++) { research_finish_item(research); } gResearchLastItem.rawValue = RESEARCHED_ITEMS_SEPARATOR; - gResearchProgressStage = RESEARCH_STAGE_INITIAL_RESEARCH; - gResearchProgress = 0; + gResearchProgressStage = RESEARCH_STAGE_INITIAL_RESEARCH; + gResearchProgress = 0; } /** @@ -451,7 +454,7 @@ void research_reset_current_item() */ static void research_insert_unresearched(int32_t rawValue, int32_t category) { - rct_research_item * researchItem, * researchItem2; + rct_research_item *researchItem, *researchItem2; researchItem = gResearchItems; do @@ -471,8 +474,7 @@ static void research_insert_unresearched(int32_t rawValue, int32_t category) researchItem->category = category; break; } - } - while (rawValue != (researchItem++)->rawValue); + } while (rawValue != (researchItem++)->rawValue); } /** @@ -481,7 +483,7 @@ static void research_insert_unresearched(int32_t rawValue, int32_t category) */ static void research_insert_researched(int32_t rawValue, uint8_t category) { - rct_research_item * researchItem, * researchItem2; + rct_research_item *researchItem, *researchItem2; researchItem = gResearchItems; // First check to make sure that entry is not already accounted for @@ -510,26 +512,23 @@ static void research_insert_researched(int32_t rawValue, uint8_t category) researchItem->category = category; break; } - } - while (rawValue != (researchItem++)->rawValue); + } while (rawValue != (researchItem++)->rawValue); } /** * * rct2: 0x006857CF */ -void research_remove(rct_research_item * researchItem) +void research_remove(rct_research_item* researchItem) { - for (rct_research_item * researchItem2 = gResearchItems; - researchItem2->rawValue != RESEARCHED_ITEMS_END; researchItem2++) + for (rct_research_item* researchItem2 = gResearchItems; researchItem2->rawValue != RESEARCHED_ITEMS_END; researchItem2++) { if (researchItem2->rawValue == researchItem->rawValue) { do { *researchItem2 = *(researchItem2 + 1); - } - while (researchItem2++->rawValue != RESEARCHED_ITEMS_END_2); + } while (researchItem2++->rawValue != RESEARCHED_ITEMS_END_2); return; } } @@ -558,7 +557,7 @@ void research_populate_list_random() // Rides for (int32_t i = 0; i < MAX_RIDE_OBJECTS; i++) { - rct_ride_entry * rideEntry = get_ride_entry(i); + rct_ride_entry* rideEntry = get_ride_entry(i); if (rideEntry == nullptr) { continue; @@ -577,7 +576,7 @@ void research_populate_list_random() // Scenery for (int32_t i = 0; i < MAX_SCENERY_GROUP_OBJECTS; i++) { - rct_scenery_group_entry * sceneryGroupEntry = get_scenery_group_entry(i); + rct_scenery_group_entry* sceneryGroupEntry = get_scenery_group_entry(i); if (sceneryGroupEntry == nullptr) { continue; @@ -593,7 +592,7 @@ void research_populate_list_researched() // Rides for (int32_t i = 0; i < MAX_RIDE_OBJECTS; i++) { - rct_ride_entry * rideEntry = get_ride_entry(i); + rct_ride_entry* rideEntry = get_ride_entry(i); if (rideEntry == nullptr) { continue; @@ -611,7 +610,7 @@ void research_populate_list_researched() // Scenery for (int32_t i = 0; i < MAX_SCENERY_GROUP_OBJECTS; i++) { - rct_scenery_group_entry * sceneryGroupEntry = get_scenery_group_entry(i); + rct_scenery_group_entry* sceneryGroupEntry = get_scenery_group_entry(i); if (sceneryGroupEntry == nullptr) { continue; @@ -623,7 +622,7 @@ void research_populate_list_researched() void research_insert_ride_entry(uint8_t entryIndex, bool researched) { - rct_ride_entry * rideEntry = get_ride_entry(entryIndex); + rct_ride_entry* rideEntry = get_ride_entry(entryIndex); uint8_t category = rideEntry->category[0]; for (auto rideType : rideEntry->ride_type) { @@ -724,7 +723,7 @@ void set_all_scenery_groups_not_invented() { for (int32_t i = 0; i < MAX_SCENERY_GROUP_OBJECTS; ++i) { - rct_scenery_group_entry * scenery_set = get_scenery_group_entry(i); + rct_scenery_group_entry* scenery_set = get_scenery_group_entry(i); if (scenery_set == nullptr) { continue; @@ -739,62 +738,43 @@ void set_all_scenery_groups_not_invented() void set_all_scenery_items_invented() { - std::fill( - std::begin(_researchedSceneryItems), - std::end(_researchedSceneryItems), - true); + std::fill(std::begin(_researchedSceneryItems), std::end(_researchedSceneryItems), true); } void set_all_scenery_items_not_invented() { - std::fill( - std::begin(_researchedSceneryItems), - std::end(_researchedSceneryItems), - false); + std::fill(std::begin(_researchedSceneryItems), std::end(_researchedSceneryItems), false); } void set_every_ride_type_invented() { - std::fill( - std::begin(_researchedRideTypes), - std::end(_researchedRideTypes), - true); + std::fill(std::begin(_researchedRideTypes), std::end(_researchedRideTypes), true); } void set_every_ride_type_not_invented() { - std::fill( - std::begin(_researchedRideTypes), - std::end(_researchedRideTypes), - false); + std::fill(std::begin(_researchedRideTypes), std::end(_researchedRideTypes), false); } void set_every_ride_entry_invented() { - std::fill( - std::begin(_researchedRideEntries), - std::end(_researchedRideEntries), - true); + std::fill(std::begin(_researchedRideEntries), std::end(_researchedRideEntries), true); } void set_every_ride_entry_not_invented() { - std::fill( - std::begin(_researchedRideEntries), - std::end(_researchedRideEntries), - false); + std::fill(std::begin(_researchedRideEntries), std::end(_researchedRideEntries), false); } /** * * rct2: 0x0068563D */ -rct_string_id research_item_get_name(const rct_research_item * researchItem) +rct_string_id research_item_get_name(const rct_research_item* researchItem) { - if (researchItem->type == RESEARCH_ENTRY_TYPE_RIDE) { - rct_ride_entry * rideEntry = get_ride_entry(researchItem->entryIndex); + rct_ride_entry* rideEntry = get_ride_entry(researchItem->entryIndex); if (rideEntry == nullptr) { return STR_EMPTY; @@ -806,7 +786,7 @@ rct_string_id research_item_get_name(const rct_research_item * researchItem) } else { - rct_scenery_group_entry * sceneryEntry = get_scenery_group_entry(researchItem->entryIndex); + rct_scenery_group_entry* sceneryEntry = get_scenery_group_entry(researchItem->entryIndex); if (sceneryEntry == nullptr) { return STR_EMPTY; @@ -821,11 +801,11 @@ rct_string_id research_item_get_name(const rct_research_item * researchItem) /** * This will return the name of the base ride type or ride group, as seen in the research window. */ -rct_string_id research_get_friendly_base_ride_type_name(uint8_t trackType, rct_ride_entry * rideEntry) +rct_string_id research_get_friendly_base_ride_type_name(uint8_t trackType, rct_ride_entry* rideEntry) { if (RideGroupManager::RideTypeHasRideGroups(trackType)) { - const RideGroup * rideGroup = RideGroupManager::GetRideGroup(trackType, rideEntry); + const RideGroup* rideGroup = RideGroupManager::GetRideGroup(trackType, rideEntry); return rideGroup->Naming.name; } else @@ -841,7 +821,7 @@ rct_string_id research_get_friendly_base_ride_type_name(uint8_t trackType, rct_r */ void research_remove_flags() { - for (rct_research_item * research = gResearchItems; research->rawValue != RESEARCHED_ITEMS_END_2; research++) + for (rct_research_item* research = gResearchItems; research->rawValue != RESEARCHED_ITEMS_END_2; research++) { // Clear the always researched flags. if (research->rawValue > RESEARCHED_ITEMS_SEPARATOR) @@ -856,7 +836,7 @@ void research_fix() // Fix invalid research items for (int32_t i = 0; i < MAX_RESEARCH_ITEMS; i++) { - rct_research_item * researchItem = &gResearchItems[i]; + rct_research_item* researchItem = &gResearchItems[i]; if (researchItem->rawValue == RESEARCHED_ITEMS_SEPARATOR) continue; if (researchItem->rawValue == RESEARCHED_ITEMS_END) @@ -872,7 +852,7 @@ void research_fix() break; if (researchItem->type == RESEARCH_ENTRY_TYPE_RIDE) { - rct_ride_entry * rideEntry = get_ride_entry(researchItem->entryIndex); + rct_ride_entry* rideEntry = get_ride_entry(researchItem->entryIndex); if (rideEntry == nullptr) { research_remove(researchItem); @@ -881,7 +861,7 @@ void research_fix() } else { - rct_scenery_group_entry * sceneryGroupEntry = get_scenery_group_entry(researchItem->rawValue); + rct_scenery_group_entry* sceneryGroupEntry = get_scenery_group_entry(researchItem->rawValue); if (sceneryGroupEntry == nullptr) { research_remove(researchItem); @@ -901,7 +881,7 @@ void research_fix() { for (uint8_t i = 0; i < MAX_RIDE_OBJECTS; i++) { - const rct_ride_entry * rideEntry = get_ride_entry(i); + const rct_ride_entry* rideEntry = get_ride_entry(i); if (rideEntry != nullptr) { @@ -921,7 +901,7 @@ void research_fix() for (uint8_t i = 0; i < MAX_SCENERY_GROUP_OBJECTS; i++) { - const rct_scenery_group_entry * groupEntry = get_scenery_group_entry(i); + const rct_scenery_group_entry* groupEntry = get_scenery_group_entry(i); if (groupEntry != nullptr) research_insert_scenery_group_entry(i, true); @@ -931,10 +911,11 @@ void research_fix() void research_items_make_all_unresearched() { - rct_research_item * researchItem, * nextResearchItem, researchItemTemp; + rct_research_item *researchItem, *nextResearchItem, researchItemTemp; int32_t sorted; - do { + do + { sorted = 1; for (researchItem = gResearchItems; researchItem->rawValue != RESEARCHED_ITEMS_SEPARATOR; researchItem++) { @@ -942,7 +923,8 @@ void research_items_make_all_unresearched() continue; nextResearchItem = researchItem + 1; - if (nextResearchItem->rawValue == RESEARCHED_ITEMS_SEPARATOR || research_item_is_always_researched(nextResearchItem)) + if (nextResearchItem->rawValue == RESEARCHED_ITEMS_SEPARATOR + || research_item_is_always_researched(nextResearchItem)) { // Bubble up always researched item or separator researchItemTemp = *researchItem; @@ -954,16 +936,17 @@ void research_items_make_all_unresearched() break; } } - } - while (!sorted); + } while (!sorted); } void research_items_make_all_researched() { - rct_research_item * researchItem, researchItemTemp; + rct_research_item *researchItem, researchItemTemp; // Find separator - for (researchItem = gResearchItems; researchItem->rawValue != RESEARCHED_ITEMS_SEPARATOR; researchItem++) { } + for (researchItem = gResearchItems; researchItem->rawValue != RESEARCHED_ITEMS_SEPARATOR; researchItem++) + { + } // Move separator below all items for (; (researchItem + 1)->rawValue != RESEARCHED_ITEMS_END; researchItem++) @@ -981,11 +964,13 @@ void research_items_make_all_researched() */ void research_items_shuffle() { - rct_research_item * researchItem, * researchOrderBase, researchItemTemp; + rct_research_item *researchItem, *researchOrderBase, researchItemTemp; int32_t i, numNonResearchedItems; // Skip pre-researched items - for (researchItem = gResearchItems; researchItem->rawValue != RESEARCHED_ITEMS_SEPARATOR; researchItem++) {} + for (researchItem = gResearchItems; researchItem->rawValue != RESEARCHED_ITEMS_SEPARATOR; researchItem++) + { + } researchItem++; researchOrderBase = researchItem; @@ -1007,9 +992,11 @@ void research_items_shuffle() } } -bool research_item_is_always_researched(rct_research_item * researchItem) +bool research_item_is_always_researched(rct_research_item* researchItem) { - return (researchItem->flags & (RESEARCH_ENTRY_FLAG_RIDE_ALWAYS_RESEARCHED | RESEARCH_ENTRY_FLAG_SCENERY_SET_ALWAYS_RESEARCHED)) != 0; + return (researchItem->flags + & (RESEARCH_ENTRY_FLAG_RIDE_ALWAYS_RESEARCHED | RESEARCH_ENTRY_FLAG_SCENERY_SET_ALWAYS_RESEARCHED)) + != 0; } bool rct_research_item::IsInventedEndMarker() const diff --git a/src/openrct2/management/Research.h b/src/openrct2/management/Research.h index b308ba57bf..815e40d3ae 100644 --- a/src/openrct2/management/Research.h +++ b/src/openrct2/management/Research.h @@ -42,7 +42,7 @@ assert_struct_size(rct_research_item, 5); enum { RESEARCH_ENTRY_TYPE_SCENERY = 0, - RESEARCH_ENTRY_TYPE_RIDE = 1, + RESEARCH_ENTRY_TYPE_RIDE = 1, }; enum @@ -58,13 +58,14 @@ enum // Extra end of list entry. Leftover from RCT1. #define RESEARCHED_ITEMS_END_2 (-3) -#define MAX_RESEARCH_ITEMS 500 -#define MAX_RESEARCHED_TRACK_TYPES 128 +#define MAX_RESEARCH_ITEMS 500 +#define MAX_RESEARCHED_TRACK_TYPES 128 #define MAX_RESEARCHED_SCENERY_ITEMS 1792 #define RESEARCH_ENTRY_RIDE_MASK 0x10000 -enum { +enum +{ RESEARCH_FUNDING_NONE, RESEARCH_FUNDING_MINIMUM, RESEARCH_FUNDING_NORMAL, @@ -73,7 +74,8 @@ enum { RESEARCH_FUNDING_COUNT }; -enum { +enum +{ RESEARCH_STAGE_INITIAL_RESEARCH, RESEARCH_STAGE_DESIGNING, RESEARCH_STAGE_COMPLETING_DESIGN, @@ -81,7 +83,8 @@ enum { RESEARCH_STAGE_FINISHED_ALL }; -enum { +enum +{ RESEARCH_CATEGORY_TRANSPORT, RESEARCH_CATEGORY_GENTLE, RESEARCH_CATEGORY_ROLLERCOASTER, @@ -112,9 +115,9 @@ void research_populate_list_random(); void research_populate_list_researched(); void research_process_random_items(); -void research_finish_item(rct_research_item * researchItem); +void research_finish_item(rct_research_item* researchItem); void research_insert(int32_t researched, int32_t rawValue, uint8_t category); -void research_remove(rct_research_item * researchItem); +void research_remove(rct_research_item* researchItem); void research_insert_ride_entry(uint8_t entryIndex, bool researched); void research_insert_scenery_group_entry(uint8_t entryIndex, bool researched); @@ -136,12 +139,12 @@ void set_every_ride_type_invented(); void set_every_ride_type_not_invented(); void set_every_ride_entry_invented(); void set_every_ride_entry_not_invented(); -rct_string_id research_item_get_name(const rct_research_item * researchItem); -rct_string_id research_get_friendly_base_ride_type_name(uint8_t trackType, rct_ride_entry * rideEntry); +rct_string_id research_item_get_name(const rct_research_item* researchItem); +rct_string_id research_get_friendly_base_ride_type_name(uint8_t trackType, rct_ride_entry* rideEntry); void research_remove_flags(); void research_fix(); void research_items_make_all_unresearched(); void research_items_make_all_researched(); void research_items_shuffle(); -bool research_item_is_always_researched(rct_research_item * researchItem); +bool research_item_is_always_researched(rct_research_item* researchItem);