Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
842 B

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. #include "mathlib/mathlib.h"
  3. #include "util.h"
  4. #include "tier1/strtools.h"
  5. void UTIL_StringToFloatArray( float *pVector, int count, const char *pString )
  6. {
  7. char *pstr, *pfront, tempString[128];
  8. int j;
  9. Q_strncpy( tempString, pString, sizeof(tempString) );
  10. pstr = pfront = tempString;
  11. for ( j = 0; j < count; j++ ) // lifted from pr_edict.c
  12. {
  13. pVector[j] = atof( pfront );
  14. // skip any leading whitespace
  15. while ( *pstr && *pstr <= ' ' )
  16. pstr++;
  17. // skip to next whitespace
  18. while ( *pstr && *pstr > ' ' )
  19. pstr++;
  20. if (!*pstr)
  21. break;
  22. pstr++;
  23. pfront = pstr;
  24. }
  25. for ( j++; j < count; j++ )
  26. {
  27. pVector[j] = 0;
  28. }
  29. }
  30. void UTIL_StringToVector( float *pVector, const char *pString )
  31. {
  32. UTIL_StringToFloatArray( pVector, 3, pString );
  33. }