summaryrefslogtreecommitdiff
path: root/src/group.h
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-08-02 12:51:57 +0000
committerrubidium <rubidium@openttd.org>2007-08-02 12:51:57 +0000
commit9458905e4c3c638d9d1cbba3fb33108bd41e4ab5 (patch)
treeac91a1ff5145f67cfe93ac2038d379e396a7337c /src/group.h
parent53e6da1752c616388984c8906eb63673fb3b4050 (diff)
downloadopenttd-9458905e4c3c638d9d1cbba3fb33108bd41e4ab5.tar.xz
(svn r10751) -Codechange: make the group struct use the pool item class as super class.
Diffstat (limited to 'src/group.h')
-rw-r--r--src/group.h31
1 files changed, 11 insertions, 20 deletions
diff --git a/src/group.h b/src/group.h
index b0600db0f..b4303e70c 100644
--- a/src/group.h
+++ b/src/group.h
@@ -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)
-};
-
-DECLARE_OLD_POOL(Group, Group, 5, 2047)
+ Group(StringID str = STR_NULL);
+ virtual ~Group();
-static inline bool IsValidGroup(const Group *g)
-{
- return g->string_id != STR_NULL;
-}
+ void QuickFree();
-static inline void DestroyGroup(Group *g)
-{
- DeleteName(g->string_id);
-}
+ bool IsValid() const;
+};
-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 id_g)
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)
/**