mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-27 04:41:23 +00:00
Retry contacting servers in the server browser every second until nettimeout
This commit is contained in:
parent
b2eff44dc4
commit
ed9d520b4e
3 changed files with 49 additions and 13 deletions
|
@ -1954,6 +1954,10 @@ static void SendAskInfo(INT32 node)
|
||||||
serverelem_t serverlist[MAXSERVERLIST];
|
serverelem_t serverlist[MAXSERVERLIST];
|
||||||
UINT32 serverlistcount = 0;
|
UINT32 serverlistcount = 0;
|
||||||
|
|
||||||
|
static boolean resendserverlistnode[MAXNETNODES];
|
||||||
|
static boolean resendserverlist;
|
||||||
|
static tic_t serverlistepoch;
|
||||||
|
|
||||||
static void SL_ClearServerList(INT32 connectedserver)
|
static void SL_ClearServerList(INT32 connectedserver)
|
||||||
{
|
{
|
||||||
UINT32 i;
|
UINT32 i;
|
||||||
|
@ -1965,6 +1969,8 @@ static void SL_ClearServerList(INT32 connectedserver)
|
||||||
serverlist[i].node = 0;
|
serverlist[i].node = 0;
|
||||||
}
|
}
|
||||||
serverlistcount = 0;
|
serverlistcount = 0;
|
||||||
|
|
||||||
|
memset(resendserverlistnode, 0, sizeof resendserverlistnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static UINT32 SL_SearchServer(INT32 node)
|
static UINT32 SL_SearchServer(INT32 node)
|
||||||
|
@ -1981,6 +1987,8 @@ static void SL_InsertServer(serverinfo_pak* info, SINT8 node)
|
||||||
{
|
{
|
||||||
UINT32 i;
|
UINT32 i;
|
||||||
|
|
||||||
|
resendserverlistnode[node] = false;
|
||||||
|
|
||||||
// search if not already on it
|
// search if not already on it
|
||||||
i = SL_SearchServer(node);
|
i = SL_SearchServer(node);
|
||||||
if (i == UINT32_MAX)
|
if (i == UINT32_MAX)
|
||||||
|
@ -2038,6 +2046,8 @@ void CL_QueryServerList (msg_server_t *server_list)
|
||||||
|
|
||||||
CL_UpdateServerList();
|
CL_UpdateServerList();
|
||||||
|
|
||||||
|
serverlistepoch = I_GetTime();
|
||||||
|
|
||||||
for (i = 0; server_list[i].header.buffer[0]; i++)
|
for (i = 0; server_list[i].header.buffer[0]; i++)
|
||||||
{
|
{
|
||||||
// Make sure MS version matches our own, to
|
// Make sure MS version matches our own, to
|
||||||
|
@ -2050,19 +2060,42 @@ void CL_QueryServerList (msg_server_t *server_list)
|
||||||
if (node == -1)
|
if (node == -1)
|
||||||
break; // no more node free
|
break; // no more node free
|
||||||
SendAskInfo(node);
|
SendAskInfo(node);
|
||||||
// Force close the connection so that servers can't eat
|
resendserverlistnode[node] = true;
|
||||||
// up nodes forever if we never get a reply back from them
|
// Leave this node open. It'll be closed if the
|
||||||
// (usually when they've not forwarded their ports).
|
// request times out (CL_TimeoutServerList).
|
||||||
//
|
}
|
||||||
// Don't worry, we'll get in contact with the working
|
}
|
||||||
// servers again when they send SERVERINFO to us later!
|
|
||||||
//
|
resendserverlist = true;
|
||||||
// (Note: as a side effect this probably means every
|
}
|
||||||
// server in the list will probably be using the same node (e.g. node 1),
|
|
||||||
// not that it matters which nodes they use when
|
#define SERVERLISTRESENDRATE NEWTICRATE
|
||||||
// the connections are closed afterwards anyway)
|
|
||||||
// -- Monster Iestyn 12/11/18
|
void CL_TimeoutServerList(void)
|
||||||
Net_CloseConnection(node|FORCECLOSE);
|
{
|
||||||
|
if (netgame && resendserverlist)
|
||||||
|
{
|
||||||
|
const tic_t timediff = I_GetTime() - serverlistepoch;
|
||||||
|
const tic_t timetoresend = timediff % SERVERLISTRESENDRATE;
|
||||||
|
const boolean timedout = timediff > connectiontimeout;
|
||||||
|
|
||||||
|
if (timedout || (timediff > 0 && timetoresend == 0))
|
||||||
|
{
|
||||||
|
INT32 node;
|
||||||
|
|
||||||
|
for (node = 1; node < MAXNETNODES; ++node)
|
||||||
|
{
|
||||||
|
if (resendserverlistnode[node])
|
||||||
|
{
|
||||||
|
if (timedout)
|
||||||
|
Net_CloseConnection(node|FORCECLOSE);
|
||||||
|
else
|
||||||
|
SendAskInfo(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (timedout)
|
||||||
|
resendserverlist = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -594,6 +594,7 @@ void CL_ClearPlayer(INT32 playernum);
|
||||||
void CL_RemovePlayer(INT32 playernum, INT32 reason);
|
void CL_RemovePlayer(INT32 playernum, INT32 reason);
|
||||||
void CL_QueryServerList(msg_server_t *list);
|
void CL_QueryServerList(msg_server_t *list);
|
||||||
void CL_UpdateServerList(void);
|
void CL_UpdateServerList(void);
|
||||||
|
void CL_TimeoutServerList(void);
|
||||||
// Is there a game running
|
// Is there a game running
|
||||||
boolean Playing(void);
|
boolean Playing(void);
|
||||||
|
|
||||||
|
|
|
@ -3447,6 +3447,8 @@ void M_Ticker(void)
|
||||||
}
|
}
|
||||||
I_unlock_mutex(ms_ServerList_mutex);
|
I_unlock_mutex(ms_ServerList_mutex);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
CL_TimeoutServerList();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in a new issue