Core/Items: Add helper function to get item name including suffix

Port From (https://github.com/TrinityCore/TrinityCore/commit/ecdf3d1a141af4cc0c1ced1bd23e8148ed3a2000)
This commit is contained in:
hondacrx
2020-04-26 01:04:13 -04:00
parent a229f29a27
commit 24a1bb6331
4 changed files with 31 additions and 12 deletions
+5 -5
View File
@@ -2506,19 +2506,19 @@ namespace Game.Entities
return vCount.count; return vCount.count;
} }
public override string GetName(LocaleConstant locale_idx = LocaleConstant.enUS) public override string GetName(LocaleConstant locale = LocaleConstant.enUS)
{ {
if (locale_idx != LocaleConstant.enUS) if (locale != LocaleConstant.enUS)
{ {
CreatureLocale cl = Global.ObjectMgr.GetCreatureLocale(GetEntry()); CreatureLocale cl = Global.ObjectMgr.GetCreatureLocale(GetEntry());
if (cl != null) if (cl != null)
{ {
if (cl.Name.Length > (byte)locale_idx && !string.IsNullOrEmpty(cl.Name[(byte)locale_idx])) if (cl.Name.Length > (int)locale && !cl.Name[(int)locale].IsEmpty())
return cl.Name[(byte)locale_idx]; return cl.Name[(int)locale];
} }
} }
return base.GetName(locale_idx); return base.GetName(locale);
} }
public virtual byte GetPetAutoSpellSize() { return 4; } public virtual byte GetPetAutoSpellSize() { return 4; }
@@ -2085,18 +2085,17 @@ namespace Game.Entities
return GetGoInfo().ScriptId; return GetGoInfo().ScriptId;
} }
public override string GetName(LocaleConstant loc_idx = LocaleConstant.enUS) public override string GetName(LocaleConstant locale = LocaleConstant.enUS)
{ {
if (loc_idx != LocaleConstant.enUS) if (locale != LocaleConstant.enUS)
{ {
byte uloc_idx = (byte)loc_idx;
GameObjectLocale cl = Global.ObjectMgr.GetGameObjectLocale(GetEntry()); GameObjectLocale cl = Global.ObjectMgr.GetGameObjectLocale(GetEntry());
if (cl != null) if (cl != null)
if (cl.Name.Length > uloc_idx && !string.IsNullOrEmpty(cl.Name[uloc_idx])) if (cl.Name.Length > (int)locale && !cl.Name[(int)locale].IsEmpty())
return cl.Name[uloc_idx]; return cl.Name[(int)locale];
} }
return base.GetName(loc_idx); return base.GetName(locale);
} }
public void UpdatePackedRotation() public void UpdatePackedRotation()
+20
View File
@@ -106,6 +106,16 @@ namespace Game.Entities
return true; return true;
} }
public override string GetName(LocaleConstant locale = LocaleConstant.enUS)
{
ItemTemplate itemTemplate = GetTemplate();
var suffix = CliDB.ItemNameDescriptionStorage.LookupByKey(_bonusData.Suffix);
if (suffix != null)
return $"{itemTemplate.GetName(locale)} {suffix.Description[locale]}";
return itemTemplate.GetName(locale);
}
public bool IsNotEmptyBag() public bool IsNotEmptyBag()
{ {
Bag bag = ToBag(); Bag bag = ToBag();
@@ -2861,6 +2871,7 @@ namespace Game.Entities
CanDisenchant = !proto.GetFlags().HasAnyFlag(ItemFlags.NoDisenchant); CanDisenchant = !proto.GetFlags().HasAnyFlag(ItemFlags.NoDisenchant);
CanScrap = proto.GetFlags4().HasAnyFlag(ItemFlags4.Scrapable); CanScrap = proto.GetFlags4().HasAnyFlag(ItemFlags4.Scrapable);
_state.SuffixPriority = int.MaxValue;
_state.AppearanceModPriority = int.MaxValue; _state.AppearanceModPriority = int.MaxValue;
_state.ScalingStatDistributionPriority = int.MaxValue; _state.ScalingStatDistributionPriority = int.MaxValue;
_state.AzeriteTierUnlockSetPriority = int.MaxValue; _state.AzeriteTierUnlockSetPriority = int.MaxValue;
@@ -2914,6 +2925,13 @@ namespace Game.Entities
else if ((uint)Quality < values[0]) else if ((uint)Quality < values[0])
Quality = (ItemQuality)values[0]; Quality = (ItemQuality)values[0];
break; break;
case ItemBonusType.Suffix:
if (values[1] < _state.SuffixPriority)
{
Suffix = (uint)values[0];
_state.SuffixPriority = values[1];
}
break;
case ItemBonusType.Socket: case ItemBonusType.Socket:
{ {
uint socketCount = (uint)values[0]; uint socketCount = (uint)values[0];
@@ -2994,6 +3012,7 @@ namespace Game.Entities
public int RelicType; public int RelicType;
public int RequiredLevelOverride; public int RequiredLevelOverride;
public uint AzeriteTierUnlockSetId; public uint AzeriteTierUnlockSetId;
public uint Suffix;
public bool CanDisenchant; public bool CanDisenchant;
public bool CanScrap; public bool CanScrap;
public bool HasFixedLevel; public bool HasFixedLevel;
@@ -3001,6 +3020,7 @@ namespace Game.Entities
struct State struct State
{ {
public int SuffixPriority;
public int AppearanceModPriority; public int AppearanceModPriority;
public int ScalingStatDistributionPriority; public int ScalingStatDistributionPriority;
public int AzeriteTierUnlockSetPriority; public int AzeriteTierUnlockSetPriority;
+1 -1
View File
@@ -1681,7 +1681,7 @@ namespace Game.Entities
public virtual ushort GetMovementAnimKitId() { return 0; } public virtual ushort GetMovementAnimKitId() { return 0; }
public virtual ushort GetMeleeAnimKitId() { return 0; } public virtual ushort GetMeleeAnimKitId() { return 0; }
public virtual string GetName(LocaleConstant locale_idx = LocaleConstant.enUS) { return _name; } public virtual string GetName(LocaleConstant locale = LocaleConstant.enUS) { return _name; }
public void SetName(string name) { _name = name; } public void SetName(string name) { _name = name; }
public ObjectGuid GetGUID() { return m_guid; } public ObjectGuid GetGUID() { return m_guid; }