I’m making good progress on my MacOS/Swift netrek client.  It’s playable!  I’ve even gotten a couple kills.  I’m hoping to release an alpha version Friday March 15th.  “Beware the ides of March”.  I’ve attached a screenshot at the bottom.

I’m having trouble understanding the CP_MESSAGE format.  At first it looks simple:

struct mesg_cpacket { /* CP_MESSAGE py-struct "!bBBx80s" #1 */
    char type;
    char group;
    char indiv;	/* does this break anything? -da */
    char pad1;
    char mesg[MSG_LEN];

I captured a packet trace of a distress call to the Rom team with 4 in the group (MTEAM?) and 2 in the indiv (TEAM=ROM?) fields.  But I’m having trouble sending messages with the MacTrek client so I don’t have a full set of packet traces to work with.

Other client headers below but let me ask a couple specific questions:

1) If I want to send a message to ALL, what do I put in group/indiv?

2) If I want to send a message to TEAM ROM, what do I put in group/indiv (I think group=4 (MTEAM) and indiv=2 (ROM)).

3) If I want to send a message to individual player #3 what do I put in the group/indiv fields?

4) At startup, client is supposed to send the following message:
	CP_MESSAGE (MINDIV|MCONFIG, self, "@clientname clientversion")
MINDIV is 0x02
MCONFIG is 0x04
So I guess 0x06 goes in the group field.  What is the “self” that (presumably) goes in the indiv field?  Is that my PlayerID (0 through 31)?


Looking at the existing source code I’m finding a bunch of different things to put in the group and indiv fields (although I may be getting CP_MESSAGE and SP_MESSAGE mixed up).

The team flags are as follows:


Below is the message header source I’ve dug up.

#define MVALID 0x01
#define MGOD   0x10
#define MMOO   0x12

#ifdef TOOLS
#define MTOOLS 0x14

/* order flags by importance (0x100 - 0x400) */
/* restructuring of message flags to squeeze them all into 1 byte - jmn */
/* hopefully quasi-back-compatible: MVALID, MINDIV, MTEAM, MALL, MGOD use up
 * 5 bits. this leaves us 3 bits. since the server only checks for those
 * flags when deciding message related things and since each of the above
 * cases only has 1 flag on at a time we can overlap the meanings of the
 * flags */

#define MINDIV 0x02
/* these go with MINDIV flag */

#ifdef STDBG
#define MDBG   0x20

#define MCONFIG 0x40                             /* config messages from * *
                                                  * server */
#define MDIST 0x60                               /* flag distress type * *
                                                  * messages properly */
#define MMACRO 0x80

#define MTEAM  0x04
/* these go with MTEAM flag */
#define MTAKE  0x20
#define MDEST  0x40
#define MBOMB  0x60
#define MCOUP1 0x80
#define MCOUP2 0xA0
#define MDISTR 0xC0                              /* flag distress type
                                                  * messages */
#define MALL   0x08
/* these go with MALL flag */
#define MGENO  0x20                              /* MGENO is not used in INL
                                                  * here  */
#define MCONQ  0x20                              /* not enought bits to
                                                  * distinguish MCONQ/MGENO :-( */
#define MKILLA 0x40
#define MKILLP 0x60
#define MKILL  0x80
#define MLEAVE 0xA0
#define MJOIN  0xC0
#define MGHOST 0xE0
/* MMASK not used in INL server */

#define MWHOMSK  0x1f                            /* mask with this to find
                                                  * who msg to */
#define MWHATMSK 0xe0                            /* mask with this to find
                                                  * what message about */
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.us.netrek.org/pipermail/netrek-dev/attachments/20190310/e7748152/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Swift-netrek-screenshot-1.png
Type: image/png
Size: 599100 bytes
Desc: not available
URL: <http://mailman.us.netrek.org/pipermail/netrek-dev/attachments/20190310/e7748152/attachment-0001.png>