Tue, 16 Dec 2014 03:44:05 +0200
- changed write_float/read_float to use memcpy
sources/network/bytestream.cpp | file | annotate | diff | comparison | revisions |
--- a/sources/network/bytestream.cpp Tue Dec 16 03:30:15 2014 +0200 +++ b/sources/network/bytestream.cpp Tue Dec 16 03:44:05 2014 +0200 @@ -178,8 +178,10 @@ METHOD Bytestream::read_float() -> float { - int value = read_long(); - return reinterpret_cast<float&> (value); + float value; + int intvalue = read_long(); + memcpy (&value, &intvalue, sizeof intvalue); + return value; } // ------------------------------------------------------------------------------------------------- @@ -292,7 +294,9 @@ Bytestream::write_float (float val) -> void { // I know this is probably dangerous but this is what Zandronum does so yeah - write_long (reinterpret_cast<int&> (val)); + int intvalue; + memcpy (&intvalue, &val, sizeof val); + write_long (intvalue); } // -------------------------------------------------------------------------------------------------