Welcome to Anything Forums! We are a general discussion forum that believes in freedom of expression and aim to provide a low moderation (within reasonable means) environment to discuss any topic. If you want to join, simply click HERE to be taken to our account management system where you can make an account. If you had an account at iceteks.com, anythingforums.com, uovalor.com or uogateway.com in the past it has been transfered over and you can simply do a password reset.
//writes a int based on specified lenght (bits)
void RSbitstream::WriteVarInt(unsigned int tw,int bits)
{
if(bits>32)bits=32;
if(bits<1)bits=1;
unsigned long int orer=1;
for(int i=1;i<bits;i++)
{
orer*=2;
}
//make sure tw is not past its capacity
tw = (tw>((orer*2)-1)) ? ((orer*2)-1) : tw;
for(int i=0;i<bits;i++)
{
stream.Add(((orer & tw)==orer) ? true : false);
orer/=2;
}
}
Believe it or not, all this is leading up to me continuing to work on my UO client. These functions will make it easier to deal with network data.
Archived topic from AOV, old topic ID:1050, old post ID:6902
Honk if you love Jesus, text if you want to meet Him!
Hahah yeah, the 2nd code is actually the variable lenght version of the first. I can specity the number of bits. Converts a number to binary, basically. There's also a ReadVarInt version which does the oposite, takes a stream of bits and returns a number.
Archived topic from AOV, old topic ID:1050, old post ID:7038
Honk if you love Jesus, text if you want to meet Him!
Red Squirrel wrote:Hahah yeah, the 2nd code is actually the variable lenght version of the first. I can specity the number of bits. Converts a number to binary, basically. There's also a ReadVarInt version which does the oposite, takes a stream of bits and returns a number.
There's only 10 types of people in this world. Those who know binary, and those who don't.
Archived topic from AOV, old topic ID:1050, old post ID:7046
If you give someone a program, you will frustrate them for a day; if you teach them how to program, you will frustrate them for a lifetime.