Fixed svc_tempentities parsing

This commit is contained in:
Jordan Cristiano 2015-05-15 01:15:11 -04:00
parent b6ee526d54
commit 6ec0224848
2 changed files with 18 additions and 4 deletions

View File

@ -9,8 +9,8 @@ enum constants
// was 96000
NET_MAX_PAYLOAD = 288000, // largest message size in bytes
// was 17
NET_MAX_PAYLOAD_BITS = 19, // 2^NET_MAX_PAYLOAD_BITS > NET_MAX_PAYLOAD
NET_MAX_PAYLOAD_BITS_OLD = 17, // for old demos
NET_MAX_PAYLOAD_BITS = 19, // 2^NET_MAX_PAYLOAD_BITS > NET_MAX_PAYLOAD
// table index is sent in log2(MAX_TABLES) bits
MAX_TABLES = 32, // Table id is 4 bits

View File

@ -9,7 +9,14 @@ namespace NetHandlers
bool SVC_TempEntities_BitRead_Internal(bf_read& bitbuf, SourceGameContext& context, NetMsg::SVC_TempEntities* data)
{
data->numEntries = bitbuf.ReadUBitLong(EVENT_INDEX_BITS);
data->dataLengthInBits = bitbuf.ReadUBitLong(NET_MAX_PAYLOAD_BITS);
if (context.protocol > 23)
{
data->dataLengthInBits = bitbuf.ReadVarInt32();
}
else
{
data->dataLengthInBits = bitbuf.ReadUBitLong(NET_MAX_PAYLOAD_BITS_OLD);
}
data->data.reset(new uint8_t[math::BitsToBytes(data->dataLengthInBits)]);
bitbuf.ReadBits(data->data.get(), data->dataLengthInBits);
return !bitbuf.IsOverflowed();
@ -18,7 +25,14 @@ namespace NetHandlers
bool SVC_TempEntities_BitWrite_Internal(bf_write& bitbuf, SourceGameContext& context, NetMsg::SVC_TempEntities* data)
{
bitbuf.WriteUBitLong(data->numEntries, EVENT_INDEX_BITS);
bitbuf.WriteUBitLong(data->dataLengthInBits, NET_MAX_PAYLOAD_BITS);
if (context.protocol > 23)
{
bitbuf.WriteVarInt32(data->dataLengthInBits);
}
else
{
bitbuf.WriteUBitLong(data->dataLengthInBits, NET_MAX_PAYLOAD_BITS_OLD);
}
bitbuf.WriteBits(data->data.get(), data->dataLengthInBits);
return !bitbuf.IsOverflowed();
}