First Commit

For Azeroth!
This commit is contained in:
Yehonal
2016-06-26 10:39:44 +02:00
commit e8e94a0a66
3777 changed files with 1419268 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,359 @@
/*
* Copyright (C)
* Copyright (C)
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SUNWELLCORE_GROUP_H
#define SUNWELLCORE_GROUP_H
#include "DBCEnums.h"
#include "GroupRefManager.h"
#include "LootMgr.h"
#include "QueryResult.h"
#include "SharedDefines.h"
class Battlefield;
class Battleground;
class Creature;
class GroupReference;
class InstanceSave;
class Map;
class Player;
class Unit;
class WorldObject;
class WorldPacket;
class WorldSession;
struct MapEntry;
#define MAXGROUPSIZE 5
#define MAXRAIDSIZE 40
#define MAX_RAID_SUBGROUPS MAXRAIDSIZE/MAXGROUPSIZE
#define TARGETICONCOUNT 8
enum RollVote
{
PASS = 0,
NEED = 1,
GREED = 2,
DISENCHANT = 3,
NOT_EMITED_YET = 4,
NOT_VALID = 5
};
enum GroupMemberOnlineStatus
{
MEMBER_STATUS_OFFLINE = 0x0000,
MEMBER_STATUS_ONLINE = 0x0001, // Lua_UnitIsConnected
MEMBER_STATUS_PVP = 0x0002, // Lua_UnitIsPVP
MEMBER_STATUS_DEAD = 0x0004, // Lua_UnitIsDead
MEMBER_STATUS_GHOST = 0x0008, // Lua_UnitIsGhost
MEMBER_STATUS_PVP_FFA = 0x0010, // Lua_UnitIsPVPFreeForAll
MEMBER_STATUS_UNK3 = 0x0020, // used in calls from Lua_GetPlayerMapPosition/Lua_GetBattlefieldFlagPosition
MEMBER_STATUS_AFK = 0x0040, // Lua_UnitIsAFK
MEMBER_STATUS_DND = 0x0080, // Lua_UnitIsDND
};
enum GroupMemberFlags
{
MEMBER_FLAG_ASSISTANT = 0x01,
MEMBER_FLAG_MAINTANK = 0x02,
MEMBER_FLAG_MAINASSIST = 0x04,
};
enum GroupMemberAssignment
{
GROUP_ASSIGN_MAINTANK = 0,
GROUP_ASSIGN_MAINASSIST = 1,
};
enum GroupType
{
GROUPTYPE_NORMAL = 0x00,
GROUPTYPE_BG = 0x01,
GROUPTYPE_RAID = 0x02,
GROUPTYPE_BGRAID = GROUPTYPE_BG | GROUPTYPE_RAID, // mask
GROUPTYPE_LFG_RESTRICTED = 0x04, // Script_HasLFGRestrictions()
GROUPTYPE_LFG = 0x08,
// 0x10, leave/change group?, I saw this flag when leaving group and after leaving BG while in group
// GROUPTYPE_ONE_PERSON_PARTY = 0x20, 4.x Script_IsOnePersonParty()
// GROUPTYPE_EVERYONE_ASSISTANT = 0x40 4.x Script_IsEveryoneAssistant()
};
enum GroupUpdateFlags
{
GROUP_UPDATE_FLAG_NONE = 0x00000000, // nothing
GROUP_UPDATE_FLAG_STATUS = 0x00000001, // uint16, flags
GROUP_UPDATE_FLAG_CUR_HP = 0x00000002, // uint32
GROUP_UPDATE_FLAG_MAX_HP = 0x00000004, // uint32
GROUP_UPDATE_FLAG_POWER_TYPE = 0x00000008, // uint8
GROUP_UPDATE_FLAG_CUR_POWER = 0x00000010, // uint16
GROUP_UPDATE_FLAG_MAX_POWER = 0x00000020, // uint16
GROUP_UPDATE_FLAG_LEVEL = 0x00000040, // uint16
GROUP_UPDATE_FLAG_ZONE = 0x00000080, // uint16
GROUP_UPDATE_FLAG_POSITION = 0x00000100, // uint16, uint16
GROUP_UPDATE_FLAG_AURAS = 0x00000200, // uint64 mask, for each bit set uint32 spellid + uint8 unk
GROUP_UPDATE_FLAG_PET_GUID = 0x00000400, // uint64 pet guid
GROUP_UPDATE_FLAG_PET_NAME = 0x00000800, // pet name, NULL terminated string
GROUP_UPDATE_FLAG_PET_MODEL_ID = 0x00001000, // uint16, model id
GROUP_UPDATE_FLAG_PET_CUR_HP = 0x00002000, // uint32 pet cur health
GROUP_UPDATE_FLAG_PET_MAX_HP = 0x00004000, // uint32 pet max health
GROUP_UPDATE_FLAG_PET_POWER_TYPE = 0x00008000, // uint8 pet power type
GROUP_UPDATE_FLAG_PET_CUR_POWER = 0x00010000, // uint16 pet cur power
GROUP_UPDATE_FLAG_PET_MAX_POWER = 0x00020000, // uint16 pet max power
GROUP_UPDATE_FLAG_PET_AURAS = 0x00040000, // uint64 mask, for each bit set uint32 spellid + uint8 unk, pet auras...
GROUP_UPDATE_FLAG_VEHICLE_SEAT = 0x00080000, // uint32 vehicle_seat_id (index from VehicleSeat.dbc)
GROUP_UPDATE_PET = 0x0007FC00, // all pet flags
GROUP_UPDATE_FULL = 0x0007FFFF, // all known flags
};
enum lfgGroupFlags
{
GROUP_LFG_FLAG_APPLY_RANDOM_BUFF = 0x001,
GROUP_LFG_FLAG_IS_RANDOM_INSTANCE = 0x002,
GROUP_LFG_FLAG_IS_HEROIC = 0x004
};
enum DifficultyPreventionChangeType
{
DIFFICULTY_PREVENTION_CHANGE_NONE = 0,
DIFFICULTY_PREVENTION_CHANGE_RECENTLY_CHANGED = 1,
DIFFICULTY_PREVENTION_CHANGE_BOSS_KILLED = 2
};
#define GROUP_UPDATE_FLAGS_COUNT 20
// 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
static const uint8 GroupUpdateLength[GROUP_UPDATE_FLAGS_COUNT] = { 0, 2, 2, 2, 1, 2, 2, 2, 2, 4, 8, 8, 1, 2, 2, 2, 1, 2, 2, 8};
class Roll : public LootValidatorRef
{
public:
Roll(uint64 _guid, LootItem const& li);
~Roll();
void setLoot(Loot* pLoot);
Loot* getLoot();
void targetObjectBuildLink();
uint64 itemGUID;
uint32 itemid;
int32 itemRandomPropId;
uint32 itemRandomSuffix;
uint8 itemCount;
typedef std::map<uint64, RollVote> PlayerVote;
PlayerVote playerVote; //vote position correspond with player position (in group)
uint8 totalPlayersRolling;
uint8 totalNeed;
uint8 totalGreed;
uint8 totalPass;
uint8 itemSlot;
uint8 rollVoteMask;
};
/** request member stats checken **/
/** todo: uninvite people that not accepted invite **/
class Group
{
public:
struct MemberSlot
{
uint64 guid;
std::string name;
uint8 group;
uint8 flags;
uint8 roles;
};
typedef std::list<MemberSlot> MemberSlotList;
typedef MemberSlotList::const_iterator member_citerator;
protected:
typedef MemberSlotList::iterator member_witerator;
typedef std::set<Player*> InvitesList;
typedef std::vector<Roll*> Rolls;
public:
Group();
~Group();
// group manipulation methods
bool Create(Player* leader);
bool LoadGroupFromDB(Field* field);
void LoadMemberFromDB(uint32 guidLow, uint8 memberFlags, uint8 subgroup, uint8 roles);
bool AddInvite(Player* player);
void RemoveInvite(Player* player);
void RemoveAllInvites();
bool AddLeaderInvite(Player* player);
bool AddMember(Player* player);
bool RemoveMember(uint64 guid, const RemoveMethod &method = GROUP_REMOVEMETHOD_DEFAULT, uint64 kicker = 0, const char* reason = NULL);
void ChangeLeader(uint64 guid);
void SetLootMethod(LootMethod method);
void SetLooterGuid(uint64 guid);
void SetMasterLooterGuid(uint64 guid);
void UpdateLooterGuid(WorldObject* pLootedObject, bool ifneed = false);
void SetLootThreshold(ItemQualities threshold);
void Disband(bool hideDestroy=false);
void SetLfgRoles(uint64 guid, const uint8 roles);
// properties accessories
bool IsFull() const;
bool isLFGGroup() const;
bool isRaidGroup() const;
bool isBFGroup() const;
bool isBGGroup() const;
bool IsCreated() const;
uint64 GetLeaderGUID() const;
uint64 GetGUID() const;
uint32 GetLowGUID() const;
const char * GetLeaderName() const;
LootMethod GetLootMethod() const;
uint64 GetLooterGuid() const;
uint64 GetMasterLooterGuid() const;
ItemQualities GetLootThreshold() const;
// member manipulation methods
bool IsMember(uint64 guid) const;
bool IsLeader(uint64 guid) const;
uint64 GetMemberGUID(const std::string& name);
bool IsAssistant(uint64 guid) const;
Player* GetInvited(uint64 guid) const;
Player* GetInvited(const std::string& name) const;
bool SameSubGroup(uint64 guid1, uint64 guid2) const;
bool SameSubGroup(uint64 guid1, MemberSlot const* slot2) const;
bool SameSubGroup(Player const* member1, Player const* member2) const;
bool HasFreeSlotSubGroup(uint8 subgroup) const;
MemberSlotList const& GetMemberSlots() const { return m_memberSlots; }
GroupReference* GetFirstMember() { return m_memberMgr.getFirst(); }
GroupReference const* GetFirstMember() const { return m_memberMgr.getFirst(); }
uint32 GetMembersCount() const { return m_memberSlots.size(); }
uint8 GetMemberGroup(uint64 guid) const;
void ConvertToLFG();
void ConvertToRaid();
void SetBattlegroundGroup(Battleground* bg);
void SetBattlefieldGroup(Battlefield* bf);
GroupJoinBattlegroundResult CanJoinBattlegroundQueue(Battleground const* bgTemplate, BattlegroundQueueTypeId bgQueueTypeId, uint32 MinPlayerCount, uint32 MaxPlayerCount, bool isRated, uint32 arenaSlot);
void ChangeMembersGroup(uint64 guid, uint8 group);
void SetTargetIcon(uint8 id, uint64 whoGuid, uint64 targetGuid);
void SetGroupMemberFlag(uint64 guid, bool apply, GroupMemberFlags flag);
void RemoveUniqueGroupMemberFlag(GroupMemberFlags flag);
Difficulty GetDifficulty(bool isRaid) const;
Difficulty GetDungeonDifficulty() const;
Difficulty GetRaidDifficulty() const;
void SetDungeonDifficulty(Difficulty difficulty);
void SetRaidDifficulty(Difficulty difficulty);
uint16 InInstance();
void ResetInstances(uint8 method, bool isRaid, Player* leader);
// -no description-
//void SendInit(WorldSession* session);
void SendTargetIconList(WorldSession* session);
void SendUpdate();
void SendUpdateToPlayer(uint64 playerGUID, MemberSlot* slot = NULL);
void UpdatePlayerOutOfRange(Player* player);
// ignore: GUID of player that will be ignored
void BroadcastPacket(WorldPacket* packet, bool ignorePlayersInBGRaid, int group=-1, uint64 ignore=0);
void BroadcastReadyCheck(WorldPacket* packet);
void OfflineReadyCheck();
/*********************************************************/
/*** LOOT SYSTEM ***/
/*********************************************************/
bool isRollLootActive() const;
void SendLootStartRoll(uint32 CountDown, uint32 mapid, const Roll &r);
void SendLootStartRollToPlayer(uint32 countDown, uint32 mapId, Player* p, bool canNeed, Roll const& r);
void SendLootRoll(uint64 SourceGuid, uint64 TargetGuid, uint8 RollNumber, uint8 RollType, const Roll &r);
void SendLootRollWon(uint64 SourceGuid, uint64 TargetGuid, uint8 RollNumber, uint8 RollType, const Roll &r);
void SendLootAllPassed(Roll const& roll);
void SendLooter(Creature* creature, Player* pLooter);
void GroupLoot(Loot* loot, WorldObject* pLootedObject);
void NeedBeforeGreed(Loot* loot, WorldObject* pLootedObject);
void MasterLoot(Loot* loot, WorldObject* pLootedObject);
Rolls::iterator GetRoll(uint64 Guid);
void CountTheRoll(Rolls::iterator roll, Map* allowedMap);
bool CountRollVote(uint64 playerGUID, uint64 Guid, uint8 Choise);
void EndRoll(Loot* loot, Map* allowedMap);
// related to disenchant rolls
void ResetMaxEnchantingLevel();
void LinkMember(GroupReference* pRef);
// FG: evil hacks
void BroadcastGroupUpdate(void);
// LFG
void AddLfgBuffFlag() { m_lfgGroupFlags |= GROUP_LFG_FLAG_APPLY_RANDOM_BUFF; }
void AddLfgRandomInstanceFlag() { m_lfgGroupFlags |= GROUP_LFG_FLAG_IS_RANDOM_INSTANCE; }
void AddLfgHeroicFlag() { m_lfgGroupFlags |= GROUP_LFG_FLAG_IS_HEROIC; }
bool IsLfgWithBuff() const { return isLFGGroup() && (m_lfgGroupFlags & GROUP_LFG_FLAG_APPLY_RANDOM_BUFF); }
bool IsLfgRandomInstance() const { return isLFGGroup() && (m_lfgGroupFlags & GROUP_LFG_FLAG_IS_RANDOM_INSTANCE); }
bool IsLfgHeroic() const { return isLFGGroup() && (m_lfgGroupFlags & GROUP_LFG_FLAG_IS_HEROIC); }
// Difficulty Change
uint32 GetDifficultyChangePreventionTime() const { return _difficultyChangePreventionTime > time(NULL) ? _difficultyChangePreventionTime - time(NULL) : 0; }
DifficultyPreventionChangeType GetDifficultyChangePreventionReason() const { return _difficultyChangePreventionType; }
void SetDifficultyChangePrevention(DifficultyPreventionChangeType type)
{
_difficultyChangePreventionTime = time(NULL) + MINUTE;
_difficultyChangePreventionType = type;
}
protected:
void _homebindIfInstance(Player* player);
void _cancelHomebindIfInstance(Player* player);
void _initRaidSubGroupsCounter();
member_citerator _getMemberCSlot(uint64 Guid) const;
member_witerator _getMemberWSlot(uint64 Guid);
void SubGroupCounterIncrease(uint8 subgroup);
void SubGroupCounterDecrease(uint8 subgroup);
void ToggleGroupMemberFlag(member_witerator slot, uint8 flag, bool apply);
MemberSlotList m_memberSlots;
GroupRefManager m_memberMgr;
InvitesList m_invitees;
uint64 m_leaderGuid;
std::string m_leaderName;
GroupType m_groupType;
Difficulty m_dungeonDifficulty;
Difficulty m_raidDifficulty;
Battlefield* m_bfGroup;
Battleground* m_bgGroup;
uint64 m_targetIcons[TARGETICONCOUNT];
LootMethod m_lootMethod;
ItemQualities m_lootThreshold;
uint64 m_looterGuid;
uint64 m_masterLooterGuid;
Rolls RollId;
uint8* m_subGroupsCounts;
uint64 m_guid;
uint32 m_counter; // used only in SMSG_GROUP_LIST
uint32 m_maxEnchantingLevel;
uint8 m_lfgGroupFlags;
// Xinef: change difficulty prevention
uint32 _difficultyChangePreventionTime;
DifficultyPreventionChangeType _difficultyChangePreventionType;
};
#endif

