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;
// read initial delta
int delta = *((short *)pIn);
pIn += 2;
short data[3];
memcpy( data, pIn, sizeof(data) );
pIn += sizeof(data);
// read initial samples for prediction
int samp1 = *((short *)pIn);
pIn += 2;
int samp2 = *((short *)pIn);
pIn += 2;
int delta = data[0];
int samp1 = data[1];
int samp2 = data[2];
// write out the initial samples (stored in reverse order)
*pOut++ = (short)samp2;

View File

@ -63,7 +63,7 @@ inline void LocalTransfer_FastType(
const T *pSource = (const T*)( pServerBase + pCur->m_iSendOffset );
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 )
{
Quaternion48 tmp;
memcpy( &tmp, panim->pQuat48(), sizeof(Quaternion48) );
V_memcpy( &tmp, panim->pQuat48(), sizeof(Quaternion48) );
q = tmp;
Assert( q.IsValid() );
return;
@ -390,7 +390,7 @@ void CalcBoneQuaternion( int frame, float s,
if ( panim->flags & STUDIO_ANIM_RAWROT2 )
{
Quaternion64 tmp;
memcpy( &tmp, panim->pQuat64(), sizeof(Quaternion64) );
V_memcpy( &tmp, panim->pQuat64(), sizeof(Quaternion64) );
q = tmp;
Assert( q.IsValid() );
return;

View File

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

View File

@ -267,7 +267,9 @@ unsigned int MD5_PseudoRandom(unsigned int nSeed)
MD5Update(&ctx, (unsigned char*)&nSeed, sizeof(nSeed) );
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;
}
//-----------------------------------------------------------------------------