From ae6affc44a927665aac13454544ff54cf89770bb Mon Sep 17 00:00:00 2001 From: hondacrx Date: Wed, 27 Jan 2021 00:14:50 -0500 Subject: [PATCH] Core/Talents: Fixes learning pvp talents --- Source/Game/Entities/Player/Player.Fields.cs | 4 ++-- Source/Game/Entities/Player/Player.PvP.cs | 11 ++++++++--- Source/Game/Entities/Player/Player.Talents.cs | 7 +++++-- Source/Game/Networking/Packets/TalentPackets.cs | 8 ++++---- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Source/Game/Entities/Player/Player.Fields.cs b/Source/Game/Entities/Player/Player.Fields.cs index 21567b878..478fb3b33 100644 --- a/Source/Game/Entities/Player/Player.Fields.cs +++ b/Source/Game/Entities/Player/Player.Fields.cs @@ -329,13 +329,13 @@ namespace Game.Entities for (byte i = 0; i < PlayerConst.MaxSpecializations; ++i) { Talents[i] = new Dictionary(); - PvpTalents[i] = new Array(PlayerConst.MaxPvpTalentSlots, 0); + PvpTalents[i] = new uint[PlayerConst.MaxPvpTalentSlots]; Glyphs[i] = new List(); } } public Dictionary[] Talents = new Dictionary[PlayerConst.MaxSpecializations]; - public Array[] PvpTalents = new Array[PlayerConst.MaxSpecializations]; + public uint[][] PvpTalents = new uint[PlayerConst.MaxSpecializations][]; public List[] Glyphs = new List[PlayerConst.MaxSpecializations]; public uint ResetTalentsCost; public long ResetTalentsTime; diff --git a/Source/Game/Entities/Player/Player.PvP.cs b/Source/Game/Entities/Player/Player.PvP.cs index c0a61073f..5e90858ce 100644 --- a/Source/Game/Entities/Player/Player.PvP.cs +++ b/Source/Game/Entities/Player/Player.PvP.cs @@ -27,6 +27,7 @@ using Game.PvP; using Game.Spells; using System; using System.Collections.Generic; +using System.Linq; namespace Game.Entities { @@ -416,9 +417,13 @@ namespace Game.Entities if (talent.OverridesSpellID != 0) RemoveOverrideSpell(talent.OverridesSpellID, talent.SpellID); - //todo check this // if this talent rank can be found in the PlayerTalentMap, mark the talent as removed so it gets deleted - GetPvpTalentMap(GetActiveTalentGroup()).Remove(talent.Id); + var talents = GetPvpTalentMap(GetActiveTalentGroup()); + for (var i = 0; i < PlayerConst.MaxPvpTalentSlots; ++i) + { + if (talents[i] == talent.Id) + talents[i] = 0; + } } public void TogglePvpTalents(bool enable) @@ -520,7 +525,7 @@ namespace Game.Entities return false; } - public Array GetPvpTalentMap(byte spec) { return _specializationInfo.PvpTalents[spec]; } + public uint[] GetPvpTalentMap(byte spec) { return _specializationInfo.PvpTalents[spec]; } //BGs public Battleground GetBattleground() diff --git a/Source/Game/Entities/Player/Player.Talents.cs b/Source/Game/Entities/Player/Player.Talents.cs index 2569e7e14..b7b830c80 100644 --- a/Source/Game/Entities/Player/Player.Talents.cs +++ b/Source/Game/Entities/Player/Player.Talents.cs @@ -603,13 +603,16 @@ namespace Game.Entities continue; } - groupInfoPkt.PvPTalentIDs.Add((ushort)pvpTalents[slot]); + PvPTalent pvpTalent = new PvPTalent(); + pvpTalent.PvPTalentID = (ushort)pvpTalents[slot]; + pvpTalent.Slot = slot; + groupInfoPkt.PvPTalents.Add(pvpTalent); } if (i == GetActiveTalentGroup()) packet.Info.ActiveGroup = (byte)packet.Info.TalentGroups.Count; - if (!groupInfoPkt.TalentIDs.Empty() || !groupInfoPkt.PvPTalentIDs.Empty() || i == GetActiveTalentGroup()) + if (!groupInfoPkt.TalentIDs.Empty() || !groupInfoPkt.PvPTalents.Empty() || i == GetActiveTalentGroup()) packet.Info.TalentGroups.Add(groupInfoPkt); } diff --git a/Source/Game/Networking/Packets/TalentPackets.cs b/Source/Game/Networking/Packets/TalentPackets.cs index 7219225ca..a3a9c672f 100644 --- a/Source/Game/Networking/Packets/TalentPackets.cs +++ b/Source/Game/Networking/Packets/TalentPackets.cs @@ -35,13 +35,13 @@ namespace Game.Networking.Packets { _worldPacket.WriteUInt32(talentGroupInfo.SpecID); _worldPacket.WriteInt32(talentGroupInfo.TalentIDs.Count); - _worldPacket.WriteInt32(talentGroupInfo.PvPTalentIDs.Count); + _worldPacket.WriteInt32(talentGroupInfo.PvPTalents.Count); foreach (var talentID in talentGroupInfo.TalentIDs) _worldPacket.WriteUInt16(talentID); - foreach (ushort talentID in talentGroupInfo.PvPTalentIDs) - _worldPacket.WriteUInt16(talentID); + foreach (PvPTalent talent in talentGroupInfo.PvPTalents) + talent.Write(_worldPacket); } } @@ -51,7 +51,7 @@ namespace Game.Networking.Packets { public uint SpecID; public List TalentIDs = new List(); - public List PvPTalentIDs = new List(); + public List PvPTalents = new List(); } public class TalentInfoUpdate