mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Misc: Replace enable_if overload selection with if constexpr
This commit is contained in:
51
src/common/Containers/Utilities/MapUtils.h
Normal file
51
src/common/Containers/Utilities/MapUtils.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef TRINITYCORE_MAP_UTILS_H
|
||||
#define TRINITYCORE_MAP_UTILS_H
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace Trinity::Containers
|
||||
{
|
||||
/**
|
||||
* Returns a pointer to mapped value (or the value itself if map stores pointers)
|
||||
*/
|
||||
template<class M>
|
||||
auto MapGetValuePtr(M& map, typename M::key_type const& key)
|
||||
{
|
||||
auto itr = map.find(key);
|
||||
if constexpr (std::is_pointer_v<typename M::mapped_type>)
|
||||
return itr != map.end() ? itr->second : nullptr;
|
||||
else
|
||||
return itr != map.end() ? &itr->second : nullptr;
|
||||
}
|
||||
|
||||
template<class K, class V, template<class, class, class...> class M, class... Rest>
|
||||
void MultimapErasePair(M<K, V, Rest...>& multimap, K const& key, V const& value)
|
||||
{
|
||||
auto range = multimap.equal_range(key);
|
||||
for (auto itr = range.first; itr != range.second;)
|
||||
{
|
||||
if (itr->second == value)
|
||||
itr = multimap.erase(itr);
|
||||
else
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // TRINITYCORE_MAP_UTILS_H
|
||||
@@ -19,6 +19,7 @@
|
||||
#define TRINITY_CONTAINERS_H
|
||||
|
||||
#include "Define.h"
|
||||
#include "MapUtils.h"
|
||||
#include "Random.h"
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
@@ -29,18 +30,6 @@
|
||||
|
||||
namespace Trinity
|
||||
{
|
||||
template<class T>
|
||||
constexpr inline T* AddressOrSelf(T* ptr)
|
||||
{
|
||||
return ptr;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
constexpr inline T* AddressOrSelf(T& not_ptr)
|
||||
{
|
||||
return std::addressof(not_ptr);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
class CheckedBufferOutputIterator
|
||||
{
|
||||
@@ -252,55 +241,44 @@ namespace Trinity
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a pointer to mapped value (or the value itself if map stores pointers)
|
||||
*/
|
||||
template<class M>
|
||||
inline auto MapGetValuePtr(M& map, typename M::key_type const& key) -> decltype(AddressOrSelf(map.find(key)->second))
|
||||
namespace Impl
|
||||
{
|
||||
auto itr = map.find(key);
|
||||
return itr != map.end() ? AddressOrSelf(itr->second) : nullptr;
|
||||
}
|
||||
|
||||
template<class K, class V, template<class, class, class...> class M, class... Rest>
|
||||
inline void MultimapErasePair(M<K, V, Rest...>& multimap, K const& key, V const& value)
|
||||
{
|
||||
auto range = multimap.equal_range(key);
|
||||
for (auto itr = range.first; itr != range.second;)
|
||||
template <typename Container, typename Predicate>
|
||||
void EraseIfMoveAssignable(Container& c, Predicate p)
|
||||
{
|
||||
if (itr->second == value)
|
||||
itr = multimap.erase(itr);
|
||||
else
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Container, typename Predicate>
|
||||
std::enable_if_t<std::is_move_assignable_v<decltype(*std::declval<Container>().begin())>, void> EraseIf(Container& c, Predicate p)
|
||||
{
|
||||
auto wpos = c.begin();
|
||||
for (auto rpos = c.begin(), end = c.end(); rpos != end; ++rpos)
|
||||
{
|
||||
if (!p(*rpos))
|
||||
auto wpos = c.begin();
|
||||
for (auto rpos = c.begin(), end = c.end(); rpos != end; ++rpos)
|
||||
{
|
||||
if (rpos != wpos)
|
||||
std::swap(*rpos, *wpos);
|
||||
++wpos;
|
||||
if (!p(*rpos))
|
||||
{
|
||||
if (rpos != wpos)
|
||||
std::swap(*rpos, *wpos);
|
||||
++wpos;
|
||||
}
|
||||
}
|
||||
c.erase(wpos, c.end());
|
||||
}
|
||||
|
||||
template <typename Container, typename Predicate>
|
||||
void EraseIfNotMoveAssignable(Container& c, Predicate p)
|
||||
{
|
||||
for (auto it = c.begin(); it != c.end();)
|
||||
{
|
||||
if (p(*it))
|
||||
it = c.erase(it);
|
||||
else
|
||||
++it;
|
||||
}
|
||||
}
|
||||
c.erase(wpos, c.end());
|
||||
}
|
||||
|
||||
template <typename Container, typename Predicate>
|
||||
std::enable_if_t<!std::is_move_assignable_v<decltype(*std::declval<Container>().begin())>, void> EraseIf(Container& c, Predicate p)
|
||||
void EraseIf(Container& c, Predicate p)
|
||||
{
|
||||
for (auto it = c.begin(); it != c.end();)
|
||||
{
|
||||
if (p(*it))
|
||||
it = c.erase(it);
|
||||
else
|
||||
++it;
|
||||
}
|
||||
if constexpr (std::is_move_assignable_v<decltype(*c.begin())>)
|
||||
Impl::EraseIfMoveAssignable(c, std::ref(p));
|
||||
else
|
||||
Impl::EraseIfNotMoveAssignable(c, std::ref(p));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -893,7 +893,7 @@ bool StringCompareLessI(std::string_view a, std::string_view b)
|
||||
return std::lexicographical_compare(a.begin(), a.end(), b.begin(), b.end(), [](char c1, char c2) { return std::tolower(c1) < std::tolower(c2); });
|
||||
}
|
||||
|
||||
std::string GetTypeName(std::type_info const& info)
|
||||
std::string Trinity::Impl::GetTypeName(std::type_info const& info)
|
||||
{
|
||||
return boost::core::demangle(info.name());
|
||||
}
|
||||
|
||||
@@ -485,11 +485,24 @@ Ret* Coalesce(T1* first, T*... rest)
|
||||
return static_cast<Ret*>(first);
|
||||
}
|
||||
|
||||
TC_COMMON_API std::string GetTypeName(std::type_info const&);
|
||||
namespace Trinity
|
||||
{
|
||||
namespace Impl
|
||||
{
|
||||
TC_COMMON_API std::string GetTypeName(std::type_info const&);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::string GetTypeName() { return GetTypeName(typeid(T)); }
|
||||
std::string GetTypeName() { return Impl::GetTypeName(typeid(T)); }
|
||||
template <typename T>
|
||||
std::enable_if_t<!std::is_same_v<std::decay_t<T>, std::type_info>, std::string> GetTypeName(T&& v) { return GetTypeName(typeid(v)); }
|
||||
std::string GetTypeName(T&& v)
|
||||
{
|
||||
if constexpr (std::is_same_v<std::remove_cv_t<T>, std::type_info>)
|
||||
return Impl::GetTypeName(v);
|
||||
else
|
||||
return Impl::GetTypeName(typeid(v));
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
struct NonDefaultConstructible
|
||||
|
||||
@@ -62,12 +62,12 @@ namespace Trinity::Impl::ChatCommands
|
||||
if (Optional<T> v = StringTo<T>(token, 0))
|
||||
val = *v;
|
||||
else
|
||||
return FormatTrinityString(handler, LANG_CMDPARSER_STRING_VALUE_INVALID, STRING_VIEW_FMT_ARG(token), GetTypeName<T>().c_str());
|
||||
return FormatTrinityString(handler, LANG_CMDPARSER_STRING_VALUE_INVALID, STRING_VIEW_FMT_ARG(token), Trinity::GetTypeName<T>().c_str());
|
||||
|
||||
if constexpr (std::is_floating_point_v<T>)
|
||||
{
|
||||
if (!std::isfinite(val))
|
||||
return FormatTrinityString(handler, LANG_CMDPARSER_STRING_VALUE_INVALID, STRING_VIEW_FMT_ARG(token), GetTypeName<T>().c_str());
|
||||
return FormatTrinityString(handler, LANG_CMDPARSER_STRING_VALUE_INVALID, STRING_VIEW_FMT_ARG(token), Trinity::GetTypeName<T>().c_str());
|
||||
}
|
||||
|
||||
return tail;
|
||||
@@ -200,7 +200,7 @@ namespace Trinity::Impl::ChatCommands
|
||||
}
|
||||
|
||||
if (next1)
|
||||
return FormatTrinityString(handler, LANG_CMDPARSER_STRING_VALUE_INVALID, STRING_VIEW_FMT_ARG(strVal), GetTypeName<T>().c_str());
|
||||
return FormatTrinityString(handler, LANG_CMDPARSER_STRING_VALUE_INVALID, STRING_VIEW_FMT_ARG(strVal), Trinity::GetTypeName<T>().c_str());
|
||||
else
|
||||
return next1;
|
||||
}
|
||||
|
||||
@@ -31,210 +31,127 @@ namespace Trinity
|
||||
{
|
||||
// Helpers
|
||||
// Insert helpers
|
||||
template<class SPECIFIC_TYPE, class KEY_TYPE>
|
||||
bool Insert(ContainerUnorderedMap<SPECIFIC_TYPE, KEY_TYPE>& elements, KEY_TYPE const& handle, SPECIFIC_TYPE* obj)
|
||||
{
|
||||
auto i = elements._element.find(handle);
|
||||
if (i == elements._element.end())
|
||||
{
|
||||
elements._element[handle] = obj;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSERT(i->second == obj, "Object with certain key already in but objects are different!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
template<class SPECIFIC_TYPE, class KEY_TYPE>
|
||||
bool Insert(ContainerUnorderedMap<TypeNull, KEY_TYPE>& /*elements*/, KEY_TYPE const& /*handle*/, SPECIFIC_TYPE* /*obj*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
template<class SPECIFIC_TYPE, class KEY_TYPE, class T>
|
||||
bool Insert(ContainerUnorderedMap<T, KEY_TYPE>& /*elements*/, KEY_TYPE const& /*handle*/, SPECIFIC_TYPE* /*obj*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
template<class SPECIFIC_TYPE, class KEY_TYPE, class H, class T>
|
||||
bool Insert(ContainerUnorderedMap<TypeList<H, T>, KEY_TYPE>& elements, KEY_TYPE const& handle, SPECIFIC_TYPE* obj)
|
||||
inline bool Insert(ContainerUnorderedMap<TypeList<H, T>, KEY_TYPE>& elements, KEY_TYPE const& handle, SPECIFIC_TYPE* obj)
|
||||
{
|
||||
bool ret = Insert(elements._elements, handle, obj);
|
||||
return ret ? ret : Insert(elements._TailElements, handle, obj);
|
||||
if constexpr (std::is_same_v<H, SPECIFIC_TYPE>)
|
||||
{
|
||||
auto i = elements._elements._element.find(handle);
|
||||
if (i == elements._elements._element.end())
|
||||
{
|
||||
elements._elements._element[handle] = obj;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSERT(i->second == obj, "Object with certain key already in but objects are different!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if constexpr (std::is_same_v<T, TypeNull>)
|
||||
return false;
|
||||
else
|
||||
return Insert(elements._TailElements, handle, obj);
|
||||
}
|
||||
|
||||
// Find helpers
|
||||
template<class SPECIFIC_TYPE, class KEY_TYPE>
|
||||
SPECIFIC_TYPE* Find(ContainerUnorderedMap<SPECIFIC_TYPE, KEY_TYPE> const& elements, KEY_TYPE const& handle, SPECIFIC_TYPE* /*obj*/)
|
||||
template<class SPECIFIC_TYPE, class KEY_TYPE, class H, class T>
|
||||
inline SPECIFIC_TYPE* Find(ContainerUnorderedMap<TypeList<H, T>, KEY_TYPE> const& elements, KEY_TYPE const& handle, SPECIFIC_TYPE* obj)
|
||||
{
|
||||
auto i = elements._element.find(handle);
|
||||
if (i == elements._element.end())
|
||||
if constexpr (std::is_same_v<H, SPECIFIC_TYPE>)
|
||||
{
|
||||
auto i = elements._elements._element.find(handle);
|
||||
if (i == elements._elements._element.end())
|
||||
return nullptr;
|
||||
else
|
||||
return i->second;
|
||||
}
|
||||
|
||||
if constexpr (std::is_same_v<T, TypeNull>)
|
||||
return nullptr;
|
||||
else
|
||||
return i->second;
|
||||
}
|
||||
|
||||
template<class SPECIFIC_TYPE, class KEY_TYPE>
|
||||
SPECIFIC_TYPE* Find(ContainerUnorderedMap<TypeNull, KEY_TYPE> const& /*elements*/, KEY_TYPE const& /*handle*/, SPECIFIC_TYPE* /*obj*/)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template<class SPECIFIC_TYPE, class KEY_TYPE, class T>
|
||||
SPECIFIC_TYPE* Find(ContainerUnorderedMap<T, KEY_TYPE> const& /*elements*/, KEY_TYPE const& /*handle*/, SPECIFIC_TYPE* /*obj*/)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template<class SPECIFIC_TYPE, class KEY_TYPE, class H, class T>
|
||||
SPECIFIC_TYPE* Find(ContainerUnorderedMap<TypeList<H, T>, KEY_TYPE> const& elements, KEY_TYPE const& handle, SPECIFIC_TYPE* /*obj*/)
|
||||
{
|
||||
SPECIFIC_TYPE* ret = Find(elements._elements, handle, (SPECIFIC_TYPE*)nullptr);
|
||||
return ret ? ret : Find(elements._TailElements, handle, (SPECIFIC_TYPE*)nullptr);
|
||||
return Find(elements._TailElements, handle, obj);
|
||||
}
|
||||
|
||||
// Erase helpers
|
||||
template<class SPECIFIC_TYPE, class KEY_TYPE>
|
||||
bool Remove(ContainerUnorderedMap<SPECIFIC_TYPE, KEY_TYPE>& elements, KEY_TYPE const& handle, SPECIFIC_TYPE* /*obj*/)
|
||||
{
|
||||
elements._element.erase(handle);
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class SPECIFIC_TYPE, class KEY_TYPE>
|
||||
bool Remove(ContainerUnorderedMap<TypeNull, KEY_TYPE>& /*elements*/, KEY_TYPE const& /*handle*/, SPECIFIC_TYPE* /*obj*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
template<class SPECIFIC_TYPE, class KEY_TYPE, class T>
|
||||
bool Remove(ContainerUnorderedMap<T, KEY_TYPE>& /*elements*/, KEY_TYPE const& /*handle*/, SPECIFIC_TYPE* /*obj*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
template<class SPECIFIC_TYPE, class KEY_TYPE, class H, class T>
|
||||
bool Remove(ContainerUnorderedMap<TypeList<H, T>, KEY_TYPE>& elements, KEY_TYPE const& handle, SPECIFIC_TYPE* /*obj*/)
|
||||
inline bool Remove(ContainerUnorderedMap<TypeList<H, T>, KEY_TYPE>& elements, KEY_TYPE const& handle, SPECIFIC_TYPE* obj)
|
||||
{
|
||||
bool ret = Remove(elements._elements, handle, (SPECIFIC_TYPE*)nullptr);
|
||||
return ret ? ret : Remove(elements._TailElements, handle, (SPECIFIC_TYPE*)nullptr);
|
||||
if constexpr (std::is_same_v<H, SPECIFIC_TYPE>)
|
||||
{
|
||||
elements._elements._element.erase(handle);
|
||||
return true;
|
||||
}
|
||||
|
||||
if constexpr (std::is_same_v<T, TypeNull>)
|
||||
return false;
|
||||
else
|
||||
return Remove(elements._TailElements, handle, obj);
|
||||
}
|
||||
|
||||
// Count helpers
|
||||
template<class SPECIFIC_TYPE, class KEY_TYPE>
|
||||
bool Size(ContainerUnorderedMap<SPECIFIC_TYPE, KEY_TYPE> const& elements, std::size_t* size, SPECIFIC_TYPE* /*obj*/)
|
||||
{
|
||||
*size = elements._element.size();
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class SPECIFIC_TYPE, class KEY_TYPE>
|
||||
bool Size(ContainerUnorderedMap<TypeNull, KEY_TYPE> const& /*elements*/, std::size_t* /*size*/, SPECIFIC_TYPE* /*obj*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
template<class SPECIFIC_TYPE, class KEY_TYPE, class T>
|
||||
bool Size(ContainerUnorderedMap<T, KEY_TYPE> const& /*elements*/, std::size_t* /*size*/, SPECIFIC_TYPE* /*obj*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
template<class SPECIFIC_TYPE, class KEY_TYPE, class H, class T>
|
||||
bool Size(ContainerUnorderedMap<TypeList<H, T>, KEY_TYPE> const& elements, std::size_t* size, SPECIFIC_TYPE* /*obj*/)
|
||||
inline bool Size(ContainerUnorderedMap<TypeList<H, T>, KEY_TYPE> const& elements, std::size_t* size, SPECIFIC_TYPE* obj)
|
||||
{
|
||||
bool ret = Size(elements._elements, size, (SPECIFIC_TYPE*)nullptr);
|
||||
return ret ? ret : Size(elements._TailElements, size, (SPECIFIC_TYPE*)nullptr);
|
||||
if constexpr (std::is_same_v<H, SPECIFIC_TYPE>)
|
||||
{
|
||||
*size = elements._elements._element.size();
|
||||
return true;
|
||||
}
|
||||
|
||||
if constexpr (std::is_same_v<T, TypeNull>)
|
||||
return false;
|
||||
else
|
||||
return Size(elements._TailElements, size, obj);
|
||||
}
|
||||
|
||||
/* ContainerMapList Helpers */
|
||||
// count functions
|
||||
template<class SPECIFIC_TYPE>
|
||||
size_t Count(ContainerMapList<SPECIFIC_TYPE> const& elements, SPECIFIC_TYPE* /*fake*/)
|
||||
{
|
||||
return elements._element.getSize();
|
||||
}
|
||||
|
||||
template<class SPECIFIC_TYPE>
|
||||
size_t Count(ContainerMapList<TypeNull> const& /*elements*/, SPECIFIC_TYPE* /*fake*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<class SPECIFIC_TYPE, class T>
|
||||
size_t Count(ContainerMapList<T> const& /*elements*/, SPECIFIC_TYPE* /*fake*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<class SPECIFIC_TYPE, class T>
|
||||
size_t Count(ContainerMapList<TypeList<SPECIFIC_TYPE, T>> const& elements, SPECIFIC_TYPE* fake)
|
||||
{
|
||||
return Count(elements._elements, fake);
|
||||
}
|
||||
|
||||
template<class SPECIFIC_TYPE, class H, class T>
|
||||
size_t Count(ContainerMapList<TypeList<H, T>> const& elements, SPECIFIC_TYPE* fake)
|
||||
inline size_t Count(ContainerMapList<TypeList<H, T>> const& elements, SPECIFIC_TYPE* fake)
|
||||
{
|
||||
return Count(elements._TailElements, fake);
|
||||
if constexpr (std::is_same_v<H, SPECIFIC_TYPE>)
|
||||
{
|
||||
return elements._elements._element.getSize();
|
||||
}
|
||||
|
||||
if constexpr (std::is_same_v<T, TypeNull>)
|
||||
return 0;
|
||||
else
|
||||
return Count(elements._TailElements, fake);
|
||||
}
|
||||
|
||||
// non-const insert functions
|
||||
template<class SPECIFIC_TYPE>
|
||||
SPECIFIC_TYPE* Insert(ContainerMapList<SPECIFIC_TYPE>& elements, SPECIFIC_TYPE* obj)
|
||||
{
|
||||
//elements._element[hdl] = obj;
|
||||
obj->AddToGrid(elements._element);
|
||||
return obj;
|
||||
}
|
||||
|
||||
template<class SPECIFIC_TYPE>
|
||||
SPECIFIC_TYPE* Insert(ContainerMapList<TypeNull>& /*elements*/, SPECIFIC_TYPE* /*obj*/)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// this is a missed
|
||||
template<class SPECIFIC_TYPE, class T>
|
||||
SPECIFIC_TYPE* Insert(ContainerMapList<T>& /*elements*/, SPECIFIC_TYPE* /*obj*/)
|
||||
{
|
||||
return nullptr; // a missed
|
||||
}
|
||||
|
||||
// Recursion
|
||||
template<class SPECIFIC_TYPE, class H, class T>
|
||||
SPECIFIC_TYPE* Insert(ContainerMapList<TypeList<H, T>>& elements, SPECIFIC_TYPE* obj)
|
||||
inline SPECIFIC_TYPE* Insert(ContainerMapList<TypeList<H, T>>& elements, SPECIFIC_TYPE* obj)
|
||||
{
|
||||
SPECIFIC_TYPE* t = Insert(elements._elements, obj);
|
||||
return (t != nullptr ? t : Insert(elements._TailElements, obj));
|
||||
if constexpr (std::is_same_v<H, SPECIFIC_TYPE>)
|
||||
{
|
||||
obj->AddToGrid(elements._elements._element);
|
||||
return obj;
|
||||
}
|
||||
|
||||
if constexpr (std::is_same_v<T, TypeNull>)
|
||||
return nullptr;
|
||||
else
|
||||
return Insert(elements._TailElements, obj);
|
||||
}
|
||||
|
||||
//// non-const remove method
|
||||
//template<class SPECIFIC_TYPE> SPECIFIC_TYPE* Remove(ContainerMapList<SPECIFIC_TYPE> & /*elements*/, SPECIFIC_TYPE *obj)
|
||||
//template<class SPECIFIC_TYPE, class H, class T>
|
||||
//SPECIFIC_TYPE* Remove(ContainerMapList<TypeList<H, T>>& elements, SPECIFIC_TYPE* obj)
|
||||
//{
|
||||
// obj->GetGridRef().unlink();
|
||||
// return obj;
|
||||
//}
|
||||
// if constexpr (std::is_same_v<H, SPECIFIC_TYPE>)
|
||||
// {
|
||||
// obj->GetGridRef().unlink();
|
||||
// return obj;
|
||||
// }
|
||||
|
||||
//template<class SPECIFIC_TYPE> SPECIFIC_TYPE* Remove(ContainerMapList<TypeNull> &/*elements*/, SPECIFIC_TYPE * /*obj*/)
|
||||
//{
|
||||
// return nullptr;
|
||||
//}
|
||||
|
||||
//// this is a missed
|
||||
//template<class SPECIFIC_TYPE, class T> SPECIFIC_TYPE* Remove(ContainerMapList<T> &/*elements*/, SPECIFIC_TYPE * /*obj*/)
|
||||
//{
|
||||
// return nullptr; // a missed
|
||||
//}
|
||||
|
||||
//template<class SPECIFIC_TYPE, class T, class H> SPECIFIC_TYPE* Remove(ContainerMapList<TypeList<H, T> > &elements, SPECIFIC_TYPE *obj)
|
||||
//{
|
||||
// // The head element is bad
|
||||
// SPECIFIC_TYPE* t = Remove(elements._elements, obj);
|
||||
// return (t != nullptr ? t : Remove(elements._TailElements, obj));
|
||||
// if constexpr (std::is_same_v<T, TypeNull>)
|
||||
// return nullptr;
|
||||
// else
|
||||
// return Remove(elements._TailElements, obj);
|
||||
//}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
*/
|
||||
|
||||
#include "TraitMgr.h"
|
||||
#include "Containers.h"
|
||||
#include "DB2Stores.h"
|
||||
#include "IteratorPair.h"
|
||||
#include "Player.h"
|
||||
#include "MapUtils.h"
|
||||
#include "TraitPacketsCommon.h"
|
||||
|
||||
namespace TraitMgr
|
||||
|
||||
@@ -566,7 +566,7 @@ public:
|
||||
handler->PSendSysMessage(LANG_GOINFO_SIZE, gameObjectInfo->size);
|
||||
handler->PSendSysMessage(LANG_OBJECTINFO_AIINFO, gameObjectInfo->AIName.c_str(), sObjectMgr->GetScriptName(gameObjectInfo->ScriptId).c_str());
|
||||
if (GameObjectAI const* ai = thisGO ? thisGO->AI() : nullptr)
|
||||
handler->PSendSysMessage(LANG_OBJECTINFO_AITYPE, GetTypeName(*ai).c_str());
|
||||
handler->PSendSysMessage(LANG_OBJECTINFO_AITYPE, Trinity::GetTypeName(*ai).c_str());
|
||||
|
||||
if (GameObjectDisplayInfoEntry const* modelInfo = sGameObjectDisplayInfoStore.LookupEntry(displayId))
|
||||
handler->PSendSysMessage(LANG_GOINFO_MODEL, modelInfo->GeoBoxMax.X, modelInfo->GeoBoxMax.Y, modelInfo->GeoBoxMax.Z, modelInfo->GeoBoxMin.X, modelInfo->GeoBoxMin.Y, modelInfo->GeoBoxMin.Z);
|
||||
|
||||
@@ -539,7 +539,7 @@ public:
|
||||
STRING_VIEW_FMT_ARG(target->GetStringIds()[1]), STRING_VIEW_FMT_ARG(target->GetStringIds()[2]));
|
||||
handler->PSendSysMessage(LANG_NPCINFO_REACTSTATE, DescribeReactState(target->GetReactState()));
|
||||
if (CreatureAI const* ai = target->AI())
|
||||
handler->PSendSysMessage(LANG_OBJECTINFO_AITYPE, GetTypeName(*ai).c_str());
|
||||
handler->PSendSysMessage(LANG_OBJECTINFO_AITYPE, Trinity::GetTypeName(*ai).c_str());
|
||||
handler->PSendSysMessage(LANG_NPCINFO_FLAGS_EXTRA, cInfo->flags_extra);
|
||||
for (CreatureFlagsExtra flag : EnumUtils::Iterate<CreatureFlagsExtra>())
|
||||
if (cInfo->flags_extra & flag)
|
||||
|
||||
Reference in New Issue
Block a user