diff options
| author | Jørgen P. Tjernø <[email protected]> | 2013-12-02 19:31:46 -0800 |
|---|---|---|
| committer | Jørgen P. Tjernø <[email protected]> | 2013-12-02 19:46:31 -0800 |
| commit | f56bb35301836e56582a575a75864392a0177875 (patch) | |
| tree | de61ddd39de3e7df52759711950b4c288592f0dc /mp/src/tier1/byteswap.cpp | |
| parent | Mark some more files as text. (diff) | |
| download | source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.tar.xz source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.zip | |
Fix line endings. WHAMMY.
Diffstat (limited to 'mp/src/tier1/byteswap.cpp')
| -rw-r--r-- | mp/src/tier1/byteswap.cpp | 180 |
1 files changed, 90 insertions, 90 deletions
diff --git a/mp/src/tier1/byteswap.cpp b/mp/src/tier1/byteswap.cpp index ec6b996e..9f66297d 100644 --- a/mp/src/tier1/byteswap.cpp +++ b/mp/src/tier1/byteswap.cpp @@ -1,90 +1,90 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose: Low level byte swapping routines.
-//
-// $NoKeywords: $
-//=============================================================================
-
-#include "byteswap.h"
-
-//-----------------------------------------------------------------------------
-// Copy a single field from the input buffer to the output buffer, swapping the bytes if necessary
-//-----------------------------------------------------------------------------
-void CByteswap::SwapFieldToTargetEndian( void* pOutputBuffer, void *pData, typedescription_t *pField )
-{
- switch ( pField->fieldType )
- {
- case FIELD_CHARACTER:
- SwapBufferToTargetEndian<char>( (char*)pOutputBuffer, (char*)pData, pField->fieldSize );
- break;
-
- case FIELD_BOOLEAN:
- SwapBufferToTargetEndian<bool>( (bool*)pOutputBuffer, (bool*)pData, pField->fieldSize );
- break;
-
- case FIELD_SHORT:
- SwapBufferToTargetEndian<short>( (short*)pOutputBuffer, (short*)pData, pField->fieldSize );
- break;
-
- case FIELD_FLOAT:
- SwapBufferToTargetEndian<uint>( (uint*)pOutputBuffer, (uint*)pData, pField->fieldSize );
- break;
-
- case FIELD_INTEGER:
- SwapBufferToTargetEndian<int>( (int*)pOutputBuffer, (int*)pData, pField->fieldSize );
- break;
-
- case FIELD_VECTOR:
- SwapBufferToTargetEndian<uint>( (uint*)pOutputBuffer, (uint*)pData, pField->fieldSize * 3 );
- break;
-
- case FIELD_VECTOR2D:
- SwapBufferToTargetEndian<uint>( (uint*)pOutputBuffer, (uint*)pData, pField->fieldSize * 2 );
- break;
-
- case FIELD_QUATERNION:
- SwapBufferToTargetEndian<uint>( (uint*)pOutputBuffer, (uint*)pData, pField->fieldSize * 4 );
- break;
-
- case FIELD_EMBEDDED:
- {
- typedescription_t *pEmbed = pField->td->dataDesc;
- for ( int i = 0; i < pField->fieldSize; ++i )
- {
- SwapFieldsToTargetEndian( (byte*)pOutputBuffer + pEmbed->fieldOffset[ TD_OFFSET_NORMAL ],
- (byte*)pData + pEmbed->fieldOffset[ TD_OFFSET_NORMAL ],
- pField->td );
-
- pOutputBuffer = (byte*)pOutputBuffer + pField->fieldSizeInBytes;
- pData = (byte*)pData + pField->fieldSizeInBytes;
- }
- }
- break;
-
- default:
- assert(0);
- }
-}
-
-//-----------------------------------------------------------------------------
-// Write a block of fields. Works a bit like the saverestore code.
-//-----------------------------------------------------------------------------
-void CByteswap::SwapFieldsToTargetEndian( void *pOutputBuffer, void *pBaseData, datamap_t *pDataMap )
-{
- // deal with base class first
- if ( pDataMap->baseMap )
- {
- SwapFieldsToTargetEndian( pOutputBuffer, pBaseData, pDataMap->baseMap );
- }
-
- typedescription_t *pFields = pDataMap->dataDesc;
- int fieldCount = pDataMap->dataNumFields;
- for ( int i = 0; i < fieldCount; ++i )
- {
- typedescription_t *pField = &pFields[i];
- SwapFieldToTargetEndian( (BYTE*)pOutputBuffer + pField->fieldOffset[ TD_OFFSET_NORMAL ],
- (BYTE*)pBaseData + pField->fieldOffset[ TD_OFFSET_NORMAL ],
- pField );
- }
-}
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: Low level byte swapping routines. +// +// $NoKeywords: $ +//============================================================================= + +#include "byteswap.h" + +//----------------------------------------------------------------------------- +// Copy a single field from the input buffer to the output buffer, swapping the bytes if necessary +//----------------------------------------------------------------------------- +void CByteswap::SwapFieldToTargetEndian( void* pOutputBuffer, void *pData, typedescription_t *pField ) +{ + switch ( pField->fieldType ) + { + case FIELD_CHARACTER: + SwapBufferToTargetEndian<char>( (char*)pOutputBuffer, (char*)pData, pField->fieldSize ); + break; + + case FIELD_BOOLEAN: + SwapBufferToTargetEndian<bool>( (bool*)pOutputBuffer, (bool*)pData, pField->fieldSize ); + break; + + case FIELD_SHORT: + SwapBufferToTargetEndian<short>( (short*)pOutputBuffer, (short*)pData, pField->fieldSize ); + break; + + case FIELD_FLOAT: + SwapBufferToTargetEndian<uint>( (uint*)pOutputBuffer, (uint*)pData, pField->fieldSize ); + break; + + case FIELD_INTEGER: + SwapBufferToTargetEndian<int>( (int*)pOutputBuffer, (int*)pData, pField->fieldSize ); + break; + + case FIELD_VECTOR: + SwapBufferToTargetEndian<uint>( (uint*)pOutputBuffer, (uint*)pData, pField->fieldSize * 3 ); + break; + + case FIELD_VECTOR2D: + SwapBufferToTargetEndian<uint>( (uint*)pOutputBuffer, (uint*)pData, pField->fieldSize * 2 ); + break; + + case FIELD_QUATERNION: + SwapBufferToTargetEndian<uint>( (uint*)pOutputBuffer, (uint*)pData, pField->fieldSize * 4 ); + break; + + case FIELD_EMBEDDED: + { + typedescription_t *pEmbed = pField->td->dataDesc; + for ( int i = 0; i < pField->fieldSize; ++i ) + { + SwapFieldsToTargetEndian( (byte*)pOutputBuffer + pEmbed->fieldOffset[ TD_OFFSET_NORMAL ], + (byte*)pData + pEmbed->fieldOffset[ TD_OFFSET_NORMAL ], + pField->td ); + + pOutputBuffer = (byte*)pOutputBuffer + pField->fieldSizeInBytes; + pData = (byte*)pData + pField->fieldSizeInBytes; + } + } + break; + + default: + assert(0); + } +} + +//----------------------------------------------------------------------------- +// Write a block of fields. Works a bit like the saverestore code. +//----------------------------------------------------------------------------- +void CByteswap::SwapFieldsToTargetEndian( void *pOutputBuffer, void *pBaseData, datamap_t *pDataMap ) +{ + // deal with base class first + if ( pDataMap->baseMap ) + { + SwapFieldsToTargetEndian( pOutputBuffer, pBaseData, pDataMap->baseMap ); + } + + typedescription_t *pFields = pDataMap->dataDesc; + int fieldCount = pDataMap->dataNumFields; + for ( int i = 0; i < fieldCount; ++i ) + { + typedescription_t *pField = &pFields[i]; + SwapFieldToTargetEndian( (BYTE*)pOutputBuffer + pField->fieldOffset[ TD_OFFSET_NORMAL ], + (BYTE*)pBaseData + pField->fieldOffset[ TD_OFFSET_NORMAL ], + pField ); + } +} + |