Fix some Serverbrowser issues

- Fix serverlist results not being properly reset, which lead to reopening/refreshing the serverlist to show the old state, selecting one of those "old" servers then lead to just connecting to nothing
- Fix the resfresh button making servers disappear if hit too often too fast (from srb2)

https://codeberg.org/srb2classic/srb2classic/commit/3acc312923da0fe5e07c0517d9bff9e8b657b1eb
This commit is contained in:
Alug committed 2025-12-01 21:57:57 +01:00
1 parent cfcd20d44a
commit 1d33a05a85
4 files changed
+31 -64

No files matched your search

+17 -48
View File
@@ -2191,12 +2191,8 @@ static void SendAskInfo(INT32 node)
HSendPacket(node, false, 0, sizeof (askinfo_pak));
}
serverelem_t serverlist[MAXSERVERLIST];
serverelem_t serverlist[MAXSERVERLIST] = {};
UINT32 serverlistcount = 0;
UINT32 serverlistultimatecount = 0;
static boolean resendserverlistnode[MAXNETNODES];
static tic_t serverlistepoch;
static void SL_ClearServerList(INT32 connectedserver)
{
@@ -2209,8 +2205,7 @@ static void SL_ClearServerList(INT32 connectedserver)
serverlist[i].node = 0;
}
serverlistcount = 0;
memset(resendserverlistnode, 0, sizeof resendserverlistnode);
//memset(serverlist, 0, sizeof(serverlist));
}
static UINT32 SL_SearchServer(INT32 node)
@@ -2227,8 +2222,6 @@ static void SL_InsertServer(serverinfo_pak* info, SINT8 node)
{
UINT32 i;
resendserverlistnode[node] = false;
// search if not already on it
i = SL_SearchServer(node);
if (i == UINT32_MAX)
@@ -2262,7 +2255,7 @@ static void SL_InsertServer(serverinfo_pak* info, SINT8 node)
M_SortServerList();
}
void CL_UpdateServerList (void)
void CL_UpdateServerList(void)
{
SL_ClearServerList(0);
@@ -2280,14 +2273,12 @@ void CL_UpdateServerList (void)
SendAskInfo(BROADCASTADDR);
}
void CL_QueryServerList (msg_server_t *server_list)
void CL_QueryServerList(msg_server_t *server_list)
{
INT32 i;
CL_UpdateServerList();
serverlistepoch = I_GetTime();
for (i = 0; server_list[i].header.buffer[0]; i++)
{
// Make sure MS version matches our own, to
@@ -2300,42 +2291,20 @@ void CL_QueryServerList (msg_server_t *server_list)
if (node == -1)
continue; // no more node free, or resolution failure
SendAskInfo(node);
resendserverlistnode[node] = true;
// Leave this node open. It'll be closed if the
// request times out (CL_TimeoutServerList).
}
}
serverlistultimatecount = i;
}
#define SERVERLISTRESENDRATE NEWTICRATE
void CL_TimeoutServerList(void)
{
if (netgame && serverlistultimatecount > serverlistcount)
{
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)
serverlistultimatecount = serverlistcount;
// 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);
}
}
}
-2
View File
@@ -516,7 +516,6 @@ typedef struct
extern serverelem_t serverlist[MAXSERVERLIST];
extern UINT32 serverlistcount;
extern UINT32 serverlistultimatecount;
extern INT32 mapchangepending;
// Points inside doomcom
@@ -627,7 +626,6 @@ void CL_ClearPlayer(INT32 playernum);
void CL_RemovePlayer(INT32 playernum, INT32 reason);
void CL_QueryServerList(msg_server_t *list);
void CL_UpdateServerList(void);
void CL_TimeoutServerList(void);
void CL_AbortConnection(void);
-1
View File
@@ -885,7 +885,6 @@ void D_ClearState(void)
CURLAbortFile();
SV_StopServer();
SV_ResetServer();
serverlistultimatecount = 0;
for (i = 0; i < MAXPLAYERS; i++)
CL_ClearPlayer(i);
+14 -13
View File
@@ -1939,8 +1939,6 @@ void M_Ticker(void)
}
I_unlock_mutex(ms_ServerList_mutex);
#endif
CL_TimeoutServerList();
}
//
@@ -6820,12 +6818,22 @@ static void M_Connect(INT32 choice)
COM_BufAddText(va("connect node %d\n", serverlist[serverlistsearched[choice-FIRSTSERVERLINE + serverlistpage * SERVERS_PER_PAGE]].node));
}
static void M_ResetServerList(void)
{
serverlistpage = 0;
oldserverlistpage = 0;
serverlistslidex = 0.0f;
memset(serverlistsearched, 0, sizeof(serverlistsearched));
serverlistsearchedcount = 0;
}
static void M_Refresh(INT32 choice)
{
(void)choice;
// first page of servers
serverlistpage = 0;
M_ResetServerList();
CL_UpdateServerList();
@@ -6856,14 +6864,7 @@ static void M_DrawServerCountAndHorizontalBar(void)
break;
default:
if (serverlistultimatecount > serverlistcount)
{
text = va("%d/%d servers found%.*s",
serverlistcount,
serverlistultimatecount,
I_GetTime() / NEWTICRATE % 4, "...");
}
else if (serverlistcount > 0)
if (serverlistcount > 0)
{
text = va("%d servers found", serverlistcount);
}
@@ -7047,7 +7048,7 @@ static int ServerListEntryComparator_modified(const void *entry1, const void *en
void M_SortServerList(void)
{
switch(cv_serversort.value)
switch (cv_serversort.value)
{
case 0: // Ping.
qs22j(serverlist, serverlistcount, sizeof(serverelem_t), ServerListEntryComparator_time);
@@ -7122,7 +7123,7 @@ static void M_ConnectMenu(INT32 choice)
// we don't request a restart unless the filelist differs
// first page of servers
serverlistpage = 0;
M_ResetServerList();
CL_UpdateServerList();