Skip to content

Commit

Permalink
Fixed send_heartbeat sending to the wrong address
Browse files Browse the repository at this point in the history
  • Loading branch information
L committed Feb 5, 2023
1 parent 5fecffc commit 29061be
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 5 additions & 5 deletions code/gamespy/sv_gqueryreporting.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,15 +384,15 @@ static void send_heartbeat(qr_t qrec, int statechanged)
sprintf(buf, "\\heartbeat\\%d\\gamename\\%s", qrec->qport, qrec->gamename);

if (statechanged)
sprintf(&buf[strlen(buf)], "\\statechanged\\%d", statechanged);
sprintf(buf + strlen(buf), "\\statechanged\\%d", statechanged);

sendto((SOCKET)qrec->hbsock, buf, (int)strlen(buf), 0, (const struct sockaddr*)&qrec->unk1, 16);
sendto((SOCKET)qrec->hbsock, buf, (int)strlen(buf), 0, (const struct sockaddr*)&qrec->master_saddr, 16);
qrec->lastheartbeat = current_time();
}

static int do_connect(void* sock, char* addr, int port)
static int do_connect(void* sock, char* addr, int port, struct sockaddr_in* master_saddr)
{
get_sockaddrin(addr, port, &hbaddr, NULL);
get_sockaddrin(addr, port, master_saddr, NULL);
return 0;
}

Expand Down Expand Up @@ -518,5 +518,5 @@ int qr_init(
if (!qrec)
qrec = &current_rec;

return do_connect((void*)hbsock, "master.x-null.net", 27900);
return do_connect((void*)hbsock, "master.x-null.net", 27900, &(*qrec)->master_saddr);
}
4 changes: 3 additions & 1 deletion code/gamespy/sv_gqueryreporting.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <common/gsPlatformSocket.h>

typedef void (*qr_querycallback_t) (char* outbuf, int maxlen, void* userdata);
typedef void (*qr_custom_handler_t) (const char* query, struct sockaddr* sender);

Expand Down Expand Up @@ -27,7 +29,7 @@ typedef struct qr_implementation_s {
int packetnumber;
int qport;
char no_query;
int unk1;
struct sockaddr_in master_saddr;
int unk2;
int unk3;
int unk4;
Expand Down

0 comments on commit 29061be

Please sign in to comment.