From 797f9d180e6ca8b2671166407ae62bca12c36205 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 19 Nov 2018 17:46:38 +0000 Subject: [PATCH 1/3] Make sure GetMODVersion and its console equiv properly detect failing to get a reply from the MS, also added extra console/menu messages --- src/mserv.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/mserv.c b/src/mserv.c index 2bb2923d..a84266c8 100644 --- a/src/mserv.c +++ b/src/mserv.c @@ -557,9 +557,21 @@ const char *GetMODVersion(void) msg.room = MODID; // Might as well use it for something. sprintf(msg.buffer,"%d",MODVERSION); if (MS_Write(&msg) < 0) + { + CONS_Alert(CONS_ERROR, M_GetText("Could not send to the Master Server\n")); + M_StartMessage(M_GetText("Could not send to the Master Server\n"), NULL, MM_NOTHING); + CloseConnection(); return NULL; + } + + if (MS_Read(&msg) < 0) + { + CONS_Alert(CONS_ERROR, M_GetText("No reply from the Master Server\n")); + M_StartMessage(M_GetText("No reply from the Master Server\n"), NULL, MM_NOTHING); + CloseConnection(); + return NULL; + } - MS_Read(&msg); CloseConnection(); if(strcmp(msg.buffer,"NULL") != 0) @@ -587,9 +599,19 @@ void GetMODVersion_Console(void) msg.room = MODID; // Might as well use it for something. sprintf(msg.buffer,"%d",MODVERSION); if (MS_Write(&msg) < 0) + { + CONS_Alert(CONS_ERROR, M_GetText("Could not send to the Master Server\n")); + CloseConnection(); return; + } + + if (MS_Read(&msg) < 0) + { + CONS_Alert(CONS_ERROR, M_GetText("No reply from the Master Server\n")); + CloseConnection(); + return; + } - MS_Read(&msg); CloseConnection(); if(strcmp(msg.buffer,"NULL") != 0) From 418943acdc2f96cdde2446897690c89b582665ff Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 19 Nov 2018 17:47:23 +0000 Subject: [PATCH 2/3] change return type of M_CheckMODVersion to boolean --- src/m_menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index c9adbfb9..cfcb2458 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6048,7 +6048,7 @@ void M_SortServerList(void) #ifndef NONET #ifdef UPDATE_ALERT -static int M_CheckMODVersion(void) +static boolean M_CheckMODVersion(void) { char updatestring[500]; const char *updatecheck = GetMODVersion(); From 3acc312923da0fe5e07c0517d9bff9e8b657b1eb Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Wed, 21 Nov 2018 20:45:03 +0000 Subject: [PATCH 3/3] Fix servers disappearing from the server list when you refresh, by forcefully closing connnections to the servers immediately after sending ASKINFO. Also force close connections to old server list when refreshing, because we don't need to hear from them anymore full stop. --- src/d_clisrv.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 1007d085..f48920bb 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1623,6 +1623,8 @@ static void SendAskInfo(INT32 node, boolean viams) serverelem_t serverlist[MAXSERVERLIST]; UINT32 serverlistcount = 0; +#define FORCECLOSE 0x8000 + static void SL_ClearServerList(INT32 connectedserver) { UINT32 i; @@ -1630,7 +1632,7 @@ static void SL_ClearServerList(INT32 connectedserver) for (i = 0; i < serverlistcount; i++) if (connectedserver != serverlist[i].node) { - Net_CloseConnection(serverlist[i].node); + Net_CloseConnection(serverlist[i].node|FORCECLOSE); serverlist[i].node = 0; } serverlistcount = 0; @@ -1712,12 +1714,25 @@ void CL_UpdateServerList(boolean internetsearch, INT32 room) // Make sure MS version matches our own, to // thwart nefarious servers who lie to the MS. - if(strcmp(version, server_list[i].version) == 0) + if (strcmp(version, server_list[i].version) == 0) { INT32 node = I_NetMakeNodewPort(server_list[i].ip, server_list[i].port); if (node == -1) break; // no more node free SendAskInfo(node, true); + // Force close the connection so that servers can't eat + // up nodes forever if we never get a reply back from them + // (usually when they've not forwarded their ports). + // + // Don't worry, we'll get in contact with the working + // servers again when they send SERVERINFO to us later! + // + // (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 + // the connections are closed afterwards anyway) + // -- Monster Iestyn 12/11/18 + Net_CloseConnection(node|FORCECLOSE); } } }