18#ifndef TRINITYCORE_RACE_MASK_H
19#define TRINITYCORE_RACE_MASK_H
90template<
typename T,
size_t N = 1>
93 static_assert(std::is_integral_v<T>,
"RaceMask<T> must be integral");
152 return raceBit >= 0 &&
uint32(raceBit) <
sizeof(T) * 8 * N
153 && (
RawValue[raceBit / (
sizeof(T) * 8)] & (T(1) << (raceBit % (
sizeof(T) * 8)))) != T(0);
160 if (raceBit >= 0 &&
uint32(raceBit) <
sizeof(T) * 8 * N)
161 result.
RawValue[raceBit / (
sizeof(T) * 8)] = T(1) << (raceBit % (
sizeof(T) * 8));
170 if (rawValue != T(0))
178 for (std::size_t i = 0; i < N; ++i)
186 for (std::size_t i = 0; i < N; ++i)
194 for (std::size_t i = 0; i < N; ++i)
199 template<
typename OtherT,
size_t OtherN>
202 static_assert(
sizeof(OtherT) * OtherN >=
sizeof(T) * N,
"RaceMask truncating conversion not allowed");
206 if (std::is_constant_evaluated())
208 for (std::size_t i = 0; i < N; ++i)
210 for (std::size_t j = 0; j <
sizeof(T); ++j)
214 std::size_t byteIndex = j + i *
sizeof(T);
216 std::size_t resultI = byteIndex /
sizeof(OtherT);
217 std::size_t resultJ = byteIndex %
sizeof(OtherT);
219 result.
RawValue[resultI] |=
static_cast<OtherT
>(byte) << (resultJ * 8);
231template <
typename T,
size_t N = 1>
234template <
typename T,
size_t N = 1>
268template <
typename T,
size_t N = 1>
271template <
typename T,
size_t N = 1>
289template <
typename T,
size_t N = 1>
constexpr Trinity::RaceMask< uint64 > RACEMASK_ALL_PLAYABLE
constexpr Trinity::RaceMask< T, N > RACEMASK_ALL_v
constexpr Trinity::RaceMask< T, N > RACEMASK_HORDE_v
constexpr Trinity::RaceMask< T, N > RACEMASK_NEUTRAL_v
constexpr Trinity::RaceMask< uint64 > RACEMASK_ALLIANCE
constexpr Trinity::RaceMask< T, N > RACEMASK_ALL_PLAYABLE_v
constexpr Trinity::RaceMask< uint64 > RACEMASK_NEUTRAL
constexpr Trinity::RaceMask< uint64 > RACEMASK_HORDE
@ RACE_LIGHTFORGED_DRAENEI
@ RACE_EARTHEN_DWARF_HORDE
@ RACE_HIGHMOUNTAIN_TAUREN
@ RACE_EARTHEN_DWARF_ALLIANCE
constexpr Trinity::RaceMask< T, N > RACEMASK_ALLIANCE_v
constexpr Trinity::RaceMask< uint64 > RACEMASK_ALL
std::array< T, N > RawValue
constexpr bool operator==(RaceMask const &) const =default
static constexpr int32 GetRaceBit(uint32 raceId)
constexpr RaceMask operator&(RaceMask right) const
constexpr bool HasRace(uint32 raceId) const
constexpr RaceMask operator~() const
constexpr bool IsEmpty() const
constexpr RaceMask operator|(RaceMask right) const
static constexpr RaceMask GetMaskForRace(uint32 raceId)