Core/Misc: Minor compile time improving changes
Port From (https://github.com/TrinityCore/TrinityCore/commit/b5c99939a82ed956cd185cd7a2ede838e2fdf23e)
This commit is contained in:
@@ -142,12 +142,16 @@ namespace Game.Entities
|
|||||||
lineField.Flags = line.Flags;
|
lineField.Flags = line.Flags;
|
||||||
lineField.ChatType = line.ChatType;
|
lineField.ChatType = line.ChatType;
|
||||||
|
|
||||||
|
if (!_lineStartTimes.ContainsKey(line.Id))
|
||||||
|
_lineStartTimes[(int)line.Id] = new TimeSpan[(int)Locale.Total];
|
||||||
|
|
||||||
|
var startTimes = _lineStartTimes[(int)line.Id];
|
||||||
for (Locale locale = Locale.enUS; locale < Locale.Total; locale = locale + 1)
|
for (Locale locale = Locale.enUS; locale < Locale.Total; locale = locale + 1)
|
||||||
{
|
{
|
||||||
if (locale == Locale.None)
|
if (locale == Locale.None)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
_lineStartTimes[(locale, line.Id)] = _lastLineEndTimes[(int)locale];
|
startTimes[(int)locale] = _lastLineEndTimes[(int)locale];
|
||||||
if (locale == Locale.enUS)
|
if (locale == Locale.enUS)
|
||||||
lineField.StartTime = (uint)_lastLineEndTimes[(int)locale].TotalMilliseconds;
|
lineField.StartTime = (uint)_lastLineEndTimes[(int)locale].TotalMilliseconds;
|
||||||
|
|
||||||
@@ -224,7 +228,10 @@ namespace Game.Entities
|
|||||||
|
|
||||||
public TimeSpan GetLineStartTime(Locale locale, int lineId)
|
public TimeSpan GetLineStartTime(Locale locale, int lineId)
|
||||||
{
|
{
|
||||||
return _lineStartTimes.LookupByKey((locale, lineId));
|
if (_lineStartTimes.TryGetValue(lineId, out var timeSpans))
|
||||||
|
return timeSpans[(int)locale];
|
||||||
|
|
||||||
|
return default;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimeSpan GetLastLineEndTime(Locale locale)
|
public TimeSpan GetLastLineEndTime(Locale locale)
|
||||||
@@ -377,7 +384,7 @@ namespace Game.Entities
|
|||||||
TimeSpan _duration;
|
TimeSpan _duration;
|
||||||
uint _textureKitId;
|
uint _textureKitId;
|
||||||
|
|
||||||
Dictionary<(Locale locale, uint lineId), TimeSpan> _lineStartTimes = new();
|
Dictionary<int, TimeSpan[]> _lineStartTimes = new();
|
||||||
TimeSpan[] _lastLineEndTimes = new TimeSpan[(int)Locale.Total];
|
TimeSpan[] _lastLineEndTimes = new TimeSpan[(int)Locale.Total];
|
||||||
|
|
||||||
ConversationAI _ai;
|
ConversationAI _ai;
|
||||||
|
|||||||
@@ -585,6 +585,27 @@ namespace Game.Entities
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void LoadAdditionalDataFromDB(Player owner, ItemAdditionalLoadInfo addionalData)
|
||||||
|
{
|
||||||
|
if (GetTemplate().GetArtifactID() != 0 && addionalData.Artifact != null)
|
||||||
|
LoadArtifactData(owner, addionalData.Artifact.Xp, addionalData.Artifact.ArtifactAppearanceId,
|
||||||
|
addionalData.Artifact.ArtifactTierId, addionalData.Artifact.ArtifactPowers);
|
||||||
|
|
||||||
|
if (addionalData.AzeriteItem != null)
|
||||||
|
{
|
||||||
|
AzeriteItem azeriteItem = ToAzeriteItem();
|
||||||
|
if (azeriteItem != null)
|
||||||
|
azeriteItem.LoadAzeriteItemData(owner, addionalData.AzeriteItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (addionalData.AzeriteEmpoweredItem != null)
|
||||||
|
{
|
||||||
|
AzeriteEmpoweredItem azeriteEmpoweredItem = ToAzeriteEmpoweredItem();
|
||||||
|
if (azeriteEmpoweredItem != null)
|
||||||
|
azeriteEmpoweredItem.LoadAzeriteEmpoweredItemData(owner, addionalData.AzeriteEmpoweredItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void LoadArtifactData(Player owner, ulong xp, uint artifactAppearanceId, uint artifactTier, List<ArtifactPowerData> powers)
|
public void LoadArtifactData(Player owner, ulong xp, uint artifactAppearanceId, uint artifactTier, List<ArtifactPowerData> powers)
|
||||||
{
|
{
|
||||||
for (byte i = 0; i <= artifactTier; ++i)
|
for (byte i = 0; i <= artifactTier; ++i)
|
||||||
@@ -2156,10 +2177,15 @@ namespace Game.Entities
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int GetArtifactPowerIndex(uint artifactPowerId)
|
||||||
|
{
|
||||||
|
return m_itemData.ArtifactPowers.FindIndexIf(artifactPower => artifactPower.ArtifactPowerId == artifactPowerId);
|
||||||
|
}
|
||||||
|
|
||||||
public ArtifactPower GetArtifactPower(uint artifactPowerId)
|
public ArtifactPower GetArtifactPower(uint artifactPowerId)
|
||||||
{
|
{
|
||||||
var index = m_artifactPowerIdToIndex.LookupByKey(artifactPowerId);
|
int index = GetArtifactPowerIndex(artifactPowerId);
|
||||||
if (index != 0)
|
if (index >= 0)
|
||||||
return m_itemData.ArtifactPowers[index];
|
return m_itemData.ArtifactPowers[index];
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@@ -2167,9 +2193,6 @@ namespace Game.Entities
|
|||||||
|
|
||||||
void AddArtifactPower(ArtifactPowerData artifactPower)
|
void AddArtifactPower(ArtifactPowerData artifactPower)
|
||||||
{
|
{
|
||||||
int index = m_artifactPowerIdToIndex.Count;
|
|
||||||
m_artifactPowerIdToIndex[artifactPower.ArtifactPowerId] = (ushort)index;
|
|
||||||
|
|
||||||
ArtifactPower powerField = new();
|
ArtifactPower powerField = new();
|
||||||
powerField.ArtifactPowerId = (ushort)artifactPower.ArtifactPowerId;
|
powerField.ArtifactPowerId = (ushort)artifactPower.ArtifactPowerId;
|
||||||
powerField.PurchasedRank = artifactPower.PurchasedRank;
|
powerField.PurchasedRank = artifactPower.PurchasedRank;
|
||||||
@@ -2180,10 +2203,10 @@ namespace Game.Entities
|
|||||||
|
|
||||||
public void SetArtifactPower(ushort artifactPowerId, byte purchasedRank, byte currentRankWithBonus)
|
public void SetArtifactPower(ushort artifactPowerId, byte purchasedRank, byte currentRankWithBonus)
|
||||||
{
|
{
|
||||||
var foundIndex = m_artifactPowerIdToIndex.LookupByKey(artifactPowerId);
|
int index = GetArtifactPowerIndex(artifactPowerId);
|
||||||
if (foundIndex != 0)
|
if (index >= 0)
|
||||||
{
|
{
|
||||||
ArtifactPower artifactPower = m_values.ModifyValue(m_itemData).ModifyValue(m_itemData.ArtifactPowers, foundIndex);
|
ArtifactPower artifactPower = m_values.ModifyValue(m_itemData).ModifyValue(m_itemData.ArtifactPowers, index);
|
||||||
SetUpdateFieldValue(ref artifactPower.PurchasedRank, purchasedRank);
|
SetUpdateFieldValue(ref artifactPower.PurchasedRank, purchasedRank);
|
||||||
SetUpdateFieldValue(ref artifactPower.CurrentRankWithBonus, currentRankWithBonus);
|
SetUpdateFieldValue(ref artifactPower.CurrentRankWithBonus, currentRankWithBonus);
|
||||||
}
|
}
|
||||||
@@ -2191,12 +2214,16 @@ namespace Game.Entities
|
|||||||
|
|
||||||
public void InitArtifactPowers(byte artifactId, byte artifactTier)
|
public void InitArtifactPowers(byte artifactId, byte artifactTier)
|
||||||
{
|
{
|
||||||
|
List<uint> knownPowers = new();
|
||||||
|
foreach (var power in m_itemData.ArtifactPowers)
|
||||||
|
knownPowers.Add(power.ArtifactPowerId);
|
||||||
|
|
||||||
foreach (ArtifactPowerRecord artifactPower in Global.DB2Mgr.GetArtifactPowers(artifactId))
|
foreach (ArtifactPowerRecord artifactPower in Global.DB2Mgr.GetArtifactPowers(artifactId))
|
||||||
{
|
{
|
||||||
if (artifactPower.Tier != artifactTier)
|
if (artifactPower.Tier != artifactTier)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (m_artifactPowerIdToIndex.ContainsKey(artifactPower.Id))
|
if (knownPowers.Contains(artifactPower.Id))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ArtifactPowerData powerData = new();
|
ArtifactPowerData powerData = new();
|
||||||
@@ -2277,8 +2304,8 @@ namespace Game.Entities
|
|||||||
break;
|
break;
|
||||||
case ItemEnchantmentType.ArtifactPowerBonusRankByID:
|
case ItemEnchantmentType.ArtifactPowerBonusRankByID:
|
||||||
{
|
{
|
||||||
ushort artifactPowerIndex = m_artifactPowerIdToIndex.LookupByKey(enchant.EffectArg[i]);
|
int artifactPowerIndex = GetArtifactPowerIndex(enchant.EffectArg[i]);
|
||||||
if (artifactPowerIndex != 0)
|
if (artifactPowerIndex >= 0)
|
||||||
{
|
{
|
||||||
byte newRank = m_itemData.ArtifactPowers[artifactPowerIndex].CurrentRankWithBonus;
|
byte newRank = m_itemData.ArtifactPowers[artifactPowerIndex].CurrentRankWithBonus;
|
||||||
if (apply)
|
if (apply)
|
||||||
@@ -2579,6 +2606,29 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void UpdateItemSetAuras(Player player, bool formChange)
|
||||||
|
{
|
||||||
|
// item set bonuses not dependent from item broken state
|
||||||
|
foreach (var eff in player.ItemSetEff)
|
||||||
|
{
|
||||||
|
if (eff == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
foreach (var itemSetSpell in eff.SetBonuses)
|
||||||
|
{
|
||||||
|
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(itemSetSpell.SpellID, Difficulty.None);
|
||||||
|
|
||||||
|
if (itemSetSpell.ChrSpecID != 0 && (ChrSpecialization)itemSetSpell.ChrSpecID != player.GetPrimarySpecialization())
|
||||||
|
player.ApplyEquipSpell(spellInfo, null, false, false); // item set aura is not for current spec
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.ApplyEquipSpell(spellInfo, null, false, formChange); // remove spells that not fit to form - removal is skipped if shapeshift condition is satisfied
|
||||||
|
player.ApplyEquipSpell(spellInfo, null, true, formChange); // add spells that fit form but not active
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public BonusData GetBonus() { return _bonusData; }
|
public BonusData GetBonus() { return _bonusData; }
|
||||||
|
|
||||||
public override ObjectGuid GetOwnerGUID() { return m_itemData.Owner; }
|
public override ObjectGuid GetOwnerGUID() { return m_itemData.Owner; }
|
||||||
@@ -2808,7 +2858,6 @@ namespace Game.Entities
|
|||||||
List<ObjectGuid> allowedGUIDs = new();
|
List<ObjectGuid> allowedGUIDs = new();
|
||||||
uint m_randomBonusListId; // store separately to easily find which bonus list is the one randomly given for stat rerolling
|
uint m_randomBonusListId; // store separately to easily find which bonus list is the one randomly given for stat rerolling
|
||||||
ObjectGuid m_childItem;
|
ObjectGuid m_childItem;
|
||||||
Dictionary<uint, ushort> m_artifactPowerIdToIndex = new();
|
|
||||||
Array<uint> m_gemScalingLevels = new(ItemConst.MaxGemSockets);
|
Array<uint> m_gemScalingLevels = new(ItemConst.MaxGemSockets);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -3102,7 +3151,7 @@ namespace Game.Entities
|
|||||||
public byte CurrentRankWithBonus;
|
public byte CurrentRankWithBonus;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ArtifactData
|
public class ArtifactData
|
||||||
{
|
{
|
||||||
public ulong Xp;
|
public ulong Xp;
|
||||||
public uint ArtifactAppearanceId;
|
public uint ArtifactAppearanceId;
|
||||||
@@ -3115,7 +3164,7 @@ namespace Game.Entities
|
|||||||
public int[] SelectedAzeritePowers = new int[SharedConst.MaxAzeriteEmpoweredTier];
|
public int[] SelectedAzeritePowers = new int[SharedConst.MaxAzeriteEmpoweredTier];
|
||||||
}
|
}
|
||||||
|
|
||||||
class ItemAdditionalLoadInfo
|
public class ItemAdditionalLoadInfo
|
||||||
{
|
{
|
||||||
public ArtifactData Artifact;
|
public ArtifactData Artifact;
|
||||||
public AzeriteData AzeriteItem;
|
public AzeriteData AzeriteItem;
|
||||||
|
|||||||
@@ -47,25 +47,7 @@ namespace Game.Entities
|
|||||||
{
|
{
|
||||||
var addionalData = additionalData.LookupByKey(item.GetGUID().GetCounter());
|
var addionalData = additionalData.LookupByKey(item.GetGUID().GetCounter());
|
||||||
if (addionalData != null)
|
if (addionalData != null)
|
||||||
{
|
item.LoadAdditionalDataFromDB(this, addionalData);
|
||||||
if (item.GetTemplate().GetArtifactID() != 0 && addionalData.Artifact != null)
|
|
||||||
item.LoadArtifactData(this, addionalData.Artifact.Xp, addionalData.Artifact.ArtifactAppearanceId, addionalData.Artifact.ArtifactTierId, addionalData.Artifact.ArtifactPowers);
|
|
||||||
|
|
||||||
if (addionalData.AzeriteItem != null)
|
|
||||||
{
|
|
||||||
AzeriteItem azeriteItem = item.ToAzeriteItem();
|
|
||||||
if (azeriteItem != null)
|
|
||||||
azeriteItem.LoadAzeriteItemData(this, addionalData.AzeriteItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (addionalData.AzeriteEmpoweredItem != null)
|
|
||||||
{
|
|
||||||
AzeriteEmpoweredItem azeriteEmpoweredItem = item.ToAzeriteEmpoweredItem();
|
|
||||||
if (azeriteEmpoweredItem != null)
|
|
||||||
azeriteEmpoweredItem.LoadAzeriteEmpoweredItemData(this, addionalData.AzeriteEmpoweredItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ulong dbId = result.Read<ulong>(52);
|
ulong dbId = result.Read<ulong>(52);
|
||||||
ObjectGuid bagGuid = dbId != 0 ? ObjectGuid.Create(HighGuid.Item, dbId) : ObjectGuid.Empty;
|
ObjectGuid bagGuid = dbId != 0 ? ObjectGuid.Create(HighGuid.Item, dbId) : ObjectGuid.Empty;
|
||||||
@@ -1432,25 +1414,7 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (addionalData != null)
|
if (addionalData != null)
|
||||||
{
|
item.LoadAdditionalDataFromDB(player, addionalData);
|
||||||
if (item.GetTemplate().GetArtifactID() != 0 && addionalData.Artifact != null)
|
|
||||||
item.LoadArtifactData(player, addionalData.Artifact.Xp, addionalData.Artifact.ArtifactAppearanceId,
|
|
||||||
addionalData.Artifact.ArtifactTierId, addionalData.Artifact.ArtifactPowers);
|
|
||||||
|
|
||||||
if (addionalData.AzeriteItem != null)
|
|
||||||
{
|
|
||||||
AzeriteItem azeriteItem = item.ToAzeriteItem();
|
|
||||||
if (azeriteItem != null)
|
|
||||||
azeriteItem.LoadAzeriteItemData(player, addionalData.AzeriteItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (addionalData.AzeriteEmpoweredItem != null)
|
|
||||||
{
|
|
||||||
AzeriteEmpoweredItem azeriteEmpoweredItem = item.ToAzeriteEmpoweredItem();
|
|
||||||
if (azeriteEmpoweredItem != null)
|
|
||||||
azeriteEmpoweredItem.LoadAzeriteEmpoweredItemData(player, addionalData.AzeriteEmpoweredItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mail != null)
|
if (mail != null)
|
||||||
mail.AddItem(itemGuid, itemEntry);
|
mail.AddItem(itemGuid, itemEntry);
|
||||||
|
|||||||
@@ -3346,31 +3346,7 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateItemSetAuras(true);
|
Item.UpdateItemSetAuras(this, true);
|
||||||
}
|
|
||||||
|
|
||||||
void UpdateItemSetAuras(bool formChange = false)
|
|
||||||
{
|
|
||||||
// item set bonuses not dependent from item broken state
|
|
||||||
for (int setindex = 0; setindex < ItemSetEff.Count; ++setindex)
|
|
||||||
{
|
|
||||||
ItemSetEffect eff = ItemSetEff[setindex];
|
|
||||||
if (eff == null)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
foreach (ItemSetSpellRecord itemSetSpell in eff.SetBonuses)
|
|
||||||
{
|
|
||||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(itemSetSpell.SpellID, Difficulty.None);
|
|
||||||
|
|
||||||
if (itemSetSpell.ChrSpecID != 0 && (ChrSpecialization)itemSetSpell.ChrSpecID != GetPrimarySpecialization())
|
|
||||||
ApplyEquipSpell(spellInfo, null, false, false); // item set aura is not for current spec
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ApplyEquipSpell(spellInfo, null, false, formChange); // remove spells that not fit to form - removal is skipped if shapeshift condition is satisfied
|
|
||||||
ApplyEquipSpell(spellInfo, null, true, formChange); // add spells that fit form but not active
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetSpellPenetrationItemMod() { return m_spellPenetrationItemMod; }
|
public int GetSpellPenetrationItemMod() { return m_spellPenetrationItemMod; }
|
||||||
|
|||||||
@@ -232,7 +232,7 @@ namespace Game.Entities
|
|||||||
LearnSpecializationSpells();
|
LearnSpecializationSpells();
|
||||||
|
|
||||||
SendTalentsInfoData();
|
SendTalentsInfoData();
|
||||||
UpdateItemSetAuras(false);
|
Item.UpdateItemSetAuras(this, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HasTalent(uint talentId, byte group)
|
bool HasTalent(uint talentId, byte group)
|
||||||
@@ -422,7 +422,7 @@ namespace Game.Entities
|
|||||||
SetPower(PowerType.Mana, 0); // Mana must be 0 even if it isn't the active power type.
|
SetPower(PowerType.Mana, 0); // Mana must be 0 even if it isn't the active power type.
|
||||||
|
|
||||||
SetPower(pw, 0);
|
SetPower(pw, 0);
|
||||||
UpdateItemSetAuras(false);
|
Item.UpdateItemSetAuras(this, false);
|
||||||
|
|
||||||
// update visible transmog
|
// update visible transmog
|
||||||
for (byte i = EquipmentSlot.Start; i < EquipmentSlot.End; ++i)
|
for (byte i = EquipmentSlot.Start; i < EquipmentSlot.End; ++i)
|
||||||
|
|||||||
Reference in New Issue
Block a user