int64_t decode_int64(CBitRead& entityBitBuffer, const CSVCMsg_SendTable::sendprop_t* pSendProp) { if(pSendProp->flags() & SPROP_VARINT) { if(pSendProp->flags() & SPROP_UNSIGNED) { return (int64_t)entityBitBuffer.ReadVarInt64(); } else { return entityBitBuffer.ReadSignedVarInt64(); } } else { uint32_t highInt = 0; uint32_t lowInt = 0; bool bNeg = false; if(!(pSendProp->flags() & SPROP_UNSIGNED)) { bNeg = entityBitBuffer.ReadOneBit() != 0; lowInt = entityBitBuffer.ReadUBitLong(32); highInt = entityBitBuffer.ReadUBitLong(pSendProp->num_bits() - 32 - 1); } else { lowInt = entityBitBuffer.ReadUBitLong(32); highInt = entityBitBuffer.ReadUBitLong(pSendProp->num_bits() - 32); } int64_t temp; uint32_t* pInt = (uint32_t*)&temp; *pInt++ = lowInt; *pInt = highInt; if(bNeg) { temp = -temp; } return temp; } }
int Int_Decode( CBitRead &entityBitBuffer, const CSVCMsg_SendTable::sendprop_t *pSendProp ) { int flags = pSendProp->flags(); if ( flags & SPROP_VARINT ) { if ( flags & SPROP_UNSIGNED ) { return (int)entityBitBuffer.ReadVarInt32(); } else { return entityBitBuffer.ReadSignedVarInt32(); } } else { if ( flags & SPROP_UNSIGNED ) { return entityBitBuffer.ReadUBitLong( pSendProp->num_bits() ); } else { return entityBitBuffer.ReadSBitLong( pSendProp->num_bits() ); } } }
float decode_float(CBitRead& entityBitBuffer, const CSVCMsg_SendTable::sendprop_t* pSendProp) { float fVal = 0.0f; unsigned long dwInterp; if(decode_special_float(entityBitBuffer, pSendProp, fVal)) { return fVal; } dwInterp = entityBitBuffer.ReadUBitLong(pSendProp->num_bits()); fVal = (float)dwInterp / ((1 << pSendProp->num_bits()) - 1); fVal = pSendProp->low_value() + (pSendProp->high_value() - pSendProp->low_value()) * fVal; return fVal; }