Core/Unit: Make HandleEmoteCommand typesafe

Port From (https://github.com/TrinityCore/TrinityCore/commit/2e3c612c808bca7601b32ce5dca28b204e652773)
This commit is contained in:
hondacrx
2022-03-03 13:44:00 -05:00
parent b5206453f6
commit bfd3cd9731
4 changed files with 14 additions and 13 deletions
+5 -1
View File
@@ -1465,7 +1465,11 @@ namespace Framework.Constants
StateWasit04 = 986, StateWasit04 = 986,
OneshotBarsweepStand = 987, OneshotBarsweepStand = 987,
TorghastTalkingHeadMawCastSound = 989, TorghastTalkingHeadMawCastSound = 989,
TorghastTalkingHeadMawCastSound2 = 990 TorghastTalkingHeadMawCastSound2 = 990,
OneshotStandVar0 = 991,
OneshotFlycustomspell01 = 992,
OneshotSpelleffectDecay = 993,
CreatureSpecial = 994,
} }
public enum GlyphSlotType public enum GlyphSlotType
+3 -6
View File
@@ -36,15 +36,12 @@ namespace Game.Chat
class DebugCommands class DebugCommands
{ {
[Command("anim", RBACPermissions.CommandDebugAnim)] [Command("anim", RBACPermissions.CommandDebugAnim)]
static bool HandleDebugAnimCommand(CommandHandler handler, StringArguments args) static bool HandleDebugAnimCommand(CommandHandler handler, uint emoteId)
{ {
if (args.Empty())
return false;
uint animId = args.NextUInt32();
Unit unit = handler.GetSelectedUnit(); Unit unit = handler.GetSelectedUnit();
if (unit) if (unit)
unit.HandleEmoteCommand((Emote)animId); unit.HandleEmoteCommand((Emote)emoteId);
return true; return true;
} }
+5 -5
View File
@@ -567,9 +567,9 @@ namespace Game
if (em == null) if (em == null)
return; return;
Emote emoteAnim = (Emote)em.EmoteId; Emote emote = (Emote)em.EmoteId;
switch (emoteAnim) switch (emote)
{ {
case Emote.StateSleep: case Emote.StateSleep:
case Emote.StateSit: case Emote.StateSit:
@@ -578,13 +578,13 @@ namespace Game
break; break;
case Emote.StateDance: case Emote.StateDance:
case Emote.StateRead: case Emote.StateRead:
GetPlayer().SetEmoteState(emoteAnim); GetPlayer().SetEmoteState(emote);
break; break;
default: default:
// Only allow text-emotes for "dead" entities (feign death included) // Only allow text-emotes for "dead" entities (feign death included)
if (GetPlayer().HasUnitState(UnitState.Died)) if (GetPlayer().HasUnitState(UnitState.Died))
break; break;
GetPlayer().HandleEmoteCommand(emoteAnim, null, packet.SpellVisualKitIDs); GetPlayer().HandleEmoteCommand(emote, null, packet.SpellVisualKitIDs);
break; break;
} }
@@ -608,7 +608,7 @@ namespace Game
creature.GetAI().ReceiveEmote(GetPlayer(), (TextEmotes)packet.EmoteID); creature.GetAI().ReceiveEmote(GetPlayer(), (TextEmotes)packet.EmoteID);
} }
if (emoteAnim != Emote.OneshotNone) if (emote != Emote.OneshotNone)
_player.RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags.Anim); _player.RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags.Anim);
} }
+1 -1
View File
@@ -2817,7 +2817,7 @@ namespace Scripts.Spells.Generic
void HandleDummy(uint effIndex) void HandleDummy(uint effIndex)
{ {
GetCaster().HandleEmoteCommand(EmoteArray[RandomHelper.URand(0, 2)]); GetCaster().HandleEmoteCommand(EmoteArray.SelectRandom());
} }
public override void Register() public override void Register()