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

Function CmdEngineCtrl

src/engine.cpp:1057–1072  ·  view source on GitHub ↗

* Allow or forbid a specific company to use an engine * @param flags operation to perform * @param engine_id engine id * @param company_id Company to allow/forbid the use of an engine. * @param allow false to forbid, true to allow. * @return the cost of this operation or an error */

Source from the content-addressed store, hash-verified

1055 * @return the cost of this operation or an error
1056 */
1057CommandCost CmdEngineCtrl(DoCommandFlags flags, EngineID engine_id, CompanyID company_id, bool allow)
1058{
1059 if (_current_company != OWNER_DEITY) return CMD_ERROR;
1060
1061 if (!Engine::IsValidID(engine_id) || !Company::IsValidID(company_id)) return CMD_ERROR;
1062
1063 if (flags.Test(DoCommandFlag::Execute)) {
1064 if (allow) {
1065 EnableEngineForCompany(engine_id, company_id);
1066 } else {
1067 DisableEngineForCompany(engine_id, company_id);
1068 }
1069 }
1070
1071 return CommandCost();
1072}
1073
1074/**
1075 * An engine has become available for general use.

Callers

nothing calls this directly

Calls 4

EnableEngineForCompanyFunction · 0.85
DisableEngineForCompanyFunction · 0.85
CommandCostClass · 0.85
TestMethod · 0.80

Tested by

no test coverage detected