diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /engine/bitbuf_errorhandler.cpp | |
| download | archived-source-engine-2018-hl2-src-3bf9df6b2785fa6d951086978a3e66f49427166a.tar.xz archived-source-engine-2018-hl2-src-3bf9df6b2785fa6d951086978a3e66f49427166a.zip | |
Diffstat (limited to 'engine/bitbuf_errorhandler.cpp')
| -rw-r--r-- | engine/bitbuf_errorhandler.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/engine/bitbuf_errorhandler.cpp b/engine/bitbuf_errorhandler.cpp new file mode 100644 index 0000000..df4f698 --- /dev/null +++ b/engine/bitbuf_errorhandler.cpp @@ -0,0 +1,47 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#include "bitbuf.h" +#include "bitbuf_errorhandler.h" +#include "tier0/dbg.h" +#include "utlsymbol.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +void EngineBitBufErrorHandler( BitBufErrorType errorType, const char *pDebugName ) +{ + if ( !pDebugName ) + { + pDebugName = "(unknown)"; + } + + static CUtlSymbolTable errorNames[ BITBUFERROR_NUM_ERRORS ]; + + // Only print an error a couple times. + CUtlSymbol sym = errorNames[ errorType ].Find( pDebugName ); + if ( UTL_INVAL_SYMBOL == sym ) + { + errorNames[ errorType ].AddString( pDebugName ); + if ( errorType == BITBUFERROR_VALUE_OUT_OF_RANGE ) + { + Warning( "Error in bitbuf [%s]: out of range value. Debug in bitbuf_errorhandler.cpp\n", pDebugName ); + } + else if ( errorType == BITBUFERROR_BUFFER_OVERRUN ) + { + Warning( "Error in bitbuf [%s]: buffer overrun. Debug in bitbuf_errorhandler.cpp\n", pDebugName ); + } + } + + AssertMsg( false, "%s: %s errorType: %d", __FUNCTION__, pDebugName, errorType ); +} + +void InstallBitBufErrorHandler() +{ + SetBitBufErrorHandler( EngineBitBufErrorHandler ); +} + |