From 16a7e21ffa16675591f1b8c829840f986a67dfb0 Mon Sep 17 00:00:00 2001 From: Ted John Date: Wed, 14 Mar 2018 19:43:01 +0000 Subject: [PATCH 1/6] Implement game action for park set loan --- src/openrct2-ui/windows/Finances.cpp | 25 +++--- src/openrct2/Cheats.cpp | 6 +- src/openrct2/Game.cpp | 2 +- src/openrct2/Game.h | 2 +- .../actions/GameActionRegistration.cpp | 2 + src/openrct2/actions/ParkSetLoanAction.hpp | 83 +++++++++++++++++++ src/openrct2/management/Finance.cpp | 50 ----------- src/openrct2/management/Finance.h | 2 - 8 files changed, 104 insertions(+), 68 deletions(-) create mode 100644 src/openrct2/actions/ParkSetLoanAction.hpp diff --git a/src/openrct2-ui/windows/Finances.cpp b/src/openrct2-ui/windows/Finances.cpp index 52e0cf6aaf..56179599bf 100644 --- a/src/openrct2-ui/windows/Finances.cpp +++ b/src/openrct2-ui/windows/Finances.cpp @@ -14,6 +14,7 @@ *****************************************************************************/ #pragma endregion +#include #include #include #include @@ -594,19 +595,21 @@ static void window_finances_summary_mouseup(rct_window *w, rct_widgetindex widge */ static void window_finances_summary_mousedown(rct_window *w, rct_widgetindex widgetIndex, rct_widget* widget) { - money32 newLoan; - - switch (widgetIndex) { + switch (widgetIndex) + { case WIDX_LOAN_INCREASE: - newLoan = gBankLoan + MONEY(1000, 00); - gGameCommandErrorTitle = STR_CANT_BORROW_ANY_MORE_MONEY; - finance_set_loan(newLoan); - break; + { + auto newLoan = gBankLoan + MONEY(1000, 00); + auto gameAction = ParkSetLoanAction(newLoan); + GameActions::Execute(&gameAction); + break; + } case WIDX_LOAN_DECREASE: - if (gBankLoan > 0) { - newLoan = gBankLoan - MONEY(1000, 00); - gGameCommandErrorTitle = STR_CANT_PAY_BACK_LOAN; - finance_set_loan(newLoan); + if (gBankLoan > 0) + { + auto newLoan = gBankLoan - MONEY(1000, 00); + auto gameAction = ParkSetLoanAction(newLoan); + GameActions::Execute(&gameAction); } break; } diff --git a/src/openrct2/Cheats.cpp b/src/openrct2/Cheats.cpp index 4292bf6a63..471caae21c 100644 --- a/src/openrct2/Cheats.cpp +++ b/src/openrct2/Cheats.cpp @@ -14,6 +14,7 @@ *****************************************************************************/ #pragma endregion +#include "actions/ParkSetLoanAction.hpp" #include "Cheats.h" #include "config/Config.h" #include "localisation/Localisation.h" @@ -259,9 +260,8 @@ static void cheat_clear_loan() cheat_add_money(gBankLoan); // Then pay the loan - money32 newLoan; - newLoan = MONEY(0, 00); - game_do_command(0, GAME_COMMAND_FLAG_APPLY, 0, newLoan, GAME_COMMAND_SET_CURRENT_LOAN, 0, 0); + auto gameAction = ParkSetLoanAction(MONEY(0, 00)); + GameActions::Execute(&gameAction); } static void cheat_generate_guests(sint32 count) diff --git a/src/openrct2/Game.cpp b/src/openrct2/Game.cpp index d9b0ecc251..a71f96b665 100644 --- a/src/openrct2/Game.cpp +++ b/src/openrct2/Game.cpp @@ -1733,7 +1733,7 @@ GAME_COMMAND_POINTER * new_game_command_table[GAME_COMMAND_COUNT] = { game_command_remove_wall, game_command_place_large_scenery, game_command_remove_large_scenery, - game_command_set_current_loan, + nullptr, game_command_set_research_funding, game_command_place_track_design, game_command_start_campaign, diff --git a/src/openrct2/Game.h b/src/openrct2/Game.h index 1824f0b823..71e7054ae6 100644 --- a/src/openrct2/Game.h +++ b/src/openrct2/Game.h @@ -72,7 +72,7 @@ enum GAME_COMMAND GAME_COMMAND_REMOVE_WALL, GAME_COMMAND_PLACE_LARGE_SCENERY, GAME_COMMAND_REMOVE_LARGE_SCENERY, - GAME_COMMAND_SET_CURRENT_LOAN, + GAME_COMMAND_SET_CURRENT_LOAN, // GA GAME_COMMAND_SET_RESEARCH_FUNDING, GAME_COMMAND_PLACE_TRACK_DESIGN, GAME_COMMAND_START_MARKETING_CAMPAIGN, diff --git a/src/openrct2/actions/GameActionRegistration.cpp b/src/openrct2/actions/GameActionRegistration.cpp index c10a5b743b..27b0d3620a 100644 --- a/src/openrct2/actions/GameActionRegistration.cpp +++ b/src/openrct2/actions/GameActionRegistration.cpp @@ -16,6 +16,7 @@ #include "GameAction.h" #include "GuestSetNameAction.hpp" +#include "ParkSetLoanAction.hpp" #include "PlaceParkEntranceAction.hpp" #include "SetParkEntranceFeeAction.hpp" #include "StaffSetNameAction.hpp" @@ -31,6 +32,7 @@ namespace GameActions void Register() { Register(); + Register(); Register(); Register(); Register(); diff --git a/src/openrct2/actions/ParkSetLoanAction.hpp b/src/openrct2/actions/ParkSetLoanAction.hpp new file mode 100644 index 0000000000..b9e17aacba --- /dev/null +++ b/src/openrct2/actions/ParkSetLoanAction.hpp @@ -0,0 +1,83 @@ +#pragma region Copyright (c) 2014-2018 OpenRCT2 Developers +/***************************************************************************** +* OpenRCT2, an open source clone of Roller Coaster Tycoon 2. +* +* OpenRCT2 is the work of many authors, a full list can be found in contributors.md +* For more information, visit https://github.com/OpenRCT2/OpenRCT2 +* +* OpenRCT2 is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* A full copy of the GNU General Public License can be found in licence.txt +*****************************************************************************/ +#pragma endregion + +#pragma once + +#include "../Context.h" +#include "../core/MemoryStream.h" +#include "../localisation/StringIds.h" +#include "../management/Finance.h" +#include "../ui/UiContext.h" +#include "../ui/WindowManager.h" +#include "../windows/Intent.h" +#include "GameAction.h" + +using namespace OpenRCT2; + +struct ParkSetLoanAction : public GameActionBase +{ +private: + money32 _value; + +public: + ParkSetLoanAction() {} + ParkSetLoanAction(money32 value) + : _value(value) + { + } + + uint16 GetActionFlags() const override + { + return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + } + + void Serialise(DataSerialiser& stream) override + { + GameAction::Serialise(stream); + stream << _value; + } + + GameActionResult::Ptr Query() const override + { + auto currentLoan = gBankLoan; + auto loanDifference = currentLoan - _value; + if (_value > currentLoan) + { + if (_value > gMaxBankLoan) + { + return std::make_unique(GA_ERROR::DISALLOWED, STR_CANT_BORROW_ANY_MORE_MONEY, STR_BANK_REFUSES_TO_INCREASE_LOAN); + } + } + else + { + if (loanDifference > gCash) + { + return std::make_unique(GA_ERROR::INSUFFICIENT_FUNDS, STR_CANT_PAY_BACK_LOAN, STR_NOT_ENOUGH_CASH_AVAILABLE); + } + } + return std::make_unique(); + } + + GameActionResult::Ptr Execute() const override + { + gCash -= (gBankLoan - _value); + gBankLoan = _value; + + auto windowManager = GetContext()->GetUiContext()->GetWindowManager(); + windowManager->BroadcastIntent(Intent(INTENT_ACTION_UPDATE_CASH)); + return std::make_unique(); + } +}; diff --git a/src/openrct2/management/Finance.cpp b/src/openrct2/management/Finance.cpp index 105bca1842..0e8db543c5 100644 --- a/src/openrct2/management/Finance.cpp +++ b/src/openrct2/management/Finance.cpp @@ -284,11 +284,6 @@ void finance_update_daily_profit() window_invalidate_by_class(WC_FINANCES); } -void finance_set_loan(money32 loan) -{ - game_do_command(0, GAME_COMMAND_FLAG_APPLY, 0, loan, GAME_COMMAND_SET_CURRENT_LOAN, 0, 0); -} - money32 finance_get_initial_cash() { return gInitialCash; @@ -309,51 +304,6 @@ money32 finance_get_current_cash() return gCash; } -/** - * - * rct2: 0x0069DFB3 - */ -void game_command_set_current_loan(sint32 * eax, sint32 * ebx, sint32 * ecx, sint32 * edx, sint32 * esi, sint32 * edi, sint32 * ebp) -{ - money32 loanDifference, currentLoan; - money32 newLoan = *edx; - - currentLoan = gBankLoan; - loanDifference = currentLoan - newLoan; - - gCommandExpenditureType = RCT_EXPENDITURE_TYPE_INTEREST; - if (newLoan > currentLoan) - { - if (newLoan > gMaxBankLoan) - { - gGameCommandErrorText = STR_BANK_REFUSES_TO_INCREASE_LOAN; - *ebx = MONEY32_UNDEFINED; - return; - } - } - else - { - if (loanDifference > gCash) - { - gGameCommandErrorText = STR_NOT_ENOUGH_CASH_AVAILABLE; - *ebx = MONEY32_UNDEFINED; - return; - } - } - - if (*ebx & GAME_COMMAND_FLAG_APPLY) - { - gCash -= loanDifference; - gBankLoan = newLoan; - gInitialCash = gCash; - - auto intent = Intent(INTENT_ACTION_UPDATE_CASH); - context_broadcast_intent(&intent); - } - - *ebx = 0; -} - /** * Shift the expenditure table history one month to the left * If the table is full, accumulate the sum of the oldest month first diff --git a/src/openrct2/management/Finance.h b/src/openrct2/management/Finance.h index 066b5c06f9..9fd47c7b6b 100644 --- a/src/openrct2/management/Finance.h +++ b/src/openrct2/management/Finance.h @@ -80,11 +80,9 @@ void finance_update_daily_profit(); void finance_shift_expenditure_table(); void finance_reset_cash_to_initial(); -void finance_set_loan(money32 loan); money32 finance_get_initial_cash(); money32 finance_get_current_loan(); money32 finance_get_maximum_loan(); money32 finance_get_current_cash(); -void game_command_set_current_loan(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp); money32 finance_get_last_month_shop_profit(); From 5a803d25511471f33d87561053b52e493b4ab8de Mon Sep 17 00:00:00 2001 From: Ted John Date: Thu, 15 Mar 2018 21:09:45 +0000 Subject: [PATCH 2/6] Implement game action for park set research funding --- src/openrct2-ui/WindowManager.cpp | 5 +- src/openrct2-ui/windows/Finances.cpp | 18 +++-- src/openrct2-ui/windows/Research.cpp | 18 +++-- src/openrct2/Game.cpp | 2 +- src/openrct2/Game.h | 2 +- .../actions/GameActionRegistration.cpp | 2 + .../actions/ParkSetResearchFundingAction.hpp | 74 +++++++++++++++++++ src/openrct2/management/Research.cpp | 50 +------------ src/openrct2/management/Research.h | 3 - src/openrct2/windows/Intent.h | 1 + 10 files changed, 107 insertions(+), 68 deletions(-) create mode 100644 src/openrct2/actions/ParkSetResearchFundingAction.hpp diff --git a/src/openrct2-ui/WindowManager.cpp b/src/openrct2-ui/WindowManager.cpp index 32a5b72a93..fdb95a8751 100644 --- a/src/openrct2-ui/WindowManager.cpp +++ b/src/openrct2-ui/WindowManager.cpp @@ -410,7 +410,10 @@ public: } break; } - + case INTENT_ACTION_UPDATE_RESEARCH: + window_invalidate_by_class(WC_FINANCES); + window_invalidate_by_class(WC_RESEARCH); + break; } } diff --git a/src/openrct2-ui/windows/Finances.cpp b/src/openrct2-ui/windows/Finances.cpp index 56179599bf..a8e3d5fe7d 100644 --- a/src/openrct2-ui/windows/Finances.cpp +++ b/src/openrct2-ui/windows/Finances.cpp @@ -15,6 +15,7 @@ #pragma endregion #include +#include #include #include #include @@ -1265,8 +1266,6 @@ static void window_finances_marketing_paint(rct_window *w, rct_drawpixelinfo *dp */ static void window_finances_research_mouseup(rct_window *w, rct_widgetindex widgetIndex) { - sint32 activeResearchTypes; - switch (widgetIndex) { case WIDX_CLOSE: window_close(w); @@ -1286,10 +1285,14 @@ static void window_finances_research_mouseup(rct_window *w, rct_widgetindex widg case WIDX_WATER_RIDES: case WIDX_SHOPS_AND_STALLS: case WIDX_SCENERY_AND_THEMING: - activeResearchTypes = gResearchPriorities; - activeResearchTypes ^= 1ULL << (widgetIndex - WIDX_TRANSPORT_RIDES); - research_set_priority(activeResearchTypes); - break; + { + auto activeResearchTypes = gResearchPriorities; + activeResearchTypes ^= 1ULL << (widgetIndex - WIDX_TRANSPORT_RIDES); + + auto gameAction = ParkSetResearchFundingAction(activeResearchTypes, gResearchFundingLevel); + GameActions::Execute(&gameAction); + break; + } } } @@ -1335,7 +1338,8 @@ static void window_finances_research_dropdown(rct_window *w, rct_widgetindex wid if (widgetIndex != WIDX_RESEARCH_FUNDING_DROPDOWN_BUTTON || dropdownIndex == -1) return; - research_set_funding(dropdownIndex); + auto gameAction = ParkSetResearchFundingAction(gResearchPriorities, dropdownIndex); + GameActions::Execute(&gameAction); } /** diff --git a/src/openrct2-ui/windows/Research.cpp b/src/openrct2-ui/windows/Research.cpp index 33605df4c0..04ddabb268 100644 --- a/src/openrct2-ui/windows/Research.cpp +++ b/src/openrct2-ui/windows/Research.cpp @@ -16,6 +16,7 @@ #include +#include #include #include #include @@ -412,8 +413,6 @@ void window_research_development_page_paint(rct_window *w, rct_drawpixelinfo *dp */ static void window_research_funding_mouseup(rct_window *w, rct_widgetindex widgetIndex) { - sint32 activeResearchTypes; - switch (widgetIndex) { case WIDX_CLOSE: window_close(w); @@ -429,10 +428,13 @@ static void window_research_funding_mouseup(rct_window *w, rct_widgetindex widge case WIDX_WATER_RIDES: case WIDX_SHOPS_AND_STALLS: case WIDX_SCENERY_AND_THEMING: - activeResearchTypes = gResearchPriorities; - activeResearchTypes ^= 1 << (widgetIndex - WIDX_TRANSPORT_RIDES); - research_set_priority(activeResearchTypes); - break; + { + auto activeResearchTypes = gResearchPriorities; + activeResearchTypes ^= 1 << (widgetIndex - WIDX_TRANSPORT_RIDES); + auto gameAction = ParkSetResearchFundingAction(activeResearchTypes, gResearchFundingLevel); + GameActions::Execute(&gameAction); + break; + } } } @@ -478,8 +480,8 @@ static void window_research_funding_dropdown(rct_window *w, rct_widgetindex widg if (widgetIndex != WIDX_RESEARCH_FUNDING_DROPDOWN_BUTTON || dropdownIndex == -1) return; - research_set_funding(dropdownIndex); - window_invalidate(w); + auto gameAction = ParkSetResearchFundingAction(gResearchPriorities, dropdownIndex); + GameActions::Execute(&gameAction); } /** diff --git a/src/openrct2/Game.cpp b/src/openrct2/Game.cpp index a71f96b665..6d1bac53d7 100644 --- a/src/openrct2/Game.cpp +++ b/src/openrct2/Game.cpp @@ -1734,7 +1734,7 @@ GAME_COMMAND_POINTER * new_game_command_table[GAME_COMMAND_COUNT] = { game_command_place_large_scenery, game_command_remove_large_scenery, nullptr, - game_command_set_research_funding, + nullptr, game_command_place_track_design, game_command_start_campaign, game_command_place_maze_design, diff --git a/src/openrct2/Game.h b/src/openrct2/Game.h index 71e7054ae6..01eff5ec45 100644 --- a/src/openrct2/Game.h +++ b/src/openrct2/Game.h @@ -73,7 +73,7 @@ enum GAME_COMMAND GAME_COMMAND_PLACE_LARGE_SCENERY, GAME_COMMAND_REMOVE_LARGE_SCENERY, GAME_COMMAND_SET_CURRENT_LOAN, // GA - GAME_COMMAND_SET_RESEARCH_FUNDING, + GAME_COMMAND_SET_RESEARCH_FUNDING, // GA GAME_COMMAND_PLACE_TRACK_DESIGN, GAME_COMMAND_START_MARKETING_CAMPAIGN, GAME_COMMAND_PLACE_MAZE_DESIGN, diff --git a/src/openrct2/actions/GameActionRegistration.cpp b/src/openrct2/actions/GameActionRegistration.cpp index 27b0d3620a..e983f04fde 100644 --- a/src/openrct2/actions/GameActionRegistration.cpp +++ b/src/openrct2/actions/GameActionRegistration.cpp @@ -17,6 +17,7 @@ #include "GameAction.h" #include "GuestSetNameAction.hpp" #include "ParkSetLoanAction.hpp" +#include "ParkSetResearchFundingAction.hpp" #include "PlaceParkEntranceAction.hpp" #include "SetParkEntranceFeeAction.hpp" #include "StaffSetNameAction.hpp" @@ -33,6 +34,7 @@ namespace GameActions { Register(); Register(); + Register(); Register(); Register(); Register(); diff --git a/src/openrct2/actions/ParkSetResearchFundingAction.hpp b/src/openrct2/actions/ParkSetResearchFundingAction.hpp new file mode 100644 index 0000000000..a4cb84052f --- /dev/null +++ b/src/openrct2/actions/ParkSetResearchFundingAction.hpp @@ -0,0 +1,74 @@ +#pragma region Copyright (c) 2014-2018 OpenRCT2 Developers +/***************************************************************************** +* OpenRCT2, an open source clone of Roller Coaster Tycoon 2. +* +* OpenRCT2 is the work of many authors, a full list can be found in contributors.md +* For more information, visit https://github.com/OpenRCT2/OpenRCT2 +* +* OpenRCT2 is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* A full copy of the GNU General Public License can be found in licence.txt +*****************************************************************************/ +#pragma endregion + +#pragma once + +#include "../Context.h" +#include "../core/MemoryStream.h" +#include "../localisation/StringIds.h" +#include "../management/Research.h" +#include "../ui/UiContext.h" +#include "../ui/WindowManager.h" +#include "../windows/Intent.h" +#include "GameAction.h" + +using namespace OpenRCT2; + +struct ParkSetResearchFundingAction : public GameActionBase +{ +private: + // TODO change to std::optional when C++17 + uint32 _priorities; + uint8 _fundingAmount; + +public: + ParkSetResearchFundingAction() {} + ParkSetResearchFundingAction(uint32 priorities, uint8 fundingAmount) + : _priorities(priorities), + _fundingAmount(fundingAmount) + { + } + + uint16 GetActionFlags() const override + { + return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + } + + void Serialise(DataSerialiser& stream) override + { + GameAction::Serialise(stream); + stream << _priorities << _fundingAmount; + } + + GameActionResult::Ptr Query() const override + { + if (_fundingAmount >= RESEARCH_FUNDING_COUNT) + { + return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + } + return std::make_unique(); + } + + GameActionResult::Ptr Execute() const override + { + gResearchPriorities = _priorities; + gResearchFundingLevel = _fundingAmount; + + auto windowManager = GetContext()->GetUiContext()->GetWindowManager(); + windowManager->BroadcastIntent(Intent(INTENT_ACTION_UPDATE_RESEARCH)); + return std::make_unique(); + } +}; diff --git a/src/openrct2/management/Research.cpp b/src/openrct2/management/Research.cpp index 00a50a4519..0518d327b3 100644 --- a/src/openrct2/management/Research.cpp +++ b/src/openrct2/management/Research.cpp @@ -15,6 +15,7 @@ #pragma endregion #include +#include "../actions/ParkSetResearchFundingAction.hpp" #include "../config/Config.h" #include "../core/Guard.hpp" #include "../core/Util.hpp" @@ -161,7 +162,8 @@ static void research_next_design() gResearchProgressStage = RESEARCH_STAGE_FINISHED_ALL; research_invalidate_related_windows(); // Reset funding to 0 if no more rides. - research_set_funding(0); + auto gameAction = ParkSetResearchFundingAction(gResearchPriorities, 0); + GameActions::Execute(&gameAction); return; } } @@ -605,52 +607,6 @@ void research_populate_list_researched() } } -void research_set_funding(sint32 amount) -{ - game_do_command(0, GAME_COMMAND_FLAG_APPLY, 0, amount, GAME_COMMAND_SET_RESEARCH_FUNDING, 0, 0); - -} - -void research_set_priority(sint32 activeCategories) -{ - game_do_command(0, (1 << 8) | GAME_COMMAND_FLAG_APPLY, 0, activeCategories, GAME_COMMAND_SET_RESEARCH_FUNDING, 0, 0); -} - -/** - * - * rct2: 0x00684A7F - */ -void game_command_set_research_funding(sint32 * eax, sint32 * ebx, sint32 * ecx, sint32 * edx, sint32 * esi, sint32 * edi, sint32 * ebp) -{ - sint32 setPriorities = (*ebx & (1 << 8)) != 0; - uint32 fundingAmount = *edx; - sint32 activeCategories = *edx; - - gCommandExpenditureType = RCT_EXPENDITURE_TYPE_RESEARCH; - if (*ebx & GAME_COMMAND_FLAG_APPLY) - { - if (!setPriorities) - { - if (fundingAmount >= Util::CountOf(_researchRate)) - { - *ebx = MONEY32_UNDEFINED; - log_warning("Invalid research rate %d", fundingAmount); - return; - } - gResearchFundingLevel = fundingAmount; - } - else - { - gResearchPriorities = activeCategories; - } - - window_invalidate_by_class(WC_FINANCES); - window_invalidate_by_class(WC_RESEARCH); - } - - *ebx = 0; -} - void research_insert_ride_entry(uint8 entryIndex, bool researched) { rct_ride_entry * rideEntry = get_ride_entry(entryIndex); diff --git a/src/openrct2/management/Research.h b/src/openrct2/management/Research.h index eda4641f43..bc40e9a698 100644 --- a/src/openrct2/management/Research.h +++ b/src/openrct2/management/Research.h @@ -115,9 +115,6 @@ void research_populate_list_random(); void research_populate_list_researched(); void research_process_random_items(); -void research_set_funding(sint32 amount); -void research_set_priority(sint32 activeCategories); -void game_command_set_research_funding(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp); void research_finish_item(rct_research_item * researchItem); void research_insert(sint32 researched, sint32 rawValue, uint8 category); void research_remove(rct_research_item * researchItem); diff --git a/src/openrct2/windows/Intent.h b/src/openrct2/windows/Intent.h index d7e3836221..29bfd625bc 100644 --- a/src/openrct2/windows/Intent.h +++ b/src/openrct2/windows/Intent.h @@ -99,4 +99,5 @@ enum INTENT_ACTION_UPDATE_DATE, INTENT_ACTION_UPDATE_CASH, INTENT_ACTION_UPDATE_BANNER, + INTENT_ACTION_UPDATE_RESEARCH, }; From 708843b526ccaafceb0effa4a3c890b06fbf9a2b Mon Sep 17 00:00:00 2001 From: Ted John Date: Thu, 15 Mar 2018 22:44:24 +0000 Subject: [PATCH 3/6] Implement game action for park marketing --- src/openrct2-ui/windows/NewCampaign.cpp | 19 +++- src/openrct2/Game.cpp | 5 +- src/openrct2/Game.h | 2 +- .../actions/GameActionRegistration.cpp | 2 + src/openrct2/actions/ParkMarketingAction.hpp | 100 ++++++++++++++++++ src/openrct2/management/Marketing.cpp | 51 --------- src/openrct2/management/Marketing.h | 3 - 7 files changed, 121 insertions(+), 61 deletions(-) create mode 100644 src/openrct2/actions/ParkMarketingAction.hpp diff --git a/src/openrct2-ui/windows/NewCampaign.cpp b/src/openrct2-ui/windows/NewCampaign.cpp index fd6fa29c44..a14795f79c 100644 --- a/src/openrct2-ui/windows/NewCampaign.cpp +++ b/src/openrct2-ui/windows/NewCampaign.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -236,13 +237,25 @@ static void window_new_campaign_get_shop_items() */ static void window_new_campaign_mouseup(rct_window *w, rct_widgetindex widgetIndex) { - switch (widgetIndex) { + switch (widgetIndex) + { case WIDX_CLOSE: window_close(w); break; case WIDX_START_BUTTON: - marketing_start_campaign(w->campaign.campaign_type, w->campaign.ride_id, w->campaign.no_weeks); - break; + { + auto gameAction = ParkMarketingAction(w->campaign.campaign_type, w->campaign.ride_id, w->campaign.no_weeks); + gameAction.SetCallback( + [](const GameAction *ga, const GameActionResult * result) + { + if (result->Error == GA_ERROR::OK) + { + window_close_by_class(WC_NEW_CAMPAIGN); + } + }); + GameActions::Execute(&gameAction); + break; + } } } diff --git a/src/openrct2/Game.cpp b/src/openrct2/Game.cpp index 6d1bac53d7..4a02f5d7d3 100644 --- a/src/openrct2/Game.cpp +++ b/src/openrct2/Game.cpp @@ -98,8 +98,7 @@ static GAME_COMMAND_CALLBACK_POINTER * const game_command_callback_table[] = { game_command_callback_place_ride_entrance_or_exit, game_command_callback_hire_new_staff_member, game_command_callback_pickup_guest, - game_command_callback_pickup_staff, - game_command_callback_marketing_start_campaign, + game_command_callback_pickup_staff }; sint32 game_command_playerid = -1; @@ -1736,7 +1735,7 @@ GAME_COMMAND_POINTER * new_game_command_table[GAME_COMMAND_COUNT] = { nullptr, nullptr, game_command_place_track_design, - game_command_start_campaign, + nullptr, game_command_place_maze_design, game_command_place_banner, game_command_remove_banner, diff --git a/src/openrct2/Game.h b/src/openrct2/Game.h index 01eff5ec45..d572b62fe6 100644 --- a/src/openrct2/Game.h +++ b/src/openrct2/Game.h @@ -75,7 +75,7 @@ enum GAME_COMMAND GAME_COMMAND_SET_CURRENT_LOAN, // GA GAME_COMMAND_SET_RESEARCH_FUNDING, // GA GAME_COMMAND_PLACE_TRACK_DESIGN, - GAME_COMMAND_START_MARKETING_CAMPAIGN, + GAME_COMMAND_START_MARKETING_CAMPAIGN, // GA GAME_COMMAND_PLACE_MAZE_DESIGN, GAME_COMMAND_PLACE_BANNER, GAME_COMMAND_REMOVE_BANNER, diff --git a/src/openrct2/actions/GameActionRegistration.cpp b/src/openrct2/actions/GameActionRegistration.cpp index e983f04fde..e736d3e553 100644 --- a/src/openrct2/actions/GameActionRegistration.cpp +++ b/src/openrct2/actions/GameActionRegistration.cpp @@ -18,6 +18,7 @@ #include "GuestSetNameAction.hpp" #include "ParkSetLoanAction.hpp" #include "ParkSetResearchFundingAction.hpp" +#include "ParkMarketingAction.hpp" #include "PlaceParkEntranceAction.hpp" #include "SetParkEntranceFeeAction.hpp" #include "StaffSetNameAction.hpp" @@ -33,6 +34,7 @@ namespace GameActions void Register() { Register(); + Register(); Register(); Register(); Register(); diff --git a/src/openrct2/actions/ParkMarketingAction.hpp b/src/openrct2/actions/ParkMarketingAction.hpp new file mode 100644 index 0000000000..0b430ddbf2 --- /dev/null +++ b/src/openrct2/actions/ParkMarketingAction.hpp @@ -0,0 +1,100 @@ +#pragma region Copyright (c) 2014-2018 OpenRCT2 Developers +/***************************************************************************** +* OpenRCT2, an open source clone of Roller Coaster Tycoon 2. +* +* OpenRCT2 is the work of many authors, a full list can be found in contributors.md +* For more information, visit https://github.com/OpenRCT2/OpenRCT2 +* +* OpenRCT2 is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* A full copy of the GNU General Public License can be found in licence.txt +*****************************************************************************/ +#pragma endregion + +#pragma once + +#include "../Context.h" +#include "../core/MemoryStream.h" +#include "../core/Util.hpp" +#include "../localisation/StringIds.h" +#include "../management/Marketing.h" +#include "../ui/UiContext.h" +#include "../ui/WindowManager.h" +#include "../windows/Intent.h" +#include "../world/Park.h" +#include "GameAction.h" + +using namespace OpenRCT2; + +struct ParkMarketingAction : public GameActionBase +{ +private: + sint32 _type; + sint32 _item; + sint32 _numWeeks; + +public: + ParkMarketingAction() {} + ParkMarketingAction(sint32 type, sint32 item, sint32 numWeeks) + : _type(type), + _item(item), + _numWeeks(numWeeks) + { + } + + uint16 GetActionFlags() const override + { + return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + } + + void Serialise(DataSerialiser& stream) override + { + GameAction::Serialise(stream); + stream << _type << _item << _numWeeks; + } + + GameActionResult::Ptr Query() const override + { + if ((size_t)_type >= Util::CountOf(AdvertisingCampaignPricePerWeek) || + _numWeeks >= 256) + { + return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_CANT_START_MARKETING_CAMPAIGN); + } + if (gParkFlags & PARK_FLAGS_FORBID_MARKETING_CAMPAIGN) + { + return std::make_unique(GA_ERROR::DISALLOWED, STR_CANT_START_MARKETING_CAMPAIGN, STR_MARKETING_CAMPAIGNS_FORBIDDEN_BY_LOCAL_AUTHORITY); + } + + return CreateResult(); + } + + GameActionResult::Ptr Execute() const override + { + gMarketingCampaignDaysLeft[_type] = _numWeeks | CAMPAIGN_ACTIVE_FLAG; + gMarketingCampaignRideIndex[_type] = _item; + + // We are only interested in invalidating the finances (marketing) window + auto windowManager = GetContext()->GetUiContext()->GetWindowManager(); + windowManager->BroadcastIntent(Intent(INTENT_ACTION_UPDATE_CASH)); + + return CreateResult(); + } + +private: + GameActionResult::Ptr CreateResult() const + { + auto result = std::make_unique(); + result->ErrorTitle = STR_CANT_START_MARKETING_CAMPAIGN; + result->ExpenditureType = RCT_EXPENDITURE_TYPE_MARKETING; + result->Cost = CalculatePrice(); + return result; + } + + money32 CalculatePrice() const + { + return _numWeeks * AdvertisingCampaignPricePerWeek[_type]; + } +}; diff --git a/src/openrct2/management/Marketing.cpp b/src/openrct2/management/Marketing.cpp index 3029251867..d9a63871d4 100644 --- a/src/openrct2/management/Marketing.cpp +++ b/src/openrct2/management/Marketing.cpp @@ -148,57 +148,6 @@ void marketing_set_guest_campaign(rct_peep * peep, sint32 campaign) } } -void game_command_callback_marketing_start_campaign(sint32 eax, sint32 ebx, sint32 ecx, sint32 edx, sint32 esi, sint32 edi, sint32 ebp) -{ - if (ebx != MONEY32_UNDEFINED) - { - window_close_by_class(WC_NEW_CAMPAIGN); - } -} - -void marketing_start_campaign(sint32 type, sint32 rideOrItem, sint32 numWeeks) -{ - gGameCommandErrorTitle = STR_CANT_START_MARKETING_CAMPAIGN; - game_command_callback = game_command_callback_marketing_start_campaign; - game_do_command(0, (numWeeks << 8) | GAME_COMMAND_FLAG_APPLY, 0, (rideOrItem << 8) | type, GAME_COMMAND_START_MARKETING_CAMPAIGN, 0, 0); -} - -/** - * - * rct2: 0x0069E73C - */ -void game_command_start_campaign(sint32 * eax, sint32 * ebx, sint32 * ecx, sint32 * edx, sint32 * esi, sint32 * edi, sint32 * ebp) -{ - uint8 type = *edx & 0xFF; - sint32 rideOrItem = (*edx >> 8) & 0xFF; - sint32 numWeeks = (*ebx >> 8) & 0xFF; - - if (type >= Util::CountOf(AdvertisingCampaignPricePerWeek)) - { - log_warning("Invalid game command, type = %d", type); - *ebx = MONEY32_UNDEFINED; - return; - } - - gCommandExpenditureType = RCT_EXPENDITURE_TYPE_MARKETING; - if (gParkFlags & PARK_FLAGS_FORBID_MARKETING_CAMPAIGN) - { - gGameCommandErrorText = STR_MARKETING_CAMPAIGNS_FORBIDDEN_BY_LOCAL_AUTHORITY; - *ebx = MONEY32_UNDEFINED; - return; - } - - if (*ebx & GAME_COMMAND_FLAG_APPLY) - { - gMarketingCampaignDaysLeft[type] = numWeeks | CAMPAIGN_ACTIVE_FLAG; - gMarketingCampaignRideIndex[type] = rideOrItem; - - window_invalidate_by_class(WC_FINANCES); - } - - *ebx = numWeeks * AdvertisingCampaignPricePerWeek[type]; -} - bool marketing_is_campaign_type_applicable(sint32 campaignType) { sint32 i; diff --git a/src/openrct2/management/Marketing.h b/src/openrct2/management/Marketing.h index 5e6babd154..b5775c8149 100644 --- a/src/openrct2/management/Marketing.h +++ b/src/openrct2/management/Marketing.h @@ -48,7 +48,4 @@ extern uint8 gMarketingCampaignRideIndex[22]; sint32 marketing_get_campaign_guest_generation_probability(sint32 campaign); void marketing_update(); void marketing_set_guest_campaign(rct_peep *peep, sint32 campaign); -void game_command_callback_marketing_start_campaign(sint32 eax, sint32 ebx, sint32 ecx, sint32 edx, sint32 esi, sint32 edi, sint32 ebp); -void marketing_start_campaign(sint32 type, sint32 rideOrItem, sint32 numWeeks); -void game_command_start_campaign(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp); bool marketing_is_campaign_type_applicable(sint32 campaignType); From 6a8ea7e8d47cba4329a3a81e4ed3389c687f4ba3 Mon Sep 17 00:00:00 2001 From: Ted John Date: Fri, 16 Mar 2018 12:35:02 +0000 Subject: [PATCH 4/6] Create helper method to create the game action result --- src/openrct2/actions/GameAction.h | 8 ++++++++ src/openrct2/actions/ParkMarketingAction.hpp | 6 +++--- src/openrct2/actions/ParkSetLoanAction.hpp | 8 ++++---- src/openrct2/actions/ParkSetResearchFundingAction.hpp | 6 +++--- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/openrct2/actions/GameAction.h b/src/openrct2/actions/GameAction.h index 4692cbbf80..ede4fa27a7 100644 --- a/src/openrct2/actions/GameAction.h +++ b/src/openrct2/actions/GameAction.h @@ -19,6 +19,7 @@ #include #include #include +#include #include "../common.h" #include "../core/DataSerialiser.h" @@ -221,6 +222,13 @@ public: typedCallback(ga, static_cast(result)); }); } + +protected: + template + static constexpr std::unique_ptr MakeResult(TTypes&&... args) + { + return std::make_unique(std::forward(args)...); + } }; using GameActionFactory = GameAction *(*)(); diff --git a/src/openrct2/actions/ParkMarketingAction.hpp b/src/openrct2/actions/ParkMarketingAction.hpp index 0b430ddbf2..27d8bac61e 100644 --- a/src/openrct2/actions/ParkMarketingAction.hpp +++ b/src/openrct2/actions/ParkMarketingAction.hpp @@ -61,11 +61,11 @@ public: if ((size_t)_type >= Util::CountOf(AdvertisingCampaignPricePerWeek) || _numWeeks >= 256) { - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_CANT_START_MARKETING_CAMPAIGN); + return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_START_MARKETING_CAMPAIGN); } if (gParkFlags & PARK_FLAGS_FORBID_MARKETING_CAMPAIGN) { - return std::make_unique(GA_ERROR::DISALLOWED, STR_CANT_START_MARKETING_CAMPAIGN, STR_MARKETING_CAMPAIGNS_FORBIDDEN_BY_LOCAL_AUTHORITY); + return MakeResult(GA_ERROR::DISALLOWED, STR_CANT_START_MARKETING_CAMPAIGN, STR_MARKETING_CAMPAIGNS_FORBIDDEN_BY_LOCAL_AUTHORITY); } return CreateResult(); @@ -86,7 +86,7 @@ public: private: GameActionResult::Ptr CreateResult() const { - auto result = std::make_unique(); + auto result = MakeResult(); result->ErrorTitle = STR_CANT_START_MARKETING_CAMPAIGN; result->ExpenditureType = RCT_EXPENDITURE_TYPE_MARKETING; result->Cost = CalculatePrice(); diff --git a/src/openrct2/actions/ParkSetLoanAction.hpp b/src/openrct2/actions/ParkSetLoanAction.hpp index b9e17aacba..7b87733a72 100644 --- a/src/openrct2/actions/ParkSetLoanAction.hpp +++ b/src/openrct2/actions/ParkSetLoanAction.hpp @@ -58,17 +58,17 @@ public: { if (_value > gMaxBankLoan) { - return std::make_unique(GA_ERROR::DISALLOWED, STR_CANT_BORROW_ANY_MORE_MONEY, STR_BANK_REFUSES_TO_INCREASE_LOAN); + return MakeResult(GA_ERROR::DISALLOWED, STR_CANT_BORROW_ANY_MORE_MONEY, STR_BANK_REFUSES_TO_INCREASE_LOAN); } } else { if (loanDifference > gCash) { - return std::make_unique(GA_ERROR::INSUFFICIENT_FUNDS, STR_CANT_PAY_BACK_LOAN, STR_NOT_ENOUGH_CASH_AVAILABLE); + return MakeResult(GA_ERROR::INSUFFICIENT_FUNDS, STR_CANT_PAY_BACK_LOAN, STR_NOT_ENOUGH_CASH_AVAILABLE); } } - return std::make_unique(); + return MakeResult(); } GameActionResult::Ptr Execute() const override @@ -78,6 +78,6 @@ public: auto windowManager = GetContext()->GetUiContext()->GetWindowManager(); windowManager->BroadcastIntent(Intent(INTENT_ACTION_UPDATE_CASH)); - return std::make_unique(); + return MakeResult(); } }; diff --git a/src/openrct2/actions/ParkSetResearchFundingAction.hpp b/src/openrct2/actions/ParkSetResearchFundingAction.hpp index a4cb84052f..d8a6d91e3a 100644 --- a/src/openrct2/actions/ParkSetResearchFundingAction.hpp +++ b/src/openrct2/actions/ParkSetResearchFundingAction.hpp @@ -57,9 +57,9 @@ public: { if (_fundingAmount >= RESEARCH_FUNDING_COUNT) { - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); } - return std::make_unique(); + return MakeResult(); } GameActionResult::Ptr Execute() const override @@ -69,6 +69,6 @@ public: auto windowManager = GetContext()->GetUiContext()->GetWindowManager(); windowManager->BroadcastIntent(Intent(INTENT_ACTION_UPDATE_RESEARCH)); - return std::make_unique(); + return MakeResult(); } }; From 9b604310a21a80f64f5a7b6ce7617e8c47a206f7 Mon Sep 17 00:00:00 2001 From: Ted John Date: Fri, 16 Mar 2018 12:56:15 +0000 Subject: [PATCH 5/6] Implement game action for staff set colour --- src/openrct2-ui/windows/StaffList.cpp | 7 +- src/openrct2/Game.cpp | 2 +- src/openrct2/Game.h | 2 +- .../actions/GameActionRegistration.cpp | 2 + src/openrct2/actions/StaffSetColourAction.hpp | 89 +++++++++++++++++++ src/openrct2/peep/Staff.cpp | 44 --------- src/openrct2/peep/Staff.h | 3 - 7 files changed, 98 insertions(+), 51 deletions(-) create mode 100644 src/openrct2/actions/StaffSetColourAction.hpp diff --git a/src/openrct2-ui/windows/StaffList.cpp b/src/openrct2-ui/windows/StaffList.cpp index 9a0c175350..3b482cf0a0 100644 --- a/src/openrct2-ui/windows/StaffList.cpp +++ b/src/openrct2-ui/windows/StaffList.cpp @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -297,8 +298,10 @@ static void window_staff_list_mousedown(rct_window *w, rct_widgetindex widgetInd */ static void window_staff_list_dropdown(rct_window *w, rct_widgetindex widgetIndex, sint32 dropdownIndex) { - if (widgetIndex == WIDX_STAFF_LIST_UNIFORM_COLOUR_PICKER && dropdownIndex != -1) { - update_staff_colour(_windowStaffListSelectedTab, dropdownIndex); + if (widgetIndex == WIDX_STAFF_LIST_UNIFORM_COLOUR_PICKER && dropdownIndex != -1) + { + auto action = StaffSetColourAction(_windowStaffListSelectedTab, dropdownIndex); + GameActions::Execute(&action); } } diff --git a/src/openrct2/Game.cpp b/src/openrct2/Game.cpp index 4a02f5d7d3..23878edcb1 100644 --- a/src/openrct2/Game.cpp +++ b/src/openrct2/Game.cpp @@ -1727,7 +1727,7 @@ GAME_COMMAND_POINTER * new_game_command_table[GAME_COMMAND_COUNT] = { game_command_remove_park_entrance, game_command_set_maze_track, game_command_set_park_entrance_fee, - game_command_update_staff_colour, + nullptr, game_command_place_wall, game_command_remove_wall, game_command_place_large_scenery, diff --git a/src/openrct2/Game.h b/src/openrct2/Game.h index d572b62fe6..0a43002077 100644 --- a/src/openrct2/Game.h +++ b/src/openrct2/Game.h @@ -67,7 +67,7 @@ enum GAME_COMMAND GAME_COMMAND_REMOVE_PARK_ENTRANCE, GAME_COMMAND_SET_MAZE_TRACK, GAME_COMMAND_SET_PARK_ENTRANCE_FEE, // GA - GAME_COMMAND_SET_STAFF_COLOUR, + GAME_COMMAND_SET_STAFF_COLOUR, // GA GAME_COMMAND_PLACE_WALL, GAME_COMMAND_REMOVE_WALL, GAME_COMMAND_PLACE_LARGE_SCENERY, diff --git a/src/openrct2/actions/GameActionRegistration.cpp b/src/openrct2/actions/GameActionRegistration.cpp index e736d3e553..38c8f25726 100644 --- a/src/openrct2/actions/GameActionRegistration.cpp +++ b/src/openrct2/actions/GameActionRegistration.cpp @@ -21,6 +21,7 @@ #include "ParkMarketingAction.hpp" #include "PlaceParkEntranceAction.hpp" #include "SetParkEntranceFeeAction.hpp" +#include "StaffSetColourAction.hpp" #include "StaffSetNameAction.hpp" #include "RideCreateAction.hpp" #include "RideSetStatus.hpp" @@ -43,6 +44,7 @@ namespace GameActions Register(); Register(); Register(); + Register(); Register(); Register(); Register(); diff --git a/src/openrct2/actions/StaffSetColourAction.hpp b/src/openrct2/actions/StaffSetColourAction.hpp new file mode 100644 index 0000000000..b5282b94d4 --- /dev/null +++ b/src/openrct2/actions/StaffSetColourAction.hpp @@ -0,0 +1,89 @@ +#pragma region Copyright (c) 2014-2018 OpenRCT2 Developers +/***************************************************************************** +* OpenRCT2, an open source clone of Roller Coaster Tycoon 2. +* +* OpenRCT2 is the work of many authors, a full list can be found in contributors.md +* For more information, visit https://github.com/OpenRCT2/OpenRCT2 +* +* OpenRCT2 is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* A full copy of the GNU General Public License can be found in licence.txt +*****************************************************************************/ +#pragma endregion + +#pragma once + +#include "../Context.h" +#include "../core/MemoryStream.h" +#include "../localisation/StringIds.h" +#include "../peep/Staff.h" +#include "../ui/UiContext.h" +#include "../ui/WindowManager.h" +#include "../windows/Intent.h" +#include "GameAction.h" + +using namespace OpenRCT2; + +struct StaffSetColourAction : public GameActionBase +{ +private: + uint8 _staffType; + uint8 _colour; + +public: + StaffSetColourAction() {} + StaffSetColourAction(uint8 staffType, uint8 colour) + : _staffType(staffType), + _colour(colour) + { + } + + uint16 GetActionFlags() const override + { + return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + } + + void Serialise(DataSerialiser& stream) override + { + GameAction::Serialise(stream); + stream << _staffType << _colour; + } + + GameActionResult::Ptr Query() const override + { + if (_staffType != STAFF_TYPE_HANDYMAN && + _staffType != STAFF_TYPE_MECHANIC && + _staffType != STAFF_TYPE_SECURITY) + { + return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + } + return MakeResult(); + } + + GameActionResult::Ptr Execute() const override + { + // Update global uniform colour property + if (!staff_set_colour(_staffType, _colour)) + { + return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + } + + // Update each staff member's uniform + sint32 spriteIndex; + rct_peep * peep; + FOR_ALL_PEEPS(spriteIndex, peep) + { + if (peep->type == PEEP_TYPE_STAFF && peep->staff_type == _staffType) + { + peep->tshirt_colour = _colour; + peep->trousers_colour = _colour; + } + } + + gfx_invalidate_screen(); + return MakeResult(); + } +}; diff --git a/src/openrct2/peep/Staff.cpp b/src/openrct2/peep/Staff.cpp index 2ae4a16afa..c348d8d340 100644 --- a/src/openrct2/peep/Staff.cpp +++ b/src/openrct2/peep/Staff.cpp @@ -78,42 +78,6 @@ void staff_reset_modes() staff_update_greyed_patrol_areas(); } -/** - * - * rct2: 0x00669E55 - */ -void game_command_update_staff_colour(sint32 * eax, sint32 * ebx, sint32 * ecx, sint32 * edx, sint32 * esi, sint32 * edi, - sint32 * ebp) -{ - if (*ebx & GAME_COMMAND_FLAG_APPLY) - { - uint8 staffType = (*ebx >> 8) & 0xFF; - uint8 colour = (*edx >> 8) & 0xFF; - - // Client may send invalid data - bool ok = staff_set_colour(staffType, colour); - if (!ok) - { - *ebx = MONEY32_UNDEFINED; - return; - } - - sint32 spriteIndex; - rct_peep * peep; - FOR_ALL_PEEPS(spriteIndex, peep) - { - if (peep->type == PEEP_TYPE_STAFF && peep->staff_type == staffType) - { - peep->tshirt_colour = colour; - peep->trousers_colour = colour; - } - } - } - - gfx_invalidate_screen(); - *ebx = 0; -} - static inline void staff_autoposition_new_staff_member(rct_peep * newPeep) { // Find a location to place new staff member @@ -555,14 +519,6 @@ void game_command_fire_staff_member(sint32 * eax, sint32 * ebx, sint32 * ecx, si *ebx = 0; } -/** - * Updates the colour of the given staff type. - */ -void update_staff_colour(uint8 staffType, uint16 colour) -{ - game_do_command(0, (staffType << 8) | GAME_COMMAND_FLAG_APPLY, 0, (colour << 8) | 4, GAME_COMMAND_SET_STAFF_COLOUR, 0, 0); -} - /** * Hires a new staff member of the given type. If the hire cannot be completed (eg. the maximum * number of staff is reached or there are too many people in the game) it returns 0xFFFF. diff --git a/src/openrct2/peep/Staff.h b/src/openrct2/peep/Staff.h index f80fdf185d..a9d504eddc 100644 --- a/src/openrct2/peep/Staff.h +++ b/src/openrct2/peep/Staff.h @@ -78,8 +78,6 @@ extern colour_t gStaffHandymanColour; extern colour_t gStaffMechanicColour; extern colour_t gStaffSecurityColour; -void game_command_update_staff_colour(sint32 * eax, sint32 * ebx, sint32 * ecx, sint32 * edx, sint32 * esi, sint32 * edi, - sint32 * ebp); void game_command_hire_new_staff_member(sint32 * eax, sint32 * ebx, sint32 * ecx, sint32 * edx, sint32 * esi, sint32 * edi, sint32 * ebp); void game_command_callback_hire_new_staff_member(sint32 eax, sint32 ebx, sint32 ecx, sint32 edx, sint32 esi, sint32 edi, @@ -96,7 +94,6 @@ void game_command_pickup_staff(sint32 * eax, sint32 * ebx, sint32 * ecx, sint32 sint32 * ebp); void staff_reset_modes(); -void update_staff_colour(uint8 staffType, uint16 colour); void staff_set_name(uint16 spriteIndex, const char * name); uint16 hire_new_staff_member(uint8 staffType); void staff_update_greyed_patrol_areas(); From af7fd94859134acd58b74f5cd2c1a8ac89be2446 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Tue, 20 Mar 2018 09:34:19 +0100 Subject: [PATCH 6/6] Add missing includes --- src/openrct2/actions/ParkMarketingAction.hpp | 1 + src/openrct2/actions/StaffSetColourAction.hpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/openrct2/actions/ParkMarketingAction.hpp b/src/openrct2/actions/ParkMarketingAction.hpp index 27d8bac61e..4e53f8fa45 100644 --- a/src/openrct2/actions/ParkMarketingAction.hpp +++ b/src/openrct2/actions/ParkMarketingAction.hpp @@ -20,6 +20,7 @@ #include "../core/MemoryStream.h" #include "../core/Util.hpp" #include "../localisation/StringIds.h" +#include "../management/Finance.h" #include "../management/Marketing.h" #include "../ui/UiContext.h" #include "../ui/WindowManager.h" diff --git a/src/openrct2/actions/StaffSetColourAction.hpp b/src/openrct2/actions/StaffSetColourAction.hpp index b5282b94d4..8f93e8d2ba 100644 --- a/src/openrct2/actions/StaffSetColourAction.hpp +++ b/src/openrct2/actions/StaffSetColourAction.hpp @@ -18,11 +18,13 @@ #include "../Context.h" #include "../core/MemoryStream.h" +#include "../drawing/Drawing.h" #include "../localisation/StringIds.h" #include "../peep/Staff.h" #include "../ui/UiContext.h" #include "../ui/WindowManager.h" #include "../windows/Intent.h" +#include "../world/Sprite.h" #include "GameAction.h" using namespace OpenRCT2;