Updated SVC_VoiceInit for latest TF2 version.
This commit is contained in:
parent
630351e7e5
commit
ef898de18d
@ -9,6 +9,15 @@ namespace NetHandlers
|
|||||||
{
|
{
|
||||||
bitbuf.ReadString(data->voiceCodec, sizeof(data->voiceCodec));
|
bitbuf.ReadString(data->voiceCodec, sizeof(data->voiceCodec));
|
||||||
data->quality = bitbuf.ReadByte();
|
data->quality = bitbuf.ReadByte();
|
||||||
|
if(data->quality == NetMsg::SVC_VoiceInit::QUALITY_HAS_SAMPLE_RATE)
|
||||||
|
{
|
||||||
|
data->sampleRate = bitbuf.ReadShort();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// V_strnicmp < 1 is from them, not me.
|
||||||
|
data->sampleRate = V_strnicmp(data->voiceCodec, "vaudio_celt", sizeof(data->voiceCodec)) < 1 ? 22050 : 11025;
|
||||||
|
}
|
||||||
return !bitbuf.IsOverflowed();
|
return !bitbuf.IsOverflowed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -16,6 +25,10 @@ namespace NetHandlers
|
|||||||
{
|
{
|
||||||
bitbuf.WriteString(data->voiceCodec);
|
bitbuf.WriteString(data->voiceCodec);
|
||||||
bitbuf.WriteByte(data->quality);
|
bitbuf.WriteByte(data->quality);
|
||||||
|
if(data->quality == NetMsg::SVC_VoiceInit::QUALITY_HAS_SAMPLE_RATE)
|
||||||
|
{
|
||||||
|
bitbuf.WriteShort(data->sampleRate);
|
||||||
|
}
|
||||||
return !bitbuf.IsOverflowed();
|
return !bitbuf.IsOverflowed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,6 +38,7 @@ namespace NetHandlers
|
|||||||
assert(!reader.HasReadError());
|
assert(!reader.HasReadError());
|
||||||
reader.ReadString("voiceCodec", data->voiceCodec, sizeof(data->voiceCodec));
|
reader.ReadString("voiceCodec", data->voiceCodec, sizeof(data->voiceCodec));
|
||||||
data->quality = reader.ReadUInt32("quality");
|
data->quality = reader.ReadUInt32("quality");
|
||||||
|
data->sampleRate = reader.ReadInt32("sampleRate");
|
||||||
return !reader.HasReadError();
|
return !reader.HasReadError();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,13 +48,21 @@ namespace NetHandlers
|
|||||||
jsonbuf.StartObject();
|
jsonbuf.StartObject();
|
||||||
jsonbuf.WriteString("voiceCodec", data->voiceCodec);
|
jsonbuf.WriteString("voiceCodec", data->voiceCodec);
|
||||||
jsonbuf.WriteUInt32("quality", data->quality);
|
jsonbuf.WriteUInt32("quality", data->quality);
|
||||||
|
jsonbuf.WriteInt32("sampleRate", data->sampleRate);
|
||||||
jsonbuf.EndObject();
|
jsonbuf.EndObject();
|
||||||
return jsonbuf.IsComplete();
|
return jsonbuf.IsComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SVC_VoiceInit_ToString_Internal(std::ostringstream& out, NetMsg::SVC_VoiceInit* data)
|
void SVC_VoiceInit_ToString_Internal(std::ostringstream& out, NetMsg::SVC_VoiceInit* data)
|
||||||
{
|
{
|
||||||
out << "svc_VoiceInit: codec \"" << data->voiceCodec
|
out << "svc_VoiceInit: codec \"" << data->voiceCodec;
|
||||||
<< "\", qualitty " << static_cast<uint32_t>(data->quality);
|
if(data->quality == NetMsg::SVC_VoiceInit::QUALITY_HAS_SAMPLE_RATE)
|
||||||
|
{
|
||||||
|
out << "\", sample rate " << static_cast<uint32_t>(data->sampleRate);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
out << "\", qualitty " << static_cast<uint32_t>(data->quality);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,11 @@ namespace NetMsg
|
|||||||
{
|
{
|
||||||
struct SVC_VoiceInit
|
struct SVC_VoiceInit
|
||||||
{
|
{
|
||||||
|
static const uint8_t QUALITY_HAS_SAMPLE_RATE = 255;
|
||||||
|
|
||||||
char voiceCodec[MAX_OSPATH]; // used voice codec .dll
|
char voiceCodec[MAX_OSPATH]; // used voice codec .dll
|
||||||
uint8_t quality; // custom quality setting
|
uint8_t quality; // custom quality setting
|
||||||
|
int32_t sampleRate; // Hz
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <string.h>
|
||||||
#include "vector.h"
|
#include "vector.h"
|
||||||
|
|
||||||
using uint64 = std::uint64_t;
|
using uint64 = std::uint64_t;
|
||||||
@ -160,3 +161,32 @@ inline int GetBitForBitnum( int bitNum )
|
|||||||
};
|
};
|
||||||
return bitsForBitnum[ (bitNum) & (BITS_PER_INT-1) ];
|
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;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user