Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: mentalCo. on June 16, 2004, 11:06 PM

Title: [c++] 0x0E question
Post by: 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?
Title: Re:[c++] 0x0E question
Post by: Tuberload on June 16, 2004, 11:36 PM
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.
Title: Re:[c++] 0x0E question
Post by: Stealth on June 17, 2004, 12:12 AM
It would seem a stray 0xFF in the packetbuffer send code is at fault here.
Title: Re:[c++] 0x0E question
Post by: mentalCo. on June 17, 2004, 10:36 PM
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();
}