* 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. */
| 828 | * @param company The company to allow using the engine. |
| 829 | */ |
| 830 | static 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. |
no test coverage detected