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

Function CmdSetCompanyMaxLoan

src/misc_cmd.cpp:125–143  ·  view source on GitHub ↗

* Sets the max loan amount of your company. Does not respect the global loan setting. * @param company the company ID. * @param amount the new max loan amount, will be rounded down to the multitude of LOAN_INTERVAL. If set to COMPANY_MAX_LOAN_DEFAULT reset the max loan to default(global) value. * @return zero cost or an error */

Source from the content-addressed store, hash-verified

123 * @return zero cost or an error
124 */
125CommandCost CmdSetCompanyMaxLoan(DoCommandFlags flags, CompanyID company, Money amount)
126{
127 if (_current_company != OWNER_DEITY) return CMD_ERROR;
128 if (amount != COMPANY_MAX_LOAN_DEFAULT) {
129 if (amount < 0 || amount > (Money)MAX_LOAN_LIMIT) return CMD_ERROR;
130 }
131
132 Company *c = Company::GetIfValid(company);
133 if (c == nullptr) return CMD_ERROR;
134
135 if (flags.Test(DoCommandFlag::Execute)) {
136 /* Round the amount down to a multiple of LOAN_INTERVAL. */
137 if (amount != COMPANY_MAX_LOAN_DEFAULT) amount -= (int64_t)amount % LOAN_INTERVAL;
138
139 c->max_loan = amount;
140 InvalidateCompanyWindows(c);
141 }
142 return CommandCost();
143}
144
145/**
146 * In case of an unsafe unpause, we want the

Callers

nothing calls this directly

Calls 3

InvalidateCompanyWindowsFunction · 0.85
CommandCostClass · 0.85
TestMethod · 0.80

Tested by

no test coverage detected