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:
Shauren
2010-08-02 17:28:47 +02:00
parent 21db4757a9
commit 46c1a4640d
10 changed files with 36 additions and 52 deletions
+9 -13
View File
@@ -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());
+5 -5
View File
@@ -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;