1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-16 21:59:55 +00:00

Treat std::array like regular arrays

This commit is contained in:
Evil Eye 2023-07-21 17:00:33 +02:00
parent 45ba05c0ed
commit 9d4877d432
4 changed files with 23 additions and 6 deletions

View file

@ -17,8 +17,25 @@
namespace ESM namespace ESM
{ {
template <class T> template <class T>
constexpr bool IsReadable struct GetArray
= std::is_arithmetic_v<T> || std::is_enum_v<T> || (std::is_array_v<T> && IsReadable<std::remove_extent_t<T>>); {
using type = void;
};
template <class T, size_t N>
struct GetArray<std::array<T, N>>
{
using type = T;
};
template <class T, size_t N>
struct GetArray<T[N]>
{
using type = T;
};
template <class T>
constexpr bool IsReadable = std::is_arithmetic_v<T> || std::is_enum_v<T> || IsReadable<typename GetArray<T>::type>;
template <>
constexpr bool IsReadable<void> = false;
class ReadersCache; class ReadersCache;

View file

@ -53,11 +53,11 @@ namespace ESM
mName = esm.getHString(); mName = esm.getHString();
break; break;
case fourCC("CNDT"): case fourCC("CNDT"):
esm.getHTSized<4>(mWeight); esm.getHT(mWeight);
hasWeight = true; hasWeight = true;
break; break;
case fourCC("FLAG"): case fourCC("FLAG"):
esm.getHTSized<4>(mFlags); esm.getHT(mFlags);
if (mFlags & 0xf4) if (mFlags & 0xf4)
esm.fail("Unknown flags"); esm.fail("Unknown flags");
if (!(mFlags & 0x8)) if (!(mFlags & 0x8))

View file

@ -23,7 +23,7 @@ namespace ESM
hasName = true; hasName = true;
break; break;
case fourCC("DATA"): case fourCC("DATA"):
esm.getHTSized<4>(mType); esm.getHT(mType);
hasData = true; hasData = true;
break; break;
case fourCC("CNAM"): case fourCC("CNAM"):

View file

@ -35,7 +35,7 @@ namespace ESM
if (esm.isNextSub("POS_")) if (esm.isNextSub("POS_"))
{ {
std::array<float, 6> pos; std::array<float, 6> pos;
esm.getHTSized<24>(pos); esm.getHT(pos);
memcpy(mPosition.pos, pos.data(), sizeof(float) * 3); memcpy(mPosition.pos, pos.data(), sizeof(float) * 3);
memcpy(mPosition.rot, pos.data() + 3, sizeof(float) * 3); memcpy(mPosition.rot, pos.data() + 3, sizeof(float) * 3);
} }