Core/Misc: Turn ChrSpecialization into enum
Port From (https://github.com/TrinityCore/TrinityCore/commit/98007f859b7318570c0c923a00aa32fc485c8ec8)
This commit is contained in:
@@ -1137,7 +1137,7 @@ namespace Game.Entities
|
||||
int activeConfig = m_activePlayerData.TraitConfigs.FindIndexIf(traitConfig =>
|
||||
{
|
||||
return traitConfig.Type == (int)TraitConfigType.Combat
|
||||
&& traitConfig.ChrSpecializationID == GetPrimarySpecialization()
|
||||
&& traitConfig.ChrSpecializationID == (int)GetPrimarySpecialization()
|
||||
&& (traitConfig.CombatConfigFlags & (int)TraitCombatConfigFlags.ActiveForSpec) != 0;
|
||||
});
|
||||
|
||||
@@ -3321,7 +3321,7 @@ namespace Game.Entities
|
||||
SetNumRespecs(numRespecs);
|
||||
SetPrimarySpecialization(primarySpecialization);
|
||||
SetActiveTalentGroup(activeTalentGroup);
|
||||
ChrSpecializationRecord primarySpec = CliDB.ChrSpecializationStorage.LookupByKey(GetPrimarySpecialization());
|
||||
ChrSpecializationRecord primarySpec = GetPrimarySpecializationEntry();
|
||||
if (primarySpec == null || primarySpec.ClassID != (byte)GetClass() || GetActiveTalentGroup() >= PlayerConst.MaxSpecializations)
|
||||
ResetTalentSpecialization();
|
||||
|
||||
@@ -3676,7 +3676,7 @@ namespace Game.Entities
|
||||
//save, but in tavern/city
|
||||
stmt.AddValue(index++, GetTalentResetCost());
|
||||
stmt.AddValue(index++, GetTalentResetTime());
|
||||
stmt.AddValue(index++, GetPrimarySpecialization());
|
||||
stmt.AddValue(index++, (uint)GetPrimarySpecialization());
|
||||
stmt.AddValue(index++, (ushort)m_ExtraFlags);
|
||||
stmt.AddValue(index++, 0); // summonedPetNumber
|
||||
stmt.AddValue(index++, (ushort)atLoginFlags);
|
||||
@@ -3806,7 +3806,7 @@ namespace Game.Entities
|
||||
stmt.AddValue(index++, GetTalentResetCost());
|
||||
stmt.AddValue(index++, GetTalentResetTime());
|
||||
stmt.AddValue(index++, GetNumRespecs());
|
||||
stmt.AddValue(index++, GetPrimarySpecialization());
|
||||
stmt.AddValue(index++, (uint)GetPrimarySpecialization());
|
||||
stmt.AddValue(index++, (ushort)m_ExtraFlags);
|
||||
PetStable petStable = GetPetStable();
|
||||
if (petStable != null)
|
||||
|
||||
@@ -1481,7 +1481,7 @@ namespace Game.Entities
|
||||
|
||||
ArtifactRecord artifact = CliDB.ArtifactStorage.LookupByKey(proto.GetArtifactID());
|
||||
if (artifact != null)
|
||||
if (artifact.ChrSpecializationID != GetPrimarySpecialization())
|
||||
if ((ChrSpecialization)artifact.ChrSpecializationID != GetPrimarySpecialization())
|
||||
return InventoryResult.CantUseItem;
|
||||
|
||||
return InventoryResult.Ok;
|
||||
@@ -3829,7 +3829,7 @@ namespace Game.Entities
|
||||
if (spellproto == null)
|
||||
continue;
|
||||
|
||||
if (effectData.ChrSpecializationID != 0 && effectData.ChrSpecializationID != GetPrimarySpecialization())
|
||||
if (effectData.ChrSpecializationID != 0 && (ChrSpecialization)effectData.ChrSpecializationID != GetPrimarySpecialization())
|
||||
continue;
|
||||
|
||||
ApplyEquipSpell(spellproto, item, apply, formChange);
|
||||
@@ -5495,7 +5495,7 @@ namespace Game.Entities
|
||||
{
|
||||
if (apply)
|
||||
{
|
||||
if (azeritePower.SpecSetID == 0 || Global.DB2Mgr.IsSpecSetMember(azeritePower.SpecSetID, GetPrimarySpecialization()))
|
||||
if (azeritePower.SpecSetID == 0 || Global.DB2Mgr.IsSpecSetMember(azeritePower.SpecSetID, (uint)GetPrimarySpecialization()))
|
||||
CastSpell(this, azeritePower.SpellID, item);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -299,7 +299,7 @@ namespace Game.Entities
|
||||
|
||||
void LearnSpecializationSpells()
|
||||
{
|
||||
var specSpells = Global.DB2Mgr.GetSpecializationSpells(GetPrimarySpecialization());
|
||||
var specSpells = Global.DB2Mgr.GetSpecializationSpells((uint)GetPrimarySpecialization());
|
||||
if (specSpells != null)
|
||||
{
|
||||
for (int j = 0; j < specSpells.Count; ++j)
|
||||
@@ -1029,7 +1029,7 @@ namespace Game.Entities
|
||||
|
||||
public bool CanUseMastery()
|
||||
{
|
||||
ChrSpecializationRecord chrSpec = CliDB.ChrSpecializationStorage.LookupByKey(GetPrimarySpecialization());
|
||||
ChrSpecializationRecord chrSpec = GetPrimarySpecializationEntry();
|
||||
if (chrSpec != null)
|
||||
return HasSpell(chrSpec.MasterySpellID[0]) || HasSpell(chrSpec.MasterySpellID[1]);
|
||||
|
||||
@@ -3257,7 +3257,7 @@ namespace Game.Entities
|
||||
{
|
||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(itemSetSpell.SpellID, Difficulty.None);
|
||||
|
||||
if (itemSetSpell.ChrSpecID != 0 && itemSetSpell.ChrSpecID != GetPrimarySpecialization())
|
||||
if (itemSetSpell.ChrSpecID != 0 && (ChrSpecialization)itemSetSpell.ChrSpecID != GetPrimarySpecialization())
|
||||
ApplyEquipSpell(spellInfo, null, false, false); // item set aura is not for current spec
|
||||
else
|
||||
{
|
||||
|
||||
@@ -120,14 +120,14 @@ namespace Game.Entities
|
||||
if (IsDead())
|
||||
return TalentLearnResult.FailedCantDoThatRightNow;
|
||||
|
||||
if (GetPrimarySpecialization() == 0)
|
||||
if (GetPrimarySpecialization() == ChrSpecialization.None)
|
||||
return TalentLearnResult.FailedNoPrimaryTreeSelected;
|
||||
|
||||
TalentRecord talentInfo = CliDB.TalentStorage.LookupByKey(talentId);
|
||||
if (talentInfo == null)
|
||||
return TalentLearnResult.FailedUnknown;
|
||||
|
||||
if (talentInfo.SpecID != 0 && talentInfo.SpecID != GetPrimarySpecialization())
|
||||
if (talentInfo.SpecID != 0 && (ChrSpecialization)talentInfo.SpecID != GetPrimarySpecialization())
|
||||
return TalentLearnResult.FailedUnknown;
|
||||
|
||||
// prevent learn talent for different class (cheating)
|
||||
@@ -152,7 +152,7 @@ namespace Game.Entities
|
||||
if (talent.SpecID == 0)
|
||||
bestSlotMatch = talent;
|
||||
|
||||
else if (talent.SpecID == GetPrimarySpecialization())
|
||||
else if ((ChrSpecialization)talent.SpecID == GetPrimarySpecialization())
|
||||
{
|
||||
bestSlotMatch = talent;
|
||||
break;
|
||||
@@ -167,7 +167,7 @@ namespace Game.Entities
|
||||
{
|
||||
foreach (TalentRecord talent in Global.DB2Mgr.GetTalentsByPosition(GetClass(), talentInfo.TierID, c))
|
||||
{
|
||||
if (talent.SpecID != 0 && talent.SpecID != GetPrimarySpecialization())
|
||||
if (talent.SpecID != 0 && (ChrSpecialization)talent.SpecID != GetPrimarySpecialization())
|
||||
continue;
|
||||
|
||||
if (!HasTalent(talent.Id, GetActiveTalentGroup()))
|
||||
@@ -241,16 +241,29 @@ namespace Game.Entities
|
||||
}
|
||||
|
||||
uint GetTalentResetCost() { return _specializationInfo.ResetTalentsCost; }
|
||||
|
||||
void SetTalentResetCost(uint cost) { _specializationInfo.ResetTalentsCost = cost; }
|
||||
|
||||
long GetTalentResetTime() { return _specializationInfo.ResetTalentsTime; }
|
||||
|
||||
void SetTalentResetTime(long time_) { _specializationInfo.ResetTalentsTime = time_; }
|
||||
public uint GetPrimarySpecialization() { return m_playerData.CurrentSpecID; }
|
||||
|
||||
public ChrSpecialization GetPrimarySpecialization() { return (ChrSpecialization)m_playerData.CurrentSpecID.GetValue(); }
|
||||
|
||||
void SetPrimarySpecialization(uint spec) { SetUpdateFieldValue(m_values.ModifyValue(m_playerData).ModifyValue(m_playerData.CurrentSpecID), spec); }
|
||||
|
||||
public ChrSpecializationRecord GetPrimarySpecializationEntry()
|
||||
{
|
||||
return CliDB.ChrSpecializationStorage.LookupByKey((uint)GetPrimarySpecialization());
|
||||
}
|
||||
|
||||
public byte GetActiveTalentGroup() { return _specializationInfo.ActiveGroup; }
|
||||
|
||||
void SetActiveTalentGroup(byte group) { _specializationInfo.ActiveGroup = group; }
|
||||
|
||||
// Loot Spec
|
||||
public void SetLootSpecId(uint id) { SetUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.LootSpecID), (ushort)id); }
|
||||
|
||||
public uint GetLootSpecId() { return m_activePlayerData.LootSpecID; }
|
||||
|
||||
public uint GetDefaultSpecId()
|
||||
@@ -602,7 +615,7 @@ namespace Game.Entities
|
||||
public void SendTalentsInfoData()
|
||||
{
|
||||
UpdateTalentData packet = new();
|
||||
packet.Info.PrimarySpecialization = GetPrimarySpecialization();
|
||||
packet.Info.PrimarySpecialization = (uint)GetPrimarySpecialization();
|
||||
|
||||
for (byte i = 0; i < PlayerConst.MaxSpecializations; ++i)
|
||||
{
|
||||
@@ -711,7 +724,7 @@ namespace Game.Entities
|
||||
if (talentInfo == null)
|
||||
return TalentLearnResult.FailedUnknown;
|
||||
|
||||
if (talentInfo.SpecID != GetPrimarySpecialization())
|
||||
if ((ChrSpecialization)talentInfo.SpecID != GetPrimarySpecialization())
|
||||
return TalentLearnResult.FailedUnknown;
|
||||
|
||||
if (talentInfo.LevelRequired > GetLevel())
|
||||
|
||||
Reference in New Issue
Block a user