Open Kiddinglife opened 8 years ago
this function supposes that the memory adress after write position is default initilized with value of 0. However, it may not be so
Does this actually cause an issue? My understanding is that there can always be some 'junk' bits (byte padding) at the end of a BitStream once sent since it must send full bytes and does not send the number of bits used. The receiving bit stream does not know where the meat of the payload ends (in terms of bits). As such you need to always consider that and never read past what you know has been written (am I making any sense?)..
I could be totally wrong here, but my analysis suggests this.
Unsure if changed since I last programmed on RakNet a decade ago, but the not setting it to 0 should not affect anything and was purposefully not done to help performance.
At lines between 220 and 227 in void BitStream::Write(BitStream *bitStream, BitSize_t bits2Write): } else { // Existing byte if( bitStream->data[bitStream->mReadPosBits >> 3] & ( 0x80 >> ( bitStream->mReadPosBits & 7 ) ) ) data[mWritePosBits >> 3] |= 0x80 >> ( numberOfBitsMod8 ); // Set the bit to 1else 0, do nothing }