aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Globals/ObjectMgr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Globals/ObjectMgr.cpp')
-rwxr-xr-xsrc/server/game/Globals/ObjectMgr.cpp209
1 files changed, 2 insertions, 207 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index 870e3cc2790..9a2f078de15 100755
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -23,10 +23,10 @@
#include "ObjectMgr.h"
#include "ArenaTeamMgr.h"
#include "GuildMgr.h"
+#include "GroupMgr.h"
#include "SpellMgr.h"
#include "UpdateMask.h"
#include "World.h"
-#include "Group.h"
#include "ArenaTeam.h"
#include "Transport.h"
#include "Language.h"
@@ -265,13 +265,11 @@ ObjectMgr::ObjectMgr()
m_hiDoGuid = 1;
m_hiCorpseGuid = 1;
m_hiPetNumber = 1;
- m_hiGroupGuid = 1;
m_hiMoTransGuid = 1;
m_ItemTextId = 1;
m_mailid = 1;
m_equipmentSetGuid = 1;
m_auctionid = 1;
- NextGroupStorageId = 1;
}
ObjectMgr::~ObjectMgr()
@@ -290,33 +288,12 @@ ObjectMgr::~ObjectMgr()
for (int class_ = 0; class_ < MAX_CLASSES; ++class_)
delete[] playerInfo[race][class_].levelInfo;
- // free group and guild objects
- for (GroupSet::iterator itr = mGroupSet.begin(); itr != mGroupSet.end(); ++itr)
- delete *itr;
-
for (CacheVendorItemMap::iterator itr = m_mCacheVendorItemMap.begin(); itr != m_mCacheVendorItemMap.end(); ++itr)
itr->second.Clear();
m_mCacheTrainerSpellMap.clear();
}
-Group * ObjectMgr::GetGroupByGUID(uint32 guid) const
-{
- for (GroupSet::const_iterator itr = mGroupSet.begin(); itr != mGroupSet.end(); ++itr)
- if ((*itr)->GetLowGUID() == guid)
- return *itr;
-
- return NULL;
-}
-
-Group* ObjectMgr::GetGroupByStorageId(uint32 storageId) const
-{
- if (storageId < mGroupStorage.size())
- return mGroupStorage[storageId];
-
- return NULL;
-}
-
void ObjectMgr::AddLocaleString(std::string& s, LocaleConstant locale, StringVector& data)
{
if (!s.empty())
@@ -3787,140 +3764,6 @@ void ObjectMgr::BuildPlayerLevelInfo(uint8 race, uint8 _class, uint8 level, Play
}
}
-void ObjectMgr::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
- CharacterDatabase.DirectExecute("DELETE FROM groups WHERE guid NOT IN (SELECT guid FROM group_member GROUP BY guid HAVING COUNT(guid) > 1)");
-
- // 0 1 2 3 4 5 6 7 8 9
- QueryResult result = CharacterDatabase.PQuery("SELECT leaderGuid, lootMethod, looterGuid, lootThreshold, icon1, icon2, icon3, icon4, icon5, icon6"
- // 10 11 12 13 14 15
- ", icon7, icon8, groupType, difficulty, raiddifficulty, guid FROM groups ORDER BY guid ASC");
- if (!result)
- {
- sLog->outString(">> Loaded 0 group definitions. DB table `groups` is empty!");
- sLog->outString();
- return;
- }
-
- uint32 count = 0;
-
- do
- {
- Field *fields = result->Fetch();
- Group *group = new Group;
- group->LoadGroupFromDB(fields);
- AddGroup(group);
-
- //
- uint32 storageId = group->GetStorageId();
-
- RegisterGroupStorageId(storageId, group);
-
- if (storageId == NextGroupStorageId)
- NextGroupStorageId++;
-
- ++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 or group_instance with no group
- CharacterDatabase.DirectExecute("DELETE FROM group_member WHERE guid NOT IN (SELECT guid FROM groups)");
- CharacterDatabase.DirectExecute("DELETE FROM group_instance 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();
- return;
- }
-
- uint32 count = 0;
-
- do
- {
- Field* fields = result->Fetch();
- Group* group = GetGroupByStorageId(fields[0].GetUInt32());
-
- if (group)
- group->LoadMemberFromDB(fields[1].GetUInt32(), fields[2].GetUInt8(), fields[3].GetUInt8(), fields[4].GetUInt8());
- else
- sLog->outError("ObjectMgr::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();
- }
-
- sLog->outString("Loading Group instance saves...");
- {
- uint32 oldMSTime = getMSTime();
-
- // 0 1 2 3 4 5
- QueryResult result = CharacterDatabase.Query("SELECT guid, map, instance, permanent, difficulty, resettime, "
- // 6
- "(SELECT COUNT(1) FROM groups JOIN character_instance ON leaderGuid = groups.guid WHERE instance = group_instance.instance AND permanent = 1 LIMIT 1) "
- "FROM group_instance LEFT JOIN instance ON instance = id ORDER BY guid");
-
- if (!result)
- {
- sLog->outString();
- sLog->outString(">> Loaded 0 group-instance saves. DB table `group_instance` is empty!");
- return;
- }
-
- uint32 count = 0;
- do
- {
- Field *fields = result->Fetch();
- Group *group = GetGroupByStorageId(fields[0].GetUInt32());
- // group will never be NULL (we have run consistency sql's before loading)
-
- MapEntry const* mapEntry = sMapStore.LookupEntry(fields[1].GetUInt32());
- if (!mapEntry || !mapEntry->IsDungeon())
- {
- sLog->outErrorDb("Incorrect entry in group_instance table : no dungeon map %d", fields[1].GetUInt32());
- continue;
- }
-
- uint32 diff = fields[4].GetUInt8();
- if (diff >= uint32(mapEntry->IsRaid() ? MAX_RAID_DIFFICULTY : MAX_DUNGEON_DIFFICULTY))
- {
- sLog->outErrorDb("Wrong dungeon difficulty use in group_instance table: %d", diff + 1);
- diff = 0; // default for both difficaly types
- }
-
- InstanceSave *save = sInstanceSaveMgr->AddInstanceSave(mapEntry->MapID, fields[2].GetUInt32(), Difficulty(diff), time_t(fields[5].GetUInt64()), fields[6].GetBool(), true);
- group->BindToInstance(save, fields[3].GetBool(), true);
- ++count;
- }
- while (result->NextRow());
-
- sLog->outString(">> Loaded %u group-instance saves in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
- sLog->outString();
- }
-}
-
void ObjectMgr::LoadQuests()
{
uint32 oldMSTime = getMSTime();
@@ -6474,7 +6317,7 @@ void ObjectMgr::SetHighestGuids()
result = CharacterDatabase.Query("SELECT MAX(guid) FROM groups");
if (result)
- mGroupStorage.resize((*result)[0].GetUInt32()+1);
+ sGroupMgr->SetGroupDbStoreSize((*result)[0].GetUInt32()+1);
}
@@ -6569,13 +6412,6 @@ uint32 ObjectMgr::GenerateLowGuid(HighGuid guidhigh)
World::StopNow(ERROR_EXIT_CODE);
}
return m_hiDoGuid++;
- case HIGHGUID_GROUP:
- if (m_hiGroupGuid >= 0xFFFFFFFE)
- {
- sLog->outError("Group guid overflow!! Can't continue, shutting down server. ");
- World::StopNow(ERROR_EXIT_CODE);
- }
- return m_hiGroupGuid++;
case HIGHGUID_MO_TRANSPORT:
if (m_hiMoTransGuid >= 0xFFFFFFFE)
{
@@ -9221,47 +9057,6 @@ void ObjectMgr::LoadFactionChangeReputations()
sLog->outString();
}
-uint32 ObjectMgr::GenerateNewGroupStorageId()
-{
- uint32 newStorageId = NextGroupStorageId;
-
- for (uint32 i = ++NextGroupStorageId; i < 0xFFFFFFFF; ++i)
- {
- if ((i < mGroupStorage.size() && mGroupStorage[i] == NULL) || i >= mGroupStorage.size())
- {
- NextGroupStorageId = i;
- break;
- }
- }
-
- if (newStorageId == NextGroupStorageId)
- {
- sLog->outError("Group storage ID overflow!! Can't continue, shutting down server. ");
- World::StopNow(ERROR_EXIT_CODE);
- }
-
- return newStorageId;
-}
-
-void ObjectMgr::RegisterGroupStorageId(uint32 storageId, Group* group)
-{
- // Allocate space if necessary.
- if (storageId >= uint32(mGroupStorage.size()))
- mGroupStorage.resize(storageId + 1);
-
- mGroupStorage[storageId] = group;
-}
-
-void ObjectMgr::FreeGroupStorageId(Group* group)
-{
- uint32 storageId = group->GetStorageId();
-
- if (storageId < NextGroupStorageId)
- NextGroupStorageId = storageId;
-
- mGroupStorage[storageId] = NULL;
-}
-
GameObjectTemplate const* ObjectMgr::GetGameObjectTemplate(uint32 entry)
{
GameObjectTemplateContainer::const_iterator itr = GameObjectTemplateStore.find(entry);