From 4b42ecb0f64c0044786412c15fb31b3705016375 Mon Sep 17 00:00:00 2001 From: Pavel Stupnikov Date: Fri, 22 Jan 2021 12:28:26 +0300 Subject: Feature: Add tile parameter for GSCompany.ChangeBankBalance to show text effect if needed (#8573) --- src/script/api/script_company.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/script/api/script_company.cpp') 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) -- cgit v1.2.3-54-g00ecf