again boring misalignment fixes

This commit is contained in:
nillerusr 2022-08-09 21:24:27 +03:00
parent c5607661f0
commit 08073ae622
5 changed files with 13 additions and 15 deletions

View File

@ -123,15 +123,13 @@ void CAudioMixerWaveADPCM::DecompressBlockMono( short *pOut, const char *pIn, in
int co2 = m_pCoefficients[pred].iCoef2; int co2 = m_pCoefficients[pred].iCoef2;
// read initial delta // read initial delta
int delta = *((short *)pIn); short data[3];
pIn += 2; memcpy( data, pIn, sizeof(data) );
pIn += sizeof(data);
// read initial samples for prediction int delta = data[0];
int samp1 = *((short *)pIn); int samp1 = data[1];
pIn += 2; int samp2 = data[2];
int samp2 = *((short *)pIn);
pIn += 2;
// write out the initial samples (stored in reverse order) // write out the initial samples (stored in reverse order)
*pOut++ = (short)samp2; *pOut++ = (short)samp2;

View File

@ -63,7 +63,7 @@ inline void LocalTransfer_FastType(
const T *pSource = (const T*)( pServerBase + pCur->m_iSendOffset ); const T *pSource = (const T*)( pServerBase + pCur->m_iSendOffset );
T *pDest = (T*)( pClientBase + pCur->m_iRecvOffset ); T *pDest = (T*)( pClientBase + pCur->m_iRecvOffset );
*pDest = *pSource; memcpy( pDest, pSource, sizeof(T) );
} }
} }
} }

View File

@ -381,7 +381,7 @@ void CalcBoneQuaternion( int frame, float s,
if ( panim->flags & STUDIO_ANIM_RAWROT ) if ( panim->flags & STUDIO_ANIM_RAWROT )
{ {
Quaternion48 tmp; Quaternion48 tmp;
memcpy( &tmp, panim->pQuat48(), sizeof(Quaternion48) ); V_memcpy( &tmp, panim->pQuat48(), sizeof(Quaternion48) );
q = tmp; q = tmp;
Assert( q.IsValid() ); Assert( q.IsValid() );
return; return;
@ -390,7 +390,7 @@ void CalcBoneQuaternion( int frame, float s,
if ( panim->flags & STUDIO_ANIM_RAWROT2 ) if ( panim->flags & STUDIO_ANIM_RAWROT2 )
{ {
Quaternion64 tmp; Quaternion64 tmp;
memcpy( &tmp, panim->pQuat64(), sizeof(Quaternion64) ); V_memcpy( &tmp, panim->pQuat64(), sizeof(Quaternion64) );
q = tmp; q = tmp;
Assert( q.IsValid() ); Assert( q.IsValid() );
return; return;

View File

@ -705,7 +705,6 @@ inline void CUtlBuffer::GetTypeBin( T &dest )
if ( !m_Byteswap.IsSwappingBytes() || ( sizeof( T ) == 1 ) ) if ( !m_Byteswap.IsSwappingBytes() || ( sizeof( T ) == 1 ) )
{ {
memcpy(&dest, PeekGet(), sizeof(T) ); memcpy(&dest, PeekGet(), sizeof(T) );
dest = *(T *)PeekGet();
} }
else else
{ {
@ -735,8 +734,7 @@ inline void CUtlBuffer::GetTypeBin< float >( float &dest )
} }
else else
{ {
// aligned read memcpy( &dest, (void*)pData, sizeof(float) );
dest = *(float *)pData;
} }
if ( m_Byteswap.IsSwappingBytes() ) if ( m_Byteswap.IsSwappingBytes() )
{ {

View File

@ -267,7 +267,9 @@ unsigned int MD5_PseudoRandom(unsigned int nSeed)
MD5Update(&ctx, (unsigned char*)&nSeed, sizeof(nSeed) ); MD5Update(&ctx, (unsigned char*)&nSeed, sizeof(nSeed) );
MD5Final(digest, &ctx); MD5Final(digest, &ctx);
return *(unsigned int*)(digest+6); // use 4 middle bytes for random value unsigned int rand;
memcpy(&rand, digest+6, sizeof(rand)); // use 4 middle bytes for random value
return rand;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------