mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 01:15:35 +01:00
GCC build fix
This commit is contained in:
@@ -18,6 +18,13 @@
|
||||
#ifndef TRINITY_ADVSTD_H
|
||||
#define TRINITY_ADVSTD_H
|
||||
|
||||
#include <version>
|
||||
|
||||
#ifdef __cpp_lib_bit_cast
|
||||
#include <bit>
|
||||
#else
|
||||
#include <cstring> // for memcpy
|
||||
#endif
|
||||
#include <compare>
|
||||
|
||||
// this namespace holds implementations of upcoming stdlib features that our c++ version doesn't have yet
|
||||
@@ -26,6 +33,23 @@ namespace advstd
|
||||
// libc++ is missing these two
|
||||
[[nodiscard]] constexpr bool is_eq(std::partial_ordering cmp) noexcept { return cmp == 0; }
|
||||
[[nodiscard]] constexpr bool is_neq(std::partial_ordering cmp) noexcept { return cmp != 0; }
|
||||
|
||||
#ifdef __cpp_lib_bit_cast
|
||||
using std::bit_cast;
|
||||
#else
|
||||
// libstdc++ v10 is missing this
|
||||
template <typename To, typename From,
|
||||
std::enable_if_t<std::conjunction_v<
|
||||
std::bool_constant<sizeof(To) == sizeof(From)>,
|
||||
std::is_trivially_copyable<To>,
|
||||
std::is_trivially_copyable<From>>, int> = 0>
|
||||
[[nodiscard]] constexpr To bit_cast(From const& from) noexcept
|
||||
{
|
||||
To to;
|
||||
std::memcpy(&to, &from, sizeof(To));
|
||||
return to;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "Transport.h"
|
||||
#include "Unit.h"
|
||||
#include "UpdateData.h"
|
||||
#include "advstd.h"
|
||||
#include <bit>
|
||||
|
||||
AreaTrigger::AreaTrigger() : WorldObject(false), MapObject(), _spawnId(0), _aurEff(nullptr), _maxSearchRadius(0.0f),
|
||||
@@ -364,7 +365,7 @@ float AreaTrigger::GetScaleCurveValue(UF::ScaleCurve const& scaleCurve, float x)
|
||||
|
||||
// unpack ParameterCurve
|
||||
if (*scaleCurve.ParameterCurve & 1)
|
||||
return std::bit_cast<float>(*scaleCurve.ParameterCurve & ~1);
|
||||
return advstd::bit_cast<float>(*scaleCurve.ParameterCurve & ~1);
|
||||
|
||||
std::array<DBCPosition2D, 2> points;
|
||||
for (std::size_t i = 0; i < scaleCurve.Points.size(); ++i)
|
||||
@@ -394,7 +395,7 @@ void AreaTrigger::SetScaleCurve(UF::MutableFieldReference<UF::ScaleCurve, false>
|
||||
|
||||
if (float const* simpleFloat = std::get_if<float>(&curve->Curve))
|
||||
{
|
||||
uint32 packedCurve = std::bit_cast<uint32>(*simpleFloat);
|
||||
uint32 packedCurve = advstd::bit_cast<uint32>(*simpleFloat);
|
||||
packedCurve |= 1;
|
||||
|
||||
SetUpdateFieldValue(scaleCurveMutator.ModifyValue(&UF::ScaleCurve::ParameterCurve), packedCurve);
|
||||
|
||||
Reference in New Issue
Block a user