mirror of https://github.com/OpenTTD/OpenTTD
(svn r19930) -Codechange: Deduplicate magic command parameter casts. (rubidium)
parent
e7f70987a4
commit
406c2a9865
|
@ -222,14 +222,15 @@ CommandCost CmdGiveMoney(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
||||||
|
|
||||||
const Company *c = Company::Get(_current_company);
|
const Company *c = Company::Get(_current_company);
|
||||||
CommandCost amount(EXPENSES_OTHER, min((Money)p1, (Money)20000000LL));
|
CommandCost amount(EXPENSES_OTHER, min((Money)p1, (Money)20000000LL));
|
||||||
|
CompanyID dest_company = (CompanyID)p2;
|
||||||
|
|
||||||
/* You can only transfer funds that is in excess of your loan */
|
/* 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;
|
if (c->money - c->current_loan < amount.GetCost() || amount.GetCost() < 0) return CMD_ERROR;
|
||||||
if (!_networking || !Company::IsValidID((CompanyID)p2)) return CMD_ERROR;
|
if (!_networking || !Company::IsValidID(dest_company)) return CMD_ERROR;
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
/* Add money to company */
|
/* Add money to company */
|
||||||
Backup<CompanyByte> cur_company(_current_company, (CompanyID)p2);
|
Backup<CompanyByte> cur_company(_current_company, dest_company);
|
||||||
SubtractMoneyFromCompany(CommandCost(EXPENSES_OTHER, -amount.GetCost()));
|
SubtractMoneyFromCompany(CommandCost(EXPENSES_OTHER, -amount.GetCost()));
|
||||||
cur_company.Restore();
|
cur_company.Restore();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue