Core/Groups: Execute all group related database cleanup at the beginning of LoadGroups.

Port From (https://github.com/TrinityCore/TrinityCore/commit/86ecc83514f2aea21291595d68dca125893b166c)
This commit is contained in:
hondacrx
2022-06-01 13:03:04 -04:00
parent 8cddeb0fc5
commit d4a1bd0fc3
+5 -6
View File
@@ -110,10 +110,15 @@ namespace Game.Groups
{
uint oldMSTime = Time.GetMSTime();
// Delete all members that does not exist
DB.Characters.DirectExecute("DELETE FROM group_member WHERE memberGuid NOT IN (SELECT guid FROM characters)");
// Delete all groups whose leader does not exist
DB.Characters.DirectExecute("DELETE FROM groups WHERE leaderGuid NOT IN (SELECT guid FROM characters)");
// Delete all groups with less than 2 members
DB.Characters.DirectExecute("DELETE FROM groups WHERE guid NOT IN (SELECT guid FROM group_member GROUP BY guid HAVING COUNT(guid) > 1)");
// Delete all rows from group_member or group_instance with no group
DB.Characters.DirectExecute("DELETE FROM group_member WHERE guid NOT IN (SELECT guid FROM `groups`)");
DB.Characters.DirectExecute("DELETE FROM group_instance WHERE guid NOT IN (SELECT guid FROM `groups`)");
// 0 1 2 3 4 5 6 7 8 9
SQLResult result = DB.Characters.Query("SELECT g.leaderGuid, g.lootMethod, g.looterGuid, g.lootThreshold, g.icon1, g.icon2, g.icon3, g.icon4, g.icon5, g.icon6" +
@@ -152,12 +157,6 @@ namespace Game.Groups
{
uint oldMSTime = Time.GetMSTime();
// Delete all rows from group_member or group_instance with no group
DB.Characters.DirectExecute("DELETE FROM group_member WHERE guid NOT IN (SELECT guid FROM groups)");
DB.Characters.DirectExecute("DELETE FROM group_instance WHERE guid NOT IN (SELECT guid FROM groups)");
// Delete all members that does not exist
DB.Characters.DirectExecute("DELETE FROM group_member WHERE memberGuid NOT IN (SELECT guid FROM characters)");
// 0 1 2 3 4
SQLResult result = DB.Characters.Query("SELECT guid, memberGuid, memberFlags, subgroup, roles FROM group_member ORDER BY guid");
if (result.IsEmpty())