[Guide]New Habbo Protocol

Adil

DevBest CEO
May 28, 2011
1,276
714
Habbo Packets

This is a quick overview, nothing special.

As most of you guys may know, Sulake have fiddled with their protocol. However, though the protocol looks hard to understand,
it's main concept (of raw bytes) is actually easier to work with (if you know what you're doing). The new implementation is also
faster and as I've said, easier to grasp.
So... Down to business.

4BYTES [INT, MSG LEN], 2BYTES [SHORT, MSG ID], 2BYTES [SHORT, STRLEN], STR

Basically, what this means is:
4 bytes (2 bits) are used for the message length. For example, you could have 00 00 00 0f [15 in hexadecimal]
2 bytes (1 bit) are used for the message ID. E.g 0fa0 [4000 in hexadecimal]
2 bytes (1 bit) are used for the string length. E.g 0008 [8 in hexadecimal]

00 00 00 0f //Packet length
0f a0 //Packet ID
00 08 //String length
lalacats //String

This is a quick overview, there are other bits (like booleans) that aren't covered here.

So.. Some code.
PHP:
int msgLen = buffer.readInt(); //reads four bytes of the buffer
short msgId = buffer.readShort();
short strlen = buffer.readShort();
String msgString = buffer.readBytes( strlen );

This code will basically do the following:
>Read the message length as an integer.
>Read the message id as a short.
>Read the string length as a short.
>Read the bytes of the string, length specified by the string length.


Please leave any feedback here, thanks.

I will also be adding classes and files (Java, and C++(?) if I can find them!)
 

Users who are viewing this thread

Top