Updated SVC_VoiceInit for latest TF2 version.

This commit is contained in:
Jordan Cristiano
2018-01-11 01:35:00 -05:00
parent 630351e7e5
commit ef898de18d
3 changed files with 57 additions and 2 deletions

View File

@ -4,6 +4,7 @@
#include <cstdint>
#include <cstddef>
#include <cassert>
#include <string.h>
#include "vector.h"
using uint64 = std::uint64_t;
@ -160,3 +161,32 @@ inline int GetBitForBitnum( int bitNum )
};
return bitsForBitnum[ (bitNum) & (BITS_PER_INT-1) ];
}
#ifndef _WIN32
#define _strnicmp strncasecmp
#endif
inline int V_strnicmp( const char *str1, const char *str2, int n )
{
const unsigned char *s1 = (const unsigned char*)str1;
const unsigned char *s2 = (const unsigned char*)str2;
for ( ; n > 0 && *s1; --n, ++s1, ++s2 )
{
if ( *s1 != *s2 )
{
// in ascii char set, lowercase = uppercase | 0x20
unsigned char c1 = *s1 | 0x20;
unsigned char c2 = *s2 | 0x20;
if ( c1 != c2 || (unsigned char)(c1 - 'a') > ('z' - 'a') )
{
// if non-ascii mismatch, fall back to CRT for locale
if ( (c1 | c2) >= 0x80 ) return _strnicmp( (const char*)s1, (const char*)s2, n );
// ascii mismatch. only use the | 0x20 value if alphabetic.
if ((unsigned char)(c1 - 'a') > ('z' - 'a')) c1 = *s1;
if ((unsigned char)(c2 - 'a') > ('z' - 'a')) c2 = *s2;
return c1 > c2 ? 1 : -1;
}
}
}
return (n > 0 && *s2) ? -1 : 0;
}