diff --git a/Source/Game/Groups/GroupManager.cs b/Source/Game/Groups/GroupManager.cs index 8a885a142..3122e33ab 100644 --- a/Source/Game/Groups/GroupManager.cs +++ b/Source/Game/Groups/GroupManager.cs @@ -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())