summaryrefslogtreecommitdiffstats
path: root/src/WorldStorage
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-02-26 22:17:28 +0100
committermadmaxoft <github@xoft.cz>2014-02-26 22:17:28 +0100
commitcb40d114abe8a41ed5193e9cc99b06727f497452 (patch)
tree72e72320ad00c3731b3b0bd40eaf3b43c4df6757 /src/WorldStorage
parentAttempted fix for several GCC warnings. (diff)
downloadcuberite-cb40d114abe8a41ed5193e9cc99b06727f497452.tar
cuberite-cb40d114abe8a41ed5193e9cc99b06727f497452.tar.gz
cuberite-cb40d114abe8a41ed5193e9cc99b06727f497452.tar.bz2
cuberite-cb40d114abe8a41ed5193e9cc99b06727f497452.tar.lz
cuberite-cb40d114abe8a41ed5193e9cc99b06727f497452.tar.xz
cuberite-cb40d114abe8a41ed5193e9cc99b06727f497452.tar.zst
cuberite-cb40d114abe8a41ed5193e9cc99b06727f497452.zip
Diffstat (limited to 'src/WorldStorage')
-rw-r--r--src/WorldStorage/FastNBT.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/WorldStorage/FastNBT.h b/src/WorldStorage/FastNBT.h
index b84eda1a1..a78b610cb 100644
--- a/src/WorldStorage/FastNBT.h
+++ b/src/WorldStorage/FastNBT.h
@@ -172,8 +172,17 @@ 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(int) != sizeof(float)
+ char Check1[sizeof(int) - sizeof(float) + 1]; // sizeof(int) >= sizeof(float)
+ char Check2[sizeof(float) - sizeof(int) + 1]; // sizeof(float) >= sizeof(int)
+ UNUSED(Check1);
+ UNUSED(Check2);
+
+ int 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