From 4c7c2abf03b692e67a89d2ba0856aec1553c8ae1 Mon Sep 17 00:00:00 2001 From: Shauren Date: Mon, 20 Apr 2015 01:54:18 +0200 Subject: Core/Misc: Removed gcc specific packing pragma syntax - only unsupported (now) versions required it --- src/server/bnetserver/Packets/BitStream.h | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'src/server/bnetserver/Packets/BitStream.h') diff --git a/src/server/bnetserver/Packets/BitStream.h b/src/server/bnetserver/Packets/BitStream.h index f780a4dd867..432f0243149 100644 --- a/src/server/bnetserver/Packets/BitStream.h +++ b/src/server/bnetserver/Packets/BitStream.h @@ -28,6 +28,12 @@ namespace Battlenet { + union FloatToInt + { + float AsFloat; + uint32 AsInt; + }; + class BitStreamPositionException : public std::exception { static uint32 const MessageSize = 128; @@ -102,8 +108,14 @@ namespace Battlenet float ReadFloat() { - uint32 val = Read(32); - return *reinterpret_cast(&val); + union + { + float AsFloat; + uint32 AsInt; + } convert; + + convert.AsInt = Read(32); + return convert.AsFloat; } std::string ReadFourCC() @@ -167,8 +179,14 @@ namespace Battlenet void WriteFloat(float value) { - uint32 intVal = *reinterpret_cast(&value); - Write(intVal, 32); + union + { + float AsFloat; + uint32 AsInt; + } convert; + + convert.AsFloat = value; + Write(convert.AsInt, 32); } void WriteFourCC(std::string const& fcc) -- cgit v1.2.3