Core/ChatCommands: Add support for enum type arguments

Port From (https://github.com/TrinityCore/TrinityCore/commit/3923650aeb75611023aa1d46a4328838c8e0a33c)
This commit is contained in:
hondacrx
2022-03-03 13:51:22 -05:00
parent bfd3cd9731
commit 0116a7efa5
2 changed files with 7 additions and 9 deletions
+3
View File
@@ -66,6 +66,9 @@ namespace Game.Chat
if (Hyperlink.TryConsume(out value, type, args))
return value;
if (type.IsEnum)
type = type.GetEnumUnderlyingType();
switch (Type.GetTypeCode(type))
{
case TypeCode.SByte:
+4 -9
View File
@@ -1122,13 +1122,8 @@ namespace Game.Chat
}
[Command("flag", RBACPermissions.CommandNpcSetFlag)]
static bool HandleNpcSetFlagCommand(CommandHandler handler, StringArguments args)
static bool HandleNpcSetFlagCommand(CommandHandler handler, NPCFlags npcFlags, NPCFlags2 npcFlags2)
{
if (args.Empty())
return false;
ulong npcFlags = args.NextUInt64();
Creature creature = handler.GetSelectedCreature();
if (!creature)
{
@@ -1136,11 +1131,11 @@ namespace Game.Chat
return false;
}
creature.SetNpcFlags((NPCFlags)(npcFlags & 0xFFFFFFFF));
creature.SetNpcFlags2((NPCFlags2)(npcFlags >> 32));
creature.SetNpcFlags(npcFlags);
creature.SetNpcFlags2(npcFlags2);
PreparedStatement stmt = DB.World.GetPreparedStatement(WorldStatements.UPD_CREATURE_NPCFLAG);
stmt.AddValue(0, npcFlags);
stmt.AddValue(0, (ulong)npcFlags | ((ulong)npcFlags2 << 32));
stmt.AddValue(1, creature.GetEntry());
DB.World.Execute(stmt);