diff --git a/src/game/Group.cpp b/src/game/Group.cpp index 4408d640a..37297af8d 100644 --- a/src/game/Group.cpp +++ b/src/game/Group.cpp @@ -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; diff --git a/src/game/Group.h b/src/game/Group.h index 9a0450db4..30244386f 100644 --- a/src/game/Group.h +++ b/src/game/Group.h @@ -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); diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 45776e790..965fb9fd1 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -3124,7 +3124,7 @@ void ObjectMgr::LoadGroups() // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 QueryResult *result = CharacterDatabase.Query("SELECT mainTank, mainAssistant, lootMethod, looterGuid, lootThreshold, icon1, icon2, icon3, icon4, icon5, icon6, icon7, icon8, isRaid, difficulty, raiddifficulty, leaderGuid FROM groups"); - if( !result ) + if (!result) { barGoLink bar( 1 ); @@ -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; @@ -3165,7 +3164,7 @@ void ObjectMgr::LoadGroups() count = 0; // 0 1 2 3 result = CharacterDatabase.Query("SELECT memberGuid, assistant, subgroup, leaderGuid FROM group_member ORDER BY leaderGuid"); - if(!result) + if (!result) { barGoLink bar2( 1 ); bar2.step(); @@ -3185,14 +3184,14 @@ void ObjectMgr::LoadGroups() bool assistent = fields[1].GetBool(); uint8 subgroup = fields[2].GetUInt8(); uint32 leaderGuidLow = fields[3].GetUInt32(); - if(!group || GUID_LOPART(group->GetLeaderGUID()) != leaderGuidLow) + if (!group || GUID_LOPART(group->GetLeaderGUID()) != leaderGuidLow) { // find group id in map by leader low guid std::map::const_iterator l2g_itr = leader2groupMap.find(leaderGuidLow); if (l2g_itr != leader2groupMap.end()) group = GetGroupById(l2g_itr->second); - if(!group) + if (!group) { sLog.outErrorDb("Incorrect entry in group_member table : no group with leader %d for member %d!", leaderGuidLow, memberGuidlow); CharacterDatabase.PExecute("DELETE FROM group_member WHERE memberGuid = '%d'", memberGuidlow); @@ -3200,7 +3199,7 @@ void ObjectMgr::LoadGroups() } } - if(!group->LoadMemberFromDB(memberGuidlow, subgroup, assistent)) + if (!group->LoadMemberFromDB(memberGuidlow, subgroup, assistent)) { sLog.outErrorDb("Incorrect entry in group_member table : member %d cannot be added to player %d's group!", memberGuidlow, leaderGuidLow); CharacterDatabase.PExecute("DELETE FROM group_member WHERE memberGuid = '%d'", memberGuidlow); @@ -3233,7 +3232,7 @@ void ObjectMgr::LoadGroups() "FROM group_instance LEFT JOIN instance ON instance = id ORDER BY leaderGuid" ); - if(!result) + if (!result) { barGoLink bar2( 1 ); bar2.step(); @@ -3253,14 +3252,14 @@ void ObjectMgr::LoadGroups() uint32 mapId = fields[1].GetUInt32(); Difficulty diff = (Difficulty)fields[4].GetUInt8(); - if(!group || GUID_LOPART(group->GetLeaderGUID()) != leaderGuidLow) + if (!group || GUID_LOPART(group->GetLeaderGUID()) != leaderGuidLow) { // find group id in map by leader low guid std::map::const_iterator l2g_itr = leader2groupMap.find(leaderGuidLow); if (l2g_itr != leader2groupMap.end()) group = GetGroupById(l2g_itr->second); - if(!group) + if (!group) { sLog.outErrorDb("Incorrect entry in group_instance table : no group with leader %d", leaderGuidLow); continue; @@ -3268,13 +3267,13 @@ void ObjectMgr::LoadGroups() } MapEntry const* mapEntry = sMapStore.LookupEntry(mapId); - if(!mapEntry || !mapEntry->IsDungeon()) + if (!mapEntry || !mapEntry->IsDungeon()) { sLog.outErrorDb("Incorrect entry in group_instance table : no dungeon map %d", mapId); continue; } - if(diff >= (mapEntry->IsRaid() ? MAX_RAID_DIFFICULTY : MAX_DUNGEON_DIFFICULTY)) + if (diff >= (mapEntry->IsRaid() ? MAX_RAID_DIFFICULTY : MAX_DUNGEON_DIFFICULTY)) { sLog.outErrorDb("Wrong dungeon difficulty use in group_instance table: %d", diff + 1); diff = REGULAR_DIFFICULTY; // default for both difficaly types diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 7659088bb..c877f5c5b 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "9337" + #define REVISION_NR "9338" #endif // __REVISION_NR_H__