101{
102 {
104
105
106 CharacterDatabase.DirectExecute(
"DELETE FROM `groups` WHERE leaderGuid NOT IN (SELECT guid FROM characters)");
107
108
109 CharacterDatabase.DirectExecute(
"DELETE FROM `groups` WHERE guid NOT IN (SELECT guid FROM group_member GROUP BY guid HAVING COUNT(guid) > 1)");
110
111
112 CharacterDatabase.DirectExecute(
"DELETE lfg_data FROM lfg_data LEFT JOIN `groups` ON lfg_data.guid = groups.guid WHERE groups.guid IS NULL OR groups.groupType <> 12");
113
114
116
117
118 QueryResult result =
CharacterDatabase.Query(
"SELECT g.leaderGuid, g.lootMethod, g.looterGuid, g.lootThreshold, g.icon1, g.icon2, g.icon3, g.icon4, g.icon5, g.icon6"
119
120 ", g.icon7, g.icon8, g.groupType, g.difficulty, g.raidDifficulty, g.masterLooterGuid, g.guid, lfg.dungeon, lfg.state FROM `groups` g LEFT JOIN lfg_data lfg ON lfg.guid = g.guid ORDER BY g.guid ASC");
121
122 if (!result)
123 {
124 LOG_WARN(
"server.loading",
">> Loaded 0 group definitions. DB table `groups` is empty!");
126 }
127 else
128 {
130 do
131 {
132 Field* fields = result->Fetch();
135 {
136 delete group;
137 continue;
138 }
140
142
143 ++count;
144 } while (result->NextRow());
145
148 }
149 }
150
151 LOG_INFO(
"server.loading",
"Loading Group Members...");
152 {
154
155
156 CharacterDatabase.DirectExecute(
"DELETE FROM group_member WHERE guid NOT IN (SELECT guid FROM `groups`)");
157
158 CharacterDatabase.DirectExecute(
"DELETE FROM group_member WHERE memberGuid NOT IN (SELECT guid FROM characters)");
159
160
162 if (!result)
163 {
164 LOG_WARN(
"server.loading",
">> Loaded 0 group members. DB table `group_member` is empty!");
166 }
167 else
168 {
170 do
171 {
172 Field* fields = result->Fetch();
174
175 if (group)
176 group->
LoadMemberFromDB(fields[1].Get<uint32>(), fields[2].Get<uint8>(), fields[3].Get<uint8>(), fields[4].Get<uint8>());
177
178 ++count;
179 } while (result->NextRow());
180
183 }
184 }
185}
#define LOG_INFO(filterType__,...)
Definition: Log.h:165
#define LOG_WARN(filterType__,...)
Definition: Log.h:161
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition: Timer.h:131
uint32 getMSTime()
Definition: Timer.h:103
Class used to access individual fields of database query result.
Definition: Field.h:98
void LoadMemberFromDB(ObjectGuid::LowType guidLow, uint8 memberFlags, uint8 subgroup, uint8 roles)
Definition: Group.cpp:227
bool LoadGroupFromDB(Field *field)
Definition: Group.cpp:172
Group * GetGroupByGUID(ObjectGuid::LowType guid) const
Definition: GroupMgr.cpp:81
void InitGroupIds()
Definition: GroupMgr.cpp:42
void RegisterGroupId(ObjectGuid::LowType groupId)
Definition: GroupMgr.cpp:54
void AddGroup(Group *group)
Definition: GroupMgr.cpp:90