View File

@@ -0,0 +1,180 @@
/*
* Copyright (C)
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Common.h"
#include "GroupMgr.h"
#include "InstanceSaveMgr.h"
#include "World.h"
#include "DBCStores.h"
GroupMgr::GroupMgr()
{
_nextGroupId = 0;
}
GroupMgr::~GroupMgr()
{
for (GroupContainer::iterator itr = GroupStore.begin(); itr != GroupStore.end(); ++itr)
delete itr->second;
}
void GroupMgr::InitGroupIds()
{
_nextGroupId = 1;
QueryResult result = CharacterDatabase.Query("SELECT MAX(guid) FROM groups");
if (result)
{
uint32 maxId = (*result)[0].GetUInt32();
_groupIds.resize(maxId+1);
}
}
void GroupMgr::RegisterGroupId(uint32 groupId)
{
// Allocation was done in InitGroupIds()
_groupIds[groupId] = true;
// Groups are pulled in ascending order from db and _nextGroupId is initialized with 1,
// so if the instance id is used, increment
if (_nextGroupId == groupId)
++_nextGroupId;
}
uint32 GroupMgr::GenerateGroupId()
{
uint32 newGroupId = _nextGroupId;
// find the lowest available id starting from the current _nextGroupId
while (_nextGroupId < 0xFFFFFFFF && ++_nextGroupId < _groupIds.size() && _groupIds[_nextGroupId]);
if (_nextGroupId == 0xFFFFFFFF)
{
sLog->outError("Group ID overflow!! Can't continue, shutting down server.");
World::StopNow(ERROR_EXIT_CODE);
}
return newGroupId;
}
Group* GroupMgr::GetGroupByGUID(uint32 groupId) const
{
GroupContainer::const_iterator itr = GroupStore.find(groupId);
if (itr != GroupStore.end())
return itr->second;
return NULL;
}
void GroupMgr::AddGroup(Group* group)
{
GroupStore[group->GetLowGUID()] = group;
}
void GroupMgr::RemoveGroup(Group* group)
{
GroupStore.erase(group->GetLowGUID());
}
void GroupMgr::LoadGroups()
{
{
uint32 oldMSTime = getMSTime();
// Delete all groups whose leader does not exist
CharacterDatabase.DirectExecute("DELETE FROM groups WHERE leaderGuid NOT IN (SELECT guid FROM characters)");
// Delete all groups with less than 2 members (or less than 1 for lfg groups)
CharacterDatabase.DirectExecute("DELETE groups FROM groups LEFT JOIN ((SELECT guid, count(*) as cnt FROM group_member GROUP BY guid) t) ON groups.guid = t.guid WHERE t.guid IS NULL OR (t.cnt<=1 AND groups.groupType <> 12)");
// Delete invalid lfg_data
CharacterDatabase.DirectExecute("DELETE lfg_data FROM lfg_data LEFT JOIN groups ON lfg_data.guid = groups.guid WHERE groups.guid IS NULL OR groups.groupType <> 12");
// CharacterDatabase.DirectExecute("DELETE groups FROM groups LEFT JOIN lfg_data ON groups.guid = lfg_data.guid WHERE groups.groupType=12 AND lfg_data.guid IS NULL"); // group should be left so binds are cleared when disbanded
InitGroupIds();
// 0 1 2 3 4 5 6 7 8 9
QueryResult result = CharacterDatabase.Query("SELECT g.leaderGuid, g.lootMethod, g.looterGuid, g.lootThreshold, g.icon1, g.icon2, g.icon3, g.icon4, g.icon5, g.icon6"
// 10 11 12 13 14 15 16 17 18
", g.icon7, g.icon8, g.groupType, g.difficulty, g.raiddifficulty, g.masterLooterGuid, g.guid, lfg.dungeon, lfg.state FROM groups g LEFT JOIN lfg_data lfg ON lfg.guid = g.guid ORDER BY g.guid ASC");
if (!result)
{
sLog->outString(">> Loaded 0 group definitions. DB table `groups` is empty!");
sLog->outString();
}
else
{
uint32 count = 0;
do
{
Field* fields = result->Fetch();
Group* group = new Group;
if (!group->LoadGroupFromDB(fields))
{
delete group;
continue;
}
AddGroup(group);
RegisterGroupId(group->GetLowGUID());
++count;
}
while (result->NextRow());
sLog->outString(">> Loaded %u group definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog->outString();
}
}
sLog->outString("Loading Group members...");
{
uint32 oldMSTime = getMSTime();
// Delete all rows from group_member with no group
CharacterDatabase.DirectExecute("DELETE FROM group_member WHERE guid NOT IN (SELECT guid FROM groups)");
// Delete all members that does not exist
CharacterDatabase.DirectExecute("DELETE FROM group_member WHERE memberGuid NOT IN (SELECT guid FROM characters)");
// 0 1 2 3 4
QueryResult result = CharacterDatabase.Query("SELECT guid, memberGuid, memberFlags, subgroup, roles FROM group_member ORDER BY guid");
if (!result)
{
sLog->outString(">> Loaded 0 group members. DB table `group_member` is empty!");
sLog->outString();
}
else
{
uint32 count = 0;
do
{
Field* fields = result->Fetch();
Group* group = GetGroupByGUID(fields[0].GetUInt32());
if (group)
group->LoadMemberFromDB(fields[1].GetUInt32(), fields[2].GetUInt8(), fields[3].GetUInt8(), fields[4].GetUInt8());
//else
// sLog->outError("GroupMgr::LoadGroups: Consistency failed, can't find group (storage id: %u)", fields[0].GetUInt32());
++count;
}
while (result->NextRow());
sLog->outString(">> Loaded %u group members in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog->outString();
}
}
}

View File

@@ -0,0 +1,53 @@
/*
* Copyright (C)
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _GROUPMGR_H
#define _GROUPMGR_H
#include "Group.h"
class GroupMgr
{
friend class ACE_Singleton<GroupMgr, ACE_Null_Mutex>;
private:
GroupMgr();
~GroupMgr();
public:
typedef std::map<uint32, Group*> GroupContainer;
Group* GetGroupByGUID(uint32 guid) const;
void InitGroupIds();
void RegisterGroupId(uint32 groupId);
uint32 GenerateGroupId();
void LoadGroups();
void AddGroup(Group* group);
void RemoveGroup(Group* group);
protected:
typedef std::vector<bool> GroupIds;
GroupIds _groupIds;
uint32 _nextGroupId;
GroupContainer GroupStore;
};
#define sGroupMgr ACE_Singleton<GroupMgr, ACE_Null_Mutex>::instance()
#endif

View File

@@ -0,0 +1,35 @@
/*
* Copyright (C)
* Copyright (C)
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _GROUPREFMANAGER
#define _GROUPREFMANAGER
#include "RefManager.h"
class Group;
class Player;
class GroupReference;
class GroupRefManager : public RefManager<Group, Player>
{
public:
GroupReference* getFirst() { return ((GroupReference*)RefManager<Group, Player>::getFirst()); }
GroupReference const* getFirst() const { return ((GroupReference const*)RefManager<Group, Player>::getFirst()); }
};
#endif

View File

@@ -0,0 +1,37 @@
/*
* Copyright (C)
* Copyright (C)
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Group.h"
#include "GroupReference.h"
void GroupReference::targetObjectBuildLink()
{
// called from link()
getTarget()->LinkMember(this);
}
void GroupReference::targetObjectDestroyLink()
{
// called from unlink()
}
void GroupReference::sourceObjectDestroyLink()
{
// called from invalidate()
}

View File

@@ -0,0 +1,43 @@
/*
* Copyright (C)
* Copyright (C)
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _GROUPREFERENCE_H
#define _GROUPREFERENCE_H
#include "LinkedReference/Reference.h"
class Group;
class Player;
class GroupReference : public Reference<Group, Player>
{
protected:
uint8 iSubGroup;
void targetObjectBuildLink();
void targetObjectDestroyLink();
void sourceObjectDestroyLink();
public:
GroupReference() : Reference<Group, Player>(), iSubGroup(0) {}
~GroupReference() { unlink(); }
GroupReference* next() { return (GroupReference*)Reference<Group, Player>::next(); }
GroupReference const* next() const { return (GroupReference const*)Reference<Group, Player>::next(); }
uint8 getSubGroup() const { return iSubGroup; }
void setSubGroup(uint8 pSubGroup) { iSubGroup = pSubGroup; }
};
#endif