File diff r7381:7ca8ddb92031 → r7382:750cdd87ddef
src/group.h
Show inline comments
 
@@ -13,40 +13,31 @@ enum {
 
	INVALID_GROUP = 0xFFFF,
 
};
 

	
 
struct Group {
 
struct Group;
 
DECLARE_OLD_POOL(Group, Group, 5, 2047)
 

	
 
struct Group : PoolItem<Group, GroupID, &_Group_pool> {
 
	StringID string_id;                     ///< Group Name
 

	
 
	uint16 num_vehicle;                     ///< Number of vehicles wich belong to the group
 
	PlayerID owner;                         ///< Group Owner
 
	GroupID index;                          ///< Array index
 
	VehicleTypeByte vehicle_type;           ///< Vehicle type of the group
 

	
 
	bool replace_protection;                ///< If set to true, the global autoreplace have no effect on the group
 
	uint16 num_engines[TOTAL_NUM_ENGINES];  ///< Caches the number of engines of each type the player owns (no need to save this)
 

	
 
	Group(StringID str = STR_NULL);
 
	virtual ~Group();
 

	
 
	void QuickFree();
 

	
 
	bool IsValid() const;
 
};
 

	
 
DECLARE_OLD_POOL(Group, Group, 5, 2047)
 

	
 

	
 
static inline bool IsValidGroup(const Group *g)
 
{
 
	return g->string_id != STR_NULL;
 
}
 

	
 
static inline void DestroyGroup(Group *g)
 
{
 
	DeleteName(g->string_id);
 
}
 

	
 
static inline void DeleteGroup(Group *g)
 
{
 
	DestroyGroup(g);
 
	g->string_id = STR_NULL;
 
}
 

	
 
static inline bool IsValidGroupID(GroupID index)
 
{
 
	return index < GetGroupPoolSize() && IsValidGroup(GetGroup(index));
 
	return index < GetGroupPoolSize() && GetGroup(index)->IsValid();
 
}
 

	
 
static inline bool IsDefaultGroupID(GroupID index)
 
@@ -64,7 +55,7 @@ static inline bool IsAllGroupID(GroupID 
 
	return id_g == ALL_GROUP;
 
}
 

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

	
 
/**