Skip to content

Commit

Permalink
Fix unaligned access in util.cpp on gcc 4.8
Browse files Browse the repository at this point in the history
  • Loading branch information
mittorn committed Apr 30, 2015
1 parent 2567059 commit 7bfefe8
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion dlls/util.cpp
Expand Up @@ -2247,13 +2247,20 @@ int CRestore::ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCou
switch( pTest->fieldType )
{
case FIELD_TIME:
#ifdef __VFP_FP__
memcpy(&timeData, pInputData, 4);
// Re-base time variables
timeData += time;
memcpy(pOutputData, &timeData, 4);
#else
timeData = *(float *)pInputData;
// Re-base time variables
timeData += time;
*((float *)pOutputData) = timeData;
#endif
break;
case FIELD_FLOAT:
*((float *)pOutputData) = *(float *)pInputData;
memcpy(pOutputData, pInputData, 4);
break;
case FIELD_MODELNAME:
case FIELD_SOUNDNAME:
Expand Down Expand Up @@ -2331,9 +2338,22 @@ int CRestore::ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCou
((float *)pOutputData)[2] = ((float *)pInputData)[2];
break;
case FIELD_POSITION_VECTOR:
#ifdef __VFP_FP__
float tmp;
memcpy(&tmp, (char *)pInputData + 0, 4);
tmp += position.x;
memcpy((char *)pOutputData + 0, &tmp, 4);
memcpy(&tmp, (char *)pInputData + 4, 4);
tmp += position.y;
memcpy((char *)pOutputData + 4, &tmp, 4);
memcpy(&tmp, (char *)pInputData + 8, 4);
tmp += position.z;
memcpy((char *)pOutputData + 8, &tmp, 4);
#else
((float *)pOutputData)[0] = ((float *)pInputData)[0] + position.x;
((float *)pOutputData)[1] = ((float *)pInputData)[1] + position.y;
((float *)pOutputData)[2] = ((float *)pInputData)[2] + position.z;
#endif
break;

case FIELD_BOOLEAN:
Expand Down

0 comments on commit 7bfefe8

Please sign in to comment.