Core/Transmog: Implemented TransmogIllusionFlags::PlayerConditionGrantsOnLogin and fixed transmog illusion validation when transmogging items

This commit is contained in:
Shauren
2022-06-09 20:50:03 +02:00
parent 125ada42f6
commit f820ff178d
8 changed files with 47 additions and 24 deletions

View File

@@ -236,6 +236,7 @@ TC_GAME_API extern DB2Storage<TalentEntry> sTalentStore
TC_GAME_API extern DB2Storage<TaxiNodesEntry> sTaxiNodesStore;
TC_GAME_API extern DB2Storage<TaxiPathEntry> sTaxiPathStore;
TC_GAME_API extern DB2Storage<TransmogHolidayEntry> sTransmogHolidayStore;
TC_GAME_API extern DB2Storage<TransmogIllusionEntry> sTransmogIllusionStore;
TC_GAME_API extern DB2Storage<TransmogSetEntry> sTransmogSetStore;
TC_GAME_API extern DB2Storage<TransmogSetGroupEntry> sTransmogSetGroupStore;
TC_GAME_API extern DB2Storage<TransmogSetItemEntry> sTransmogSetItemStore;

View File

@@ -3763,6 +3763,8 @@ struct TransmogIllusionEntry
int32 TransmogCost;
int32 SpellItemEnchantmentID;
int32 Flags;
EnumFlag<TransmogIllusionFlags> GetFlags() const { return static_cast<TransmogIllusionFlags>(Flags); }
};
struct TransmogSetEntry

View File

@@ -1612,6 +1612,14 @@ enum TotemCategoryType
TOTEM_CATEGORY_TYPE_SPANNER = 24
};
enum class TransmogIllusionFlags : int32
{
HideUntilCollected = 0x1,
PlayerConditionGrantsOnLogin = 0x2,
};
DEFINE_ENUM_FLAG(TransmogIllusionFlags);
// SummonProperties.dbc, col 1
enum SummonPropGroup
{

View File

@@ -950,21 +950,26 @@ void CollectionMgr::SaveAccountTransmogIllusions(LoginDatabaseTransaction trans)
}));
}
void CollectionMgr::AddTransmogIllusion(uint16 illusionId)
void CollectionMgr::AddTransmogIllusion(uint32 transmogIllusionId)
{
Player* owner = _owner->GetPlayer();
if (_transmogIllusions->size() <= illusionId)
if (_transmogIllusions->size() <= transmogIllusionId)
{
std::size_t numBlocks = _transmogIllusions->num_blocks();
_transmogIllusions->resize(illusionId + 1);
_transmogIllusions->resize(transmogIllusionId + 1);
numBlocks = _transmogIllusions->num_blocks() - numBlocks;
while (numBlocks--)
owner->AddIllusionBlock(0);
}
_transmogIllusions->set(illusionId);
uint32 blockIndex = illusionId / 32;
uint32 bitIndex = illusionId % 32;
_transmogIllusions->set(transmogIllusionId);
uint32 blockIndex = transmogIllusionId / 32;
uint32 bitIndex = transmogIllusionId % 32;
owner->AddIllusionFlag(blockIndex, 1 << bitIndex);
}
bool CollectionMgr::HasTransmogIllusion(uint32 transmogIllusionId) const
{
return transmogIllusionId < _transmogIllusions->size() && _transmogIllusions->test(transmogIllusionId);
}

View File

@@ -140,9 +140,10 @@ public:
// Illusions
void LoadTransmogIllusions();
void LoadAccountTransmogIllusions(PreparedQueryResult knownIllusions);
void LoadAccountTransmogIllusions(PreparedQueryResult knownTransmogIllusions);
void SaveAccountTransmogIllusions(LoginDatabaseTransaction trans);
void AddTransmogIllusion(uint16 illusionId);
void AddTransmogIllusion(uint32 transmogIllusionId);
bool HasTransmogIllusion(uint32 transmogIllusionId) const;
enum class FavoriteAppearanceState
{

View File

@@ -18715,6 +18715,22 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol
m_questObjectiveCriteriaMgr->CheckAllQuestObjectiveCriteria(this);
PushQuests();
for (TransmogIllusionEntry const* transmogIllusion : sTransmogIllusionStore)
{
if (!transmogIllusion->GetFlags().HasFlag(TransmogIllusionFlags::PlayerConditionGrantsOnLogin))
continue;
if (GetSession()->GetCollectionMgr()->HasTransmogIllusion(transmogIllusion->ID))
continue;
if (PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(transmogIllusion->UnlockConditionID))
if (!ConditionMgr::IsPlayerMeetingCondition(this, playerCondition))
continue;
GetSession()->GetCollectionMgr()->AddTransmogIllusion(transmogIllusion->ID);
}
return true;
}

View File

@@ -128,34 +128,22 @@ void WorldSession::HandleTransmogrifyItems(WorldPackets::Transmogrification::Tra
return;
}
SpellItemEnchantmentEntry const* illusion = sSpellItemEnchantmentStore.LookupEntry(transmogItem.SpellItemEnchantmentID);
TransmogIllusionEntry const* illusion = sDB2Manager.GetTransmogIllusionForEnchantment(transmogItem.SpellItemEnchantmentID);
if (!illusion)
{
TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - %s, Name: %s tried to transmogrify illusion using invalid enchant (%d).", player->GetGUID().ToString().c_str(), player->GetName().c_str(), transmogItem.SpellItemEnchantmentID);
return;
}
if (!illusion->ItemVisual || !illusion->GetFlags().HasFlag(SpellItemEnchantmentFlags::AllowTransmog))
if (PlayerConditionEntry const* condition = sPlayerConditionStore.LookupEntry(illusion->UnlockConditionID))
{
TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - %s, Name: %s tried to transmogrify illusion using not allowed enchant (%d).", player->GetGUID().ToString().c_str(), player->GetName().c_str(), transmogItem.SpellItemEnchantmentID);
return;
}
if (PlayerConditionEntry const* condition = sPlayerConditionStore.LookupEntry(illusion->TransmogUseConditionID))
{
if (!sConditionMgr->IsPlayerMeetingCondition(player, condition))
if (!ConditionMgr::IsPlayerMeetingCondition(player, condition))
{
TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - %s, Name: %s tried to transmogrify illusion using not allowed enchant (%d).", player->GetGUID().ToString().c_str(), player->GetName().c_str(), transmogItem.SpellItemEnchantmentID);
return;
}
}
if (illusion->ScalingClassRestricted > 0 && uint8(illusion->ScalingClassRestricted) != player->GetClass())
{
TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - %s, Name: %s tried to transmogrify illusion using not allowed class enchant (%d).", player->GetGUID().ToString().c_str(), player->GetName().c_str(), transmogItem.SpellItemEnchantmentID);
return;
}
illusionItems[itemTransmogrified] = transmogItem.SpellItemEnchantmentID;
cost += illusion->TransmogCost;
}

View File

@@ -5853,7 +5853,9 @@ void Spell::EffectLearnTransmogIllusion()
if (!player)
return;
uint16 illusionId = effectInfo->MiscValue;
uint32 illusionId = effectInfo->MiscValue;
if (!sTransmogIllusionStore.LookupEntry(illusionId))
return;
player->GetSession()->GetCollectionMgr()->AddTransmogIllusion(illusionId);
}