mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/ChatCommands: Check whether a passed numeric enum value is valid (#25285)
(cherry picked from commit 4286e7aa02)
This commit is contained in:
committed by
Shauren
parent
3ba767c438
commit
3c82863c52
@@ -108,9 +108,7 @@ def processFile(path, filename):
|
||||
output.write('#include "SmartEnum.h"\n')
|
||||
output.write('#include <stdexcept>\n')
|
||||
output.write('\n')
|
||||
output.write('namespace Trinity\n')
|
||||
output.write('{\n')
|
||||
output.write('namespace Impl\n')
|
||||
output.write('namespace Trinity::Impl\n')
|
||||
output.write('{\n')
|
||||
for name, values in enums:
|
||||
tag = ('data for enum \'%s\' in \'%s.h\' auto-generated' % (name, filename))
|
||||
@@ -129,10 +127,10 @@ def processFile(path, filename):
|
||||
output.write(' }\n')
|
||||
output.write('}\n')
|
||||
output.write('\n')
|
||||
output.write('template <>\n');
|
||||
output.write('template <>\n')
|
||||
output.write('TC_API_EXPORT size_t EnumUtils<%s>::Count() { return %d; }\n' % (name, len(values)))
|
||||
output.write('\n')
|
||||
output.write('template <>\n');
|
||||
output.write('template <>\n')
|
||||
output.write('TC_API_EXPORT %s EnumUtils<%s>::FromIndex(size_t index)\n' % (name, name))
|
||||
output.write('{\n')
|
||||
output.write(' switch (index)\n')
|
||||
@@ -142,9 +140,19 @@ def processFile(path, filename):
|
||||
output.write(' default: throw std::out_of_range("index");\n')
|
||||
output.write(' }\n')
|
||||
output.write('}\n')
|
||||
output.write('\n')
|
||||
output.write('template <>\n')
|
||||
output.write('TC_API_EXPORT size_t EnumUtils<%s>::ToIndex(%s value)\n' % (name, name))
|
||||
output.write('{\n')
|
||||
output.write(' switch (value)\n')
|
||||
output.write(' {\n')
|
||||
for i in range(len(values)):
|
||||
output.write(' case %s: return %d;\n' % (values[i][0], i))
|
||||
output.write(' default: throw std::out_of_range("value");\n')
|
||||
output.write(' }\n')
|
||||
output.write('}\n')
|
||||
|
||||
output.write('}\n')
|
||||
output.write('}\n')
|
||||
|
||||
FilenamePattern = compile(r'^(.+)\.h$')
|
||||
for root, dirs, files in walk('.'):
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
struct EnumText
|
||||
{
|
||||
EnumText(char const* c, char const* t, char const* d) : Constant(c), Title(t), Description(d) {}
|
||||
EnumText(char const* c, char const* t, char const* d) : Constant(c), Title(t), Description(d) { }
|
||||
// Enum constant of the value
|
||||
char const* const Constant;
|
||||
// Human-readable title of the value
|
||||
@@ -42,6 +42,7 @@ namespace Trinity
|
||||
static size_t Count();
|
||||
static EnumText ToString(Enum value);
|
||||
static Enum FromIndex(size_t index);
|
||||
static size_t ToIndex(Enum index);
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -55,6 +56,24 @@ class EnumUtils
|
||||
static EnumText ToString(Enum value) { return Trinity::Impl::EnumUtils<Enum>::ToString(value); }
|
||||
template <typename Enum>
|
||||
static Enum FromIndex(size_t index) { return Trinity::Impl::EnumUtils<Enum>::FromIndex(index); }
|
||||
template <typename Enum>
|
||||
static uint32 ToIndex(Enum value) { return Trinity::Impl::EnumUtils<Enum>::ToIndex(value);}
|
||||
|
||||
template<typename Enum>
|
||||
static bool IsValid(Enum value)
|
||||
{
|
||||
try
|
||||
{
|
||||
Trinity::Impl::EnumUtils<Enum>::ToIndex(value);
|
||||
return true;
|
||||
} catch (...)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Enum>
|
||||
static bool IsValid(std::underlying_type_t<Enum> value) { return IsValid(static_cast<Enum>(value)); }
|
||||
|
||||
template <typename Enum>
|
||||
class Iterator
|
||||
|
||||
@@ -20,9 +20,7 @@
|
||||
#include "SmartEnum.h"
|
||||
#include <stdexcept>
|
||||
|
||||
namespace Trinity
|
||||
{
|
||||
namespace Impl
|
||||
namespace Trinity::Impl
|
||||
{
|
||||
|
||||
/************************************************************************\
|
||||
@@ -63,6 +61,22 @@ TC_API_EXPORT AuctionQuality EnumUtils<AuctionQuality>::FromIndex(size_t index)
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
TC_API_EXPORT size_t EnumUtils<AuctionQuality>::ToIndex(AuctionQuality value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case AUCTION_QUALITY_GRAY: return 0;
|
||||
case AUCTION_QUALITY_WHITE: return 1;
|
||||
case AUCTION_QUALITY_GREEN: return 2;
|
||||
case AUCTION_QUALITY_BLUE: return 3;
|
||||
case AUCTION_QUALITY_PURPLE: return 4;
|
||||
case AUCTION_QUALITY_ORANGE: return 5;
|
||||
case AUCTION_QUALITY_YELLOW: return 6;
|
||||
default: throw std::out_of_range("value");
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************\
|
||||
|* data for enum 'AuctionHouseType' in 'AuctionHouseBot.h' auto-generated *|
|
||||
\**************************************************************************/
|
||||
@@ -92,5 +106,16 @@ TC_API_EXPORT AuctionHouseType EnumUtils<AuctionHouseType>::FromIndex(size_t ind
|
||||
default: throw std::out_of_range("index");
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
TC_API_EXPORT size_t EnumUtils<AuctionHouseType>::ToIndex(AuctionHouseType value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case AUCTION_HOUSE_NEUTRAL: return 0;
|
||||
case AUCTION_HOUSE_ALLIANCE: return 1;
|
||||
case AUCTION_HOUSE_HORDE: return 2;
|
||||
default: throw std::out_of_range("value");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,7 +193,11 @@ struct ArgInfo<T, std::enable_if_t<std::is_enum_v<T>>>
|
||||
U uVal = 0;
|
||||
ret = ArgInfo<U>::TryConsume(uVal, args);
|
||||
if (ret)
|
||||
{
|
||||
val = static_cast<T>(uVal);
|
||||
if (!EnumUtils::IsValid(val))
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -20,9 +20,7 @@
|
||||
#include "SmartEnum.h"
|
||||
#include <stdexcept>
|
||||
|
||||
namespace Trinity
|
||||
{
|
||||
namespace Impl
|
||||
namespace Trinity::Impl
|
||||
{
|
||||
|
||||
/*************************************************************************\
|
||||
@@ -112,5 +110,45 @@ TC_API_EXPORT CreatureFlagsExtra EnumUtils<CreatureFlagsExtra>::FromIndex(size_t
|
||||
default: throw std::out_of_range("index");
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
TC_API_EXPORT size_t EnumUtils<CreatureFlagsExtra>::ToIndex(CreatureFlagsExtra value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case CREATURE_FLAG_EXTRA_INSTANCE_BIND: return 0;
|
||||
case CREATURE_FLAG_EXTRA_CIVILIAN: return 1;
|
||||
case CREATURE_FLAG_EXTRA_NO_PARRY: return 2;
|
||||
case CREATURE_FLAG_EXTRA_NO_PARRY_HASTEN: return 3;
|
||||
case CREATURE_FLAG_EXTRA_NO_BLOCK: return 4;
|
||||
case CREATURE_FLAG_EXTRA_NO_CRUSH: return 5;
|
||||
case CREATURE_FLAG_EXTRA_NO_XP_AT_KILL: return 6;
|
||||
case CREATURE_FLAG_EXTRA_TRIGGER: return 7;
|
||||
case CREATURE_FLAG_EXTRA_NO_TAUNT: return 8;
|
||||
case CREATURE_FLAG_EXTRA_NO_MOVE_FLAGS_UPDATE: return 9;
|
||||
case CREATURE_FLAG_EXTRA_GHOST_VISIBILITY: return 10;
|
||||
case CREATURE_FLAG_EXTRA_USE_OFFHAND_ATTACK: return 11;
|
||||
case CREATURE_FLAG_EXTRA_NO_SELL_VENDOR: return 12;
|
||||
case CREATURE_FLAG_EXTRA_NO_COMBAT: return 13;
|
||||
case CREATURE_FLAG_EXTRA_WORLDEVENT: return 14;
|
||||
case CREATURE_FLAG_EXTRA_GUARD: return 15;
|
||||
case CREATURE_FLAG_EXTRA_UNUSED_16: return 16;
|
||||
case CREATURE_FLAG_EXTRA_NO_CRIT: return 17;
|
||||
case CREATURE_FLAG_EXTRA_NO_SKILLGAIN: return 18;
|
||||
case CREATURE_FLAG_EXTRA_TAUNT_DIMINISH: return 19;
|
||||
case CREATURE_FLAG_EXTRA_ALL_DIMINISH: return 20;
|
||||
case CREATURE_FLAG_EXTRA_NO_PLAYER_DAMAGE_REQ: return 21;
|
||||
case CREATURE_FLAG_EXTRA_UNUSED_22: return 22;
|
||||
case CREATURE_FLAG_EXTRA_UNUSED_23: return 23;
|
||||
case CREATURE_FLAG_EXTRA_UNUSED_24: return 24;
|
||||
case CREATURE_FLAG_EXTRA_UNUSED_25: return 25;
|
||||
case CREATURE_FLAG_EXTRA_UNUSED_26: return 26;
|
||||
case CREATURE_FLAG_EXTRA_UNUSED_27: return 27;
|
||||
case CREATURE_FLAG_EXTRA_DUNGEON_BOSS: return 28;
|
||||
case CREATURE_FLAG_EXTRA_IGNORE_PATHFINDING: return 29;
|
||||
case CREATURE_FLAG_EXTRA_IMMUNITY_KNOCKBACK: return 30;
|
||||
case CREATURE_FLAG_EXTRA_UNUSED_31: return 31;
|
||||
default: throw std::out_of_range("value");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,9 +20,7 @@
|
||||
#include "SmartEnum.h"
|
||||
#include <stdexcept>
|
||||
|
||||
namespace Trinity
|
||||
{
|
||||
namespace Impl
|
||||
namespace Trinity::Impl
|
||||
{
|
||||
|
||||
/***************************************************************\
|
||||
@@ -113,6 +111,47 @@ TC_API_EXPORT UnitFlags EnumUtils<UnitFlags>::FromIndex(size_t index)
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
TC_API_EXPORT size_t EnumUtils<UnitFlags>::ToIndex(UnitFlags value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case UNIT_FLAG_SERVER_CONTROLLED: return 0;
|
||||
case UNIT_FLAG_NON_ATTACKABLE: return 1;
|
||||
case UNIT_FLAG_REMOVE_CLIENT_CONTROL: return 2;
|
||||
case UNIT_FLAG_PLAYER_CONTROLLED: return 3;
|
||||
case UNIT_FLAG_RENAME: return 4;
|
||||
case UNIT_FLAG_PREPARATION: return 5;
|
||||
case UNIT_FLAG_UNK_6: return 6;
|
||||
case UNIT_FLAG_NOT_ATTACKABLE_1: return 7;
|
||||
case UNIT_FLAG_IMMUNE_TO_PC: return 8;
|
||||
case UNIT_FLAG_IMMUNE_TO_NPC: return 9;
|
||||
case UNIT_FLAG_LOOTING: return 10;
|
||||
case UNIT_FLAG_PET_IN_COMBAT: return 11;
|
||||
case UNIT_FLAG_PVP: return 12;
|
||||
case UNIT_FLAG_SILENCED: return 13;
|
||||
case UNIT_FLAG_CANT_SWIM: return 14;
|
||||
case UNIT_FLAG_CAN_SWIM: return 15;
|
||||
case UNIT_FLAG_NON_ATTACKABLE_2: return 16;
|
||||
case UNIT_FLAG_PACIFIED: return 17;
|
||||
case UNIT_FLAG_STUNNED: return 18;
|
||||
case UNIT_FLAG_IN_COMBAT: return 19;
|
||||
case UNIT_FLAG_TAXI_FLIGHT: return 20;
|
||||
case UNIT_FLAG_DISARMED: return 21;
|
||||
case UNIT_FLAG_CONFUSED: return 22;
|
||||
case UNIT_FLAG_FLEEING: return 23;
|
||||
case UNIT_FLAG_POSSESSED: return 24;
|
||||
case UNIT_FLAG_NOT_SELECTABLE: return 25;
|
||||
case UNIT_FLAG_SKINNABLE: return 26;
|
||||
case UNIT_FLAG_MOUNT: return 27;
|
||||
case UNIT_FLAG_UNK_28: return 28;
|
||||
case UNIT_FLAG_UNK_29: return 29;
|
||||
case UNIT_FLAG_SHEATHE: return 30;
|
||||
case UNIT_FLAG_IMMUNE: return 31;
|
||||
default: throw std::out_of_range("value");
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************\
|
||||
|* data for enum 'UnitFlags2' in 'UnitDefines.h' auto-generated *|
|
||||
\****************************************************************/
|
||||
@@ -197,6 +236,45 @@ TC_API_EXPORT UnitFlags2 EnumUtils<UnitFlags2>::FromIndex(size_t index)
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
TC_API_EXPORT size_t EnumUtils<UnitFlags2>::ToIndex(UnitFlags2 value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case UNIT_FLAG2_FEIGN_DEATH: return 0;
|
||||
case UNIT_FLAG2_HIDE_BODY: return 1;
|
||||
case UNIT_FLAG2_IGNORE_REPUTATION: return 2;
|
||||
case UNIT_FLAG2_COMPREHEND_LANG: return 3;
|
||||
case UNIT_FLAG2_MIRROR_IMAGE: return 4;
|
||||
case UNIT_FLAG2_DONT_FADE_IN: return 5;
|
||||
case UNIT_FLAG2_FORCE_MOVEMENT: return 6;
|
||||
case UNIT_FLAG2_DISARM_OFFHAND: return 7;
|
||||
case UNIT_FLAG2_DISABLE_PRED_STATS: return 8;
|
||||
case UNIT_FLAG2_ALLOW_CHANGING_TALENTS: return 9;
|
||||
case UNIT_FLAG2_DISARM_RANGED: return 10;
|
||||
case UNIT_FLAG2_REGENERATE_POWER: return 11;
|
||||
case UNIT_FLAG2_RESTRICT_PARTY_INTERACTION: return 12;
|
||||
case UNIT_FLAG2_PREVENT_SPELL_CLICK: return 13;
|
||||
case UNIT_FLAG2_INTERACT_WHILE_HOSTILE: return 14;
|
||||
case UNIT_FLAG2_CANNOT_TURN: return 15;
|
||||
case UNIT_FLAG2_UNK2: return 16;
|
||||
case UNIT_FLAG2_PLAY_DEATH_ANIM: return 17;
|
||||
case UNIT_FLAG2_ALLOW_CHEAT_SPELLS: return 18;
|
||||
case UNIT_FLAG2_SUPPRESS_HIGHLIGHT_WHEN_TARGETED_OR_MOUSED_OVER: return 19;
|
||||
case UNIT_FLAG2_TREAT_AS_RAID_UNIT_FOR_HELPFUL_SPELLS: return 20;
|
||||
case UNIT_FLAG2_LARGE_AOI: return 21;
|
||||
case UNIT_FLAG2_GIGANTIC_AOI: return 22;
|
||||
case UNIT_FLAG2_NO_ACTIONS: return 23;
|
||||
case UNIT_FLAG2_AI_WILL_ONLY_SWIM_IF_TARGET_SWIMS: return 24;
|
||||
case UNIT_FLAG2_DONT_GENERATE_COMBAT_LOG_WHEN_ENGAGED_WITH_NPCS: return 25;
|
||||
case UNIT_FLAG2_UNTARGETABLE_BY_CLIENT: return 26;
|
||||
case UNIT_FLAG2_ATTACKER_IGNORES_MINIMUM_RANGES: return 27;
|
||||
case UNIT_FLAG2_UNINTERACTIBLE_IF_HOSTILE: return 28;
|
||||
case UNIT_FLAG2_INFINITE_AOI: return 29;
|
||||
default: throw std::out_of_range("value");
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************\
|
||||
|* data for enum 'UnitFlags3' in 'UnitDefines.h' auto-generated *|
|
||||
\****************************************************************/
|
||||
@@ -223,6 +301,16 @@ TC_API_EXPORT UnitFlags3 EnumUtils<UnitFlags3>::FromIndex(size_t index)
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
TC_API_EXPORT size_t EnumUtils<UnitFlags3>::ToIndex(UnitFlags3 value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case UNIT_FLAG3_UNK1: return 0;
|
||||
default: throw std::out_of_range("value");
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************\
|
||||
|* data for enum 'NPCFlags' in 'UnitDefines.h' auto-generated *|
|
||||
\**************************************************************/
|
||||
@@ -313,6 +401,48 @@ TC_API_EXPORT NPCFlags EnumUtils<NPCFlags>::FromIndex(size_t index)
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
TC_API_EXPORT size_t EnumUtils<NPCFlags>::ToIndex(NPCFlags value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case UNIT_NPC_FLAG_NONE: return 0;
|
||||
case UNIT_NPC_FLAG_GOSSIP: return 1;
|
||||
case UNIT_NPC_FLAG_QUESTGIVER: return 2;
|
||||
case UNIT_NPC_FLAG_UNK1: return 3;
|
||||
case UNIT_NPC_FLAG_UNK2: return 4;
|
||||
case UNIT_NPC_FLAG_TRAINER: return 5;
|
||||
case UNIT_NPC_FLAG_TRAINER_CLASS: return 6;
|
||||
case UNIT_NPC_FLAG_TRAINER_PROFESSION: return 7;
|
||||
case UNIT_NPC_FLAG_VENDOR: return 8;
|
||||
case UNIT_NPC_FLAG_VENDOR_AMMO: return 9;
|
||||
case UNIT_NPC_FLAG_VENDOR_FOOD: return 10;
|
||||
case UNIT_NPC_FLAG_VENDOR_POISON: return 11;
|
||||
case UNIT_NPC_FLAG_VENDOR_REAGENT: return 12;
|
||||
case UNIT_NPC_FLAG_REPAIR: return 13;
|
||||
case UNIT_NPC_FLAG_FLIGHTMASTER: return 14;
|
||||
case UNIT_NPC_FLAG_SPIRITHEALER: return 15;
|
||||
case UNIT_NPC_FLAG_SPIRITGUIDE: return 16;
|
||||
case UNIT_NPC_FLAG_INNKEEPER: return 17;
|
||||
case UNIT_NPC_FLAG_BANKER: return 18;
|
||||
case UNIT_NPC_FLAG_PETITIONER: return 19;
|
||||
case UNIT_NPC_FLAG_TABARDDESIGNER: return 20;
|
||||
case UNIT_NPC_FLAG_BATTLEMASTER: return 21;
|
||||
case UNIT_NPC_FLAG_AUCTIONEER: return 22;
|
||||
case UNIT_NPC_FLAG_STABLEMASTER: return 23;
|
||||
case UNIT_NPC_FLAG_GUILD_BANKER: return 24;
|
||||
case UNIT_NPC_FLAG_SPELLCLICK: return 25;
|
||||
case UNIT_NPC_FLAG_PLAYER_VEHICLE: return 26;
|
||||
case UNIT_NPC_FLAG_MAILBOX: return 27;
|
||||
case UNIT_NPC_FLAG_ARTIFACT_POWER_RESPEC: return 28;
|
||||
case UNIT_NPC_FLAG_TRANSMOGRIFIER: return 29;
|
||||
case UNIT_NPC_FLAG_VAULTKEEPER: return 30;
|
||||
case UNIT_NPC_FLAG_WILD_BATTLE_PET: return 31;
|
||||
case UNIT_NPC_FLAG_BLACK_MARKET: return 32;
|
||||
default: throw std::out_of_range("value");
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************\
|
||||
|* data for enum 'NPCFlags2' in 'UnitDefines.h' auto-generated *|
|
||||
\***************************************************************/
|
||||
@@ -360,5 +490,25 @@ TC_API_EXPORT NPCFlags2 EnumUtils<NPCFlags2>::FromIndex(size_t index)
|
||||
default: throw std::out_of_range("index");
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
TC_API_EXPORT size_t EnumUtils<NPCFlags2>::ToIndex(NPCFlags2 value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case UNIT_NPC_FLAG_2_NONE: return 0;
|
||||
case UNIT_NPC_FLAG_2_ITEM_UPGRADE_MASTER: return 1;
|
||||
case UNIT_NPC_FLAG_2_GARRISON_ARCHITECT: return 2;
|
||||
case UNIT_NPC_FLAG_2_STEERING: return 3;
|
||||
case UNIT_NPC_FLAG_2_SHIPMENT_CRAFTER: return 4;
|
||||
case UNIT_NPC_FLAG_2_GARRISON_MISSION_NPC: return 5;
|
||||
case UNIT_NPC_FLAG_2_TRADESKILL_NPC: return 6;
|
||||
case UNIT_NPC_FLAG_2_BLACK_MARKET_VIEW: return 7;
|
||||
case UNIT_NPC_FLAG_2_GARRISON_TALENT_NPC: return 8;
|
||||
case UNIT_NPC_FLAG_2_CONTRIBUTION_COLLECTOR: return 9;
|
||||
case UNIT_NPC_FLAG_2_AZERITE_RESPEC: return 10;
|
||||
case UNIT_NPC_FLAG_2_ISLANDS_QUEUE: return 11;
|
||||
default: throw std::out_of_range("value");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ enum EncounterFrameType
|
||||
ENCOUNTER_FRAME_ADD_COMBAT_RES_LIMIT = 10
|
||||
};
|
||||
|
||||
// EnumUtils: DESCRIBE THIS
|
||||
enum EncounterState
|
||||
{
|
||||
NOT_STARTED = 0,
|
||||
|
||||
76
src/server/game/Instances/enuminfo_InstanceScript.cpp
Normal file
76
src/server/game/Instances/enuminfo_InstanceScript.cpp
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "InstanceScript.h"
|
||||
#include "Define.h"
|
||||
#include "SmartEnum.h"
|
||||
#include <stdexcept>
|
||||
|
||||
namespace Trinity::Impl
|
||||
{
|
||||
|
||||
/***********************************************************************\
|
||||
|* data for enum 'EncounterState' in 'InstanceScript.h' auto-generated *|
|
||||
\***********************************************************************/
|
||||
template <>
|
||||
TC_API_EXPORT EnumText EnumUtils<EncounterState>::ToString(EncounterState value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case NOT_STARTED: return { "NOT_STARTED", "NOT_STARTED", "" };
|
||||
case IN_PROGRESS: return { "IN_PROGRESS", "IN_PROGRESS", "" };
|
||||
case FAIL: return { "FAIL", "FAIL", "" };
|
||||
case DONE: return { "DONE", "DONE", "" };
|
||||
case SPECIAL: return { "SPECIAL", "SPECIAL", "" };
|
||||
case TO_BE_DECIDED: return { "TO_BE_DECIDED", "TO_BE_DECIDED", "" };
|
||||
default: throw std::out_of_range("value");
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
TC_API_EXPORT size_t EnumUtils<EncounterState>::Count() { return 6; }
|
||||
|
||||
template <>
|
||||
TC_API_EXPORT EncounterState EnumUtils<EncounterState>::FromIndex(size_t index)
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case 0: return NOT_STARTED;
|
||||
case 1: return IN_PROGRESS;
|
||||
case 2: return FAIL;
|
||||
case 3: return DONE;
|
||||
case 4: return SPECIAL;
|
||||
case 5: return TO_BE_DECIDED;
|
||||
default: throw std::out_of_range("index");
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
TC_API_EXPORT size_t EnumUtils<EncounterState>::ToIndex(EncounterState value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case NOT_STARTED: return 0;
|
||||
case IN_PROGRESS: return 1;
|
||||
case FAIL: return 2;
|
||||
case DONE: return 3;
|
||||
case SPECIAL: return 4;
|
||||
case TO_BE_DECIDED: return 5;
|
||||
default: throw std::out_of_range("value");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,9 +20,7 @@
|
||||
#include "SmartEnum.h"
|
||||
#include <stdexcept>
|
||||
|
||||
namespace Trinity
|
||||
{
|
||||
namespace Impl
|
||||
namespace Trinity::Impl
|
||||
{
|
||||
|
||||
/*******************************************************************\
|
||||
@@ -54,5 +52,16 @@ TC_API_EXPORT SpawnObjectType EnumUtils<SpawnObjectType>::FromIndex(size_t index
|
||||
default: throw std::out_of_range("index");
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
TC_API_EXPORT size_t EnumUtils<SpawnObjectType>::ToIndex(SpawnObjectType value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case SPAWN_TYPE_CREATURE: return 0;
|
||||
case SPAWN_TYPE_GAMEOBJECT: return 1;
|
||||
case SPAWN_TYPE_AREATRIGGER: return 2;
|
||||
default: throw std::out_of_range("value");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,9 +20,7 @@
|
||||
#include "SmartEnum.h"
|
||||
#include <stdexcept>
|
||||
|
||||
namespace Trinity
|
||||
{
|
||||
namespace Impl
|
||||
namespace Trinity::Impl
|
||||
{
|
||||
|
||||
/********************************************************\
|
||||
@@ -98,5 +96,38 @@ TC_API_EXPORT Races EnumUtils<Races>::FromIndex(size_t index)
|
||||
default: throw std::out_of_range("index");
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
TC_API_EXPORT size_t EnumUtils<Races>::ToIndex(Races value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case RACE_HUMAN: return 0;
|
||||
case RACE_ORC: return 1;
|
||||
case RACE_DWARF: return 2;
|
||||
case RACE_NIGHTELF: return 3;
|
||||
case RACE_UNDEAD_PLAYER: return 4;
|
||||
case RACE_TAUREN: return 5;
|
||||
case RACE_GNOME: return 6;
|
||||
case RACE_TROLL: return 7;
|
||||
case RACE_GOBLIN: return 8;
|
||||
case RACE_BLOODELF: return 9;
|
||||
case RACE_DRAENEI: return 10;
|
||||
case RACE_WORGEN: return 11;
|
||||
case RACE_PANDAREN_NEUTRAL: return 12;
|
||||
case RACE_PANDAREN_ALLIANCE: return 13;
|
||||
case RACE_PANDAREN_HORDE: return 14;
|
||||
case RACE_NIGHTBORNE: return 15;
|
||||
case RACE_HIGHMOUNTAIN_TAUREN: return 16;
|
||||
case RACE_VOID_ELF: return 17;
|
||||
case RACE_LIGHTFORGED_DRAENEI: return 18;
|
||||
case RACE_ZANDALARI_TROLL: return 19;
|
||||
case RACE_KUL_TIRAN: return 20;
|
||||
case RACE_DARK_IRON_DWARF: return 21;
|
||||
case RACE_VULPERA: return 22;
|
||||
case RACE_MAGHAR_ORC: return 23;
|
||||
case RACE_MECHAGNOME: return 24;
|
||||
default: throw std::out_of_range("value");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -20,9 +20,7 @@
|
||||
#include "SmartEnum.h"
|
||||
#include <stdexcept>
|
||||
|
||||
namespace Trinity
|
||||
{
|
||||
namespace Impl
|
||||
namespace Trinity::Impl
|
||||
{
|
||||
|
||||
/**********************************************************************\
|
||||
@@ -55,6 +53,18 @@ TC_API_EXPORT WardenActions EnumUtils<WardenActions>::FromIndex(size_t index)
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
TC_API_EXPORT size_t EnumUtils<WardenActions>::ToIndex(WardenActions value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case WARDEN_ACTION_LOG: return 0;
|
||||
case WARDEN_ACTION_KICK: return 1;
|
||||
case WARDEN_ACTION_BAN: return 2;
|
||||
default: throw std::out_of_range("value");
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************\
|
||||
|* data for enum 'WardenCheckType' in 'WardenCheckMgr.h' auto-generated *|
|
||||
\************************************************************************/
|
||||
@@ -96,5 +106,22 @@ TC_API_EXPORT WardenCheckType EnumUtils<WardenCheckType>::FromIndex(size_t index
|
||||
default: throw std::out_of_range("index");
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
TC_API_EXPORT size_t EnumUtils<WardenCheckType>::ToIndex(WardenCheckType value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case MEM_CHECK: return 0;
|
||||
case PAGE_CHECK_A: return 1;
|
||||
case PAGE_CHECK_B: return 2;
|
||||
case MPQ_CHECK: return 3;
|
||||
case LUA_STR_CHECK: return 4;
|
||||
case DRIVER_CHECK: return 5;
|
||||
case TIMING_CHECK: return 6;
|
||||
case PROC_CHECK: return 7;
|
||||
case MODULE_CHECK: return 8;
|
||||
default: throw std::out_of_range("value");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1163,14 +1163,8 @@ public:
|
||||
if (Unit* unit = handler->getSelectedUnit())
|
||||
unit->HandleEmoteCommand(emote);
|
||||
|
||||
try
|
||||
{
|
||||
handler->PSendSysMessage("Playing emote %s", EnumUtils::ToConstant(emote));
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
handler->PSendSysMessage("Playing unknown emote");
|
||||
}
|
||||
handler->PSendSysMessage("Playing emote %s", EnumUtils::ToConstant(emote));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user