diff options
author | Pavel Stupnikov <dp@dpointer.org> | 2021-01-22 12:28:26 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-22 10:28:26 +0100 |
commit | 4b42ecb0f64c0044786412c15fb31b3705016375 (patch) | |
tree | 316d7c36b2522d2b7022b259f3165fbb6b0d109b /src/script | |
parent | 3345d54ad932773b74171a7ae6c00a3ec3c8556b (diff) | |
download | openttd-4b42ecb0f64c0044786412c15fb31b3705016375.tar.xz |
Feature: Add tile parameter for GSCompany.ChangeBankBalance to show text effect if needed (#8573)
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/api/game_changelog.hpp | 3 | ||||
-rw-r--r-- | src/script/api/script_company.cpp | 6 | ||||
-rw-r--r-- | src/script/api/script_company.hpp | 3 |
3 files changed, 9 insertions, 3 deletions
diff --git a/src/script/api/game_changelog.hpp b/src/script/api/game_changelog.hpp index cbb862f1c..82f0c0523 100644 --- a/src/script/api/game_changelog.hpp +++ b/src/script/api/game_changelog.hpp @@ -35,6 +35,9 @@ * \li GSStoryPage::MakeVehicleButtonReference * \li GSPriorityQueue * + * Other changes: + * \li GSCompany::ChangeBankBalance takes one extra parameter to refer to a location to show text effect on + * * \b 1.10.0 * * API additions: diff --git a/src/script/api/script_company.cpp b/src/script/api/script_company.cpp index 93bba6332..20f1b3f7a 100644 --- a/src/script/api/script_company.cpp +++ b/src/script/api/script_company.cpp @@ -226,17 +226,19 @@ return GetLoanAmount() == loan; } -/* static */ bool ScriptCompany::ChangeBankBalance(CompanyID company, Money delta, ExpensesType expenses_type) +/* static */ bool ScriptCompany::ChangeBankBalance(CompanyID company, Money delta, ExpensesType expenses_type, TileIndex tile) { EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY); EnforcePrecondition(false, expenses_type < (ExpensesType)::EXPENSES_END); EnforcePrecondition(false, (int64)delta >= INT32_MIN); EnforcePrecondition(false, (int64)delta <= INT32_MAX); + EnforcePrecondition(false, tile == INVALID_TILE || ::IsValidTile(tile)); company = ResolveCompanyID(company); EnforcePrecondition(false, company != COMPANY_INVALID); - return ScriptObject::DoCommand(0, (uint32)(delta), company | expenses_type << 8 , CMD_CHANGE_BANK_BALANCE); + /* Network commands only allow 0 to indicate invalid tiles, not INVALID_TILE */ + return ScriptObject::DoCommand(tile == INVALID_TILE ? 0 : tile , (uint32)(delta), company | expenses_type << 8 , CMD_CHANGE_BANK_BALANCE); } /* static */ bool ScriptCompany::BuildCompanyHQ(TileIndex tile) diff --git a/src/script/api/script_company.hpp b/src/script/api/script_company.hpp index ea2f0cdd1..635b6fdee 100644 --- a/src/script/api/script_company.hpp +++ b/src/script/api/script_company.hpp @@ -242,6 +242,7 @@ public: * @param company The company to change the bank balance of. * @param delta Amount of money to give or take from the bank balance. A positive value adds money to the bank balance. * @param expenses_type The account in the finances window that will register the cost. + * @param tile The tile to show text effect on or ScriptMap::TILE_INVALID * @return True, if the bank balance was changed. * @game @pre No ScriptCompanyMode active in scope. * @pre ResolveCompanyID(company) != COMPANY_INVALID. @@ -250,7 +251,7 @@ public: * @note You need to create your own news message to inform about costs/gifts that you create using this command. * @api -ai */ - static bool ChangeBankBalance(CompanyID company, Money delta, ExpensesType expenses_type); + static bool ChangeBankBalance(CompanyID company, Money delta, ExpensesType expenses_type, TileIndex tile); /** * Get the income of the company in the given quarter. |