mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-11-10 07:12:03 +00:00
Merge branch 'hole-punch-less-getaddrinfo' into 'next'
Call getaddrinfo less frequently when hole punching See merge request KartKrew/Kart-Public!303
This commit is contained in:
commit
886bda775b
2 changed files with 29 additions and 14 deletions
|
@ -1933,7 +1933,16 @@ static void CL_LoadReceivedSavegame(void)
|
|||
#ifndef NONET
|
||||
static void SendAskInfo(INT32 node)
|
||||
{
|
||||
const tic_t asktime = I_GetTime();
|
||||
tic_t asktime;
|
||||
|
||||
if (node != 0 && node != BROADCASTADDR &&
|
||||
cv_rendezvousserver.string[0])
|
||||
{
|
||||
I_NetRequestHolePunch();
|
||||
}
|
||||
|
||||
asktime = I_GetTime();
|
||||
|
||||
netbuffer->packettype = PT_ASKINFO;
|
||||
netbuffer->u.askinfo.version = VERSION;
|
||||
netbuffer->u.askinfo.time = (tic_t)LONG(asktime);
|
||||
|
@ -1942,12 +1951,6 @@ static void SendAskInfo(INT32 node)
|
|||
// now allowed traffic from the host to us in, so once the MS relays
|
||||
// our address to the host, it'll be able to speak to us.
|
||||
HSendPacket(node, false, 0, sizeof (askinfo_pak));
|
||||
|
||||
if (node != 0 && node != BROADCASTADDR &&
|
||||
cv_rendezvousserver.string[0])
|
||||
{
|
||||
I_NetRequestHolePunch();
|
||||
}
|
||||
}
|
||||
|
||||
serverelem_t serverlist[MAXSERVERLIST];
|
||||
|
|
26
src/i_tcp.c
26
src/i_tcp.c
|
@ -175,6 +175,7 @@ static UINT8 UPNP_support = TRUE;
|
|||
#endif // !NONET
|
||||
|
||||
#include "i_system.h"
|
||||
#include "i_time.h"
|
||||
#include "i_net.h"
|
||||
#include "d_net.h"
|
||||
#include "d_netfil.h"
|
||||
|
@ -1517,18 +1518,29 @@ static void rendezvous(int size)
|
|||
char *host = strtok(addrs, ":");
|
||||
char *port = strtok(NULL, ":");
|
||||
|
||||
mysockaddr_t rzv;
|
||||
static mysockaddr_t rzv;
|
||||
static tic_t refreshtic = (tic_t)-1;
|
||||
|
||||
if (SOCK_GetAddr(&rzv.ip4, host, (port ? port : "7777"), false))
|
||||
tic_t tic = I_GetTime();
|
||||
|
||||
if (tic != refreshtic)
|
||||
{
|
||||
if (SOCK_GetAddr(&rzv.ip4, host, (port ? port : "7777"), false))
|
||||
{
|
||||
refreshtic = tic;
|
||||
}
|
||||
else
|
||||
{
|
||||
CONS_Alert(CONS_ERROR, "Failed to contact rendezvous server (%s).\n",
|
||||
cv_rendezvousserver.string);
|
||||
}
|
||||
}
|
||||
|
||||
if (tic == refreshtic)
|
||||
{
|
||||
holepunchpacket->magic = hole_punch_magic;
|
||||
sendto(mysockets[0], doomcom->data, size, 0, &rzv.any, sizeof rzv.ip4);
|
||||
}
|
||||
else
|
||||
{
|
||||
CONS_Alert(CONS_ERROR, "Failed to contact rendezvous server (%s).\n",
|
||||
cv_rendezvousserver.string);
|
||||
}
|
||||
|
||||
free(addrs);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue