From 31e1ad43a8c8d08ca869f5a5b97c3822b90341ef Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Fri, 6 Oct 2017 22:37:06 +0200 Subject: [PATCH] Compile finance.c as C++, clean up --- OpenRCT2.xcodeproj/project.pbxproj | 12 +- src/openrct2/cheats.c | 2 +- src/openrct2/game.c | 2 +- src/openrct2/interface/console.c | 2 +- .../management/{finance.c => Finance.cpp} | 169 +++++++++++------- .../management/{finance.h => Finance.h} | 13 +- src/openrct2/management/Research.cpp | 4 +- src/openrct2/management/Research.h | 4 +- src/openrct2/management/marketing.c | 2 +- src/openrct2/network/Network.cpp | 2 +- .../network/NetworkServerAdvertiser.cpp | 2 +- src/openrct2/peep/peep.c | 2 +- src/openrct2/peep/staff.c | 2 +- src/openrct2/rct1/S4Importer.cpp | 2 +- src/openrct2/rct2/S6Exporter.cpp | 2 +- src/openrct2/rct2/S6Importer.cpp | 2 +- src/openrct2/ride/TrackDesign.cpp | 2 +- src/openrct2/ride/ride.c | 2 +- src/openrct2/ride/track.c | 2 +- src/openrct2/scenario/scenario.c | 2 +- src/openrct2/scenario/scenario.h | 2 +- src/openrct2/world/Entrance.cpp | 2 +- src/openrct2/world/map.c | 2 +- src/openrct2/world/park.c | 2 +- 24 files changed, 140 insertions(+), 100 deletions(-) rename src/openrct2/management/{finance.c => Finance.cpp} (71%) rename src/openrct2/management/{finance.h => Finance.h} (89%) diff --git a/OpenRCT2.xcodeproj/project.pbxproj b/OpenRCT2.xcodeproj/project.pbxproj index 0a89656c86..cb20a29aac 100644 --- a/OpenRCT2.xcodeproj/project.pbxproj +++ b/OpenRCT2.xcodeproj/project.pbxproj @@ -27,6 +27,7 @@ 4C8B42721EEB1AE400F015CA /* HardwareDisplayDrawingEngine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C8B42711EEB1AE400F015CA /* HardwareDisplayDrawingEngine.cpp */; }; 4C8B42741EEB1B6F00F015CA /* Screenshot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C8B42731EEB1B6F00F015CA /* Screenshot.cpp */; }; 4C93F1141F86728F00A9330D /* Research.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C93F1121F86728F00A9330D /* Research.cpp */; }; + 4C93F1171F881F9C00A9330D /* Finance.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C93F1151F881F9C00A9330D /* Finance.cpp */; }; 4CB832A71EFBDCCE00B88761 /* land_tool.c in Sources */ = {isa = PBXBuildFile; fileRef = 4CB832A51EFBDCCE00B88761 /* land_tool.c */; }; 4CB832AB1EFFB8D100B88761 /* ttf_sdlport.c in Sources */ = {isa = PBXBuildFile; fileRef = 4CB832A81EFFB8D100B88761 /* ttf_sdlport.c */; }; 4CB832AC1EFFB8D100B88761 /* ttf.c in Sources */ = {isa = PBXBuildFile; fileRef = 4CB832A91EFFB8D100B88761 /* ttf.c */; }; @@ -248,7 +249,6 @@ F76C86381EC4E88300FA49E2 /* user.c in Sources */ = {isa = PBXBuildFile; fileRef = F76C83E71EC4E7CC00FA49E2 /* user.c */; }; F76C863A1EC4E88300FA49E2 /* utf8.c in Sources */ = {isa = PBXBuildFile; fileRef = F76C83E91EC4E7CC00FA49E2 /* utf8.c */; }; F76C863B1EC4E88300FA49E2 /* award.c in Sources */ = {isa = PBXBuildFile; fileRef = F76C83EB1EC4E7CC00FA49E2 /* award.c */; }; - F76C863D1EC4E88300FA49E2 /* finance.c in Sources */ = {isa = PBXBuildFile; fileRef = F76C83ED1EC4E7CC00FA49E2 /* finance.c */; }; F76C863F1EC4E88300FA49E2 /* marketing.c in Sources */ = {isa = PBXBuildFile; fileRef = F76C83EF1EC4E7CC00FA49E2 /* marketing.c */; }; F76C86411EC4E88300FA49E2 /* news_item.c in Sources */ = {isa = PBXBuildFile; fileRef = F76C83F11EC4E7CC00FA49E2 /* news_item.c */; }; F76C86451EC4E88300FA49E2 /* Http.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F76C83F61EC4E7CC00FA49E2 /* Http.cpp */; }; @@ -620,6 +620,8 @@ 4C8B42731EEB1B6F00F015CA /* Screenshot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Screenshot.cpp; sourceTree = ""; }; 4C93F1121F86728F00A9330D /* Research.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Research.cpp; sourceTree = ""; }; 4C93F1131F86728F00A9330D /* Research.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Research.h; sourceTree = ""; }; + 4C93F1151F881F9C00A9330D /* Finance.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Finance.cpp; sourceTree = ""; }; + 4C93F1161F881F9C00A9330D /* Finance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Finance.h; sourceTree = ""; }; 4CB832A51EFBDCCE00B88761 /* land_tool.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = land_tool.c; sourceTree = ""; }; 4CB832A61EFBDCCE00B88761 /* land_tool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = land_tool.h; sourceTree = ""; }; 4CB832A81EFFB8D100B88761 /* ttf_sdlport.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttf_sdlport.c; sourceTree = ""; }; @@ -1075,8 +1077,6 @@ F76C83E91EC4E7CC00FA49E2 /* utf8.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = utf8.c; sourceTree = ""; }; F76C83EB1EC4E7CC00FA49E2 /* award.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = award.c; sourceTree = ""; }; F76C83EC1EC4E7CC00FA49E2 /* award.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = award.h; sourceTree = ""; }; - F76C83ED1EC4E7CC00FA49E2 /* finance.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = finance.c; sourceTree = ""; }; - F76C83EE1EC4E7CC00FA49E2 /* finance.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = finance.h; sourceTree = ""; }; F76C83EF1EC4E7CC00FA49E2 /* marketing.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = marketing.c; sourceTree = ""; }; F76C83F01EC4E7CC00FA49E2 /* marketing.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = marketing.h; sourceTree = ""; }; F76C83F11EC4E7CC00FA49E2 /* news_item.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = news_item.c; sourceTree = ""; }; @@ -2073,8 +2073,8 @@ children = ( F76C83EB1EC4E7CC00FA49E2 /* award.c */, F76C83EC1EC4E7CC00FA49E2 /* award.h */, - F76C83ED1EC4E7CC00FA49E2 /* finance.c */, - F76C83EE1EC4E7CC00FA49E2 /* finance.h */, + 4C93F1151F881F9C00A9330D /* Finance.cpp */, + 4C93F1161F881F9C00A9330D /* Finance.h */, F76C83EF1EC4E7CC00FA49E2 /* marketing.c */, F76C83F01EC4E7CC00FA49E2 /* marketing.h */, F76C83F11EC4E7CC00FA49E2 /* news_item.c */, @@ -3105,6 +3105,7 @@ F76C88791EC5324E00FA49E2 /* AudioContext.cpp in Sources */, C666EE7A1F37ACB10061AA04 /* Themes.cpp in Sources */, C666EE7F1F37ACB10061AA04 /* Viewport.cpp in Sources */, + 4C93F1171F881F9C00A9330D /* Finance.cpp in Sources */, C654DF3C1F69C0430040F43D /* TrackDesignManage.cpp in Sources */, 4CB832AC1EFFB8D100B88761 /* ttf.c in Sources */, C654DF3B1F69C0430040F43D /* TitleScenarioSelect.cpp in Sources */, @@ -3276,7 +3277,6 @@ F76C86381EC4E88300FA49E2 /* user.c in Sources */, F76C863A1EC4E88300FA49E2 /* utf8.c in Sources */, F76C863B1EC4E88300FA49E2 /* award.c in Sources */, - F76C863D1EC4E88300FA49E2 /* finance.c in Sources */, C666EE1A1F33E3800061AA04 /* EditorObjectSelection.cpp in Sources */, F76C863F1EC4E88300FA49E2 /* marketing.c in Sources */, F76C86411EC4E88300FA49E2 /* news_item.c in Sources */, diff --git a/src/openrct2/cheats.c b/src/openrct2/cheats.c index ad86b1969d..f88edaa2ea 100644 --- a/src/openrct2/cheats.c +++ b/src/openrct2/cheats.c @@ -20,7 +20,7 @@ #include "game.h" #include "interface/window.h" #include "localisation/localisation.h" -#include "management/finance.h" +#include "management/Finance.h" #include "network/network.h" #include "ride/station.h" #include "util/util.h" diff --git a/src/openrct2/game.c b/src/openrct2/game.c index f78f152887..da208aeb01 100644 --- a/src/openrct2/game.c +++ b/src/openrct2/game.c @@ -27,7 +27,7 @@ #include "interface/widget.h" #include "interface/window.h" #include "localisation/localisation.h" -#include "management/finance.h" +#include "management/Finance.h" #include "management/marketing.h" #include "management/news_item.h" #include "management/Research.h" diff --git a/src/openrct2/interface/console.c b/src/openrct2/interface/console.c index e422836694..e3d176ce28 100644 --- a/src/openrct2/interface/console.c +++ b/src/openrct2/interface/console.c @@ -24,7 +24,7 @@ #include "../input.h" #include "../localisation/localisation.h" #include "../localisation/user.h" -#include "../management/finance.h" +#include "../management/Finance.h" #include "../management/Research.h" #include "../network/network.h" #include "../network/twitch.h" diff --git a/src/openrct2/management/finance.c b/src/openrct2/management/Finance.cpp similarity index 71% rename from src/openrct2/management/finance.c rename to src/openrct2/management/Finance.cpp index 000d5257ec..e7b1cf400e 100644 --- a/src/openrct2/management/finance.c +++ b/src/openrct2/management/Finance.cpp @@ -19,47 +19,50 @@ #include "../localisation/date.h" #include "../localisation/localisation.h" #include "../peep/peep.h" +#include "../peep/staff.h" #include "../ride/ride.h" #include "../util/util.h" #include "../world/park.h" #include "../world/sprite.h" -#include "finance.h" +#include "Finance.h" /** * Monthly staff wages * * rct2: 0x00992A00 */ -const money32 wage_table[4] = { - 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[4] = { - 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 }; -sint32 dword_988E60[] = { 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0 }; +sint32 dword_988E60[RCT_EXPENDITURE_TYPE_COUNT] = {1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0}; money32 gInitialCash; money32 gCashEncrypted; money32 gBankLoan; -uint8 gBankLoanInterestRate; +uint8 gBankLoanInterestRate; money32 gMaxBankLoan; money32 gCurrentExpenditure; money32 gCurrentProfit; money32 gHistoricalProfit; money32 gWeeklyProfitAverageDividend; -uint16 gWeeklyProfitAverageDivisor; -money32 gCashHistory[128]; -money32 gWeeklyProfitHistory[128]; -money32 gParkValueHistory[128]; +uint16 gWeeklyProfitAverageDivisor; +money32 gCashHistory[FINANCE_GRAPH_SIZE]; +money32 gWeeklyProfitHistory[FINANCE_GRAPH_SIZE]; +money32 gParkValueHistory[FINANCE_GRAPH_SIZE]; money32 gExpenditureTable[EXPENDITURE_TABLE_TOTAL_COUNT]; uint8 gCommandExpenditureType; @@ -81,7 +84,10 @@ void finance_payment(money32 amount, rct_expenditure_type type) gCashEncrypted = ENCRYPT_MONEY(new_money); gExpenditureTable[type] -= amount; if (dword_988E60[type] & 1) - gCurrentExpenditure -= amount; // Cumulative amount of money spent this day + { + // Cumulative amount of money spent this day + gCurrentExpenditure -= amount; + } gToolbarDirtyFlags |= BTM_TB_DIRTY_FLAG_MONEY; @@ -94,14 +100,18 @@ void finance_payment(money32 amount, rct_expenditure_type type) */ void finance_pay_wages() { - rct_peep* peep; + rct_peep * peep; uint16 spriteIndex; if (gParkFlags & PARK_FLAGS_NO_MONEY) + { return; + } FOR_ALL_STAFF(spriteIndex, peep) + { finance_payment(wage_table[peep->staff_type] / 4, RCT_EXPENDITURE_TYPE_WAGES); + } } /** @@ -113,7 +123,9 @@ void finance_pay_research() uint8 level; if (gParkFlags & PARK_FLAGS_NO_MONEY) + { return; + } level = gResearchFundingLevel; finance_payment(research_cost_table[level] / 4, RCT_EXPENDITURE_TYPE_RESEARCH); @@ -127,12 +139,14 @@ 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 current_interest_rate = gBankLoanInterestRate; + money64 current_loan = gBankLoan; + uint8 current_interest_rate = gBankLoanInterestRate; money32 interest_to_pay; if (gParkFlags & PARK_FLAGS_NO_MONEY) + { return; + } interest_to_pay = (current_loan * 5 * current_interest_rate) >> 14; @@ -146,24 +160,29 @@ void finance_pay_interest() void finance_pay_ride_upkeep() { sint32 i; - Ride* ride; + Ride * ride; - FOR_ALL_RIDES(i, ride) { - if (!(ride->lifecycle_flags & RIDE_LIFECYCLE_EVER_BEEN_OPENED)) { - ride->build_date = gDateMonthsElapsed; + FOR_ALL_RIDES(i, ride) + { + if (!(ride->lifecycle_flags & RIDE_LIFECYCLE_EVER_BEEN_OPENED)) + { + ride->build_date = gDateMonthsElapsed; ride->reliability = RIDE_INITIAL_RELIABILITY; } - if (ride->status != RIDE_STATUS_CLOSED && !(gParkFlags & PARK_FLAGS_NO_MONEY)) { + if (ride->status != RIDE_STATUS_CLOSED && !(gParkFlags & PARK_FLAGS_NO_MONEY)) + { sint16 upkeep = ride->upkeep_cost; - if (upkeep != -1) { + if (upkeep != -1) + { ride->total_profit -= upkeep; ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_INCOME; finance_payment(upkeep, RCT_EXPENDITURE_TYPE_RIDE_RUNNING_COSTS); } } - if (ride->last_crash_type != RIDE_CRASH_TYPE_NONE) { + if (ride->last_crash_type != RIDE_CRASH_TYPE_NONE) + { ride->last_crash_type--; } } @@ -171,10 +190,11 @@ void finance_pay_ride_upkeep() void finance_reset_history() { - for (sint32 i = 0; i < 128; i++) { - gCashHistory[i] = MONEY32_UNDEFINED; + for (sint32 i = 0; i < FINANCE_GRAPH_SIZE; i++) + { + gCashHistory[i] = MONEY32_UNDEFINED; gWeeklyProfitHistory[i] = MONEY32_UNDEFINED; - gParkValueHistory[i] = MONEY32_UNDEFINED; + gParkValueHistory[i] = MONEY32_UNDEFINED; } } @@ -182,33 +202,34 @@ void finance_reset_history() * * rct2: 0x0069DEFB */ -void finance_init() { - +void finance_init() +{ // It only initialises the first month - for (uint32 i = 0; i < RCT_EXPENDITURE_TYPE_COUNT; i++) { + for (uint32 i = 0; i < RCT_EXPENDITURE_TYPE_COUNT; i++) + { gExpenditureTable[i] = 0; } gCurrentExpenditure = 0; - gCurrentProfit = 0; + gCurrentProfit = 0; gWeeklyProfitAverageDividend = 0; - gWeeklyProfitAverageDivisor = 0; + gWeeklyProfitAverageDivisor = 0; - gInitialCash = MONEY(10000,00); // Cheat detection + gInitialCash = MONEY(10000, 00); // Cheat detection - gCashEncrypted = ENCRYPT_MONEY(MONEY(10000,00)); - gBankLoan = MONEY(10000,00); - gMaxBankLoan = MONEY(20000,00); + gCashEncrypted = ENCRYPT_MONEY(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)); } @@ -218,7 +239,7 @@ void finance_init() { */ void finance_update_daily_profit() { - gCurrentProfit = 7 * gCurrentExpenditure; + gCurrentProfit = 7 * gCurrentExpenditure; gCurrentExpenditure = 0; // Reset daily expenditure money32 current_profit = 0; @@ -227,9 +248,10 @@ void finance_update_daily_profit() { // Staff costs uint16 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]; } @@ -242,10 +264,12 @@ void finance_update_daily_profit() current_profit -= current_loan / 600; // Ride costs - Ride *ride; + Ride * ride; sint32 i; - FOR_ALL_RIDES(i, ride) { - if (ride->status != RIDE_STATUS_CLOSED && ride->upkeep_cost != -1) { + FOR_ALL_RIDES(i, ride) + { + if (ride->status != RIDE_STATUS_CLOSED && ride->upkeep_cost != -1) + { current_profit -= 2 * ride->upkeep_cost; } } @@ -292,34 +316,40 @@ money32 finance_get_current_cash() * * rct2: 0x0069DFB3 */ -void game_command_set_current_loan(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp) +void game_command_set_current_loan(sint32 * eax, sint32 * ebx, sint32 * ecx, sint32 * edx, sint32 * esi, sint32 * edi, sint32 * ebp) { money32 money, loanDifference, currentLoan; money32 newLoan = *edx; - currentLoan = gBankLoan; - money = DECRYPT_MONEY(gCashEncrypted); + currentLoan = gBankLoan; + money = DECRYPT_MONEY(gCashEncrypted); loanDifference = currentLoan - newLoan; gCommandExpenditureType = RCT_EXPENDITURE_TYPE_INTEREST; - if (newLoan > currentLoan) { - if (newLoan > gMaxBankLoan) { + if (newLoan > currentLoan) + { + if (newLoan > gMaxBankLoan) + { gGameCommandErrorText = STR_BANK_REFUSES_TO_INCREASE_LOAN; *ebx = MONEY32_UNDEFINED; return; } - } else { - if (loanDifference > money) { + } + else + { + if (loanDifference > money) + { gGameCommandErrorText = STR_NOT_ENOUGH_CASH_AVAILABLE; *ebx = MONEY32_UNDEFINED; return; } } - if (*ebx & GAME_COMMAND_FLAG_APPLY) { + if (*ebx & GAME_COMMAND_FLAG_APPLY) + { money -= loanDifference; - gBankLoan = newLoan; - gInitialCash = money; + gBankLoan = newLoan; + gInitialCash = money; gCashEncrypted = ENCRYPT_MONEY(money); window_invalidate_by_class(WC_FINANCES); @@ -337,21 +367,25 @@ void game_command_set_current_loan(sint32* eax, sint32* ebx, sint32* ecx, sint32 void finance_shift_expenditure_table() { // If EXPENDITURE_TABLE_MONTH_COUNT months have passed then is full, sum the oldest month - if (gDateMonthsElapsed >= EXPENDITURE_TABLE_MONTH_COUNT) { + if (gDateMonthsElapsed >= EXPENDITURE_TABLE_MONTH_COUNT) + { money32 sum = 0; - for (uint32 i = EXPENDITURE_TABLE_TOTAL_COUNT - RCT_EXPENDITURE_TYPE_COUNT; i < EXPENDITURE_TABLE_TOTAL_COUNT; i++) { + for (uint32 i = EXPENDITURE_TABLE_TOTAL_COUNT - RCT_EXPENDITURE_TYPE_COUNT; i < EXPENDITURE_TABLE_TOTAL_COUNT; i++) + { sum += gExpenditureTable[i]; } gHistoricalProfit += sum; } // Shift the table - for (uint32 i = EXPENDITURE_TABLE_TOTAL_COUNT - 1; i >= RCT_EXPENDITURE_TYPE_COUNT; i--) { + for (uint32 i = EXPENDITURE_TABLE_TOTAL_COUNT - 1; i >= RCT_EXPENDITURE_TYPE_COUNT; i--) + { gExpenditureTable[i] = gExpenditureTable[i - RCT_EXPENDITURE_TYPE_COUNT]; } // Zero the beginning of the table, which is the new month - for (uint32 i = 0; i < RCT_EXPENDITURE_TYPE_COUNT; i++) { + for (uint32 i = 0; i < RCT_EXPENDITURE_TYPE_COUNT; i++) + { gExpenditureTable[i] = 0; } @@ -373,8 +407,9 @@ void finance_reset_cash_to_initial() money32 finance_get_last_month_shop_profit() { money32 profit = 0; - if (gDateMonthsElapsed != 0) { - money32 * lastMonthExpenditure = &gExpenditureTable[1 * RCT_EXPENDITURE_TYPE_COUNT]; + if (gDateMonthsElapsed != 0) + { + money32 * lastMonthExpenditure = &gExpenditureTable[RCT_EXPENDITURE_TYPE_COUNT]; profit += lastMonthExpenditure[RCT_EXPENDITURE_TYPE_SHOP_SHOP_SALES]; profit += lastMonthExpenditure[RCT_EXPENDITURE_TYPE_SHOP_STOCK]; profit += lastMonthExpenditure[RCT_EXPENDITURE_TYPE_FOODDRINK_SALES]; diff --git a/src/openrct2/management/finance.h b/src/openrct2/management/Finance.h similarity index 89% rename from src/openrct2/management/finance.h rename to src/openrct2/management/Finance.h index 931ac3a071..32e313bb68 100644 --- a/src/openrct2/management/finance.h +++ b/src/openrct2/management/Finance.h @@ -18,6 +18,8 @@ #define _FINANCE_H_ #include "../common.h" +#include "../peep/staff.h" +#include "Research.h" typedef sint32 rct_expenditure_type; @@ -41,13 +43,14 @@ enum { #define EXPENDITURE_TABLE_MONTH_COUNT 16 #define EXPENDITURE_TABLE_TOTAL_COUNT (EXPENDITURE_TABLE_MONTH_COUNT * RCT_EXPENDITURE_TYPE_COUNT) +#define FINANCE_GRAPH_SIZE 128 #ifdef __cplusplus extern "C" { #endif -extern const money32 research_cost_table[4]; -extern const money32 wage_table[4]; +extern const money32 wage_table[STAFF_TYPE_COUNT]; +extern const money32 research_cost_table[RESEARCH_FUNDING_COUNT]; extern money32 gInitialCash; extern money32 gCashEncrypted; @@ -65,9 +68,9 @@ extern money32 gHistoricalProfit; extern money32 gWeeklyProfitAverageDividend; extern uint16 gWeeklyProfitAverageDivisor; -extern money32 gCashHistory[128]; -extern money32 gWeeklyProfitHistory[128]; -extern money32 gParkValueHistory[128]; +extern money32 gCashHistory[FINANCE_GRAPH_SIZE]; +extern money32 gWeeklyProfitHistory[FINANCE_GRAPH_SIZE]; +extern money32 gParkValueHistory[FINANCE_GRAPH_SIZE]; extern money32 gExpenditureTable[EXPENDITURE_TABLE_TOTAL_COUNT]; extern uint8 gCommandExpenditureType; diff --git a/src/openrct2/management/Research.cpp b/src/openrct2/management/Research.cpp index f5b6a7030f..0aff55348f 100644 --- a/src/openrct2/management/Research.cpp +++ b/src/openrct2/management/Research.cpp @@ -22,7 +22,7 @@ #include "../localisation/date.h" #include "../localisation/localisation.h" #include "../localisation/string_ids.h" -#include "../management/finance.h" +#include "../object_list.h" #include "../OpenRCT2.h" #include "../scenario/scenario.h" #include "../rct1.h" @@ -32,8 +32,8 @@ #include "../ride/track_data.h" #include "../world/scenery.h" #include "news_item.h" +#include "Finance.h" #include "Research.h" -#include "../object_list.h" const sint32 _researchRate[] = {0, 160, 250, 400}; diff --git a/src/openrct2/management/Research.h b/src/openrct2/management/Research.h index a0a665e0a1..909c067860 100644 --- a/src/openrct2/management/Research.h +++ b/src/openrct2/management/Research.h @@ -53,7 +53,9 @@ enum { RESEARCH_FUNDING_NONE, RESEARCH_FUNDING_MINIMUM, RESEARCH_FUNDING_NORMAL, - RESEARCH_FUNDING_MAXIMUM + RESEARCH_FUNDING_MAXIMUM, + + RESEARCH_FUNDING_COUNT }; enum { diff --git a/src/openrct2/management/marketing.c b/src/openrct2/management/marketing.c index 89145967bb..fdfc919902 100644 --- a/src/openrct2/management/marketing.c +++ b/src/openrct2/management/marketing.c @@ -18,10 +18,10 @@ #include "../game.h" #include "../interface/window.h" #include "../localisation/localisation.h" -#include "../management/finance.h" #include "../ride/ride.h" #include "../ride/ride_data.h" #include "../cheats.h" +#include "Finance.h" #include "marketing.h" #include "news_item.h" diff --git a/src/openrct2/network/Network.cpp b/src/openrct2/network/Network.cpp index d4b5023a9c..bbe276e4c6 100644 --- a/src/openrct2/network/Network.cpp +++ b/src/openrct2/network/Network.cpp @@ -60,7 +60,7 @@ sint32 _pickup_peep_old_x = SPRITE_LOCATION_NULL; #include "../interface/window.h" #include "../localisation/date.h" #include "../localisation/localisation.h" -#include "../management/finance.h" +#include "../management/Finance.h" #include "../network/http.h" #include "../scenario/scenario.h" #include "../util/util.h" diff --git a/src/openrct2/network/NetworkServerAdvertiser.cpp b/src/openrct2/network/NetworkServerAdvertiser.cpp index b75535ecb7..8636efeb1f 100644 --- a/src/openrct2/network/NetworkServerAdvertiser.cpp +++ b/src/openrct2/network/NetworkServerAdvertiser.cpp @@ -25,7 +25,7 @@ #include "../config/Config.h" #include "../localisation/date.h" -#include "../management/finance.h" +#include "../management/Finance.h" #include "../peep/peep.h" #include "../platform/platform.h" #include "../util/util.h" diff --git a/src/openrct2/peep/peep.c b/src/openrct2/peep/peep.c index a53f169cbf..f52fb3f24b 100644 --- a/src/openrct2/peep/peep.c +++ b/src/openrct2/peep/peep.c @@ -23,7 +23,7 @@ #include "../input.h" #include "../interface/window.h" #include "../localisation/localisation.h" -#include "../management/finance.h" +#include "../management/Finance.h" #include "../management/marketing.h" #include "../management/news_item.h" #include "../network/network.h" diff --git a/src/openrct2/peep/staff.c b/src/openrct2/peep/staff.c index 9f5f258a1c..4481b5f659 100644 --- a/src/openrct2/peep/staff.c +++ b/src/openrct2/peep/staff.c @@ -22,7 +22,7 @@ #include "../localisation/date.h" #include "../localisation/localisation.h" #include "../localisation/string_ids.h" -#include "../management/finance.h" +#include "../management/Finance.h" #include "../network/network.h" #include "../scenario/scenario.h" #include "../util/util.h" diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index dce8ba53e0..9aa2cd731c 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -42,7 +42,7 @@ #include "../interface/window.h" #include "../localisation/date.h" #include "../localisation/localisation.h" -#include "../management/finance.h" +#include "../management/Finance.h" #include "../management/marketing.h" #include "../object.h" #include "../object/ObjectManager.h" diff --git a/src/openrct2/rct2/S6Exporter.cpp b/src/openrct2/rct2/S6Exporter.cpp index 759b0289e8..30ab599c98 100644 --- a/src/openrct2/rct2/S6Exporter.cpp +++ b/src/openrct2/rct2/S6Exporter.cpp @@ -33,7 +33,7 @@ #include "../interface/window.h" #include "../localisation/date.h" #include "../localisation/localisation.h" -#include "../management/finance.h" +#include "../management/Finance.h" #include "../management/marketing.h" #include "../management/news_item.h" #include "../management/Research.h" diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index b6677b93bf..40f06a427c 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -35,7 +35,7 @@ #include "../interface/viewport.h" #include "../localisation/date.h" #include "../localisation/localisation.h" -#include "../management/finance.h" +#include "../management/Finance.h" #include "../management/marketing.h" #include "../management/news_item.h" #include "../management/Research.h" diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index 629b3e532c..703a3984a0 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -28,7 +28,7 @@ #include "../game.h" #include "../localisation/localisation.h" #include "../localisation/string_ids.h" -#include "../management/finance.h" +#include "../management/Finance.h" #include "../rct1.h" #include "../util/sawyercoding.h" #include "../util/util.h" diff --git a/src/openrct2/ride/ride.c b/src/openrct2/ride/ride.c index 64d8c67c62..9b2ecea5d2 100644 --- a/src/openrct2/ride/ride.c +++ b/src/openrct2/ride/ride.c @@ -26,7 +26,7 @@ #include "../interface/window.h" #include "../localisation/date.h" #include "../localisation/localisation.h" -#include "../management/finance.h" +#include "../management/Finance.h" #include "../management/marketing.h" #include "../management/news_item.h" #include "../network/network.h" diff --git a/src/openrct2/ride/track.c b/src/openrct2/ride/track.c index 5e7e58aa27..8c1d66b3ff 100644 --- a/src/openrct2/ride/track.c +++ b/src/openrct2/ride/track.c @@ -20,7 +20,7 @@ #include "../game.h" #include "../interface/viewport.h" #include "../localisation/localisation.h" -#include "../management/finance.h" +#include "../management/Finance.h" #include "../network/network.h" #include "../platform/platform.h" #include "../rct1.h" diff --git a/src/openrct2/scenario/scenario.c b/src/openrct2/scenario/scenario.c index bab2b15a8b..ddbfe5dd0a 100644 --- a/src/openrct2/scenario/scenario.c +++ b/src/openrct2/scenario/scenario.c @@ -23,7 +23,7 @@ #include "../localisation/date.h" #include "../localisation/localisation.h" #include "../management/award.h" -#include "../management/finance.h" +#include "../management/Finance.h" #include "../management/marketing.h" #include "../management/news_item.h" #include "../management/Research.h" diff --git a/src/openrct2/scenario/scenario.h b/src/openrct2/scenario/scenario.h index 5ac44c0655..01e6ca7133 100644 --- a/src/openrct2/scenario/scenario.h +++ b/src/openrct2/scenario/scenario.h @@ -18,7 +18,7 @@ #define _SCENARIO_H_ #include "../common.h" -#include "../management/finance.h" +#include "../management/Finance.h" #include "../management/Research.h" #include "../object.h" #include "../rct12.h" diff --git a/src/openrct2/world/Entrance.cpp b/src/openrct2/world/Entrance.cpp index 3887f4bf74..5221630516 100644 --- a/src/openrct2/world/Entrance.cpp +++ b/src/openrct2/world/Entrance.cpp @@ -24,7 +24,7 @@ #include "../cheats.h" #include "../game.h" #include "../localisation/string_ids.h" -#include "../management/finance.h" +#include "../management/Finance.h" #include "../ride/track.h" bool gParkEntranceGhostExists = false; diff --git a/src/openrct2/world/map.c b/src/openrct2/world/map.c index 1dafbf6456..0b2b161f28 100644 --- a/src/openrct2/world/map.c +++ b/src/openrct2/world/map.c @@ -24,7 +24,7 @@ #include "../interface/window.h" #include "../localisation/date.h" #include "../localisation/localisation.h" -#include "../management/finance.h" +#include "../management/Finance.h" #include "../network/network.h" #include "../OpenRCT2.h" #include "../ride/ride_data.h" diff --git a/src/openrct2/world/park.c b/src/openrct2/world/park.c index 672ce71a91..baf0c8f25e 100644 --- a/src/openrct2/world/park.c +++ b/src/openrct2/world/park.c @@ -21,7 +21,7 @@ #include "../interface/window.h" #include "../localisation/localisation.h" #include "../management/award.h" -#include "../management/finance.h" +#include "../management/Finance.h" #include "../management/marketing.h" #include "../management/news_item.h" #include "../management/Research.h"