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

Function DisableEngineForCompany

src/engine.cpp:858–874  ·  view source on GitHub ↗

* Forbids engine \a eid to be used by a company \a company. * @param eid The engine to disable. * @param company The company to forbid using the engine. */

Source from the content-addressed store, hash-verified

856 * @param company The company to forbid using the engine.
857 */
858static void DisableEngineForCompany(EngineID eid, CompanyID company)
859{
860 Engine *e = Engine::Get(eid);
861 Company *c = Company::Get(company);
862
863 e->company_avail.Reset(company);
864 if (e->type == VEH_TRAIN) {
865 c->avail_railtypes = GetCompanyRailTypes(c->index);
866 } else if (e->type == VEH_ROAD) {
867 c->avail_roadtypes = GetCompanyRoadTypes(c->index);
868 }
869
870 if (company == _local_company) {
871 ClearLastVariant(e->index, e->type);
872 AddRemoveEngineFromAutoreplaceAndBuildWindows(e->type);
873 }
874}
875
876/**
877 * Company \a company accepts engine \a eid for preview.

Callers 1

CmdEngineCtrlFunction · 0.85

Calls 5

GetCompanyRailTypesFunction · 0.85
GetCompanyRoadTypesFunction · 0.85
ClearLastVariantFunction · 0.85
ResetMethod · 0.45

Tested by

no test coverage detected