diff options
author | Treeston <treeston.mmoc@gmail.com> | 2019-07-17 22:58:49 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2021-12-16 21:41:24 +0100 |
commit | e270351a16702fabedc8651afe6030d12792fdbe (patch) | |
tree | cf6b218f947eaece8240fc866889bfa4876dbd08 /src/server/game/Maps | |
parent | 39ef3e3e78b9020d3252efd619c9811198d1d930 (diff) |
Scripts/Commands: Adjust .list respawns to use enum iteration. Add enum iteration capability to SpawnObjectTypes.
(cherry picked from commit b64834c3f5dd7e1be472950532ce00e70b4601fa)
Diffstat (limited to 'src/server/game/Maps')
-rw-r--r-- | src/server/game/Maps/SpawnData.h | 7 | ||||
-rw-r--r-- | src/server/game/Maps/enuminfo_SpawnData.cpp | 56 |
2 files changed, 60 insertions, 3 deletions
diff --git a/src/server/game/Maps/SpawnData.h b/src/server/game/Maps/SpawnData.h index 40972a5a8f1..d1023ffbeb2 100644 --- a/src/server/game/Maps/SpawnData.h +++ b/src/server/game/Maps/SpawnData.h @@ -22,12 +22,13 @@ #include "Position.h" #include <vector> +// EnumUtils: DESCRIBE THIS enum SpawnObjectType { - SPAWN_TYPE_CREATURE = 0, - SPAWN_TYPE_GAMEOBJECT = 1, + SPAWN_TYPE_CREATURE = 0, // TITLE Creature + SPAWN_TYPE_GAMEOBJECT = 1, // TITLE Gameobject - SPAWN_TYPE_MAX + SPAWN_TYPE_MAX // SKIP }; enum SpawnObjectTypeMask diff --git a/src/server/game/Maps/enuminfo_SpawnData.cpp b/src/server/game/Maps/enuminfo_SpawnData.cpp new file mode 100644 index 00000000000..55487a8d50b --- /dev/null +++ b/src/server/game/Maps/enuminfo_SpawnData.cpp @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2008-2019 TrinityCore <https://www.trinitycore.org/> + * + * 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 "SpawnData.h" +#include "Define.h" +#include "SmartEnum.h" +#include <stdexcept> + +namespace Trinity +{ +namespace Impl +{ + +/*******************************************************************\ +|* data for enum 'SpawnObjectType' in 'SpawnData.h' auto-generated *| +\*******************************************************************/ +template <> +TC_API_EXPORT EnumText EnumUtils<SpawnObjectType>::ToString(SpawnObjectType value) +{ + switch (value) + { + case SPAWN_TYPE_CREATURE: return { "SPAWN_TYPE_CREATURE", "Creature", "" }; + case SPAWN_TYPE_GAMEOBJECT: return { "SPAWN_TYPE_GAMEOBJECT", "Gameobject", "" }; + default: throw std::out_of_range("value"); + } +} + +template <> +TC_API_EXPORT size_t EnumUtils<SpawnObjectType>::Count() { return 2; } + +template <> +TC_API_EXPORT SpawnObjectType EnumUtils<SpawnObjectType>::FromIndex(size_t index) +{ + switch (index) + { + case 0: return SPAWN_TYPE_CREATURE; + case 1: return SPAWN_TYPE_GAMEOBJECT; + default: throw std::out_of_range("index"); + } +} +} +} |