Core/Transmog: Implemented TransmogIllusionFlags::PlayerConditionGrantsOnLogin and fixed transmog illusion validation when transmogging items
Port From (https://github.com/TrinityCore/TrinityCore/commit/f820ff178decf7d844b7c398b79be7269feeb53e)
This commit is contained in:
@@ -2448,4 +2448,11 @@ namespace Framework.Constants
|
||||
UnitItemOffHandIgnoreDisarmed = 9,
|
||||
UnitItemRangedIgnoreDisarmed = 10
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum TransmogIllusionFlags
|
||||
{
|
||||
HideUntilCollected = 0x1,
|
||||
PlayerConditionGrantsOnLogin = 0x2,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,6 +110,8 @@ namespace Game.DataStorage
|
||||
public int TransmogCost;
|
||||
public int SpellItemEnchantmentID;
|
||||
public int Flags;
|
||||
|
||||
public TransmogIllusionFlags GetFlags() { return (TransmogIllusionFlags)Flags; }
|
||||
}
|
||||
|
||||
public sealed class TransmogSetRecord
|
||||
|
||||
@@ -909,25 +909,30 @@ namespace Game.Entities
|
||||
}
|
||||
}
|
||||
|
||||
public void AddTransmogIllusion(ushort illusionId)
|
||||
public void AddTransmogIllusion(uint transmogIllusionId)
|
||||
{
|
||||
Player owner = _owner.GetPlayer();
|
||||
if (_transmogIllusions.Count <= illusionId)
|
||||
if (_transmogIllusions.Count <= transmogIllusionId)
|
||||
{
|
||||
uint numBlocks = (uint)(_transmogIllusions.Count << 2);
|
||||
_transmogIllusions.Length = illusionId + 1;
|
||||
_transmogIllusions.Length = (int)transmogIllusionId + 1;
|
||||
numBlocks = (uint)(_transmogIllusions.Count << 2) - numBlocks;
|
||||
while (numBlocks-- != 0)
|
||||
owner.AddIllusionBlock(0);
|
||||
}
|
||||
|
||||
_transmogIllusions.Set(illusionId, true);
|
||||
int blockIndex = illusionId / 32;
|
||||
int bitIndex = illusionId % 32;
|
||||
_transmogIllusions.Set((int)transmogIllusionId, true);
|
||||
uint blockIndex = transmogIllusionId / 32;
|
||||
uint bitIndex = transmogIllusionId % 32;
|
||||
|
||||
owner.AddIllusionFlag(blockIndex, (uint)(1 << bitIndex));
|
||||
owner.AddIllusionFlag((int)blockIndex, (uint)(1 << (int)bitIndex));
|
||||
}
|
||||
|
||||
public bool HasTransmogIllusion(uint transmogIllusionId)
|
||||
{
|
||||
return transmogIllusionId < _transmogIllusions.Count && _transmogIllusions.Get((int)transmogIllusionId);
|
||||
}
|
||||
|
||||
public bool HasToy(uint itemId) { return _toys.ContainsKey(itemId); }
|
||||
public Dictionary<uint, ToyFlags> GetAccountToys() { return _toys; }
|
||||
public Dictionary<uint, HeirloomData> GetAccountHeirlooms() { return _heirlooms; }
|
||||
|
||||
@@ -2785,7 +2785,7 @@ namespace Game.Entities
|
||||
mapId = homebind.GetMapId();
|
||||
instance_id = 0;
|
||||
Relocate(homebind);
|
||||
});
|
||||
});
|
||||
|
||||
_LoadGroup(holder.GetResult(PlayerLoginQueryLoad.Group));
|
||||
|
||||
@@ -3354,6 +3354,23 @@ namespace Game.Entities
|
||||
m_questObjectiveCriteriaMgr.CheckAllQuestObjectiveCriteria(this);
|
||||
|
||||
PushQuests();
|
||||
|
||||
foreach (var transmogIllusion in CliDB.TransmogIllusionStorage.Values)
|
||||
{
|
||||
if (!transmogIllusion.GetFlags().HasFlag(TransmogIllusionFlags.PlayerConditionGrantsOnLogin))
|
||||
continue;
|
||||
|
||||
if (GetSession().GetCollectionMgr().HasTransmogIllusion(transmogIllusion.Id))
|
||||
continue;
|
||||
|
||||
var playerCondition = CliDB.PlayerConditionStorage.LookupByKey(transmogIllusion.UnlockConditionID);
|
||||
if (playerCondition != null)
|
||||
if (!ConditionManager.IsPlayerMeetingCondition(this, playerCondition))
|
||||
continue;
|
||||
|
||||
GetSession().GetCollectionMgr().AddTransmogIllusion(transmogIllusion.Id);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -136,20 +136,14 @@ namespace Game
|
||||
return;
|
||||
}
|
||||
|
||||
SpellItemEnchantmentRecord illusion = CliDB.SpellItemEnchantmentStorage.LookupByKey(transmogItem.SpellItemEnchantmentID);
|
||||
TransmogIllusionRecord illusion = Global.DB2Mgr.GetTransmogIllusionForEnchantment((uint)transmogItem.SpellItemEnchantmentID);
|
||||
if (illusion == null)
|
||||
{
|
||||
Log.outDebug(LogFilter.Network, "WORLD: HandleTransmogrifyItems - {0}, Name: {1} tried to transmogrify illusion using invalid enchant ({2}).", player.GetGUID().ToString(), player.GetName(), transmogItem.SpellItemEnchantmentID);
|
||||
return;
|
||||
}
|
||||
|
||||
if (illusion.ItemVisual == 0 || !illusion.GetFlags().HasFlag(SpellItemEnchantmentFlags.AllowTransmog))
|
||||
{
|
||||
Log.outDebug(LogFilter.Network, "WORLD: HandleTransmogrifyItems - {0}, Name: {1} tried to transmogrify illusion using not allowed enchant ({2}).", player.GetGUID().ToString(), player.GetName(), transmogItem.SpellItemEnchantmentID);
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerConditionRecord condition = CliDB.PlayerConditionStorage.LookupByKey(illusion.TransmogUseConditionID);
|
||||
var condition = CliDB.PlayerConditionStorage.LookupByKey(illusion.UnlockConditionID);
|
||||
if (condition != null)
|
||||
{
|
||||
if (!ConditionManager.IsPlayerMeetingCondition(player, condition))
|
||||
@@ -159,12 +153,6 @@ namespace Game
|
||||
}
|
||||
}
|
||||
|
||||
if (illusion.ScalingClassRestricted > 0 && illusion.ScalingClassRestricted != (byte)player.GetClass())
|
||||
{
|
||||
Log.outDebug(LogFilter.Network, "WORLD: HandleTransmogrifyItems - {0}, Name: {1} tried to transmogrify illusion using not allowed class enchant ({2}).", player.GetGUID().ToString(), player.GetName(), transmogItem.SpellItemEnchantmentID);
|
||||
return;
|
||||
}
|
||||
|
||||
illusionItems[itemTransmogrified] = (uint)transmogItem.SpellItemEnchantmentID;
|
||||
cost += illusion.TransmogCost;
|
||||
}
|
||||
|
||||
@@ -5666,7 +5666,11 @@ namespace Game.Spells
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
player.GetSession().GetCollectionMgr().AddTransmogIllusion((ushort)effectInfo.MiscValue);
|
||||
uint illusionId = (uint)effectInfo.MiscValue;
|
||||
if (!CliDB.TransmogIllusionStorage.ContainsKey(illusionId))
|
||||
return;
|
||||
|
||||
player.GetSession().GetCollectionMgr().AddTransmogIllusion(illusionId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user