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 /tracker/common/util.cpp | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'tracker/common/util.cpp')
| -rw-r--r-- | tracker/common/util.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/tracker/common/util.cpp b/tracker/common/util.cpp new file mode 100644 index 0000000..d28b1c7 --- /dev/null +++ b/tracker/common/util.cpp @@ -0,0 +1,70 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#include "util.h" +#include <string.h> + +#define NUM_BUFFERS 4 +#define MAX_INFO_TOKEN_LENGTH 512 +const char *CUtil::InfoGetValue( const char *s, const char *key ) +{ + char pkey[MAX_INFO_TOKEN_LENGTH]; + // Use multiple buffers so compares + // work without stomping on each other + static char value[NUM_BUFFERS][MAX_INFO_TOKEN_LENGTH]; + static int valueindex; + char *o; + + valueindex = (valueindex + 1) % NUM_BUFFERS; + + if (*s == '\\') + s++; + while (1) + { + o = pkey; + while (*s != '\\') + { + if (!*s) + return ""; + *o++ = *s++; + } + *o = 0; + s++; + + o = value[valueindex]; + + while (*s != '\\' && *s) + { + if (!*s) + return ""; + *o++ = *s++; + } + *o = 0; + + if (!strcmp (key, pkey) ) + return value[valueindex]; + + if (!*s) + return ""; + s++; + } +} + +//----------------------------------------------------------------------------- +// Purpose: This function is supposed to localise the strings, but for now just return internal value +// Input : *stringName - +// Output : const char +//----------------------------------------------------------------------------- +const char *CUtil::GetString(const char *stringName) +{ + return stringName; +} + +static CUtil g_Util; +CUtil *util = &g_Util; + + |