diff --git a/src/command.cpp b/src/command.cpp index 7b5c6890a2..895c2e5007 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -177,10 +177,10 @@ CommandProc CmdCloneOrder; CommandProc CmdClearArea; -CommandProc CmdGiveMoney; +CommandProcEx CmdGiveMoney; CommandProcEx CmdMoneyCheat; CommandProcEx CmdMoneyCheatAdmin; -CommandProc CmdChangeBankBalance; +CommandProcEx CmdChangeBankBalance; CommandProc CmdCheatSetting; CommandProc CmdBuildCanal; CommandProc CmdBuildLock; diff --git a/src/company_gui.cpp b/src/company_gui.cpp index e50d84c4ca..9e75c3146b 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -2807,7 +2807,7 @@ struct CompanyWindow : Window default: NOT_REACHED(); case WID_C_GIVE_MONEY: - DoCommandP(0, (std::strtoull(str, nullptr, 10) / _currency->rate), this->window_number, CMD_GIVE_MONEY | CMD_MSG(STR_ERROR_CAN_T_GIVE_MONEY), CcGiveMoney, str); + DoCommandPEx(0, this->window_number, 0, (std::strtoull(str, nullptr, 10) / _currency->rate), CMD_GIVE_MONEY | CMD_MSG(STR_ERROR_CAN_T_GIVE_MONEY), CcGiveMoney); break; case WID_C_PRESIDENT_NAME: diff --git a/src/main_gui.cpp b/src/main_gui.cpp index dc410490b4..3f46407e23 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -54,14 +54,14 @@ void CcGiveMoney(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2 /* Inform the company of the action of one of its clients (controllers). */ char msg[64]; - SetDParam(0, p2); + SetDParam(0, p1); GetString(msg, STR_COMPANY_NAME, lastof(msg)); /* * bits 31-16: source company * bits 15-0: target company */ - uint64 auxdata = (p2 & 0xFFFF) | (((uint64) _local_company) << 16); + uint64 auxdata = (p1 & 0xFFFF) | (((uint64) _local_company) << 16); if (!_network_server) { NetworkClientSendChat(NETWORK_ACTION_GIVE_MONEY, DESTTYPE_BROADCAST_SS, p2, msg, NetworkTextMessageData(result.GetCost(), auxdata)); diff --git a/src/misc_cmd.cpp b/src/misc_cmd.cpp index b3ea4a53b3..063eb7c0c7 100644 --- a/src/misc_cmd.cpp +++ b/src/misc_cmd.cpp @@ -319,17 +319,18 @@ CommandCost CmdCheatSetting(TileIndex tile, DoCommandFlag flags, uint32 p1, uint * Change the bank bank balance of a company by inserting or removing money without affecting the loan. * @param tile tile to show text effect on (if not 0) * @param flags operation to perform - * @param p1 the amount of money to receive (if positive), or spend (if negative) - * @param p2 (bit 0-7) - the company ID. + * @param p1 (bit 0-7) - the company ID. * (bit 8-15) - the expenses type which should register the cost/income @see ExpensesType. + * @param p2 unused + * @param p3 the amount of money to receive (if positive), or spend (if negative) * @param text unused * @return zero cost or an error */ -CommandCost CmdChangeBankBalance(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdChangeBankBalance(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, uint64 p3, const char *text, const CommandAuxiliaryBase *aux_data) { - int32 delta = (int32)p1; - CompanyID company = (CompanyID) GB(p2, 0, 8); - ExpensesType expenses_type = Extract(p2); + int64 delta = (int64)p3; + CompanyID company = (CompanyID) GB(p1, 0, 8); + ExpensesType expenses_type = Extract(p1); if (!Company::IsValidID(company)) return CMD_ERROR; if (expenses_type >= EXPENSES_END) return CMD_ERROR; @@ -358,18 +359,19 @@ CommandCost CmdChangeBankBalance(TileIndex tile, DoCommandFlag flags, uint32 p1, * given the fact that you have more money than loan). * @param tile unused * @param flags operation to perform - * @param p1 the amount of money to transfer; max 20.000.000 - * @param p2 the company to transfer the money to + * @param p1 the company to transfer the money to + * @param p2 unused + * @param p3 the amount of money to transfer; max 20.000.000 * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdGiveMoney(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdGiveMoney(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, uint64 p3, const char *text, const CommandAuxiliaryBase *aux_data) { if (!_settings_game.economy.give_money) return CMD_ERROR; const Company *c = Company::Get(_current_company); - CommandCost amount(EXPENSES_OTHER, std::min((Money)p1, (Money)20000000LL)); - CompanyID dest_company = (CompanyID)p2; + CommandCost amount(EXPENSES_OTHER, std::min((int64)p3, 20000000LL)); + CompanyID dest_company = (CompanyID)p1; /* You can only transfer funds that is in excess of your loan */ if (c->money - c->current_loan < amount.GetCost() || amount.GetCost() < 0) return CMD_ERROR; diff --git a/src/script/api/script_company.cpp b/src/script/api/script_company.cpp index ab706abe3d..4c081b68f1 100644 --- a/src/script/api/script_company.cpp +++ b/src/script/api/script_company.cpp @@ -256,7 +256,7 @@ EnforcePrecondition(false, company != COMPANY_INVALID); /* 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); + return ScriptObject::DoCommandEx(tile == INVALID_TILE ? 0 : tile, company | expenses_type << 8, 0, (uint64)(delta), CMD_CHANGE_BANK_BALANCE); } /* static */ bool ScriptCompany::BuildCompanyHQ(TileIndex tile)