mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-16 18:59:57 +00:00
Treat std::array like regular arrays
This commit is contained in:
parent
45ba05c0ed
commit
9d4877d432
4 changed files with 23 additions and 6 deletions
|
@ -17,8 +17,25 @@
|
|||
namespace ESM
|
||||
{
|
||||
template <class T>
|
||||
constexpr bool IsReadable
|
||||
= std::is_arithmetic_v<T> || std::is_enum_v<T> || (std::is_array_v<T> && IsReadable<std::remove_extent_t<T>>);
|
||||
struct GetArray
|
||||
{
|
||||
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;
|
||||
|
||||
|
|
|
@ -53,11 +53,11 @@ namespace ESM
|
|||
mName = esm.getHString();
|
||||
break;
|
||||
case fourCC("CNDT"):
|
||||
esm.getHTSized<4>(mWeight);
|
||||
esm.getHT(mWeight);
|
||||
hasWeight = true;
|
||||
break;
|
||||
case fourCC("FLAG"):
|
||||
esm.getHTSized<4>(mFlags);
|
||||
esm.getHT(mFlags);
|
||||
if (mFlags & 0xf4)
|
||||
esm.fail("Unknown flags");
|
||||
if (!(mFlags & 0x8))
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace ESM
|
|||
hasName = true;
|
||||
break;
|
||||
case fourCC("DATA"):
|
||||
esm.getHTSized<4>(mType);
|
||||
esm.getHT(mType);
|
||||
hasData = true;
|
||||
break;
|
||||
case fourCC("CNAM"):
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace ESM
|
|||
if (esm.isNextSub("POS_"))
|
||||
{
|
||||
std::array<float, 6> pos;
|
||||
esm.getHTSized<24>(pos);
|
||||
esm.getHT(pos);
|
||||
memcpy(mPosition.pos, pos.data(), sizeof(float) * 3);
|
||||
memcpy(mPosition.rot, pos.data() + 3, sizeof(float) * 3);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue