3737#include " Common/GameType.h"
3838#include " GameLogic/Damage.h"
3939#include " Common/STLTypedefs.h"
40+ #include " refcount.h"
41+ #include " ref_ptr.h"
4042
4143class AIGroup ;
4244class AttackPriorityInfo ;
@@ -57,6 +59,12 @@ enum WeaponSetType CPP_11(: Int);
5759enum WeaponLockType CPP_11 (: Int);
5860enum SpecialPowerType CPP_11 (: Int);
5961
62+ #if RETAIL_COMPATIBLE_AIGROUP
63+ typedef AIGroup* AIGroupPtr;
64+ #else
65+ typedef RefCountPtr<AIGroup> AIGroupPtr;
66+ #endif
67+
6068typedef std::vector<ObjectID> VecObjectID;
6169typedef VecObjectID::iterator VecObjectIDIt;
6270
@@ -265,7 +273,7 @@ class AI : public SubsystemInterface, public Snapshot
265273 void loadPostProcess ( void );
266274
267275 // AI Groups -----------------------------------------------------------------------------------------------
268- AIGroup * createGroup ( void ); // /< instantiate a new AI Group
276+ AIGroupPtr createGroup ( void ); // /< instantiate a new AI Group
269277 void destroyGroup ( AIGroup *group ); // /< destroy the given AI Group
270278 AIGroup *findGroup ( UnsignedInt id ); // /< return the AI Group with the given ID
271279
@@ -851,6 +859,12 @@ class AIGroup : public MemoryPoolObject, public Snapshot
851859 void xfer ( Xfer *xfer );
852860 void loadPostProcess ( void );
853861
862+ #if !RETAIL_COMPATIBLE_AIGROUP
863+ void Add_Ref () const { m_refCount.Add_Ref (); }
864+ void Release_Ref () const { m_refCount.Release_Ref (destroy, this ); }
865+ UnsignedShort Num_Refs () const { return m_refCount.Num_Refs (); }
866+ #endif
867+
854868 void groupMoveToPosition ( const Coord3D *pos, Bool addWaypoint, CommandSourceType cmdSource );
855869 void groupMoveToAndEvacuate ( const Coord3D *pos, CommandSourceType cmdSource ); // /< move to given position(s)
856870 void groupMoveToAndEvacuateAndExit ( const Coord3D *pos, CommandSourceType cmdSource ); // /< move to given position & unload transport.
@@ -938,13 +952,15 @@ class AIGroup : public MemoryPoolObject, public Snapshot
938952
939953 void add ( Object *obj ); // /< add object to group
940954
941- // returns true if remove destroyed the group for us .
955+ // Returns true if the group was emptied .
942956 Bool remove ( Object *obj);
957+
958+ void removeAll ( void );
943959
944960 // If the group contains any objects not owned by ownerPlayer, return TRUE.
945961 Bool containsAnyObjectsNotOwnedByPlayer ( const Player *ownerPlayer );
946962
947- // Remove any objects that aren't owned by the player, and return true if the group was destroyed due to emptiness
963+ // Removes any objects that aren't owned by the player, and returns true if the group was emptied.
948964 Bool removeAnyObjectsNotOwnedByPlayer ( const Player *ownerPlayer );
949965
950966 UnsignedInt getID ( void );
@@ -974,6 +990,13 @@ class AIGroup : public MemoryPoolObject, public Snapshot
974990 friend class AI ;
975991 AIGroup ( void );
976992
993+ #if !RETAIL_COMPATIBLE_AIGROUP
994+ static void destroy (AIGroup* self)
995+ {
996+ TheAI->destroyGroup (self);
997+ }
998+ #endif
999+
9771000 void recompute ( void ); // /< recompute various group info, such as speed, leader, etc
9781001
9791002 ListObjectPtr m_memberList; // /< the list of member Objects
@@ -982,6 +1005,10 @@ class AIGroup : public MemoryPoolObject, public Snapshot
9821005 Real m_speed; // /< maximum speed of group (slowest member)
9831006 Bool m_dirty; // /< "dirty bit" - if true then group speed, leader, needs recompute
9841007
1008+ #if !RETAIL_COMPATIBLE_AIGROUP
1009+ RefCountValue<UnsignedShort> m_refCount; // /< the reference counter
1010+ #endif
1011+
9851012 UnsignedInt m_id; // /< the unique ID of this group
9861013 Path *m_groundPath; // /< Group ground path.
9871014
0 commit comments