Hello i'm a C++ newbie and i am starting my exploration of mangos sourcecode.
The first files i tried to read have been some /libmpq/ sources, huffman.cpp in particular.
I don't really understand a statement in that file, can someone explain it to me with some patience?
The line of interest lies within a function called libmpq_huff_get_8bits:
static unsigned long libmpq_huff_get_8bits(struct huffman_input_stream *is) {
unsigned long one_byte;
if (is->bits <= 8) {
is->bit_buf |= *(unsigned short *)is->in_buf << is->bits;
is->in_buf += sizeof(unsigned short);
is->bits += 16;
}
one_byte = (is->bit_buf & 0xFF);
is->bit_buf >>= 8;
is->bits -= 8;
return one_byte;
}
this function takes on a huffman_input_stream * pointer as a parameter. This struct is declared in huffman.h as it follows:
struct huffman_input_stream {
unsigned char *in_buf; /* 00 - Input data */
unsigned long bit_buf; /* 04 - Input bit buffer */
unsigned int bits; /* 08 - Number of bits remaining in 'byte' */
};
so now let's get to the point i'm missing:
is->bit_buf |= *(unsigned short *)is->in_buf << is->bits;
What does this line do exactly?
Anticipated thanks for the ones who will answer me and my apologies if i committed any mistakes in posting this question here.