Merge branch 'master' of github.com:TrinityCore/TrinityCore
This commit is contained in:
@@ -285,7 +285,7 @@ ObjectMgr::~ObjectMgr()
|
|||||||
delete[] playerInfo[race][class_].levelInfo;
|
delete[] playerInfo[race][class_].levelInfo;
|
||||||
|
|
||||||
// free group and guild objects
|
// free group and guild objects
|
||||||
for (GroupSet::iterator itr = mGroupSet.begin(); itr != mGroupSet.end(); ++itr)
|
for (GroupMap::iterator itr = mGroupMap.begin(); itr != mGroupMap.end(); ++itr)
|
||||||
delete *itr;
|
delete *itr;
|
||||||
|
|
||||||
for (GuildMap::iterator itr = mGuildMap.begin(); itr != mGuildMap.end(); ++itr)
|
for (GuildMap::iterator itr = mGuildMap.begin(); itr != mGuildMap.end(); ++itr)
|
||||||
@@ -303,10 +303,9 @@ ObjectMgr::~ObjectMgr()
|
|||||||
|
|
||||||
Group * ObjectMgr::GetGroupByGUID(uint32 guid) const
|
Group * ObjectMgr::GetGroupByGUID(uint32 guid) const
|
||||||
{
|
{
|
||||||
for (GroupSet::const_iterator itr = mGroupSet.begin(); itr != mGroupSet.end(); ++itr)
|
// Make sure given index exists in collection
|
||||||
if ((*itr)->GetLowGUID() == guid)
|
if (guid < uint32(mGroupMap.size()))
|
||||||
return *itr;
|
return mGroupMap[guid];
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3980,7 +3979,7 @@ void ObjectMgr::LoadGroups()
|
|||||||
// 0 1 2 3 4 5 6 7 8 9
|
// 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"
|
QueryResult result = CharacterDatabase.PQuery("SELECT leaderGuid, lootMethod, looterGuid, lootThreshold, icon1, icon2, icon3, icon4, icon5, icon6"
|
||||||
// 10 11 12 13 14 15
|
// 10 11 12 13 14 15
|
||||||
",icon7, icon8, groupType, difficulty, raiddifficulty, guid FROM groups");
|
",icon7, icon8, groupType, difficulty, raiddifficulty, guid FROM groups ORDER BY guid ASC");
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
sLog->outString(">> Loaded 0 group definitions. DB table `groups` is empty!");
|
sLog->outString(">> Loaded 0 group definitions. DB table `groups` is empty!");
|
||||||
@@ -3993,9 +3992,17 @@ void ObjectMgr::LoadGroups()
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
Field *fields = result->Fetch();
|
Field *fields = result->Fetch();
|
||||||
|
|
||||||
|
uint32 guid = fields[15].GetUInt32();
|
||||||
|
|
||||||
|
// Groups are pulled in ascending order from db and m_hiGroupGuid is initialized with 1,
|
||||||
|
// so if the group slot is used increment until we find the first free one for a potential new group
|
||||||
|
if (sObjectMgr->GetNextGroupGuid() == guid)
|
||||||
|
sObjectMgr->SetNextGroupGuid(guid + 1);
|
||||||
|
|
||||||
++count;
|
++count;
|
||||||
Group *group = new Group;
|
Group *group = new Group;
|
||||||
group->LoadGroupFromDB(fields[15].GetUInt32(), result, false);
|
group->LoadGroupFromDB(guid, result, false);
|
||||||
// group load will never be false (we have run consistency sql's before loading)
|
// group load will never be false (we have run consistency sql's before loading)
|
||||||
AddGroup(group);
|
AddGroup(group);
|
||||||
}
|
}
|
||||||
@@ -6643,9 +6650,10 @@ void ObjectMgr::SetHighestGuids()
|
|||||||
if (result)
|
if (result)
|
||||||
m_guildId = (*result)[0].GetUInt32()+1;
|
m_guildId = (*result)[0].GetUInt32()+1;
|
||||||
|
|
||||||
|
// The next free guid is determined during group loading, here we just preallocate the group holder
|
||||||
result = CharacterDatabase.Query("SELECT MAX(guid) FROM groups");
|
result = CharacterDatabase.Query("SELECT MAX(guid) FROM groups");
|
||||||
if (result)
|
if (result)
|
||||||
m_hiGroupGuid = (*result)[0].GetUInt32()+1;
|
mGroupMap.resize((*result)[0].GetUInt32()+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 ObjectMgr::GenerateArenaTeamId()
|
uint32 ObjectMgr::GenerateArenaTeamId()
|
||||||
@@ -6759,12 +6767,26 @@ uint32 ObjectMgr::GenerateLowGuid(HighGuid guidhigh)
|
|||||||
}
|
}
|
||||||
return m_hiDoGuid++;
|
return m_hiDoGuid++;
|
||||||
case HIGHGUID_GROUP:
|
case HIGHGUID_GROUP:
|
||||||
if (m_hiGroupGuid >= 0xFFFFFFFE)
|
{
|
||||||
|
uint32 newGuid = m_hiGroupGuid;
|
||||||
|
|
||||||
|
for (uint32 i = ++m_hiGroupGuid; i < 0xFFFFFFFF; ++i)
|
||||||
|
{
|
||||||
|
if (!GetGroupByGUID(i))
|
||||||
|
{
|
||||||
|
m_hiGroupGuid = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If newGuid doesn't differ from m_hiGroupGuid after the loop there is no free guid available
|
||||||
|
if (newGuid == m_hiGroupGuid)
|
||||||
{
|
{
|
||||||
sLog->outError("Group guid overflow!! Can't continue, shutting down server. ");
|
sLog->outError("Group guid overflow!! Can't continue, shutting down server. ");
|
||||||
World::StopNow(ERROR_EXIT_CODE);
|
World::StopNow(ERROR_EXIT_CODE);
|
||||||
}
|
}
|
||||||
return m_hiGroupGuid++;
|
return newGuid;
|
||||||
|
}
|
||||||
case HIGHGUID_MO_TRANSPORT:
|
case HIGHGUID_MO_TRANSPORT:
|
||||||
if (m_hiMoTransGuid >= 0xFFFFFFFE)
|
if (m_hiMoTransGuid >= 0xFFFFFFFE)
|
||||||
{
|
{
|
||||||
@@ -9424,3 +9446,18 @@ void ObjectMgr::LoadFactionChangeReputations()
|
|||||||
sLog->outString(">> Loaded %u faction change reputation pairs in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
sLog->outString(">> Loaded %u faction change reputation pairs in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||||
sLog->outString();
|
sLog->outString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ObjectMgr::AddGroup(Group* group)
|
||||||
|
{
|
||||||
|
uint32 groupGuid = group->GetLowGUID();
|
||||||
|
// Allocate space if necessary.
|
||||||
|
if (groupGuid >= uint32(mGroupMap.size()))
|
||||||
|
mGroupMap.resize(groupGuid + 1);
|
||||||
|
|
||||||
|
mGroupMap[groupGuid] = group;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ObjectMgr::RemoveGroup(Group* group)
|
||||||
|
{
|
||||||
|
mGroupMap[group->GetLowGUID()] = NULL;
|
||||||
|
}
|
||||||
|
|||||||
@@ -591,7 +591,7 @@ class ObjectMgr
|
|||||||
public:
|
public:
|
||||||
typedef UNORDERED_MAP<uint32, Item*> ItemMap;
|
typedef UNORDERED_MAP<uint32, Item*> ItemMap;
|
||||||
|
|
||||||
typedef std::set<Group *> GroupSet;
|
typedef std::vector<Group *> GroupMap;
|
||||||
|
|
||||||
typedef std::vector <Guild *> GuildMap;
|
typedef std::vector <Guild *> GuildMap;
|
||||||
|
|
||||||
@@ -626,8 +626,10 @@ class ObjectMgr
|
|||||||
void AddGameobjectInfo(GameObjectInfo *goinfo);
|
void AddGameobjectInfo(GameObjectInfo *goinfo);
|
||||||
|
|
||||||
Group * GetGroupByGUID(uint32 guid) const;
|
Group * GetGroupByGUID(uint32 guid) const;
|
||||||
void AddGroup(Group* group) { mGroupSet.insert(group); }
|
void AddGroup(Group* group);
|
||||||
void RemoveGroup(Group* group) { mGroupSet.erase(group); }
|
void RemoveGroup(Group* group);
|
||||||
|
uint32 GetNextGroupGuid() { return m_hiGroupGuid; };
|
||||||
|
void SetNextGroupGuid(uint32 nextGuid) { m_hiGroupGuid = nextGuid; };
|
||||||
|
|
||||||
Guild* GetGuildByLeader(uint64 const&guid) const;
|
Guild* GetGuildByLeader(uint64 const&guid) const;
|
||||||
Guild* GetGuildById(uint32 guildId) const;
|
Guild* GetGuildById(uint32 guildId) const;
|
||||||
@@ -1269,7 +1271,7 @@ class ObjectMgr
|
|||||||
typedef std::set<uint32> TavernAreaTriggerSet;
|
typedef std::set<uint32> TavernAreaTriggerSet;
|
||||||
typedef std::set<uint32> GameObjectForQuestSet;
|
typedef std::set<uint32> GameObjectForQuestSet;
|
||||||
|
|
||||||
GroupSet mGroupSet;
|
GroupMap mGroupMap;
|
||||||
GuildMap mGuildMap;
|
GuildMap mGuildMap;
|
||||||
ArenaTeamMap mArenaTeamMap;
|
ArenaTeamMap mArenaTeamMap;
|
||||||
|
|
||||||
|
|||||||
@@ -635,6 +635,12 @@ void Group::Disband(bool hideDestroy /* = false */)
|
|||||||
CharacterDatabase.CommitTransaction(trans);
|
CharacterDatabase.CommitTransaction(trans);
|
||||||
ResetInstances(INSTANCE_RESET_GROUP_DISBAND, false, NULL);
|
ResetInstances(INSTANCE_RESET_GROUP_DISBAND, false, NULL);
|
||||||
ResetInstances(INSTANCE_RESET_GROUP_DISBAND, true, NULL);
|
ResetInstances(INSTANCE_RESET_GROUP_DISBAND, true, NULL);
|
||||||
|
|
||||||
|
// If the deleted group guid is lower than the one we have stored for the next group creation,
|
||||||
|
// use this one instead.
|
||||||
|
if (lowguid < sObjectMgr->GetNextGroupGuid())
|
||||||
|
sObjectMgr->SetNextGroupGuid(lowguid);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sObjectMgr->RemoveGroup(this);
|
sObjectMgr->RemoveGroup(this);
|
||||||
|
|||||||
@@ -123,7 +123,6 @@ class InstanceSaveManager
|
|||||||
~InstanceSaveManager();
|
~InstanceSaveManager();
|
||||||
|
|
||||||
typedef UNORDERED_MAP<uint32 /*InstanceId*/, InstanceSave*> InstanceSaveHashMap;
|
typedef UNORDERED_MAP<uint32 /*InstanceId*/, InstanceSave*> InstanceSaveHashMap;
|
||||||
typedef UNORDERED_MAP<uint32 /*mapId*/, InstanceSaveHashMap> InstanceSaveMapMap;
|
|
||||||
|
|
||||||
/* resetTime is a global propery of each (raid/heroic) map
|
/* resetTime is a global propery of each (raid/heroic) map
|
||||||
all instances of that map reset at the same time */
|
all instances of that map reset at the same time */
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ class MapManager
|
|||||||
{
|
{
|
||||||
friend class ACE_Singleton<MapManager, ACE_Thread_Mutex>;
|
friend class ACE_Singleton<MapManager, ACE_Thread_Mutex>;
|
||||||
typedef UNORDERED_MAP<uint32, Map*> MapMapType;
|
typedef UNORDERED_MAP<uint32, Map*> MapMapType;
|
||||||
typedef std::pair<UNORDERED_MAP<uint32, Map*>::iterator, bool> MapMapPair;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user