mirror of
https://github.com/araxiaonline/TrinityCore2.git
synced 2026-06-18 05:49:41 -04:00
Groups are now stored by low guid in map
Creatures and gameobjects also store looting group by low guid instead of full guid --HG-- branch : trunk
This commit is contained in:
@@ -140,7 +140,7 @@ bool ForcedDespawnDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
|
||||
|
||||
Creature::Creature() :
|
||||
Unit(),
|
||||
lootForPickPocketed(false), lootForBody(false), m_groupLootTimer(0), lootingGroupGUID(0),
|
||||
lootForPickPocketed(false), lootForBody(false), m_groupLootTimer(0), lootingGroupLowGUID(0),
|
||||
m_lootMoney(0), m_lootRecipient(0),
|
||||
m_deathTimer(0), m_respawnTime(0), m_respawnDelay(300), m_corpseDelay(60), m_respawnradius(0.0f),
|
||||
m_defaultMovementType(IDLE_MOTION_TYPE), m_DBTableGuid(0), m_equipmentId(0), m_AlreadyCallAssistance(false),
|
||||
@@ -472,18 +472,18 @@ void Creature::Update(uint32 diff)
|
||||
if (m_isDeadByDefault)
|
||||
break;
|
||||
|
||||
if (m_groupLootTimer && lootingGroupGUID)
|
||||
if (m_groupLootTimer && lootingGroupLowGUID)
|
||||
{
|
||||
// for delayed spells
|
||||
m_Events.Update(diff);
|
||||
|
||||
if (m_groupLootTimer <= diff)
|
||||
{
|
||||
Group* group = objmgr.GetGroupByGUID(lootingGroupGUID);
|
||||
Group* group = objmgr.GetGroupByGUID(lootingGroupLowGUID);
|
||||
if (group)
|
||||
group->EndRoll(&loot);
|
||||
m_groupLootTimer = 0;
|
||||
lootingGroupGUID = 0;
|
||||
lootingGroupLowGUID = 0;
|
||||
}
|
||||
else m_groupLootTimer -= diff;
|
||||
}
|
||||
|
||||
@@ -611,7 +611,7 @@ class Creature : public Unit, public GridObject<Creature>
|
||||
const CreatureData* GetLinkedRespawnCreatureData() const;
|
||||
|
||||
uint32 m_groupLootTimer; // (msecs)timer used for group loot
|
||||
uint64 lootingGroupGUID; // used to find group which is looting corpse
|
||||
uint32 lootingGroupLowGUID; // used to find group which is looting corpse
|
||||
|
||||
void SendZoneUnderAttackMessage(Player* attacker);
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ GameObject::GameObject() : WorldObject(), m_goValue(new GameObjectValue)
|
||||
m_rotation = 0;
|
||||
|
||||
m_groupLootTimer = 0;
|
||||
lootingGroupGUID = 0;
|
||||
lootingGroupLowGUID = 0;
|
||||
|
||||
ResetLootMode(); // restore default loot mode
|
||||
}
|
||||
@@ -444,11 +444,11 @@ void GameObject::Update(uint32 diff)
|
||||
{
|
||||
if (m_groupLootTimer <= diff)
|
||||
{
|
||||
Group* group = objmgr.GetGroupByGUID(lootingGroupGUID);
|
||||
Group* group = objmgr.GetGroupByGUID(lootingGroupLowGUID);
|
||||
if (group)
|
||||
group->EndRoll(&loot);
|
||||
m_groupLootTimer = 0;
|
||||
lootingGroupGUID = 0;
|
||||
lootingGroupLowGUID = 0;
|
||||
}
|
||||
else m_groupLootTimer -= diff;
|
||||
}
|
||||
|
||||
@@ -719,7 +719,7 @@ class GameObject : public WorldObject, public GridObject<GameObject>
|
||||
Loot loot;
|
||||
|
||||
uint32 m_groupLootTimer; // (msecs)timer used for group loot
|
||||
uint64 lootingGroupGUID; // used to find group which is looting
|
||||
uint32 lootingGroupLowGUID; // used to find group which is looting
|
||||
|
||||
bool hasQuest(uint32 quest_id) const;
|
||||
bool hasInvolvedQuest(uint32 quest_id) const;
|
||||
|
||||
@@ -628,7 +628,7 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask
|
||||
dynamicFlags &= ~UNIT_DYNFLAG_TAPPED_BY_PLAYER;
|
||||
}
|
||||
|
||||
if (!target->isAllowedToLoot(ToCreature()))
|
||||
if (!target->isAllowedToLoot(creature))
|
||||
dynamicFlags &= ~UNIT_DYNFLAG_LOOTABLE;
|
||||
}
|
||||
|
||||
|
||||
@@ -4384,11 +4384,8 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC
|
||||
// the player was uninvited already on logout so just remove from group
|
||||
QueryResult_AutoPtr resultGroup = CharacterDatabase.PQuery("SELECT guid FROM group_member WHERE memberGuid=%u", guid);
|
||||
if (resultGroup)
|
||||
{
|
||||
uint64 guid = MAKE_NEW_GUID((*resultGroup)[0].GetUInt32(), 0, HIGHGUID_GROUP);
|
||||
if (Group* group = objmgr.GetGroupByGUID(guid))
|
||||
if (Group* group = objmgr.GetGroupByGUID((*resultGroup)[0].GetUInt32()))
|
||||
RemoveFromGroup(group, playerguid);
|
||||
}
|
||||
|
||||
// Remove signs from petitions (also remove petitions if owner);
|
||||
RemovePetitionsAndSigns(playerguid, 10);
|
||||
@@ -17203,8 +17200,7 @@ void Player::_LoadGroup(QueryResult_AutoPtr result)
|
||||
//QueryResult *result = CharacterDatabase.PQuery("SELECT guid FROM group_member WHERE memberGuid=%u", GetGUIDLow());
|
||||
if (result)
|
||||
{
|
||||
uint64 guid = MAKE_NEW_GUID((*result)[0].GetUInt32(), 0, HIGHGUID_GROUP);
|
||||
if (Group* group = objmgr.GetGroupByGUID(guid))
|
||||
if (Group* group = objmgr.GetGroupByGUID((*result)[0].GetUInt32()))
|
||||
{
|
||||
uint8 subgroup = group->GetMemberGroup(GetGUID());
|
||||
SetGroup(group, subgroup);
|
||||
|
||||
@@ -199,8 +199,8 @@ ObjectMgr::~ObjectMgr()
|
||||
delete[] playerInfo[race][class_].levelInfo;
|
||||
|
||||
// free group and guild objects
|
||||
for (GroupSet::iterator itr = mGroupSet.begin(); itr != mGroupSet.end(); ++itr)
|
||||
delete (*itr);
|
||||
for (GroupMap::iterator itr = mGroupMap.begin(); itr != mGroupMap.end(); ++itr)
|
||||
delete itr->second;
|
||||
|
||||
for (GuildMap::iterator itr = mGuildMap.begin(); itr != mGuildMap.end(); ++itr)
|
||||
delete itr->second;
|
||||
@@ -215,11 +215,11 @@ ObjectMgr::~ObjectMgr()
|
||||
itr->second.Clear();
|
||||
}
|
||||
|
||||
Group * ObjectMgr::GetGroupByGUID(const uint64 &guid) const
|
||||
Group * ObjectMgr::GetGroupByGUID(const uint32 &guid) const
|
||||
{
|
||||
for (GroupSet::const_iterator itr = mGroupSet.begin(); itr != mGroupSet.end(); ++itr)
|
||||
if ((*itr)->GetGUID() == guid)
|
||||
return *itr;
|
||||
GroupMap::const_iterator itr = mGroupMap.find(guid);
|
||||
if (itr != mGroupMap.end())
|
||||
return itr->second;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -3525,7 +3525,6 @@ void ObjectMgr::LoadGroups()
|
||||
{
|
||||
Group *group = NULL;
|
||||
Field *fields = NULL;
|
||||
uint64 groupGuid = 0;
|
||||
uint32 count = 0;
|
||||
|
||||
// Consistency cleaning before load to avoid having to do some checks later
|
||||
@@ -3559,8 +3558,7 @@ void ObjectMgr::LoadGroups()
|
||||
fields = result->Fetch();
|
||||
++count;
|
||||
group = new Group;
|
||||
groupGuid = MAKE_NEW_GUID(fields[15].GetUInt32(),0,HIGHGUID_GROUP);
|
||||
group->LoadGroupFromDB(groupGuid, result, false);
|
||||
group->LoadGroupFromDB(fields[15].GetUInt32(), result, false);
|
||||
// group load will never be false (we have run consistency sql's before loading)
|
||||
AddGroup(group);
|
||||
}while (result->NextRow());
|
||||
@@ -3591,8 +3589,7 @@ void ObjectMgr::LoadGroups()
|
||||
if (groupLowGuid != fields[0].GetUInt32())
|
||||
{
|
||||
groupLowGuid = fields[0].GetUInt32();
|
||||
groupGuid = MAKE_NEW_GUID(groupLowGuid, 0, HIGHGUID_GROUP);
|
||||
group = GetGroupByGUID(groupGuid);
|
||||
group = GetGroupByGUID(groupLowGuid);
|
||||
// group will never be NULL (we have run consistency sql's before loading)
|
||||
}
|
||||
group->LoadMemberFromDB(fields[1].GetUInt32(), fields[2].GetUInt8(), fields[3].GetUInt8());
|
||||
@@ -3625,8 +3622,7 @@ void ObjectMgr::LoadGroups()
|
||||
{
|
||||
bar3.step();
|
||||
fields = result->Fetch();
|
||||
groupGuid = MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_GROUP);
|
||||
group = GetGroupByGUID(groupGuid);
|
||||
group = GetGroupByGUID(fields[0].GetUInt32());
|
||||
// group will never be NULL (we have run consistency sql's before loading)
|
||||
|
||||
MapEntry const* mapEntry = sMapStore.LookupEntry(fields[1].GetUInt32());
|
||||
|
||||
@@ -377,7 +377,7 @@ class ObjectMgr
|
||||
public:
|
||||
typedef UNORDERED_MAP<uint32, Item*> ItemMap;
|
||||
|
||||
typedef std::set< Group * > GroupSet;
|
||||
typedef UNORDERED_MAP<uint32, Group *> GroupMap;
|
||||
|
||||
typedef UNORDERED_MAP<uint32, Guild *> GuildMap;
|
||||
|
||||
@@ -410,9 +410,9 @@ class ObjectMgr
|
||||
void LoadGameobjectInfo();
|
||||
void AddGameobjectInfo(GameObjectInfo *goinfo);
|
||||
|
||||
Group * GetGroupByGUID(const uint64 &guid) const;
|
||||
void AddGroup(Group* group) { mGroupSet.insert(group); }
|
||||
void RemoveGroup(Group* group) { mGroupSet.erase(group); }
|
||||
Group * GetGroupByGUID(const uint32 &guid) const;
|
||||
void AddGroup(Group* group) { mGroupMap[group->GetLowGUID()] = group; }
|
||||
void RemoveGroup(Group* group) { mGroupMap.erase(group->GetLowGUID()); }
|
||||
|
||||
Guild* GetGuildByLeader(uint64 const&guid) const;
|
||||
Guild* GetGuildById(uint32 GuildId) const;
|
||||
@@ -1012,7 +1012,7 @@ class ObjectMgr
|
||||
typedef std::set<uint32> TavernAreaTriggerSet;
|
||||
typedef std::set<uint32> GameObjectForQuestSet;
|
||||
|
||||
GroupSet mGroupSet;
|
||||
GroupMap mGroupMap;
|
||||
GuildMap mGuildMap;
|
||||
ArenaTeamMap mArenaTeamMap;
|
||||
|
||||
|
||||
@@ -132,31 +132,22 @@ bool Group::Create(const uint64 &guid, const char * name)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Group::LoadGroupFromDB(const uint64 &groupGuid, QueryResult_AutoPtr result, bool loadMembers)
|
||||
bool Group::LoadGroupFromDB(const uint32 &groupGuid, QueryResult_AutoPtr result, bool loadMembers)
|
||||
{
|
||||
if (isBGGroup())
|
||||
return false;
|
||||
|
||||
uint32 groupLowGuid = GUID_LOPART(groupGuid);
|
||||
if (!result)
|
||||
{
|
||||
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
||||
result = CharacterDatabase.PQuery("SELECT leaderGuid, lootMethod, looterGuid, lootThreshold, icon1, icon2, icon3, icon4, icon5, icon6, icon7, icon8, groupType, difficulty, raiddifficulty FROM groups WHERE guid=%u", groupLowGuid);
|
||||
|
||||
if (!result)
|
||||
return false;
|
||||
}
|
||||
Field *fields = result->Fetch();
|
||||
m_guid = groupGuid;
|
||||
m_guid = MAKE_NEW_GUID(groupGuid, 0, HIGHGUID_GROUP);
|
||||
m_leaderGuid = MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER);
|
||||
|
||||
// group leader not exist
|
||||
if (!objmgr.GetPlayerNameByGUID(fields[0].GetUInt32(), m_leaderName))
|
||||
return false;
|
||||
|
||||
m_lootMethod = (LootMethod)fields[1].GetUInt8();
|
||||
m_lootMethod = LootMethod(fields[1].GetUInt8());
|
||||
m_looterGuid = MAKE_NEW_GUID(fields[2].GetUInt32(), 0, HIGHGUID_PLAYER);
|
||||
m_lootThreshold = (ItemQualities)fields[3].GetUInt16();
|
||||
m_lootThreshold = ItemQualities(fields[3].GetUInt16());
|
||||
|
||||
for (uint8 i = 0; i < TARGETICONCOUNT; ++i)
|
||||
m_targetIcons[i] = fields[4+i].GetUInt64();
|
||||
@@ -177,7 +168,7 @@ bool Group::LoadGroupFromDB(const uint64 &groupGuid, QueryResult_AutoPtr result,
|
||||
|
||||
if (loadMembers)
|
||||
{
|
||||
result = CharacterDatabase.PQuery("SELECT memberGuid, memberFlags, subgroup FROM group_member WHERE guid=%u", groupLowGuid);
|
||||
result = CharacterDatabase.PQuery("SELECT memberGuid, memberFlags, subgroup FROM group_member WHERE guid=%u", groupGuid);
|
||||
if (!result)
|
||||
return false;
|
||||
|
||||
@@ -684,12 +675,12 @@ void Group::GroupLoot(Loot *loot, WorldObject* pLootedObject)
|
||||
if (Creature* creature = dynamic_cast<Creature *>(pLootedObject))
|
||||
{
|
||||
creature->m_groupLootTimer = 60000;
|
||||
creature->lootingGroupGUID = GetGUID();
|
||||
creature->lootingGroupLowGUID = GetLowGUID();
|
||||
}
|
||||
else if (GameObject* go = dynamic_cast<GameObject *>(pLootedObject))
|
||||
{
|
||||
go->m_groupLootTimer = 60000;
|
||||
go->lootingGroupGUID = GetGUID();
|
||||
go->lootingGroupLowGUID = GetLowGUID();
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -778,7 +769,7 @@ void Group::NeedBeforeGreed(Loot *loot, WorldObject* pLootedObject)
|
||||
if (Creature* creature = dynamic_cast<Creature *>(pLootedObject))
|
||||
{
|
||||
creature->m_groupLootTimer = 60000;
|
||||
creature->lootingGroupGUID = GetGUID();
|
||||
creature->lootingGroupLowGUID = GetLowGUID();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -175,7 +175,7 @@ class Group
|
||||
|
||||
// group manipulation methods
|
||||
bool Create(const uint64 &guid, const char * name);
|
||||
bool LoadGroupFromDB(const uint64 &guid, QueryResult_AutoPtr result = QueryResult_AutoPtr(NULL), bool loadMembers = true);
|
||||
bool LoadGroupFromDB(const uint32 &guid, QueryResult_AutoPtr result = QueryResult_AutoPtr(NULL), bool loadMembers = true);
|
||||
bool LoadMemberFromDB(uint32 guidLow, uint8 memberFlags, uint8 subgroup);
|
||||
bool AddInvite(Player *player);
|
||||
uint32 RemoveInvite(Player *player);
|
||||
@@ -198,6 +198,7 @@ class Group
|
||||
bool IsCreated() const { return GetMembersCount() > 0; }
|
||||
const uint64& GetLeaderGUID() const { return m_leaderGuid; }
|
||||
const uint64& GetGUID() const { return m_guid; }
|
||||
const uint32& GetLowGUID() const { return GUID_LOPART(m_guid); }
|
||||
const char * GetLeaderName() const { return m_leaderName.c_str(); }
|
||||
LootMethod GetLootMethod() const { return m_lootMethod; }
|
||||
const uint64& GetLooterGuid() const { return m_looterGuid; }
|
||||
|
||||
Reference in New Issue
Block a user