diff --git a/src/server/game/DataStores/DBCEnums.h b/src/server/game/DataStores/DBCEnums.h index 56499921243..b38969cf857 100644 --- a/src/server/game/DataStores/DBCEnums.h +++ b/src/server/game/DataStores/DBCEnums.h @@ -496,13 +496,17 @@ enum SkillRaceClassInfoFlags SKILL_FLAG_MONO_VALUE = 0x400 // Skill always has value 1 - clientside display flag, real value can be different }; -enum SpellCategoryFlags +enum class SpellCategoryFlags : uint8 { - SPELL_CATEGORY_FLAG_COOLDOWN_SCALES_WITH_WEAPON_SPEED = 0x01, // unused - SPELL_CATEGORY_FLAG_COOLDOWN_STARTS_ON_EVENT = 0x04, - SPELL_CATEGORY_FLAG_COOLDOWN_EXPIRES_AT_DAILY_RESET = 0x08 + None = 0, + CooldownModifiesItem = 0x1, // NYI + GlobalCooldown = 0x2, // NYI + CooldownEventOnLeaveCombat = 0x4, + CooldownInDays = 0x8, }; +DEFINE_ENUM_FLAG(SpellCategoryFlags); + #define MAX_SPELL_EFFECTS 3 #define MAX_EFFECT_MASK 7 #define MAX_SPELL_REAGENTS 8 diff --git a/src/server/game/DataStores/DBCStores.cpp b/src/server/game/DataStores/DBCStores.cpp index bb58af34562..89359494686 100644 --- a/src/server/game/DataStores/DBCStores.cpp +++ b/src/server/game/DataStores/DBCStores.cpp @@ -1315,23 +1315,6 @@ EmotesTextSoundEntry const* DBCManager::FindTextSoundEmoteFor(uint32 emote, uint return itr != sEmotesTextSoundMap.end() ? itr->second : nullptr; } -uint32 DBCManager::GetParentSpellCategoryId(uint32 childCategory) -{ - // Weekly profession reset linking - switch (childCategory) - { - case 1278: // Dream of Skywall - case 1279: // Dream of Azshara - case 1280: // Dream of Ragnaros - case 1281: // Dream of Deepholm - case 1282: // Dream of Hyjal - return 1328; - default: - return 0; - } - return 0; -} - bool DBCManager::IsInArea(uint32 objectAreaId, uint32 areaId) { do diff --git a/src/server/game/DataStores/DBCStores.h b/src/server/game/DataStores/DBCStores.h index 25aeaf4f3f5..0886dc6fd9f 100644 --- a/src/server/game/DataStores/DBCStores.h +++ b/src/server/game/DataStores/DBCStores.h @@ -248,7 +248,6 @@ public: SkillRaceClassInfoEntry const* GetSkillRaceClassInfo(uint32 skill, uint8 race, uint8 class_); ResponseCodes ValidateName(std::wstring const& name, LocaleConstant locale); EmotesTextSoundEntry const* FindTextSoundEmoteFor(uint32 emote, uint32 race, uint32 gender); - static uint32 GetParentSpellCategoryId(uint32 childCategory); }; #define sDBCManager DBCManager::Instance() diff --git a/src/server/game/DataStores/DBCStructure.h b/src/server/game/DataStores/DBCStructure.h index b84e85dd9f2..11fab570e28 100644 --- a/src/server/game/DataStores/DBCStructure.h +++ b/src/server/game/DataStores/DBCStructure.h @@ -2145,6 +2145,8 @@ struct SpellCategoryEntry uint32 Flags; // 1 uint32 UsesPerWeek; // 2 // char* Name; // 3 + + EnumFlag GetFlags() const { return static_cast(Flags); } }; struct SpellDifficultyEntry diff --git a/src/server/game/Spells/SpellHistory.cpp b/src/server/game/Spells/SpellHistory.cpp index e1268c3decc..78dab009b9e 100644 --- a/src/server/game/Spells/SpellHistory.cpp +++ b/src/server/game/Spells/SpellHistory.cpp @@ -340,15 +340,15 @@ void SpellHistory::StartCooldown(SpellInfo const* spellInfo, uint32 itemId, Spel } SpellCategoryEntry const* categoryEntry = sSpellCategoryStore.AssertEntry(categoryId); - if (categoryEntry->Flags & SPELL_CATEGORY_FLAG_COOLDOWN_EXPIRES_AT_DAILY_RESET) + if (categoryEntry->GetFlags().HasFlag(SpellCategoryFlags::CooldownInDays)) { - uint32 parentCategoryId = DBCManager::GetParentSpellCategoryId(categoryEntry->ID); - SpellCategoryEntry const* parentCategory = sSpellCategoryStore.LookupEntry(parentCategoryId); + uint32 days = std::max((categoryCooldown / 1000) - 1, 0); - if (parentCategory && parentCategory->UsesPerWeek) - categoryCooldown = WEEK * IN_MILLISECONDS; - else - categoryCooldown = int32(std::chrono::duration_cast(Clock::from_time_t(sWorld->GetNextDailyQuestsResetTime()) - Clock::now()).count()); + // Initially start with the cooldown in plain days. Substract one day as we add the remaining cooldown until daily reset in the next step + categoryCooldown += int32(std::chrono::duration_cast(std::chrono::hours(days * 24)).count()); + + // Day based cooldowns have their reset at daily reset times so we now apply the remaining cooldown + categoryCooldown += int32(std::chrono::duration_cast(Clock::from_time_t(sWorld->GetNextDailyQuestsResetTime()) - Clock::now()).count()); } } diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index b9f98d0a35b..ab7c323431f 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -1377,7 +1377,7 @@ bool SpellInfo::IsCooldownStartedOnEvent() const if (HasAttribute(SPELL_ATTR0_DISABLED_WHILE_ACTIVE)) return true; - return CategoryEntry && CategoryEntry->Flags & SPELL_CATEGORY_FLAG_COOLDOWN_STARTS_ON_EVENT; + return CategoryEntry && CategoryEntry->GetFlags().HasFlag(SpellCategoryFlags::CooldownEventOnLeaveCombat); } bool SpellInfo::IsDeathPersistent() const