• Welcome to Valhalla Legends Archive.
 

[c++] 0x0E question

Started by mentalCo., June 16, 2004, 11:06 PM

Previous topic - Next topic

mentalCo.

problem:


packetbuf.insert("hello");
packetbuf.sendpacket(sockfd, 0x0e);



in the channel it says

<name>ÿhello

why is the 'ÿ' there?

Tuberload

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.
Quote"Pray not for lighter burdens, but for stronger backs." -- Teddy Roosevelt
"Your forefathers have given you freedom, so good luck, see you around, hope you make it" -- Unknown

Stealth

It would seem a stray 0xFF in the packetbuffer send code is at fault here.
- Stealth
Author of StealthBot

mentalCo.

#3
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();
}