* Get the number of engines with EngineID id_e in the group with GroupID * id_g and its sub-groups. * @param company The company the group belongs to * @param id_g The GroupID of the group used * @param id_e The EngineID of the engine to count * @return The number of engines with EngineID id_e in the group */
| 817 | * @return The number of engines with EngineID id_e in the group |
| 818 | */ |
| 819 | uint GetGroupNumEngines(CompanyID company, GroupID id_g, EngineID id_e) |
| 820 | { |
| 821 | uint count = 0; |
| 822 | |
| 823 | if (const Group *g = Group::GetIfValid(id_g); g != nullptr) { |
| 824 | for (const GroupID &childgroup : g->children) { |
| 825 | count += GetGroupNumEngines(company, childgroup, id_e); |
| 826 | } |
| 827 | } |
| 828 | |
| 829 | return count + GroupStatistics::Get(company, id_g, Engine::Get(id_e)->type).GetNumEngines(id_e); |
| 830 | } |
| 831 | |
| 832 | /** |
| 833 | * Get the number of vehicles in the group with GroupID |
no test coverage detected