105{
106 {
108
109
110 CharacterDatabase.DirectExecute(
"DELETE FROM `groups` WHERE leaderGuid NOT IN (SELECT guid FROM characters)");
111
112
113 CharacterDatabase.DirectExecute(
"DELETE FROM `groups` WHERE guid NOT IN (SELECT guid FROM group_member GROUP BY guid HAVING COUNT(guid) > 1)");
114
115
116 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");
117
118
120
121
122 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"
123
124 ", 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");
125
126 if (!result)
127 {
128 LOG_WARN(
"server.loading",
">> Loaded 0 group definitions. DB table `groups` is empty!");
130 }
131 else
132 {
134 do
135 {
136 Field* fields = result->Fetch();
139 {
140 delete group;
141 continue;
142 }
144
146
147 ++count;
148 } while (result->NextRow());
149
152 }
153 }
154
155 LOG_INFO(
"server.loading",
"Loading Group Members...");
156 {
158
159
160 CharacterDatabase.DirectExecute(
"DELETE FROM group_member WHERE guid NOT IN (SELECT guid FROM `groups`)");
161
162 CharacterDatabase.DirectExecute(
"DELETE FROM group_member WHERE memberGuid NOT IN (SELECT guid FROM characters)");
163
164
166 if (!result)
167 {
168 LOG_WARN(
"server.loading",
">> Loaded 0 group members. DB table `group_member` is empty!");
170 }
171 else
172 {
174 do
175 {
176 Field* fields = result->Fetch();
178
179 if (group)
180 group->
LoadMemberFromDB(fields[1].Get<uint32>(), fields[2].Get<uint8>(), fields[3].Get<uint8>(), fields[4].Get<uint8>());
181
182 ++count;
183 } while (result->NextRow());
184
187 }
188 }
189}
#define LOG_INFO(filterType__,...)
Definition Log.h:153
#define LOG_WARN(filterType__,...)
Definition Log.h:149
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
Group * GetGroupByGUID(ObjectGuid::LowType guid) const
Definition GroupMgr.cpp:85
void InitGroupIds()
Definition GroupMgr.cpp:42
void RegisterGroupId(ObjectGuid::LowType groupId)
Definition GroupMgr.cpp:54
void AddGroup(Group *group)
Definition GroupMgr.cpp:94
void LoadMemberFromDB(ObjectGuid::LowType guidLow, uint8 memberFlags, uint8 subgroup, uint8 roles)
Definition Group.cpp:264
bool LoadGroupFromDB(Field *field)
Definition Group.cpp:209