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

Function EnableEngineForCompany

src/engine.cpp:830–851  ·  view source on GitHub ↗

* Allows engine \a eid to be used by a company \a company. * @param eid The engine to enable. * @param company The company to allow using the engine. */

Source from the content-addressed store, hash-verified

828 * @param company The company to allow using the engine.
829 */
830static void EnableEngineForCompany(EngineID eid, CompanyID company)
831{
832 Engine *e = Engine::Get(eid);
833 Company *c = Company::Get(company);
834
835 e->company_avail.Set(company);
836 if (e->type == VEH_TRAIN) {
837 c->avail_railtypes = GetCompanyRailTypes(c->index);
838 } else if (e->type == VEH_ROAD) {
839 c->avail_roadtypes = GetCompanyRoadTypes(c->index);
840 }
841
842 if (company == _local_company) {
843 AddRemoveEngineFromAutoreplaceAndBuildWindows(e->type);
844
845 /* Update the toolbar. */
846 InvalidateWindowData(WC_MAIN_TOOLBAR, 0);
847 if (e->type == VEH_ROAD) InvalidateWindowData(WC_BUILD_TOOLBAR, TRANSPORT_ROAD);
848 if (e->type == VEH_SHIP) InvalidateWindowData(WC_BUILD_TOOLBAR, TRANSPORT_WATER);
849 if (e->type == VEH_AIRCRAFT) InvalidateWindowData(WC_BUILD_TOOLBAR, TRANSPORT_AIR);
850 }
851}
852
853/**
854 * Forbids engine \a eid to be used by a company \a company.

Callers 2

AcceptEnginePreviewFunction · 0.85
CmdEngineCtrlFunction · 0.85

Calls 5

GetCompanyRailTypesFunction · 0.85
GetCompanyRoadTypesFunction · 0.85
InvalidateWindowDataFunction · 0.70
SetMethod · 0.45

Tested by

no test coverage detected