From 190aed53bf2f9358fee3ea18fd7ee7eb0cf1783f Mon Sep 17 00:00:00 2001 From: Andrew <47818697+Nyeriah@users.noreply.github.com> Date: Mon, 26 Aug 2024 00:52:50 -0300 Subject: [PATCH] fix: Fix the transmog pet not working with the new vendor interface (#169) --- src/Transmogrification.cpp | 4 ++++ src/Transmogrification.h | 8 ++++++-- src/transmog_scripts.cpp | 9 ++++++--- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/Transmogrification.cpp b/src/Transmogrification.cpp index 6ff973c..abfff25 100644 --- a/src/Transmogrification.cpp +++ b/src/Transmogrification.cpp @@ -1,6 +1,7 @@ #include "Transmogrification.h" #include "ItemTemplate.h" #include "DatabaseEnv.h" +#include "SpellMgr.h" #include "Tokenize.h" Transmogrification* Transmogrification::instance() @@ -1188,6 +1189,9 @@ void Transmogrification::LoadConfig(bool reload) } PetSpellId = sConfigMgr->GetOption("Transmogrification.PetSpellId", 2000100); + + if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(PetSpellId)) + PetEntry = spellInfo->Effects[EFFECT_0].MiscValue; } void Transmogrification::DeleteFakeFromDB(ObjectGuid::LowType itemLowGuid, CharacterDatabaseTransaction* trans /*= nullptr*/) diff --git a/src/Transmogrification.h b/src/Transmogrification.h index 9c3b4a7..0ee8357 100644 --- a/src/Transmogrification.h +++ b/src/Transmogrification.h @@ -95,6 +95,8 @@ enum PlusFeatures PLUS_FEATURE_SKIP_LEVEL_REQ }; +const uint32 TMOG_VENDOR_CREATURE_ID = 190010; + class Transmogrification { public: @@ -134,8 +136,6 @@ public: float SetCostModifier; int32 SetCopperCost; - uint32 PetSpellId; - bool GetEnableSets() const; uint8 GetMaxSets() const; float GetSetCostModifier() const; @@ -272,6 +272,10 @@ public: [[nodiscard]] bool IsPlusFeatureEligible(ObjectGuid const& playerGuid, uint32 feature) const; uint32 getPlayerMembershipLevel(ObjectGuid const & playerGuid) const; [[nodiscard]] bool IgnoreLevelRequirement(ObjectGuid const& playerGuid) const { return IgnoreReqLevel || IsPlusFeatureEligible(playerGuid, PLUS_FEATURE_SKIP_LEVEL_REQ); } + + uint32 PetSpellId; + uint32 PetEntry; + [[nodiscard]] bool IsTransmogVendor(uint32 entry) const { return entry == TMOG_VENDOR_CREATURE_ID || entry == PetEntry; }; }; #define sTransmogrification Transmogrification::instance() diff --git a/src/transmog_scripts.cpp b/src/transmog_scripts.cpp index ca82bc9..4c36079 100644 --- a/src/transmog_scripts.cpp +++ b/src/transmog_scripts.cpp @@ -337,7 +337,6 @@ const uint32 FALLBACK_HIDE_ITEM_VENDOR_ID = 9172; //Invisibility potion const uint32 FALLBACK_REMOVE_TMOG_VENDOR_ID = 1049; //Tablet of Purge const uint32 CUSTOM_HIDE_ITEM_VENDOR_ID = 57575;//Custom Hide Item item const uint32 CUSTOM_REMOVE_TMOG_VENDOR_ID = 57576;//Custom Remove Transmog item -const uint32 TMOG_VENDOR_CREATURE_ID = 190010; std::string GetLocaleText(LocaleConstant locale, const std::string& titleType) { auto textMapIt = textMaps.find(titleType); @@ -1165,8 +1164,12 @@ public: void OnBeforeBuyItemFromVendor(Player* player, ObjectGuid vendorguid, uint32 /*vendorslot*/, uint32& itemEntry, uint8 /*count*/, uint8 /*bag*/, uint8 /*slot*/) override { Creature* vendor = player->GetMap()->GetCreature(vendorguid); - if (!vendor) return; - if (vendor->GetEntry() != TMOG_VENDOR_CREATURE_ID) return; + if (!vendor) + return; + + if (!sT->IsTransmogVendor(vendor->GetEntry())) + return; + uint8 slot = sT->selectionCache[player->GetGUID()]; if (itemEntry == CUSTOM_HIDE_ITEM_VENDOR_ID || itemEntry == FALLBACK_HIDE_ITEM_VENDOR_ID)