From 29061bea509b87154ba8593ffa32fdbe15eb4a4b Mon Sep 17 00:00:00 2001 From: L Date: Sun, 5 Feb 2023 02:08:47 +0100 Subject: [PATCH] Fixed send_heartbeat sending to the wrong address --- code/gamespy/sv_gqueryreporting.c | 10 +++++----- code/gamespy/sv_gqueryreporting.h | 4 +++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/code/gamespy/sv_gqueryreporting.c b/code/gamespy/sv_gqueryreporting.c index 725125a93..78d7bb30e 100644 --- a/code/gamespy/sv_gqueryreporting.c +++ b/code/gamespy/sv_gqueryreporting.c @@ -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; } @@ -518,5 +518,5 @@ int qr_init( if (!qrec) qrec = ¤t_rec; - return do_connect((void*)hbsock, "master.x-null.net", 27900); + return do_connect((void*)hbsock, "master.x-null.net", 27900, &(*qrec)->master_saddr); } diff --git a/code/gamespy/sv_gqueryreporting.h b/code/gamespy/sv_gqueryreporting.h index 0391d20fa..cf3352f18 100644 --- a/code/gamespy/sv_gqueryreporting.h +++ b/code/gamespy/sv_gqueryreporting.h @@ -1,3 +1,5 @@ +#include + typedef void (*qr_querycallback_t) (char* outbuf, int maxlen, void* userdata); typedef void (*qr_custom_handler_t) (const char* query, struct sockaddr* sender); @@ -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;