Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hello could i get some explaing what this type of coding does

Status
Not open for further replies.

yashere2b

Technical User
Jan 6, 2004
2
0
0
GB
Code:
void Super::send_server(uint8 * buf, int size)
{
    if(m_hook == 0)
        return;
    m_hook->send_server(buf, size);
    trace_printf("-------------- Super to server ");
    MessageType & type = m_message_types[*buf];
    trace_printf("%s\n", type.name);
    trace_dump(buf, size);

}

void Super::send_client(uint8 * buf, int size)
{
    if(m_hook == 0)
        return;
    m_hook->send_client(buf, size);
    trace_printf("-------------- Super to client ");
    MessageType & type = m_message_types[*buf];
    trace_printf("%s\n", type.name);
	trace_dump(buf, size);
}

void Super::client_print(const char * text)
{
    int size = 44 + strlen(text) + 1;
    uint8 * buf = new uint8[size];

    buf[0] = CODE_SERVER_TALK;
    pack_big_uint16(buf + 1, size);
    pack_big_uint32(buf + 3, INVALID_SERIAL);   // serial
    pack_big_uint16(buf + 7, 0);    // graphic
    buf[9] = 0;     // mode (0=normal)
    //pack_big_uint16(buf + 10, 0x03b2);    // colour (0x03b2=grey)
    pack_big_uint16(buf + 10, 0x0440);  // colour
    pack_big_uint16(buf + 12, 3);   // font
    strcpy(reinterpret_cast<char *>(buf + 14), "Super"); // name
    strcpy(reinterpret_cast<char *>(buf + 44), text);

    send_client(buf, size);
    delete /*[]*/ buf;
}

void Super::client_print(const string & text)
{
    client_print(text.c_str());
}
 
Um, what does the program that uses this class do?

Basically, it's a class named "Super" that seems to communicate with both a client and a server. The client portion is more complete than the server portion (I assume you just didn't send that bit), but it adds a header to a given message.

The real "work" seems to be done by m_hook->send_client and m_hook->send_server. What's the type of the class member m_hook?
 
but the problem is i need a way to select a m_server e.g ip adress and then send packets to that server. Is this possible?
 
That's not in the part you pasted in. I suspect that's in the "m_hook" class.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top