1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-04 05:32:54 +01:00

Merge pull request #7286 from IntelOrca/refactor/gameaction-parksetloan

Implement some more basic game actions:
- ParkMarketingAction
- ParkSetLoanAction
- ParkSetResearchFundingAction
- StaffSetColourAction
This commit is contained in:
Ted John
2018-03-20 13:38:56 +00:00
committed by GitHub
23 changed files with 441 additions and 248 deletions

View File

@@ -410,7 +410,10 @@ public:
}
break;
}
case INTENT_ACTION_UPDATE_RESEARCH:
window_invalidate_by_class(WC_FINANCES);
window_invalidate_by_class(WC_RESEARCH);
break;
}
}

View File

@@ -14,6 +14,8 @@
*****************************************************************************/
#pragma endregion
#include <openrct2/actions/ParkSetLoanAction.hpp>
#include <openrct2/actions/ParkSetResearchFundingAction.hpp>
#include <openrct2/config/Config.h>
#include <openrct2/core/Math.hpp>
#include <openrct2-ui/windows/Window.h>
@@ -594,19 +596,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;
}
@@ -1262,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);
@@ -1283,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;
}
}
}
@@ -1332,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);
}
/**

View File

@@ -18,6 +18,7 @@
#include <openrct2/core/Math.hpp>
#include <openrct2-ui/windows/Window.h>
#include <openrct2/actions/ParkMarketingAction.hpp>
#include <openrct2/Game.h>
#include <openrct2/localisation/Localisation.h>
#include <openrct2-ui/interface/Widget.h>
@@ -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;
}
}
}

View File

@@ -16,6 +16,7 @@
#include <openrct2-ui/windows/Window.h>
#include <openrct2/actions/ParkSetResearchFundingAction.hpp>
#include <openrct2/Game.h>
#include <openrct2/localisation/Localisation.h>
#include <openrct2-ui/interface/Widget.h>
@@ -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);
}
/**

View File

@@ -20,6 +20,7 @@
#include <openrct2-ui/windows/Window.h>
#include <openrct2/Context.h>
#include <openrct2/actions/StaffSetColourAction.hpp>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/Game.h>
#include <openrct2/Input.h>
@@ -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);
}
}

View File

@@ -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)

View File

@@ -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;
@@ -1728,15 +1727,15 @@ 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,
game_command_remove_large_scenery,
game_command_set_current_loan,
game_command_set_research_funding,
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,

View File

@@ -67,15 +67,15 @@ 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,
GAME_COMMAND_REMOVE_LARGE_SCENERY,
GAME_COMMAND_SET_CURRENT_LOAN,
GAME_COMMAND_SET_RESEARCH_FUNDING,
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,

View File

@@ -19,6 +19,7 @@
#include <array>
#include <functional>
#include <memory>
#include <utility>
#include "../common.h"
#include "../core/DataSerialiser.h"
@@ -221,6 +222,13 @@ public:
typedCallback(ga, static_cast<const TResultType *>(result));
});
}
protected:
template<class... TTypes>
static constexpr std::unique_ptr<TResultType> MakeResult(TTypes&&... args)
{
return std::make_unique<TResultType>(std::forward<TTypes>(args)...);
}
};
using GameActionFactory = GameAction *(*)();

View File

@@ -16,8 +16,12 @@
#include "GameAction.h"
#include "GuestSetNameAction.hpp"
#include "ParkSetLoanAction.hpp"
#include "ParkSetResearchFundingAction.hpp"
#include "ParkMarketingAction.hpp"
#include "PlaceParkEntranceAction.hpp"
#include "SetParkEntranceFeeAction.hpp"
#include "StaffSetColourAction.hpp"
#include "StaffSetNameAction.hpp"
#include "RideCreateAction.hpp"
#include "RideSetStatus.hpp"
@@ -31,12 +35,16 @@ namespace GameActions
void Register()
{
Register<SetParkEntranceFeeAction>();
Register<ParkMarketingAction>();
Register<ParkSetLoanAction>();
Register<ParkSetResearchFundingAction>();
Register<PlaceParkEntranceAction>();
Register<RideCreateAction>();
Register<RideSetStatusAction>();
Register<RideSetNameAction>();
Register<RideDemolishAction>();
Register<GuestSetNameAction>();
Register<StaffSetColourAction>();
Register<StaffSetNameAction>();
Register<PlacePeepSpawnAction>();
Register<MazeSetTrackAction>();

View File

@@ -0,0 +1,101 @@
#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/Finance.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<GAME_COMMAND_START_MARKETING_CAMPAIGN, GameActionResult>
{
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 MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_START_MARKETING_CAMPAIGN);
}
if (gParkFlags & PARK_FLAGS_FORBID_MARKETING_CAMPAIGN)
{
return MakeResult(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 = MakeResult();
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];
}
};

View File

@@ -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<GAME_COMMAND_SET_CURRENT_LOAN, GameActionResult>
{
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 MakeResult(GA_ERROR::DISALLOWED, STR_CANT_BORROW_ANY_MORE_MONEY, STR_BANK_REFUSES_TO_INCREASE_LOAN);
}
}
else
{
if (loanDifference > gCash)
{
return MakeResult(GA_ERROR::INSUFFICIENT_FUNDS, STR_CANT_PAY_BACK_LOAN, STR_NOT_ENOUGH_CASH_AVAILABLE);
}
}
return MakeResult();
}
GameActionResult::Ptr Execute() const override
{
gCash -= (gBankLoan - _value);
gBankLoan = _value;
auto windowManager = GetContext()->GetUiContext()->GetWindowManager();
windowManager->BroadcastIntent(Intent(INTENT_ACTION_UPDATE_CASH));
return MakeResult();
}
};

View File

@@ -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<GAME_COMMAND_SET_RESEARCH_FUNDING, GameActionResult>
{
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 MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE);
}
return MakeResult();
}
GameActionResult::Ptr Execute() const override
{
gResearchPriorities = _priorities;
gResearchFundingLevel = _fundingAmount;
auto windowManager = GetContext()->GetUiContext()->GetWindowManager();
windowManager->BroadcastIntent(Intent(INTENT_ACTION_UPDATE_RESEARCH));
return MakeResult();
}
};

View File

@@ -0,0 +1,91 @@
#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 "../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;
struct StaffSetColourAction : public GameActionBase<GAME_COMMAND_SET_STAFF_COLOUR, GameActionResult>
{
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();
}
};

View File

@@ -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

View File

@@ -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();

View File

@@ -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;

View File

@@ -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);

View File

@@ -15,6 +15,7 @@
#pragma endregion
#include <algorithm>
#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);

View File

@@ -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);

View File

@@ -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.

View File

@@ -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();

View File

@@ -99,4 +99,5 @@ enum
INTENT_ACTION_UPDATE_DATE,
INTENT_ACTION_UPDATE_CASH,
INTENT_ACTION_UPDATE_BANNER,
INTENT_ACTION_UPDATE_RESEARCH,
};