File diff r11961:8a97e01f7192 → r11962:0e3a6981e508
src/group.h
Show inline comments
 
@@ -30,49 +30,49 @@ struct Group : PoolItem<Group, GroupID, 
 
};
 

	
 

	
 
static inline bool IsDefaultGroupID(GroupID index)
 
{
 
	return index == DEFAULT_GROUP;
 
}
 

	
 
/**
 
 * Checks if a GroupID stands for all vehicles of a company
 
 * @param id_g The GroupID to check
 
 * @return true is id_g is identical to ALL_GROUP
 
 */
 
static inline bool IsAllGroupID(GroupID id_g)
 
{
 
	return id_g == ALL_GROUP;
 
}
 

	
 
#define FOR_ALL_GROUPS_FROM(g, start) for (g = Group::Get(start); g != NULL; g = (g->index + 1U < Group::GetPoolSize()) ? Group::Get(g->index + 1) : NULL) if (g->IsValid())
 
#define FOR_ALL_GROUPS(g) FOR_ALL_GROUPS_FROM(g, 0)
 

	
 
/**
 
 * Get the current size of the GroupPool
 
 */
 
static inline uint GetGroupArraySize(void)
 
static inline uint GetGroupArraySize()
 
{
 
	const Group *g;
 
	uint num = 0;
 

	
 
	FOR_ALL_GROUPS(g) num++;
 

	
 
	return num;
 
}
 

	
 
/**
 
 * Get the number of engines with EngineID id_e in the group with GroupID
 
 * id_g
 
 * @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
 
 */
 
uint GetGroupNumEngines(CompanyID company, GroupID id_g, EngineID id_e);
 

	
 
static inline void IncreaseGroupNumVehicle(GroupID id_g)
 
{
 
	Group *g = Group::GetIfValid(id_g);
 
	if (g != NULL) g->num_vehicle++;
 
}