Jump to content

[patch] Instance Renumbering System Cleanup


Guest Alex/AT
 Share

Recommended Posts

Instance renumbering routine requires some cleanup to work properly.

Currently it can left over some instance IDs causing them to reapper in DB each time server is run and sometimes leads to wrong instance associations for corpses and/or characters.

The patch is here:

Index: trunk/src/game/ObjectMgr.cpp
===================================================================
--- trunk/src/game/ObjectMgr.cpp        (revision 5732)
+++ trunk/src/game/ObjectMgr.cpp        (working copy)
@@ -4860,8 +4860,21 @@
                delete result;
        }

+        // corpse
+        result = CharacterDatabase.PQuery("SELECT DISTINCT(instance) FROM corpse WHERE instance <> 0");
+        if( result )
+        {
+                do
+                {
+                        Field *fields = result->Fetch();
+                        InstanceSet.insert(fields[0].GetUInt32());
+                }
+                while (result->NextRow());
+                delete result;
+        }
+
        // character_instance
-        result = CharacterDatabase.PQuery("SELECT DISTINCT(instance) FROM character_instance");
+        result = CharacterDatabase.PQuery("SELECT DISTINCT(instance) FROM character_instance WHERE instance <> 0");
        if( result )
        {
                do
@@ -4874,7 +4887,7 @@
        }

        // instance
-        result = CharacterDatabase.PQuery("SELECT id FROM instance");
+        result = CharacterDatabase.PQuery("SELECT id FROM instance WHERE id <> 0");
        if( result )
        {
                do
@@ -4890,7 +4903,7 @@
        // instances considered valid:
        //     1) reset time > current time
        //     2) bound to at least one character (id is found in character_instance table)
-        result = CharacterDatabase.PQuery("SELECT DISTINCT(instance.id) AS id FROM instance LEFT JOIN character_instance ON (character_instance.instance = instance.id) WHERE (instance.id = character_instance.instance) AND (instance.resettime > " I64FMTD ")", (uint64)time(NULL));
+        result = CharacterDatabase.PQuery("SELECT DISTINCT(instance.id) AS id FROM instance INNER JOIN character_instance ON (character_instance.instance = instance.id) WHERE (instance.id = character_instance.instance) AND (instance.resettime > " I64FMTD ")", (uint64)time(NULL));
        if( result )
        {
                do
@@ -4917,6 +4930,7 @@
                WorldDatabase.PExecute("DELETE FROM creature_respawn WHERE instance = '%u'", *i);
                WorldDatabase.PExecute("DELETE FROM gameobject_respawn WHERE instance = '%u'", *i);
                CharacterDatabase.PExecute("DELETE FROM corpse WHERE instance = '%u'", *i);
+                CharacterDatabase.PExecute("DELETE FROM character_instance WHERE instance = '%u'", *i);
                CharacterDatabase.PExecute("DELETE FROM instance WHERE id = '%u'", *i);

                bar.step();

Link to comment
Share on other sites

  • 3 years later...
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use