Hi, I'm studying some stuffs and have a question, how does packet works? I mean, I know what they are, but how to read or write a new one? I THINK I know to read this, but whow to write a new one?
For sample, we have the "mes" commands.
Packet:
/// Displays an NPC dialog message (ZC_SAY_DIALOG).
/// 00b4 <packet len>.W <npc id>.L <message>.?B
/// Client behavior (dialog window):
/// - disable mouse targeting
/// - open the dialog window
/// - set npcid of dialog window (0 by default)
/// - if set to clear on next mes, clear contents
/// - append this text
void clif_scriptmes(struct map_session_data *sd, int npcid, const char *mes)
{
int fd = sd->fd;
int slen = strlen(mes) + 9;
WFIFOHEAD(fd, slen);
WFIFOW(fd,0)=0xb4;
WFIFOW(fd,2)=slen;
WFIFOL(fd,4)=npcid;
memcpy((char*)WFIFOP(fd,8), mes, slen-8);
WFIFOSET(fd,WFIFOW(fd,2));
}
Whow to understand this?
/// 00b4 <packet len>.W <npc id>.L <message>.?B
In packet_db.txt we have:
0x00b4,-1
This mean that the packet len change your size.
But some packets like the next button, are like this:
0x00b5,6
Why the packet lenght of next button are "6"? The next button return some value or send? I'm confuse.
// 01. PacketType ID of the packet.
// 02. PacketLength Length of the packet. If 0, packet is disabled in current packet version. If -1, packet has variable size.
// 03. Name Name of the packet parser function (optional, for incoming packets only).
// 04. FieldIndex Specifies the offset of a packet field in bytes from the begin of the packet (only specified when Name is given).
// Can be 0, when the layout is not known.
What is the FieldIndex?
And for sample, if I want to write a new packet? I search for a ID not used? Just this? If i want to send for sample a "name" in a new packet? I don't need the C code, just the packet explain and maybe the clif code, but I think that I understood this.
Any way, thanks for who help or read this.
Sorry about english.