Jump to content

[10386][Patch] Correct Creature difficulty entry selection


Recommended Posts

Posted

* What bug does the patch fix? What features does the patch add?

Right now, the entries to use in an instance at a given difficulty are scanned in ascending order, and the highest one found is taken. This is wrong.

Example: 39747 has 39823 as difficulty_entry_1, the others are 0.

10 man and 25 man normal work as they should, but 10 man heroic and 25 man heroic both use the 25 man normal entry, because it is the last found one.

This patch corrects this behavior as follows:

- if 10 man heroic is 0, it uses 10 man normal

- if 25 man heroic is 0, it uses 25 man normal

- if the selected entry is still 0, it uses the normal entry (this already works and is not changed)

* For which repository revision was the patch created?

rev. 10337

* Is there a thread in the bug report section or at lighthouse? If yes, please add a link to the thread.

none that i know of.

* Who has been writing this patch? Please include either forum user names or email addresses.

me, False.Genesis

diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp
index 6780181..1577b0c 100644
--- a/src/game/Creature.cpp
+++ b/src/game/Creature.cpp
@@ -199,25 +199,55 @@ bool Creature::InitEntry(uint32 Entry, uint32 team, const CreatureData *data )
    }

    // get difficulty 1 mode entry
-    uint32 actualEntry = Entry;
    CreatureInfo const *cinfo = normalInfo;
    // TODO correctly implement spawnmodes for non-bg maps
-    for (uint32 diff = 0; diff < MAX_DIFFICULTY - 1; ++diff)
-    {
-        if (normalInfo->DifficultyEntry[diff])
+
+    // difficulty selection works like this:
+    // - dungeon normal / 10 man normal = entry
+    // - dungeon heroic / 25 man normal = difficulty_entry_1
+    // - 10 man heroic = difficulty_entry_2
+    // - 25 man heroic = difficulty_entry_3
+    // in raids it should work like: if difficulty_entry_2 not exists then use -> entry 
+    // if difficulty_entry_3 not exists then use -> difficulty_entry_1
+    uint32 diff = GetMap()->GetSpawnMode();
+    if (diff)
+    {
+        --diff; // the difficulty used as array index must be 1 lower then what the map returns
+        do
        {
-            // we already have valid Map pointer for current creature!
-            if (GetMap()->GetSpawnMode() > diff)
+            cinfo = NULL;
+            if (normalInfo->DifficultyEntry[diff])
            {
                cinfo = ObjectMgr::GetCreatureTemplate(normalInfo->DifficultyEntry[diff]);
                if (!cinfo)
                {
                    // maybe check such things already at startup
-                    sLog.outErrorDb("Creature::UpdateEntry creature difficulty %u entry %u does not exist.", diff + 1, actualEntry);
+                    sLog.outErrorDb("Creature::UpdateEntry creature difficulty %u entry %u does not exist.", diff + 1, Entry);
                    return false;
                }
+                break;
+            }
+            else
+            {
+                // if 0 in db -> select alt. entry
+                switch (diff)
+                {
+                    case 0: // difficutly_entry_1
+                    case 1: // difficutly_entry_2
+                        cinfo = normalInfo; // not found, leave the loop with default entry
+                        break;
+                    
+                    case 2: // difficutly_entry_3
+                        diff = 0;
+                        break;
+
+                    default:
+                        sLog.outError("Creature::UpdateEntry creature difficulty %u entry %u unhandled", diff + 1, Entry);
+                        cinfo = normalInfo;
+                }
            }
        }
+        while (!cinfo);
    }

    SetEntry(Entry);                                        // normal entry always

Commit in my repo: http://github.com/fgenesis/mangos/commit/ba4376aaf202b2711f33128b8a5f333102aa6540

×
×
  • 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