diff options
Diffstat (limited to 'utils/xbox/makephx/util.cpp')
| -rw-r--r-- | utils/xbox/makephx/util.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/utils/xbox/makephx/util.cpp b/utils/xbox/makephx/util.cpp new file mode 100644 index 0000000..cb5e879 --- /dev/null +++ b/utils/xbox/makephx/util.cpp @@ -0,0 +1,41 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +#include "mathlib/mathlib.h" +#include "util.h" +#include "tier1/strtools.h" + +void UTIL_StringToFloatArray( float *pVector, int count, const char *pString ) +{ + char *pstr, *pfront, tempString[128]; + int j; + + Q_strncpy( tempString, pString, sizeof(tempString) ); + pstr = pfront = tempString; + + for ( j = 0; j < count; j++ ) // lifted from pr_edict.c + { + pVector[j] = atof( pfront ); + + // skip any leading whitespace + while ( *pstr && *pstr <= ' ' ) + pstr++; + + // skip to next whitespace + while ( *pstr && *pstr > ' ' ) + pstr++; + + if (!*pstr) + break; + + pstr++; + pfront = pstr; + } + for ( j++; j < count; j++ ) + { + pVector[j] = 0; + } +} + +void UTIL_StringToVector( float *pVector, const char *pString ) +{ + UTIL_StringToFloatArray( pVector, 3, pString ); +} |