TrinityCore icon indicating copy to clipboard operation
TrinityCore copied to clipboard

[Fix][Core/Quests] Pooling system causing wrong questrelations

Open ghost opened this issue 15 years ago • 6 comments

Hi there. :)

== Description ==

The pooling system causes questgivers to have wrong questrelations. Depending on the server startup time and the values in the table characters.character_queststatus_daily (which is used to calculate next reset time of daily quests on startup), the function

"void World::ResetDailyQuests()"

is called on the fly. But this causes NPCs to get wrong questrelations. Examples are the famous "Timothy Jones" and the jewelcrafting daily quests (which appeared several times here in the bugtracker) or several quest at the Argent Tournament.

== Revisions ==

TDB: Rev. 42 Core: dad9d07 (but issue already existed in 73f0cb7)

== Reproduction ==

In order to reproduce this issue, it is the easiest way to implement a new command, which calls the function "void World::ResetDailyQuests()". So we get the call to it on the fly not depending on the startup time and the values in character_queststatus_daily table.

  1. Startup server (assuming working questrelations)
  2. Get to NPC Timothy Jones (.go cr id 28701) with a character having jewelcrafting skill >= 375 and level >= 65
  3. Execute your command, which calls "void World::ResetDailyQuests()"

If your character did not complete the quest 13041 (Finish the Shipment), you will not be able to see it anymore. If your character already completed the quest 13041 (Finish the Shipment), you will see TWO pooling daily quests available (although max limit of the pool is set to 1!).

== Fix explanation ==

This function is meant to kick out the "old" pooled quest entries. But as it seems, just the first element having the same NPC id is kicked out. This can cause heavy problems.

Example: The first element of Timothy Jones was quest 13041. At the moment this element is deleted and a new pooled element is added.

Result: 13041 unavailable and 2 pooled quests available, after an on the fly reset of daily quests.

The fix below adds a check for matching quest ids.

== Fix ==

PoolMgr.cpp

@@ -260,7 +260,7 @@ void PoolGroup<Quest>::Despawn1Object(ui
         QuestRelations::iterator lastElement = questMap->upper_bound(itr->second);
         for (; qitr != lastElement; ++qitr)
         {
-            if (qitr->first == itr->second)
+            if (qitr->first == itr->second && qitr->second == itr->first)
             {
                 questMap->erase(qitr);                  // iterator is now no more valid
                 break;                                  // but we can exit loop since the element is found
@@ -279,7 +279,7 @@ void PoolGroup<Quest>::Despawn1Object(ui
         QuestRelations::iterator lastElement = questMap->upper_bound(itr->second);
         for (; qitr != lastElement; ++qitr)
         {
-            if (qitr->first == itr->second)
+            if (qitr->first == itr->second && qitr->second == itr->first)
             {
                 questMap->erase(qitr);                  // iterator is now no more valid
                 break;                                  // but we can exit loop since the element is found

ghost avatar Sep 18 '11 11:09 ghost

Bug confirmed will test the fix

BroodWyrm avatar Sep 19 '11 07:09 BroodWyrm

Thanks for testing BroodWyrm.

At least in my tests this one fixed the issue. I called the daily pooled quest reset on the fly and only the daily pooled quest changed. All other quests were still available as intended, as far as I could notice.

Please add your testing results here BroodWyrm, at the moment I am only able to test it alone. :)

ghost avatar Sep 19 '11 21:09 ghost

Until now ... pooled quests are given correctly (only one quest per pool; without fix 1-2 Quests mostly from previous day) Other testers doesnt report anything unusual :D

BroodWyrm avatar Sep 20 '11 18:09 BroodWyrm

Okay BroodWyrm. Thanks for the report. :)

Soon I will also be able to test it with multiple testers, but obviously the fix works as intended at the moment. Since such changes deep in the core could cause other issues, a testing phase for this is necessary. :)

If anything unsual in relation to this should happen, please add a new comment.

ghost avatar Sep 21 '11 22:09 ghost

Thanks.

burnham avatar Sep 27 '11 19:09 burnham

Okay, this one seems to work fine. Tested it now with multiple testers, no errors until now caused by that.

ghost avatar Oct 01 '11 15:10 ghost