MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / CmdChangeBankBalance

Function CmdChangeBankBalance

src/misc_cmd.cpp:234–254  ·  view source on GitHub ↗

* Change the bank bank balance of a company by inserting or removing money without affecting the loan. * @param flags operation to perform * @param tile tile to show text effect on (if not 0) * @param delta the amount of money to receive (if positive), or spend (if negative) * @param company the company ID. * @param expenses_type the expenses type which should register the cost/income @see Ex

Source from the content-addressed store, hash-verified

232 * @return zero cost or an error
233 */
234CommandCost CmdChangeBankBalance(DoCommandFlags flags, TileIndex tile, Money delta, CompanyID company, ExpensesType expenses_type)
235{
236 if (!Company::IsValidID(company)) return CMD_ERROR;
237 if (expenses_type >= EXPENSES_END) return CMD_ERROR;
238 if (_current_company != OWNER_DEITY) return CMD_ERROR;
239
240 if (flags.Test(DoCommandFlag::Execute)) {
241 /* Change company bank balance of company. */
242 Backup<CompanyID> cur_company(_current_company, company);
243 SubtractMoneyFromCompany(CommandCost(expenses_type, -delta));
244 cur_company.Restore();
245
246 if (tile != 0) {
247 ShowCostOrIncomeAnimation(TileX(tile) * TILE_SIZE, TileY(tile) * TILE_SIZE, GetTilePixelZ(tile), -delta);
248 }
249 }
250
251 /* This command doesn't cost anything for deity. */
252 CommandCost zero_cost(expenses_type, (Money)0);
253 return zero_cost;
254}

Callers

nothing calls this directly

Calls 8

SubtractMoneyFromCompanyFunction · 0.85
CommandCostClass · 0.85
TileXFunction · 0.85
TileYFunction · 0.85
GetTilePixelZFunction · 0.85
TestMethod · 0.80
RestoreMethod · 0.45

Tested by

no test coverage detected