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

Function GetGroupNumEngines

src/group_cmd.cpp:819–830  ·  view source on GitHub ↗

* 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 */

Source from the content-addressed store, hash-verified

817 * @return The number of engines with EngineID id_e in the group
818 */
819uint 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

Callers 7

OnClickMethod · 0.85
UpdateAutoreplaceMethod · 0.85
DrawEngineListFunction · 0.85
NewVehicleAvailableFunction · 0.85
GetNumEnginesMethod · 0.85

Calls 1

GetNumEnginesMethod · 0.45

Tested by

no test coverage detected