mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 09:11:48 +00:00
Actually report server version mismatches
Incompatible servers get dropped from the server list. It turns out the server list is also used when connecting directly to a server. This meant that if you tried connecting to a server that was incompatible, you'd just get an infinite connection screen, as if the server was completely unreachable. Now it won't drop the server if you are directly connecting to it. I also copied some incompatibility messages from HandleConnect.
This commit is contained in:
parent
a98b0834a6
commit
0edbca5e02
1 changed files with 88 additions and 25 deletions
|
@ -1667,6 +1667,9 @@ static void SL_InsertServer(serverinfo_pak* info, SINT8 node)
|
|||
if (serverlistcount >= MAXSERVERLIST)
|
||||
return; // list full
|
||||
|
||||
/* check it later if connecting to this one */
|
||||
if (node != servernode)
|
||||
{
|
||||
if (info->_255 != 255)
|
||||
return;/* old packet format */
|
||||
|
||||
|
@ -1681,6 +1684,7 @@ static void SL_InsertServer(serverinfo_pak* info, SINT8 node)
|
|||
|
||||
if (strcmp(info->application, SRB2APPLICATION))
|
||||
return;/* that's a different mod */
|
||||
}
|
||||
|
||||
i = serverlistcount++;
|
||||
}
|
||||
|
@ -1829,6 +1833,65 @@ void CL_UpdateServerList(boolean internetsearch, INT32 room)
|
|||
|
||||
#endif // ifndef NONET
|
||||
|
||||
static const char * InvalidServerReason (INT32 i)
|
||||
{
|
||||
#define EOT "\nPress ESC\n"
|
||||
|
||||
serverinfo_pak *info = &serverlist[i].info;
|
||||
|
||||
/* magic number for new packet format */
|
||||
if (info->_255 != 255)
|
||||
{
|
||||
return
|
||||
"Outdated server (version unknown).\n" EOT;
|
||||
}
|
||||
|
||||
if (strncmp(info->application, SRB2APPLICATION, sizeof
|
||||
info->application))
|
||||
{
|
||||
return va(
|
||||
"%s cannot connect\n"
|
||||
"to %s servers.\n" EOT,
|
||||
SRB2APPLICATION,
|
||||
info->application);
|
||||
}
|
||||
|
||||
if (
|
||||
info->packetversion != PACKETVERSION ||
|
||||
info->version != VERSION ||
|
||||
info->subversion != SUBVERSION
|
||||
){
|
||||
return va(
|
||||
"Incompatible %s versions.\n"
|
||||
"(server version %d.%d.%d)\n" EOT,
|
||||
SRB2APPLICATION,
|
||||
info->version / 100,
|
||||
info->version % 100,
|
||||
info->subversion);
|
||||
}
|
||||
|
||||
if (info->refusereason)
|
||||
{
|
||||
if (serverlist[i].info.refusereason == 1)
|
||||
return
|
||||
"The server is not accepting\n"
|
||||
"joins for the moment.\n" EOT;
|
||||
else if (serverlist[i].info.refusereason == 2)
|
||||
return va(
|
||||
"Maximum players reached: %d\n" EOT,
|
||||
info->maxplayer);
|
||||
else
|
||||
return
|
||||
"You can't join.\n"
|
||||
"I don't know why,\n"
|
||||
"but you can't join.\n" EOT;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
#undef EOT
|
||||
}
|
||||
|
||||
/** Called by CL_ServerConnectionTicker
|
||||
*
|
||||
* \param asksent The last time we asked the server to join. We re-ask every second in case our request got lost in transmit.
|
||||
|
@ -1859,23 +1922,23 @@ static boolean CL_ServerConnectionSearchTicker(tic_t *asksent)
|
|||
return true;
|
||||
}
|
||||
|
||||
// Quit here rather than downloading files and being refused later.
|
||||
if (serverlist[i].info.refusereason)
|
||||
if (client)
|
||||
{
|
||||
const char *reason = InvalidServerReason(i);
|
||||
|
||||
// Quit here rather than downloading files
|
||||
// and being refused later.
|
||||
if (reason)
|
||||
{
|
||||
char *message = Z_StrDup(reason);
|
||||
D_QuitNetGame();
|
||||
CL_Reset();
|
||||
D_StartTitle();
|
||||
if (serverlist[i].info.refusereason == 1)
|
||||
M_StartMessage(M_GetText("The server is not accepting\njoins for the moment.\n\nPress ESC\n"), NULL, MM_NOTHING);
|
||||
else if (serverlist[i].info.refusereason == 2)
|
||||
M_StartMessage(va(M_GetText("Maximum players reached: %d\n\nPress ESC\n"), serverlist[i].info.maxplayer), NULL, MM_NOTHING);
|
||||
else
|
||||
M_StartMessage(M_GetText("You can't join.\nI don't know why,\nbut you can't join.\n\nPress ESC\n"), NULL, MM_NOTHING);
|
||||
M_StartMessage(message, NULL, MM_NOTHING);
|
||||
Z_Free(message);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (client)
|
||||
{
|
||||
D_ParseFileneeded(serverlist[i].info.fileneedednum,
|
||||
serverlist[i].info.fileneeded);
|
||||
CONS_Printf(M_GetText("Checking files...\n"));
|
||||
|
|
Loading…
Reference in a new issue