Browse Source

again boring misalignment fixes

pull/110/merge
nillerusr 2 years ago
parent
commit
08073ae622
  1. 14
      engine/audio/private/snd_wave_mixer_adpcm.cpp
  2. 2
      engine/dt_localtransfer.cpp
  3. 4
      public/bone_setup.cpp
  4. 4
      public/tier1/utlbuffer.h
  5. 4
      tier1/checksum_md5.cpp

14
engine/audio/private/snd_wave_mixer_adpcm.cpp

@ -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;

2
engine/dt_localtransfer.cpp

@ -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) );
} }
} }
} }

4
public/bone_setup.cpp

@ -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;

4
public/tier1/utlbuffer.h

@ -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() )
{ {

4
tier1/checksum_md5.cpp

@ -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;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

Loading…
Cancel
Save