Fixed svc_prefetch parsing

This commit is contained in:
Jordan Cristiano 2015-05-15 01:24:24 -04:00
parent 6ec0224848
commit 9a0956e8f2
2 changed files with 19 additions and 3 deletions

View File

@ -31,7 +31,9 @@ enum constants
DELTASIZE_BITS = 20, // must be: 2^DELTASIZE_BITS > (NET_MAX_PAYLOAD * 8)
EVENT_INDEX_BITS = 8,
MAX_SOUND_INDEX_BITS = 13,
MAX_SOUND_INDEX_BITS_OLD = 13,
MAX_SOUND_INDEX_BITS = 14,
MAX_USER_MSG_DATA = 255,

View File

@ -8,13 +8,27 @@ namespace NetHandlers
bool SVC_Prefetch_BitRead_Internal(bf_read& bitbuf, SourceGameContext& context, NetMsg::SVC_Prefetch* data)
{
data->type = NetMsg::SVC_Prefetch::SOUND;
if (context.protocol > 23)
{
data->soundIndex = bitbuf.ReadUBitLong(MAX_SOUND_INDEX_BITS);
}
else
{
data->soundIndex = bitbuf.ReadUBitLong(MAX_SOUND_INDEX_BITS_OLD);
}
return !bitbuf.IsOverflowed();
}
bool SVC_Prefetch_BitWrite_Internal(bf_write& bitbuf, SourceGameContext& context, NetMsg::SVC_Prefetch* data)
{
if (context.protocol > 23)
{
bitbuf.WriteUBitLong(data->soundIndex, MAX_SOUND_INDEX_BITS);
}
else
{
bitbuf.WriteUBitLong(data->soundIndex, MAX_SOUND_INDEX_BITS_OLD);
}
return !bitbuf.IsOverflowed();
}