mirror of
https://github.com/azerothcore/mod-transmog
synced 2025-11-29 22:48:30 +08:00
refactor: Move handling of memberships to PlayerSettings() (#175)
This commit is contained in:
@@ -1214,21 +1214,6 @@ void Transmogrification::DeleteFakeFromDB(ObjectGuid::LowType itemLowGuid, Chara
|
||||
CharacterDatabase.Execute("DELETE FROM custom_transmogrification WHERE GUID = {}", itemGUID.GetCounter());
|
||||
}
|
||||
|
||||
uint32 Transmogrification::getPlayerMembershipLevel(ObjectGuid const & playerGuid) const
|
||||
{
|
||||
CharacterCacheEntry const* playerData = sCharacterCache->GetCharacterCacheByGuid(playerGuid);
|
||||
if (!playerData)
|
||||
return 0;
|
||||
|
||||
uint32 accountId = playerData->AccountId;
|
||||
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)
|
||||
return (*resultAcc)[0].Get<uint32>();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Transmogrification::IsPlusFeatureEligible(ObjectGuid const &playerGuid, uint32 feature) const
|
||||
{
|
||||
if (!IsTransmogPlusEnabled)
|
||||
@@ -1238,7 +1223,12 @@ bool Transmogrification::IsPlusFeatureEligible(ObjectGuid const &playerGuid, uin
|
||||
if (it == plusDataMap.end() || it->second.empty())
|
||||
return false;
|
||||
|
||||
const auto membershipLevel = getPlayerMembershipLevel(playerGuid);
|
||||
Player* player = ObjectAccessor::FindConnectedPlayer(playerGuid);
|
||||
|
||||
if (!player)
|
||||
return false;
|
||||
|
||||
const auto membershipLevel = GetPlayerMembershipLevel(player);
|
||||
|
||||
if (!membershipLevel)
|
||||
return false;
|
||||
|
||||
@@ -27,8 +27,9 @@ struct ItemTemplate;
|
||||
|
||||
enum TransmogSettings
|
||||
{
|
||||
SETTING_HIDE_TRANSMOG = 0,
|
||||
SETTING_RETROACTIVE_CHECK = 1
|
||||
SETTING_HIDE_TRANSMOG = 0,
|
||||
SETTING_RETROACTIVE_CHECK = 1,
|
||||
SETTING_TRANSMOG_MEMBERSHIP_LEVEL = 2
|
||||
};
|
||||
|
||||
enum MixedWeaponSettings
|
||||
@@ -270,7 +271,7 @@ public:
|
||||
// Transmog Plus
|
||||
bool IsTransmogPlusEnabled;
|
||||
[[nodiscard]] bool IsPlusFeatureEligible(ObjectGuid const& playerGuid, uint32 feature) const;
|
||||
uint32 getPlayerMembershipLevel(ObjectGuid const & playerGuid) const;
|
||||
[[nodiscard]] uint32 GetPlayerMembershipLevel(Player* player) const { return player->GetPlayerSetting("mod-transmog", SETTING_TRANSMOG_MEMBERSHIP_LEVEL).value; };
|
||||
[[nodiscard]] bool IgnoreLevelRequirement(ObjectGuid const& playerGuid) const { return IgnoreReqLevel || IsPlusFeatureEligible(playerGuid, PLUS_FEATURE_SKIP_LEVEL_REQ); }
|
||||
|
||||
uint32 PetSpellId;
|
||||
|
||||
@@ -1120,13 +1120,11 @@ public:
|
||||
void OnLogin(Player* player) override
|
||||
{
|
||||
if (sT->EnableResetRetroActiveAppearances())
|
||||
{
|
||||
player->UpdatePlayerSetting("mod-transmog", SETTING_RETROACTIVE_CHECK, 0);
|
||||
}
|
||||
|
||||
if (sT->EnableRetroActiveAppearances() && !(player->GetPlayerSetting("mod-transmog", SETTING_RETROACTIVE_CHECK).value))
|
||||
{
|
||||
CheckRetroActiveQuestAppearances(player);
|
||||
}
|
||||
|
||||
ObjectGuid playerGUID = player->GetGUID();
|
||||
sT->entryMap.erase(playerGUID);
|
||||
QueryResult result = CharacterDatabase.Query("SELECT GUID, FakeEntry FROM custom_transmogrification WHERE Owner = {}", player->GetGUID().GetCounter());
|
||||
@@ -1141,11 +1139,6 @@ public:
|
||||
sT->dataMap[itemGUID] = playerGUID;
|
||||
sT->entryMap[playerGUID][itemGUID] = fakeEntry;
|
||||
}
|
||||
else
|
||||
{
|
||||
//sLog->outError(LOG_FILTER_SQL, "Item entry (Entry: {}, itemGUID: {}, playerGUID: {}) does not exist, ignoring.", fakeEntry, GUID_LOPART(itemGUID), player->GetGUIDLow());
|
||||
// CharacterDatabase.Execute("DELETE FROM custom_transmogrification WHERE FakeEntry = {}", fakeEntry);
|
||||
}
|
||||
} while (result->NextRow());
|
||||
|
||||
for (uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot)
|
||||
@@ -1155,6 +1148,16 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
uint32 accountId = 0;
|
||||
|
||||
if (player->GetSession())
|
||||
accountId = player->GetSession()->GetAccountId();
|
||||
|
||||
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)
|
||||
player->UpdatePlayerSetting("mod-transmog", SETTING_TRANSMOG_MEMBERSHIP_LEVEL, (*resultAcc)[0].Get<uint32>());
|
||||
|
||||
#ifdef PRESETS
|
||||
if (sT->GetEnableSets())
|
||||
sT->LoadPlayerSets(playerGUID);
|
||||
|
||||
Reference in New Issue
Block a user