diff --git a/conf/transmog.conf.dist b/conf/transmog.conf.dist index 1cea85cf..1c3bb05c 100644 --- a/conf/transmog.conf.dist +++ b/conf/transmog.conf.dist @@ -268,9 +268,15 @@ Transmogrification.SetCopperCost = 0 # Example: Transmogrification.MembershipLevels = "1,2,3" # Default: "" # +# Transmogrification.MembershipLevelsLegendary +# Description: Membership levels ID from acore_cms_subscriptions that define the eligibility for legendary items +# Example: Transmogrification.MembershipLevels = "1,2,3" +# Default: "" +# Transmogrification.EnablePlus = 0 Transmogrification.MembershipLevels = "" +Transmogrification.MembershipLevelsLegendary = "" # ################################################################################################### diff --git a/src/Transmogrification.cpp b/src/Transmogrification.cpp index 7a007c01..43ed9803 100644 --- a/src/Transmogrification.cpp +++ b/src/Transmogrification.cpp @@ -923,12 +923,12 @@ bool Transmogrification::IsAllowedQuality(uint32 quality, ObjectGuid::LowType pl { switch (quality) { - case ITEM_QUALITY_POOR: return AllowPoor || isPlusEligible(playerGuid); - case ITEM_QUALITY_NORMAL: return AllowCommon || isPlusEligible(playerGuid); + case ITEM_QUALITY_POOR: return AllowPoor || isPlusWhiteGreyEligible(playerGuid); + case ITEM_QUALITY_NORMAL: return AllowCommon || isPlusWhiteGreyEligible(playerGuid); case ITEM_QUALITY_UNCOMMON: return AllowUncommon; case ITEM_QUALITY_RARE: return AllowRare; case ITEM_QUALITY_EPIC: return AllowEpic; - case ITEM_QUALITY_LEGENDARY: return AllowLegendary; + case ITEM_QUALITY_LEGENDARY: return AllowLegendary || isPlusLegendaryEligible(playerGuid); case ITEM_QUALITY_ARTIFACT: return AllowArtifact; case ITEM_QUALITY_HEIRLOOM: return AllowHeirloom; default: return false; @@ -1041,11 +1041,18 @@ void Transmogrification::LoadConfig(bool reload) TokenEntry = 49426; } + /* TransmogPlus */ IsTransmogPlusEnabled = sConfigMgr->GetOption("Transmogrification.EnablePlus", false); + std::string stringMembershipIds = sConfigMgr->GetOption("Transmogrification.MembershipLevels", ""); for (auto& itr : Acore::Tokenize(stringMembershipIds, ',', false)) { MembershipIds.push_back(Acore::StringTo(itr).value()); } + + stringMembershipIds = sConfigMgr->GetOption("Transmogrification.MembershipLevelsLegendary", ""); + for (auto& itr : Acore::Tokenize(stringMembershipIds, ',', false)) { + MembershipIdsLegendary.push_back(Acore::StringTo(itr).value()); + } } void Transmogrification::DeleteFakeFromDB(ObjectGuid::LowType itemLowGuid, CharacterDatabaseTransaction* trans /*= nullptr*/) @@ -1064,7 +1071,7 @@ void Transmogrification::DeleteFakeFromDB(ObjectGuid::LowType itemLowGuid, Chara CharacterDatabase.Execute("DELETE FROM custom_transmogrification WHERE GUID = {}", itemGUID.GetCounter()); } -bool Transmogrification::isPlusEligible(ObjectGuid::LowType playerGuid) const { +bool Transmogrification::isPlusWhiteGreyEligible(ObjectGuid::LowType playerGuid) const { if (!IsTransmogPlusEnabled) { return false; } @@ -1073,26 +1080,59 @@ bool Transmogrification::isPlusEligible(ObjectGuid::LowType playerGuid) const { return false; } + const auto membershipLevel = getPlayerMembershipLevel(playerGuid); + if (membershipLevel == 0) { + return false; + } + + for (const auto& itr : MembershipIds) + { + if (itr == membershipLevel) { + return true; + } + } + + return false; +} + + +bool Transmogrification::isPlusLegendaryEligible(ObjectGuid::LowType playerGuid) const { + if (!IsTransmogPlusEnabled) { + return false; + } + + if (MembershipIdsLegendary.size() == 0) { + return false; + } + + const auto membershipLevel = getPlayerMembershipLevel(playerGuid); + if (membershipLevel == 0) { + return false; + } + + for (const auto& itr : MembershipIdsLegendary) + { + if (itr == membershipLevel) { + return true; + } + } + + return false; +} + +uint32 Transmogrification::getPlayerMembershipLevel(ObjectGuid::LowType playerGuid) const { QueryResult result = CharacterDatabase.Query("SELECT `account` FROM `characters` WHERE `guid` = {}", playerGuid); if (result) { - uint32 accountId = (*result)[0].Get(); QueryResult resultAcc = LoginDatabase.Query("SELECT `membership_level` FROM `acore_cms_subscriptions` WHERE `account_name` COLLATE utf8mb4_general_ci = (SELECT `username` FROM `account` WHERE `id` = {})", accountId); if (resultAcc) { - const uint32 membershipLevel = (*resultAcc)[0].Get(); - for (const auto& itr : MembershipIds) - { - if (itr == membershipLevel) { - return true; - } - } - + return (*resultAcc)[0].Get(); } } - return false; + return 0; } bool Transmogrification::GetEnableTransmogInfo() const diff --git a/src/Transmogrification.h b/src/Transmogrification.h index c112e461..e22a71d4 100644 --- a/src/Transmogrification.h +++ b/src/Transmogrification.h @@ -215,7 +215,10 @@ class Transmogrification // Transmog Plus bool IsTransmogPlusEnabled; std::vector MembershipIds; - bool isPlusEligible(ObjectGuid::LowType playerGuid) const; + std::vector MembershipIdsLegendary; + bool isPlusWhiteGreyEligible(ObjectGuid::LowType playerGuid) const; + bool isPlusLegendaryEligible(ObjectGuid::LowType playerGuid) const; + uint32 getPlayerMembershipLevel(ObjectGuid::LowType playerGuid) const; }; #define sTransmogrification Transmogrification::instance()