From 53e99dbb85f38f3f5e63fc5d179d7d0c2517c976 Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Sun, 18 Aug 2019 00:29:05 +0200 Subject: [PATCH] Core/Spells: fixed cooldowns of weekly profession spells. The cooldown will now start by the time the item gets created and lasts for a whole week --- src/server/game/DataStores/DBCStores.cpp | 17 +++++++++++++++++ src/server/game/DataStores/DBCStores.h | 2 ++ src/server/game/DataStores/DBCStructure.h | 2 +- src/server/game/DataStores/DBCfmt.h | 2 +- src/server/game/Spells/SpellHistory.cpp | 10 +++++++++- 5 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/server/game/DataStores/DBCStores.cpp b/src/server/game/DataStores/DBCStores.cpp index 95ae5fb88bf..fe01ecd043a 100644 --- a/src/server/game/DataStores/DBCStores.cpp +++ b/src/server/game/DataStores/DBCStores.cpp @@ -1305,6 +1305,23 @@ EmotesTextSoundEntry const* FindTextSoundEmoteFor(uint32 emote, uint32 race, uin return itr != sEmotesTextSoundMap.end() ? itr->second : nullptr; } +uint32 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 IsInArea(uint32 objectAreaId, uint32 areaId) { do diff --git a/src/server/game/DataStores/DBCStores.h b/src/server/game/DataStores/DBCStores.h index 748fd79a1e5..46012b8ea60 100644 --- a/src/server/game/DataStores/DBCStores.h +++ b/src/server/game/DataStores/DBCStores.h @@ -89,6 +89,8 @@ TC_GAME_API ResponseCodes ValidateName(std::wstring const& name, LocaleConstant TC_GAME_API EmotesTextSoundEntry const* FindTextSoundEmoteFor(uint32 emote, uint32 race, uint32 gender); +TC_GAME_API uint32 GetParentSpellCategoryId(uint32 childCategory); + TC_GAME_API extern DBCStorage sAchievementStore; TC_GAME_API extern DBCStorage sAnimKitStore; TC_GAME_API extern DBCStorage sAchievementCriteriaStore; diff --git a/src/server/game/DataStores/DBCStructure.h b/src/server/game/DataStores/DBCStructure.h index 663d7cb9025..fb35ab83f1e 100644 --- a/src/server/game/DataStores/DBCStructure.h +++ b/src/server/game/DataStores/DBCStructure.h @@ -2151,7 +2151,7 @@ struct SpellCategoryEntry { uint32 Id; uint32 Flags; - // uint32 unk; + uint32 UsesPerWeek; // char* Name; }; diff --git a/src/server/game/DataStores/DBCfmt.h b/src/server/game/DataStores/DBCfmt.h index eda356813cf..57dfe538d71 100644 --- a/src/server/game/DataStores/DBCfmt.h +++ b/src/server/game/DataStores/DBCfmt.h @@ -140,7 +140,7 @@ char const SkillTiersfmt[] = "nxxxxxxxxxxxxxxxxiiiiiiiiiiiiiiii"; char const SoundEntriesfmt[] = "nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; char const SpellCastTimefmt[] = "nixx"; char const SpellCategoriesEntryfmt[] = "diiiiii"; -char const SpellCategoryfmt[] = "nixx"; +char const SpellCategoryfmt[] = "niix"; char const SpellDifficultyfmt[] = "niiii"; const std::string CustomSpellDifficultyfmt = "ppppp"; const std::string CustomSpellDifficultyIndex = "id"; diff --git a/src/server/game/Spells/SpellHistory.cpp b/src/server/game/Spells/SpellHistory.cpp index 614c31e973c..b1082249ed7 100644 --- a/src/server/game/Spells/SpellHistory.cpp +++ b/src/server/game/Spells/SpellHistory.cpp @@ -350,7 +350,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) - categoryCooldown = int32(std::chrono::duration_cast(Clock::from_time_t(sWorld->GetNextDailyQuestsResetTime()) - Clock::now()).count()); + { + uint32 parentCategoryId = GetParentSpellCategoryId(categoryEntry->Id); + SpellCategoryEntry const* parentCategory = sSpellCategoryStore.LookupEntry(parentCategoryId); + + if (parentCategory && parentCategory->UsesPerWeek) + categoryCooldown = WEEK * IN_MILLISECONDS; + else + categoryCooldown = int32(std::chrono::duration_cast(Clock::from_time_t(sWorld->GetNextDailyQuestsResetTime()) - Clock::now()).count()); + } } // replace negative cooldowns by 0