|
|
|
@ -60,8 +60,10 @@ CommandCost CmdIncreaseLoan(DoCommandFlag flags, LoanCommand cmd, Money amount)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Overflow protection */
|
|
|
|
|
if (c->money + c->current_loan + loan < c->money) return CMD_ERROR;
|
|
|
|
|
/* In case adding the loan triggers the overflow protection of Money,
|
|
|
|
|
* we would essentially be losing money as taking and repaying the loan
|
|
|
|
|
* immediately would not get us back to the same bank balance anymore. */
|
|
|
|
|
if (c->money > Money::max() - loan) return CMD_ERROR;
|
|
|
|
|
|
|
|
|
|
if (flags & DC_EXEC) {
|
|
|
|
|
c->money += loan;
|
|
|
|
|