aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordufernst <dufernst@epicduf.nl>2022-05-01 17:46:50 +0200
committerGitHub <noreply@github.com>2022-05-01 17:46:50 +0200
commit86ecc83514f2aea21291595d68dca125893b166c (patch)
treefd849f258785dbe2aa9eaf1dcece9a2a3be59072 /src
parent88d7b58a3dd8b0eb95c233a20c1608ddce73d9ea (diff)
Core/Groups: Execute all group related database cleanup at the beginning of LoadGroups. (#27935)
Makes certain group_member entries be deleted when their respective groups are removed during cleanup. In cases when LoadGroups aborts early if no groups remain to be loaded after cleanup they would otherwise not be removed.
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Groups/GroupMgr.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/server/game/Groups/GroupMgr.cpp b/src/server/game/Groups/GroupMgr.cpp
index cd37ef3468a..d1cdc0e75c3 100644
--- a/src/server/game/Groups/GroupMgr.cpp
+++ b/src/server/game/Groups/GroupMgr.cpp
@@ -130,10 +130,15 @@ void GroupMgr::LoadGroups()
{
uint32 oldMSTime = getMSTime();
+ // Delete all members that does not exist
+ CharacterDatabase.DirectExecute("DELETE FROM group_member WHERE memberGuid NOT IN (SELECT guid FROM characters)");
// Delete all groups whose leader does not exist
CharacterDatabase.DirectExecute("DELETE FROM `groups` WHERE leaderGuid NOT IN (SELECT guid FROM characters)");
// Delete all groups with less than 2 members
CharacterDatabase.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
+ CharacterDatabase.DirectExecute("DELETE FROM group_member WHERE guid NOT IN (SELECT guid FROM `groups`)");
+ CharacterDatabase.DirectExecute("DELETE FROM group_instance WHERE guid NOT IN (SELECT guid FROM `groups`)");
// 0 1 2 3 4 5 6 7 8 9
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"
@@ -173,12 +178,6 @@ void GroupMgr::LoadGroups()
{
uint32 oldMSTime = getMSTime();
- // Delete all rows from group_member or group_instance with no group
- CharacterDatabase.DirectExecute("DELETE FROM group_member WHERE guid NOT IN (SELECT guid FROM `groups`)");
- CharacterDatabase.DirectExecute("DELETE FROM group_instance WHERE guid NOT IN (SELECT guid FROM `groups`)");
- // Delete all members that does not exist
- CharacterDatabase.DirectExecute("DELETE FROM group_member WHERE memberGuid NOT IN (SELECT guid FROM characters)");
-
// 0 1 2 3 4
QueryResult result = CharacterDatabase.Query("SELECT guid, memberGuid, memberFlags, subgroup, roles FROM group_member ORDER BY guid");
if (!result)