mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +00:00
[9338] Simplify group loading code.
This commit is contained in:
parent
9c346fc0a9
commit
b50c3a9355
4 changed files with 27 additions and 59 deletions
|
|
@ -124,71 +124,40 @@ bool Group::Create(const uint64 &guid, const char * name)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Group::LoadGroupFromDB(const uint64 &leaderGuid, QueryResult *result, bool loadMembers)
|
||||
bool Group::LoadGroupFromDB(Field* fields)
|
||||
{
|
||||
if(isBGGroup())
|
||||
return false;
|
||||
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
||||
// result = CharacterDatabase.Query("SELECT mainTank, mainAssistant, lootMethod, looterGuid, lootThreshold, icon1, icon2, icon3, icon4, icon5, icon6, icon7, icon8, isRaid, difficulty, raiddifficulty, leaderGuid FROM groups");
|
||||
|
||||
bool external = true;
|
||||
if(!result)
|
||||
{
|
||||
external = false;
|
||||
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
||||
result = CharacterDatabase.PQuery("SELECT mainTank, mainAssistant, lootMethod, looterGuid, lootThreshold, icon1, icon2, icon3, icon4, icon5, icon6, icon7, icon8, isRaid, difficulty, raiddifficulty FROM groups WHERE leaderGuid ='%u'", GUID_LOPART(leaderGuid));
|
||||
if(!result)
|
||||
return false;
|
||||
}
|
||||
|
||||
m_leaderGuid = leaderGuid;
|
||||
m_leaderGuid = MAKE_NEW_GUID(fields[16].GetUInt32(),0,HIGHGUID_PLAYER);
|
||||
|
||||
// group leader not exist
|
||||
if(!sObjectMgr.GetPlayerNameByGUID(m_leaderGuid, m_leaderName))
|
||||
{
|
||||
if(!external) delete result;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_groupType = (*result)[13].GetBool() ? GROUPTYPE_RAID : GROUPTYPE_NORMAL;
|
||||
m_groupType = fields[13].GetBool() ? GROUPTYPE_RAID : GROUPTYPE_NORMAL;
|
||||
|
||||
if (m_groupType == GROUPTYPE_RAID)
|
||||
_initRaidSubGroupsCounter();
|
||||
|
||||
uint32 diff = (*result)[14].GetUInt8();
|
||||
uint32 diff = fields[14].GetUInt8();
|
||||
if (diff >= MAX_DUNGEON_DIFFICULTY)
|
||||
diff = DUNGEON_DIFFICULTY_NORMAL;
|
||||
m_dungeonDifficulty = Difficulty(diff);
|
||||
|
||||
uint32 r_diff = (*result)[15].GetUInt8();
|
||||
uint32 r_diff = fields[15].GetUInt8();
|
||||
if (r_diff >= MAX_RAID_DIFFICULTY)
|
||||
r_diff = RAID_DIFFICULTY_10MAN_NORMAL;
|
||||
m_raidDifficulty = Difficulty(r_diff);
|
||||
|
||||
m_mainTank = (*result)[0].GetUInt64();
|
||||
m_mainAssistant = (*result)[1].GetUInt64();
|
||||
m_lootMethod = (LootMethod)(*result)[2].GetUInt8();
|
||||
m_looterGuid = MAKE_NEW_GUID((*result)[3].GetUInt32(), 0, HIGHGUID_PLAYER);
|
||||
m_lootThreshold = (ItemQualities)(*result)[4].GetUInt16();
|
||||
m_mainTank = fields[0].GetUInt64();
|
||||
m_mainAssistant = fields[1].GetUInt64();
|
||||
m_lootMethod = (LootMethod)fields[2].GetUInt8();
|
||||
m_looterGuid = MAKE_NEW_GUID(fields[3].GetUInt32(), 0, HIGHGUID_PLAYER);
|
||||
m_lootThreshold = (ItemQualities)fields[4].GetUInt16();
|
||||
|
||||
for(int i = 0; i < TARGETICONCOUNT; ++i)
|
||||
m_targetIcons[i] = (*result)[5+i].GetUInt64();
|
||||
if(!external)
|
||||
delete result;
|
||||
|
||||
if(loadMembers)
|
||||
{
|
||||
result = CharacterDatabase.PQuery("SELECT memberGuid, assistant, subgroup FROM group_member WHERE leaderGuid ='%u'", GUID_LOPART(leaderGuid));
|
||||
if(!result)
|
||||
return false;
|
||||
|
||||
do
|
||||
{
|
||||
LoadMemberFromDB((*result)[0].GetUInt32(), (*result)[2].GetUInt8(), (*result)[1].GetBool());
|
||||
} while( result->NextRow() );
|
||||
delete result;
|
||||
// group too small
|
||||
if(GetMembersCount() < 2)
|
||||
return false;
|
||||
}
|
||||
m_targetIcons[i] = fields[5+i].GetUInt64();
|
||||
|
||||
m_Id = sObjectMgr.GenerateGroupId();
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ class MANGOS_DLL_SPEC Group
|
|||
|
||||
// group manipulation methods
|
||||
bool Create(const uint64 &guid, const char * name);
|
||||
bool LoadGroupFromDB(const uint64 &leaderGuid, QueryResult *result = NULL, bool loadMembers = true);
|
||||
bool LoadGroupFromDB(Field *fields);
|
||||
bool LoadMemberFromDB(uint32 guidLow, uint8 subgroup, bool assistant);
|
||||
bool AddInvite(Player *player);
|
||||
uint32 RemoveInvite(Player *player);
|
||||
|
|
|
|||
|
|
@ -3144,16 +3144,15 @@ void ObjectMgr::LoadGroups()
|
|||
bar.step();
|
||||
Field *fields = result->Fetch();
|
||||
++count;
|
||||
uint64 leaderGuid = MAKE_NEW_GUID(fields[16].GetUInt32(),0,HIGHGUID_PLAYER);
|
||||
Group *group = new Group;
|
||||
if(!group->LoadGroupFromDB(leaderGuid, result, false))
|
||||
if (!group->LoadGroupFromDB(fields))
|
||||
{
|
||||
group->Disband();
|
||||
delete group;
|
||||
continue;
|
||||
}
|
||||
AddGroup(group);
|
||||
leader2groupMap[GUID_LOPART(leaderGuid)] = group->GetId();
|
||||
leader2groupMap[GUID_LOPART(group->GetLeaderGUID())] = group->GetId();
|
||||
}while( result->NextRow() );
|
||||
|
||||
delete result;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "9337"
|
||||
#define REVISION_NR "9338"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue