diff --git a/public/tier1/bitbuf.h b/public/tier1/bitbuf.h index ebf40cc4..a625f5eb 100644 --- a/public/tier1/bitbuf.h +++ b/public/tier1/bitbuf.h @@ -20,7 +20,7 @@ #include "mathlib/vector.h" #include "basetypes.h" #include "tier0/dbg.h" - +#include "strtools.h" #if _DEBUG #define BITBUF_INLINE inline @@ -465,12 +465,12 @@ BITBUF_INLINE void bf_write::WriteUBitVar( unsigned int data ) // write raw IEEE float bits in little endian form BITBUF_INLINE void bf_write::WriteBitFloat(float val) { - long intVal; + int32 intVal; Assert(sizeof(long) == sizeof(float)); Assert(sizeof(float) == 4); - intVal = *((long*)&val); + Q_memcpy( &intVal, &val, sizeof(intVal)); WriteUBitLong( intVal, 32 ); } diff --git a/public/tier1/utlbuffer.h b/public/tier1/utlbuffer.h index 9773d065..fb77b1f8 100644 --- a/public/tier1/utlbuffer.h +++ b/public/tier1/utlbuffer.h @@ -598,7 +598,7 @@ inline void CUtlBuffer::GetObject( T *dest ) { if ( !m_Byteswap.IsSwappingBytes() || ( sizeof( T ) == 1 ) ) { - *dest = *(T *)PeekGet(); + Q_memcpy( dest, PeekGet(), sizeof( T ) ); } else { @@ -661,7 +661,7 @@ inline void CUtlBuffer::GetTypeBin< float >( float &dest ) else { // aligned read - Q_memcmp( &dest, pData, sizeof(float) ); + Q_memcmp( &dest, (void*)pData, sizeof(float) ); } if ( m_Byteswap.IsSwappingBytes() ) {