summaryrefslogtreecommitdiffstats
path: root/src/WorldStorage/FastNBT.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/WorldStorage/FastNBT.h')
-rw-r--r--src/WorldStorage/FastNBT.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/WorldStorage/FastNBT.h b/src/WorldStorage/FastNBT.h
index b84eda1a1..49f97c458 100644
--- a/src/WorldStorage/FastNBT.h
+++ b/src/WorldStorage/FastNBT.h
@@ -172,8 +172,18 @@ public:
inline float GetFloat(int a_Tag) const
{
ASSERT(m_Tags[a_Tag].m_Type == TAG_Float);
- Int32 tmp = GetBEInt(m_Data + m_Tags[a_Tag].m_DataStart);
- return *((float *)&tmp);
+
+ // Cause a compile-time error if sizeof(float) != 4
+ // If your platform produces a compiler error here, you'll need to add code that manually decodes 32-bit floats
+ char Check1[5 - sizeof(float)]; // sizeof(float) <= 4
+ char Check2[sizeof(float) - 3]; // sizeof(float) >= 4
+ UNUSED(Check1);
+ UNUSED(Check2);
+
+ Int32 i = GetBEInt(m_Data + m_Tags[a_Tag].m_DataStart);
+ float f;
+ memcpy(&f, &i, sizeof(f));
+ return f;
}
inline double GetDouble(int a_Tag) const