problem:
packetbuf.insert("hello");
packetbuf.sendpacket(sockfd, 0x0e);
in the channel it says
<name>ÿhello
why is the 'ÿ' there?
Quote from: mentalCo. on June 16, 2004, 11:06 PM
problem:
packetbuf.insert("hello");
packetbuf.sendpacket(sockfd, 0x0e);
in the channel it says
<name>ÿhello
why is the 'ÿ' there?
Post your packet buffer code.
It would seem a stray 0xFF in the packetbuffer send code is at fault here.
i am using a packetbuffer class used in a lot of bots.
//insert into packet
void PacketBuffer::insert(const char *data) {
strcpy(buffer + ipos, data);
if(ipos + strlen(data) + 1 > len)
len = ipos + strlen(data) + 1;
ipos += strlen(data) + 1;
}
//send packet
void PacketBuffer::sendpacket(int s, char id)
{
char packetbuffer[1024] = "";
packetbuffer[0] = (char)0xff;
packetbuffer[1] = id;
*(unsigned short *)(packetbuffer + 2) = (unsigned short)len + 4;
memcpy(packetbuffer + 4, buffer, len);
send(s, packetbuffer, len + 4, 0);
clear();
}