Example #1
0
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;
	}
}