public static void HandleNonSpellActionSetChanges(WorldSession session, ClientNonSpellActionSetChanges requestActionSetChanges) { // TODO: validate the rest of the shortcut types when known switch (requestActionSetChanges.ShortcutType) { case ShortcutType.Item: { if (GameTableManager.Instance.Item.GetEntry(requestActionSetChanges.ObjectId) == null) { throw new InvalidPacketValueException(); } break; } case ShortcutType.Spell: throw new InvalidPacketValueException(); default: throw new NotImplementedException(); } ActionSet actionSet = session.Player.SpellManager.GetActionSet(requestActionSetChanges.Unknown); if (requestActionSetChanges.ObjectId == 0u) { actionSet.RemoveShortcut(requestActionSetChanges.ActionBarIndex); } else { actionSet.AddShortcut(requestActionSetChanges.ActionBarIndex, requestActionSetChanges.ShortcutType, requestActionSetChanges.ObjectId, 0); } }
public static void HandleRequestActionSetChanges(WorldSession session, ClientRequestActionSetChanges requestActionSetChanges) { // TODO: check for client validity, e.g. Level & Spell4TierRequirements ActionSet actionSet = session.Player.SpellManager.GetActionSet(requestActionSetChanges.ActionSetIndex); List <ActionSetShortcut> shortcuts = actionSet.Actions.ToList(); for (UILocation i = 0; i < (UILocation)requestActionSetChanges.Actions.Count; i++) { ActionSetShortcut shortcut = actionSet.GetShortcut(i); if (shortcut != null) { actionSet.RemoveShortcut(i); } uint spell4BaseId = requestActionSetChanges.Actions[(int)i]; if (spell4BaseId != 0u) { ActionSetShortcut existingShortcut = shortcuts.SingleOrDefault(s => s.ObjectId == spell4BaseId); byte tier = existingShortcut?.Tier ?? 1; actionSet.AddShortcut(i, ShortcutType.Spell, spell4BaseId, tier); } } foreach (ClientRequestActionSetChanges.ActionTier actionTier in requestActionSetChanges.ActionTiers) { session.Player.SpellManager.UpdateSpell(actionTier.Action, actionTier.Tier, requestActionSetChanges.ActionSetIndex); } session.EnqueueMessageEncrypted(actionSet.BuildServerActionSet()); if (requestActionSetChanges.ActionTiers.Count > 0) { session.Player.SpellManager.SendServerAbilityPoints(); } // only new AMP can be added with this packet, filter out existing ones List <ushort> newAmps = requestActionSetChanges.Amps .Except(actionSet.Amps .Select(a => (ushort)a.Entry.Id)) .ToList(); if (newAmps.Count > 0) { foreach (ushort id in newAmps) { actionSet.AddAmp(id); } session.EnqueueMessageEncrypted(actionSet.BuildServerAmpList()); } }