I'm attempting to learn the type of messages and expected data that is part of client/server communication by reviewing packets.h from the server code.

I think that I'm missing something in the formatting of the file. I see constants that are reserved to indicate message identifiers, and I see the structs that indicate the format of different message blocks, but it isn't always clear what message block is sent with what message.

I'm using James Cameron's Python client as a guide, so don't need to write code for sending/receiving and extracting packets from messages, but it would be good to know enough about what is in packets.h so that I could figure out what data should be included with each message.

Here is an example:

packets.h gives this constant for a torp info message

#define SP_TORP_INFO	5		/* torp status */

Scrolling down further, I find:

struct torp_info_spacket { /* SP_TORP_INFO py-struct "!bbbxhxx" #5 */
    char  type;
    char  war;
    char  status;	/* TFREE, TDET, etc... */
    char  pad1;		/* pad needed for cross cpu compatibility */
    short tnum;
    short pad2;

In the first line, I think that the #5 means that the struct is associated with message 5, which is the SP_Torp_Info message.

However, what is "!bbbxhxx"?

It looks like a lot of information is sent with this packet. There aren't comments to know what each field means. Some, like type and war, don't seem clear at all to me. Type of what? War means what?

And lines like

    char  status;	/* TFREE, TDET, etc... */

I think TDET means that the torp was detonated, or does it just mean that it detonated, but it doesn't necessarily mean it was self-detonated. Maybe a client doesn't care.

What is TFREE? Can't think of how free applies to a torp.

Then, it says etc??? *shrug* There are other undocumented statuses? Maybe all statuses are enumerated somewhere, so they don't need to be here.

When I look in James's code, his handler for this message is defined like:

    def sp_torp_info(self, war, status):

So war and status obviously come from the fields in the struct. Where is type, though?

And there are three other unclearly named fields in the struct that aren't arguments to this handler. Maybe they don't contain data, and are used as some part of the packet sequencing? Perhaps James isn't sure what these are for, so just hasn't included them when he updates torps?

I suspect that I have some general misconceptions here, so if someone helps me clear them up, it will probably make everything else much more clear.