diff options
author | madmaxoft <github@xoft.cz> | 2014-02-26 22:17:28 +0100 |
---|---|---|
committer | madmaxoft <github@xoft.cz> | 2014-02-26 22:17:28 +0100 |
commit | cb40d114abe8a41ed5193e9cc99b06727f497452 (patch) | |
tree | 72e72320ad00c3731b3b0bd40eaf3b43c4df6757 /src/WorldStorage | |
parent | Attempted fix for several GCC warnings. (diff) | |
download | cuberite-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 '')
-rw-r--r-- | src/WorldStorage/FastNBT.h | 13 |
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 |