mirror of
https://github.com/nillerusr/source-engine.git
synced 2024-12-31 18:43:02 +00:00
utlbuffer,bitbuf: misalign fix
This commit is contained in:
parent
99e02e25c9
commit
2d17c2b52f
@ -20,7 +20,7 @@
|
|||||||
#include "mathlib/vector.h"
|
#include "mathlib/vector.h"
|
||||||
#include "basetypes.h"
|
#include "basetypes.h"
|
||||||
#include "tier0/dbg.h"
|
#include "tier0/dbg.h"
|
||||||
|
#include "strtools.h"
|
||||||
|
|
||||||
#if _DEBUG
|
#if _DEBUG
|
||||||
#define BITBUF_INLINE inline
|
#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
|
// write raw IEEE float bits in little endian form
|
||||||
BITBUF_INLINE void bf_write::WriteBitFloat(float val)
|
BITBUF_INLINE void bf_write::WriteBitFloat(float val)
|
||||||
{
|
{
|
||||||
long intVal;
|
int32 intVal;
|
||||||
|
|
||||||
Assert(sizeof(long) == sizeof(float));
|
Assert(sizeof(long) == sizeof(float));
|
||||||
Assert(sizeof(float) == 4);
|
Assert(sizeof(float) == 4);
|
||||||
|
|
||||||
intVal = *((long*)&val);
|
Q_memcpy( &intVal, &val, sizeof(intVal));
|
||||||
WriteUBitLong( intVal, 32 );
|
WriteUBitLong( intVal, 32 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -598,7 +598,7 @@ inline void CUtlBuffer::GetObject( T *dest )
|
|||||||
{
|
{
|
||||||
if ( !m_Byteswap.IsSwappingBytes() || ( sizeof( T ) == 1 ) )
|
if ( !m_Byteswap.IsSwappingBytes() || ( sizeof( T ) == 1 ) )
|
||||||
{
|
{
|
||||||
*dest = *(T *)PeekGet();
|
Q_memcpy( dest, PeekGet(), sizeof( T ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -661,7 +661,7 @@ inline void CUtlBuffer::GetTypeBin< float >( float &dest )
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// aligned read
|
// aligned read
|
||||||
Q_memcmp( &dest, pData, sizeof(float) );
|
Q_memcmp( &dest, (void*)pData, sizeof(float) );
|
||||||
}
|
}
|
||||||
if ( m_Byteswap.IsSwappingBytes() )
|
if ( m_Byteswap.IsSwappingBytes() )
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user