Core/ChatCommands: Add support for enum type arguments
Port From (https://github.com/TrinityCore/TrinityCore/commit/3923650aeb75611023aa1d46a4328838c8e0a33c)
This commit is contained in:
@@ -66,6 +66,9 @@ namespace Game.Chat
|
|||||||
if (Hyperlink.TryConsume(out value, type, args))
|
if (Hyperlink.TryConsume(out value, type, args))
|
||||||
return value;
|
return value;
|
||||||
|
|
||||||
|
if (type.IsEnum)
|
||||||
|
type = type.GetEnumUnderlyingType();
|
||||||
|
|
||||||
switch (Type.GetTypeCode(type))
|
switch (Type.GetTypeCode(type))
|
||||||
{
|
{
|
||||||
case TypeCode.SByte:
|
case TypeCode.SByte:
|
||||||
|
|||||||
@@ -1122,13 +1122,8 @@ namespace Game.Chat
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Command("flag", RBACPermissions.CommandNpcSetFlag)]
|
[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();
|
Creature creature = handler.GetSelectedCreature();
|
||||||
if (!creature)
|
if (!creature)
|
||||||
{
|
{
|
||||||
@@ -1136,11 +1131,11 @@ namespace Game.Chat
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
creature.SetNpcFlags((NPCFlags)(npcFlags & 0xFFFFFFFF));
|
creature.SetNpcFlags(npcFlags);
|
||||||
creature.SetNpcFlags2((NPCFlags2)(npcFlags >> 32));
|
creature.SetNpcFlags2(npcFlags2);
|
||||||
|
|
||||||
PreparedStatement stmt = DB.World.GetPreparedStatement(WorldStatements.UPD_CREATURE_NPCFLAG);
|
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());
|
stmt.AddValue(1, creature.GetEntry());
|
||||||
DB.World.Execute(stmt);
|
DB.World.Execute(stmt);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user