mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2025-01-13 13:21:31 +00:00
Merge branch 'server-browser-improvements' into 'next'
Server browser technical and aesthetic improvements See merge request KartKrew/Kart-Public!313
This commit is contained in:
commit
c4ecddb9f3
3 changed files with 171 additions and 82 deletions
|
@ -1959,6 +1959,10 @@ static void SendAskInfo(INT32 node)
|
||||||
|
|
||||||
serverelem_t serverlist[MAXSERVERLIST];
|
serverelem_t serverlist[MAXSERVERLIST];
|
||||||
UINT32 serverlistcount = 0;
|
UINT32 serverlistcount = 0;
|
||||||
|
UINT32 serverlistultimatecount = 0;
|
||||||
|
|
||||||
|
static boolean resendserverlistnode[MAXNETNODES];
|
||||||
|
static tic_t serverlistepoch;
|
||||||
|
|
||||||
static void SL_ClearServerList(INT32 connectedserver)
|
static void SL_ClearServerList(INT32 connectedserver)
|
||||||
{
|
{
|
||||||
|
@ -1971,6 +1975,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)
|
||||||
|
@ -1987,6 +1993,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)
|
||||||
|
@ -2044,6 +2052,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
|
||||||
|
@ -2056,19 +2066,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!
|
|
||||||
//
|
serverlistultimatecount = i;
|
||||||
// (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 && 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -502,6 +502,7 @@ typedef struct
|
||||||
|
|
||||||
extern serverelem_t serverlist[MAXSERVERLIST];
|
extern serverelem_t serverlist[MAXSERVERLIST];
|
||||||
extern UINT32 serverlistcount;
|
extern UINT32 serverlistcount;
|
||||||
|
extern UINT32 serverlistultimatecount;
|
||||||
extern INT32 mapchangepending;
|
extern INT32 mapchangepending;
|
||||||
|
|
||||||
// Points inside doomcom
|
// Points inside doomcom
|
||||||
|
@ -594,6 +595,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);
|
||||||
|
|
||||||
|
|
192
src/m_menu.c
192
src/m_menu.c
|
@ -157,6 +157,8 @@ UINT8 maplistoption = 0;
|
||||||
static char joystickInfo[8][29];
|
static char joystickInfo[8][29];
|
||||||
#ifndef NONET
|
#ifndef NONET
|
||||||
static UINT32 serverlistpage;
|
static UINT32 serverlistpage;
|
||||||
|
static UINT32 oldserverlistpage;
|
||||||
|
static float serverlistslidex;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//static saveinfo_t savegameinfo[MAXSAVEGAMES]; // Extra info about the save games.
|
//static saveinfo_t savegameinfo[MAXSAVEGAMES]; // Extra info about the save games.
|
||||||
|
@ -3479,6 +3481,8 @@ void M_Ticker(void)
|
||||||
}
|
}
|
||||||
I_unlock_mutex(ms_ServerList_mutex);
|
I_unlock_mutex(ms_ServerList_mutex);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
CL_TimeoutServerList();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -8569,12 +8573,18 @@ static void M_HandleServerPage(INT32 choice)
|
||||||
case KEY_RIGHTARROW:
|
case KEY_RIGHTARROW:
|
||||||
S_StartSound(NULL, sfx_menu1);
|
S_StartSound(NULL, sfx_menu1);
|
||||||
if ((serverlistpage + 1) * SERVERS_PER_PAGE < serverlistcount)
|
if ((serverlistpage + 1) * SERVERS_PER_PAGE < serverlistcount)
|
||||||
serverlistpage++;
|
{
|
||||||
|
oldserverlistpage = serverlistpage++;
|
||||||
|
serverlistslidex = BASEVIDWIDTH;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case KEY_LEFTARROW:
|
case KEY_LEFTARROW:
|
||||||
S_StartSound(NULL, sfx_menu1);
|
S_StartSound(NULL, sfx_menu1);
|
||||||
if (serverlistpage > 0)
|
if (serverlistpage > 0)
|
||||||
serverlistpage--;
|
{
|
||||||
|
oldserverlistpage = serverlistpage--;
|
||||||
|
serverlistslidex = -(BASEVIDWIDTH);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -8601,37 +8611,112 @@ static void M_Refresh(INT32 choice)
|
||||||
{
|
{
|
||||||
(void)choice;
|
(void)choice;
|
||||||
|
|
||||||
// Display a little "please wait" message.
|
|
||||||
M_DrawTextBox(52, BASEVIDHEIGHT/2-10, 25, 3);
|
|
||||||
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2, 0, "Searching for servers...");
|
|
||||||
V_DrawCenteredString(BASEVIDWIDTH/2, (BASEVIDHEIGHT/2)+12, 0, "Please wait.");
|
|
||||||
I_OsPolling();
|
|
||||||
I_UpdateNoBlit();
|
|
||||||
if (rendermode == render_soft)
|
|
||||||
I_FinishUpdate(); // page flip or blit buffer
|
|
||||||
|
|
||||||
// first page of servers
|
// first page of servers
|
||||||
serverlistpage = 0;
|
serverlistpage = 0;
|
||||||
|
|
||||||
|
CL_UpdateServerList();
|
||||||
|
|
||||||
#ifdef MASTERSERVER
|
#ifdef MASTERSERVER
|
||||||
#ifdef HAVE_THREADS
|
#ifdef HAVE_THREADS
|
||||||
Spawn_masterserver_thread("fetch-servers", Fetch_servers_thread);
|
Spawn_masterserver_thread("fetch-servers", Fetch_servers_thread);
|
||||||
#else/*HAVE_THREADS*/
|
#else/*HAVE_THREADS*/
|
||||||
Fetch_servers_thread(NULL);
|
Fetch_servers_thread(NULL);
|
||||||
#endif/*HAVE_THREADS*/
|
#endif/*HAVE_THREADS*/
|
||||||
#else/*MASTERSERVER*/
|
|
||||||
CL_UpdateServerList();
|
|
||||||
#endif/*MASTERSERVER*/
|
#endif/*MASTERSERVER*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void M_DrawServerCountAndHorizontalBar(void)
|
||||||
|
{
|
||||||
|
const char *text;
|
||||||
|
INT32 radius;
|
||||||
|
INT32 center = BASEVIDWIDTH/2;
|
||||||
|
|
||||||
|
switch (M_GetWaitingMode())
|
||||||
|
{
|
||||||
|
case M_WAITING_VERSION:
|
||||||
|
text = "Checking for updates";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case M_WAITING_SERVERS:
|
||||||
|
text = "Loading server list";
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
if (serverlistultimatecount > serverlistcount)
|
||||||
|
{
|
||||||
|
text = va("%d/%d servers found%.*s",
|
||||||
|
serverlistcount,
|
||||||
|
serverlistultimatecount,
|
||||||
|
I_GetTime() / NEWTICRATE % 4, "...");
|
||||||
|
}
|
||||||
|
else if (serverlistcount > 0)
|
||||||
|
{
|
||||||
|
text = va("%d servers found", serverlistcount);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
text = "No servers found";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
radius = V_StringWidth(text, 0) / 2;
|
||||||
|
|
||||||
|
V_DrawCenteredString(center, currentMenu->y+28, 0, text);
|
||||||
|
|
||||||
|
// Horizontal line!
|
||||||
|
V_DrawFill(1, currentMenu->y+32, center - radius - 2, 1, 0);
|
||||||
|
V_DrawFill(center + radius + 2, currentMenu->y+32, BASEVIDWIDTH - 1, 1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void M_DrawServerLines(INT32 x, INT32 page)
|
||||||
|
{
|
||||||
|
UINT16 i;
|
||||||
|
const char *gt = "Unknown";
|
||||||
|
const char *spd = "";
|
||||||
|
|
||||||
|
for (i = 0; i < min(serverlistcount - page * SERVERS_PER_PAGE, SERVERS_PER_PAGE); i++)
|
||||||
|
{
|
||||||
|
INT32 slindex = i + page * SERVERS_PER_PAGE;
|
||||||
|
UINT32 globalflags = ((serverlist[slindex].info.numberofplayer >= serverlist[slindex].info.maxplayer) ? V_TRANSLUCENT : 0)
|
||||||
|
|((itemOn == FIRSTSERVERLINE+i) ? highlightflags : 0)|V_ALLOWLOWERCASE;
|
||||||
|
|
||||||
|
V_DrawString(x, S_LINEY(i), globalflags, serverlist[slindex].info.servername);
|
||||||
|
|
||||||
|
// Don't use color flags intentionally, the global yellow color will auto override the text color code
|
||||||
|
if (serverlist[slindex].info.modifiedgame)
|
||||||
|
V_DrawSmallString(x+202, S_LINEY(i)+8, globalflags, "\x85" "Mod");
|
||||||
|
if (serverlist[slindex].info.cheatsenabled)
|
||||||
|
V_DrawSmallString(x+222, S_LINEY(i)+8, globalflags, "\x83" "Cheats");
|
||||||
|
|
||||||
|
V_DrawSmallString(x, S_LINEY(i)+8, globalflags,
|
||||||
|
va("Ping: %u", (UINT32)LONG(serverlist[slindex].info.time)));
|
||||||
|
|
||||||
|
gt = "Unknown";
|
||||||
|
if (serverlist[slindex].info.gametype < NUMGAMETYPES)
|
||||||
|
gt = Gametype_Names[serverlist[slindex].info.gametype];
|
||||||
|
|
||||||
|
V_DrawSmallString(x+46,S_LINEY(i)+8, globalflags,
|
||||||
|
va("Players: %02d/%02d", serverlist[slindex].info.numberofplayer, serverlist[slindex].info.maxplayer));
|
||||||
|
|
||||||
|
V_DrawSmallString(x+112, S_LINEY(i)+8, globalflags, gt);
|
||||||
|
|
||||||
|
// display game speed for race gametypes
|
||||||
|
if (serverlist[slindex].info.gametype == GT_RACE)
|
||||||
|
{
|
||||||
|
spd = kartspeed_cons_t[serverlist[slindex].info.kartvars & SV_SPEEDMASK].strvalue;
|
||||||
|
|
||||||
|
V_DrawSmallString(x+132, S_LINEY(i)+8, globalflags, va("(%s Speed)", spd));
|
||||||
|
}
|
||||||
|
|
||||||
|
MP_ConnectMenu[i+FIRSTSERVERLINE].status = IT_STRING | IT_CALL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void M_DrawConnectMenu(void)
|
static void M_DrawConnectMenu(void)
|
||||||
{
|
{
|
||||||
UINT16 i;
|
UINT16 i;
|
||||||
const char *gt = "Unknown";
|
|
||||||
const char *spd = "";
|
|
||||||
INT32 numPages = (serverlistcount+(SERVERS_PER_PAGE-1))/SERVERS_PER_PAGE;
|
INT32 numPages = (serverlistcount+(SERVERS_PER_PAGE-1))/SERVERS_PER_PAGE;
|
||||||
int waiting;
|
INT32 mservflags = V_ALLOWLOWERCASE;
|
||||||
int mservflags = V_ALLOWLOWERCASE;
|
|
||||||
|
|
||||||
for (i = FIRSTSERVERLINE; i < min(localservercount, SERVERS_PER_PAGE)+FIRSTSERVERLINE; i++)
|
for (i = FIRSTSERVERLINE; i < min(localservercount, SERVERS_PER_PAGE)+FIRSTSERVERLINE; i++)
|
||||||
MP_ConnectMenu[i].status = IT_STRING | IT_SPACE;
|
MP_ConnectMenu[i].status = IT_STRING | IT_SPACE;
|
||||||
|
@ -8648,72 +8733,38 @@ static void M_DrawConnectMenu(void)
|
||||||
mservflags = mservflags|highlightflags|V_30TRANS;
|
mservflags = mservflags|highlightflags|V_30TRANS;
|
||||||
else
|
else
|
||||||
mservflags = mservflags|warningflags;
|
mservflags = mservflags|warningflags;
|
||||||
V_DrawRightAlignedSmallString(BASEVIDWIDTH - currentMenu->x, currentMenu->y+14 + MP_ConnectMenu[mp_connect_page].alphaKey,
|
V_DrawRightAlignedSmallString(BASEVIDWIDTH - currentMenu->x, currentMenu->y+3 + MP_ConnectMenu[mp_connect_refresh].alphaKey,
|
||||||
mservflags, va("MS: %s", cv_masterserver.string));
|
mservflags, va("MS: %s", cv_masterserver.string));
|
||||||
|
|
||||||
// Horizontal line!
|
M_DrawServerCountAndHorizontalBar();
|
||||||
V_DrawFill(1, currentMenu->y+32, 318, 1, 0);
|
|
||||||
|
|
||||||
if (serverlistcount <= 0)
|
// When switching pages, slide the old page and the
|
||||||
V_DrawString(currentMenu->x,currentMenu->y+SERVERHEADERHEIGHT, 0, "No servers found");
|
// new page across the screen
|
||||||
else
|
if (oldserverlistpage != serverlistpage)
|
||||||
for (i = 0; i < min(serverlistcount - serverlistpage * SERVERS_PER_PAGE, SERVERS_PER_PAGE); i++)
|
|
||||||
{
|
{
|
||||||
INT32 slindex = i + serverlistpage * SERVERS_PER_PAGE;
|
const float ease = serverlistslidex / 2.f;
|
||||||
UINT32 globalflags = ((serverlist[slindex].info.numberofplayer >= serverlist[slindex].info.maxplayer) ? V_TRANSLUCENT : 0)
|
const INT32 offx = serverlistslidex > 0 ? BASEVIDWIDTH : -(BASEVIDWIDTH);
|
||||||
|((itemOn == FIRSTSERVERLINE+i) ? highlightflags : 0)|V_ALLOWLOWERCASE;
|
const INT32 x = (FLOAT_TO_FIXED(serverlistslidex) + ease * rendertimefrac) / FRACUNIT;
|
||||||
|
|
||||||
V_DrawString(currentMenu->x, S_LINEY(i), globalflags, serverlist[slindex].info.servername);
|
M_DrawServerLines(currentMenu->x + x - offx, oldserverlistpage);
|
||||||
|
M_DrawServerLines(currentMenu->x + x, serverlistpage);
|
||||||
|
|
||||||
// Don't use color flags intentionally, the global yellow color will auto override the text color code
|
if (interpTimerHackAllow)
|
||||||
if (serverlist[slindex].info.modifiedgame)
|
|
||||||
V_DrawSmallString(currentMenu->x+202, S_LINEY(i)+8, globalflags, "\x85" "Mod");
|
|
||||||
if (serverlist[slindex].info.cheatsenabled)
|
|
||||||
V_DrawSmallString(currentMenu->x+222, S_LINEY(i)+8, globalflags, "\x83" "Cheats");
|
|
||||||
|
|
||||||
V_DrawSmallString(currentMenu->x, S_LINEY(i)+8, globalflags,
|
|
||||||
va("Ping: %u", (UINT32)LONG(serverlist[slindex].info.time)));
|
|
||||||
|
|
||||||
gt = "Unknown";
|
|
||||||
if (serverlist[slindex].info.gametype < NUMGAMETYPES)
|
|
||||||
gt = Gametype_Names[serverlist[slindex].info.gametype];
|
|
||||||
|
|
||||||
V_DrawSmallString(currentMenu->x+46,S_LINEY(i)+8, globalflags,
|
|
||||||
va("Players: %02d/%02d", serverlist[slindex].info.numberofplayer, serverlist[slindex].info.maxplayer));
|
|
||||||
|
|
||||||
V_DrawSmallString(currentMenu->x+112, S_LINEY(i)+8, globalflags, gt);
|
|
||||||
|
|
||||||
// display game speed for race gametypes
|
|
||||||
if (serverlist[slindex].info.gametype == GT_RACE)
|
|
||||||
{
|
{
|
||||||
spd = kartspeed_cons_t[serverlist[slindex].info.kartvars & SV_SPEEDMASK].strvalue;
|
serverlistslidex -= ease;
|
||||||
|
|
||||||
V_DrawSmallString(currentMenu->x+132, S_LINEY(i)+8, globalflags, va("(%s Speed)", spd));
|
if ((INT32)serverlistslidex == 0)
|
||||||
|
oldserverlistpage = serverlistpage;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
MP_ConnectMenu[i+FIRSTSERVERLINE].status = IT_STRING | IT_CALL;
|
else
|
||||||
|
{
|
||||||
|
M_DrawServerLines(currentMenu->x, serverlistpage);
|
||||||
}
|
}
|
||||||
|
|
||||||
localservercount = serverlistcount;
|
localservercount = serverlistcount;
|
||||||
|
|
||||||
M_DrawGenericMenu();
|
M_DrawGenericMenu();
|
||||||
|
|
||||||
waiting = M_GetWaitingMode();
|
|
||||||
|
|
||||||
if (waiting)
|
|
||||||
{
|
|
||||||
const char *message;
|
|
||||||
|
|
||||||
if (waiting == M_WAITING_VERSION)
|
|
||||||
message = "Checking for updates...";
|
|
||||||
else
|
|
||||||
message = "Searching for servers...";
|
|
||||||
|
|
||||||
// Display a little "please wait" message.
|
|
||||||
M_DrawTextBox(52, BASEVIDHEIGHT/2-10, 25, 3);
|
|
||||||
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2, 0, message);
|
|
||||||
V_DrawCenteredString(BASEVIDWIDTH/2, (BASEVIDHEIGHT/2)+12, 0, "Please wait.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean M_CancelConnect(void)
|
static boolean M_CancelConnect(void)
|
||||||
|
@ -8840,6 +8891,9 @@ static void M_ConnectMenu(INT32 choice)
|
||||||
|
|
||||||
// first page of servers
|
// first page of servers
|
||||||
serverlistpage = 0;
|
serverlistpage = 0;
|
||||||
|
|
||||||
|
CL_UpdateServerList();
|
||||||
|
|
||||||
M_SetupNextMenu(&MP_ConnectDef);
|
M_SetupNextMenu(&MP_ConnectDef);
|
||||||
itemOn = 0;
|
itemOn = 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue