From 4e5b79207cf801c9c3e1c04d739e73604d3fc919 Mon Sep 17 00:00:00 2001 From: GAMMACASE <31375974+GAMMACASE@users.noreply.github.com> Date: Mon, 18 Mar 2024 16:46:21 +0300 Subject: [PATCH] Move CByteswap to tier0 --- public/tier1/cbyteswap.h | 6 +-- tier1/cbyteswap.cpp | 90 ---------------------------------------- 2 files changed, 3 insertions(+), 93 deletions(-) delete mode 100644 tier1/cbyteswap.cpp diff --git a/public/tier1/cbyteswap.h b/public/tier1/cbyteswap.h index 3cac1238..5d556651 100644 --- a/public/tier1/cbyteswap.h +++ b/public/tier1/cbyteswap.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2006, Valve LLC, All rights reserved. ============ +//========= Copyright � 1996-2006, Valve LLC, All rights reserved. ============ // // Purpose: Low level byte swapping routines. // @@ -25,12 +25,12 @@ public: //----------------------------------------------------------------------------- // Write a single field. //----------------------------------------------------------------------------- - void SwapFieldToTargetEndian( void* pOutputBuffer, void *pData, typedescription_t *pField ); + DLL_CLASS_IMPORT void SwapFieldToTargetEndian( void* pOutputBuffer, void *pData, typedescription_t *pField ); //----------------------------------------------------------------------------- // Write a block of fields. Works a bit like the saverestore code. //----------------------------------------------------------------------------- - void SwapFieldsToTargetEndian( void *pOutputBuffer, void *pBaseData, datamap_t *pDataMap ); + DLL_CLASS_IMPORT void SwapFieldsToTargetEndian( void *pOutputBuffer, void *pBaseData, datamap_t *pDataMap ); // Swaps fields for the templated type to the output buffer. template inline void SwapFieldsToTargetEndian( T* pOutputBuffer, void *pBaseData, unsigned int objectCount = 1 ) diff --git a/tier1/cbyteswap.cpp b/tier1/cbyteswap.cpp deleted file mode 100644 index c2071f8c..00000000 --- a/tier1/cbyteswap.cpp +++ /dev/null @@ -1,90 +0,0 @@ -//========= Copyright � 1996-2006, Valve LLC, All rights reserved. ============ -// -// Purpose: Low level byte swapping routines. -// -// $NoKeywords: $ -//============================================================================= - -#include "cbyteswap.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*)pOutputBuffer, (char*)pData, pField->fieldSize ); - break; - - case FIELD_BOOLEAN: - SwapBufferToTargetEndian( (bool*)pOutputBuffer, (bool*)pData, pField->fieldSize ); - break; - - case FIELD_SHORT: - SwapBufferToTargetEndian( (short*)pOutputBuffer, (short*)pData, pField->fieldSize ); - break; - - case FIELD_FLOAT: - SwapBufferToTargetEndian( (uint*)pOutputBuffer, (uint*)pData, pField->fieldSize ); - break; - - case FIELD_INTEGER: - SwapBufferToTargetEndian( (int*)pOutputBuffer, (int*)pData, pField->fieldSize ); - break; - - case FIELD_VECTOR: - SwapBufferToTargetEndian( (uint*)pOutputBuffer, (uint*)pData, pField->fieldSize * 3 ); - break; - - case FIELD_VECTOR2D: - SwapBufferToTargetEndian( (uint*)pOutputBuffer, (uint*)pData, pField->fieldSize * 2 ); - break; - - case FIELD_QUATERNION: - SwapBufferToTargetEndian( (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, - (byte*)pData + pEmbed->fieldOffset, - 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, - (BYTE*)pBaseData + pField->fieldOffset, - pField ); - } -} -