* 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
| 232 | * @return zero cost or an error |
| 233 | */ |
| 234 | CommandCost 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 | } |
nothing calls this directly
no test coverage detected