/* LAN CONFIG MENU */
int lanConfig_cursor = -1;
-int lanConfig_cursor_table [] = {56, 76, 112};
-#define NUM_LANCONFIG_CMDS 3
+int lanConfig_cursor_table [] = {56, 76, 84, 120};
+#define NUM_LANCONFIG_CMDS 4
int lanConfig_port;
char lanConfig_portname[6];
if (JoiningGame)
{
- M_Print(basex, lanConfig_cursor_table[1], "Search for games...");
- M_Print(basex, lanConfig_cursor_table[2]-16, "Join game at:");
- M_DrawTextBox (basex+8, lanConfig_cursor_table[2]-8, 22, 1);
- M_Print(basex+16, lanConfig_cursor_table[2], lanConfig_joinname);
+ M_Print(basex, lanConfig_cursor_table[1], "Search for DarkPlaces games...");
+ M_Print(basex, lanConfig_cursor_table[2], "Search for QuakeWorld games...");
+ M_Print(basex, lanConfig_cursor_table[3]-16, "Join game at:");
+ M_DrawTextBox (basex+8, lanConfig_cursor_table[3]-8, 22, 1);
+ M_Print(basex+16, lanConfig_cursor_table[3], lanConfig_joinname);
}
else
{
M_DrawCharacter (basex-8, lanConfig_cursor_table [lanConfig_cursor], 12+((int)(realtime*4)&1));
if (lanConfig_cursor == 0)
- M_DrawCharacter (basex+9*8 + 8*strlen(lanConfig_portname), lanConfig_cursor_table [0], 10+((int)(realtime*4)&1));
+ M_DrawCharacter (basex+9*8 + 8*strlen(lanConfig_portname), lanConfig_cursor_table [lanConfig_cursor], 10+((int)(realtime*4)&1));
- if (lanConfig_cursor == 2)
- M_DrawCharacter (basex+16 + 8*strlen(lanConfig_joinname), lanConfig_cursor_table [2], 10+((int)(realtime*4)&1));
+ if (lanConfig_cursor == 3)
+ M_DrawCharacter (basex+16 + 8*strlen(lanConfig_joinname), lanConfig_cursor_table [lanConfig_cursor], 10+((int)(realtime*4)&1));
if (*m_return_reason)
M_Print(basex, 168, m_return_reason);
lanConfig_cursor--;
if (lanConfig_cursor < 0)
lanConfig_cursor = NUM_LANCONFIG_CMDS-1;
+ // when in start game menu, skip the unused search qw servers item
+ if (StartingGame && lanConfig_cursor == 2)
+ lanConfig_cursor = 1;
break;
case K_DOWNARROW:
lanConfig_cursor++;
if (lanConfig_cursor >= NUM_LANCONFIG_CMDS)
lanConfig_cursor = 0;
+ // when in start game menu, skip the unused search qw servers item
+ if (StartingGame && lanConfig_cursor == 1)
+ lanConfig_cursor = 2;
break;
case K_ENTER:
Cvar_SetValue("port", lanConfig_port);
- if (lanConfig_cursor == 1)
+ if (lanConfig_cursor == 1 || lanConfig_cursor == 2)
{
if (StartingGame)
{
break;
}
- if (lanConfig_cursor == 2)
+ if (lanConfig_cursor == 3)
Cbuf_AddText ( va ("connect \"%s\"\n", lanConfig_joinname) );
break;
lanConfig_portname[strlen(lanConfig_portname)-1] = 0;
}
- if (lanConfig_cursor == 2)
+ if (lanConfig_cursor == 3)
{
if (strlen(lanConfig_joinname))
lanConfig_joinname[strlen(lanConfig_joinname)-1] = 0;
if (ascii < 32)
break;
- if (lanConfig_cursor == 2)
+ if (lanConfig_cursor == 3)
{
l = (int)strlen(lanConfig_joinname);
if (l < 21)
}
}
- if (StartingGame && lanConfig_cursor == 2)
+ if (StartingGame && lanConfig_cursor == 3)
{
if (key == K_UPARROW)
lanConfig_cursor = 1;
m_entersound = true;
slist_cursor = 0;
M_Update_Return_Reason("");
- Net_Slist_f();
+ if (lanConfig_cursor == 2)
+ Net_SlistQW_f();
+ else
+ Net_Slist_f();
}
M_PrintColored(0, y, serverlist_viewlist[n]->line2);y += 8;
}
}
- else if (realtime - masterquerytime < 3)
+ else if (realtime - masterquerytime > 10)
{
if (masterquerycount)
M_Print(0, y, "No servers found");
else
M_Print(0, y, "No master servers found (network problem?)");
}
+ else
+ {
+ if (serverquerycount)
+ M_Print(0, y, "Querying servers");
+ else
+ M_Print(0, y, "Querying master servers");
+ }
}
break;
case K_SPACE:
- Net_Slist_f();
+ if (lanConfig_cursor == 2)
+ Net_SlistQW_f();
+ else
+ Net_Slist_f();
break;
case K_UPARROW:
int serverreplycount = 0;
// this is only false if there are still servers left to query
-int serverlist_querysleep = true;
+static qboolean serverlist_querysleep = true;
// this is pushed a second or two ahead of realtime whenever a master server
// reply is received, to avoid issuing queries while master replies are still
// flooding in (which would make a mess of the ping times)
-double serverlist_querywaittime = 0;
+static double serverlist_querywaittime = 0;
static unsigned char sendbuffer[NET_HEADERSIZE+NET_MAXMESSAGE];
static unsigned char readbuffer[NET_HEADERSIZE+NET_MAXMESSAGE];
}
#endif
-void ServerList_QueryList(void)
+void ServerList_QueryList(qboolean querydp, qboolean queryqw)
{
//masterquerytime = realtime;
masterquerytime = Sys_DoubleTime();
//_ServerList_Test();
- NetConn_QueryMasters();
+ NetConn_QueryMasters(querydp, queryqw);
}
// rest
}
}
-void NetConn_QueryMasters(void)
+void NetConn_QueryMasters(qboolean querydp, qboolean queryqw)
{
int i;
int masternum;
// note this is IPv4-only, I doubt there are IPv6-only LANs out there
LHNETADDRESS_FromString(&broadcastaddress, "255.255.255.255", 26000);
- for (i = 0;i < cl_numsockets;i++)
+ if (querydp)
{
- if (cl_sockets[i])
+ for (i = 0;i < cl_numsockets;i++)
{
- // search LAN for Quake servers
- SZ_Clear(&net_message);
- // save space for the header, filled in later
- MSG_WriteLong(&net_message, 0);
- MSG_WriteByte(&net_message, CCREQ_SERVER_INFO);
- MSG_WriteString(&net_message, "QUAKE");
- MSG_WriteByte(&net_message, NET_PROTOCOL_VERSION);
- *((int *)net_message.data) = BigLong(NETFLAG_CTL | (net_message.cursize & NETFLAG_LENGTH_MASK));
- NetConn_Write(cl_sockets[i], net_message.data, net_message.cursize, &broadcastaddress);
- SZ_Clear(&net_message);
-
- // search LAN for DarkPlaces servers
- NetConn_WriteString(cl_sockets[i], "\377\377\377\377getinfo", &broadcastaddress);
-
- // build the getservers message to send to the dpmaster master servers
- dpsnprintf(request, sizeof(request), "\377\377\377\377getservers %s %u empty full\x0A", gamename, NET_PROTOCOL_VERSION);
-
- // search internet
- for (masternum = 0;sv_masters[masternum].name;masternum++)
+ if (cl_sockets[i])
{
- if (sv_masters[masternum].string && LHNETADDRESS_FromString(&masteraddress, sv_masters[masternum].string, DPMASTER_PORT) && LHNETADDRESS_GetAddressType(&masteraddress) == LHNETADDRESS_GetAddressType(LHNET_AddressFromSocket(cl_sockets[i])))
+ // search LAN for Quake servers
+ SZ_Clear(&net_message);
+ // save space for the header, filled in later
+ MSG_WriteLong(&net_message, 0);
+ MSG_WriteByte(&net_message, CCREQ_SERVER_INFO);
+ MSG_WriteString(&net_message, "QUAKE");
+ MSG_WriteByte(&net_message, NET_PROTOCOL_VERSION);
+ *((int *)net_message.data) = BigLong(NETFLAG_CTL | (net_message.cursize & NETFLAG_LENGTH_MASK));
+ NetConn_Write(cl_sockets[i], net_message.data, net_message.cursize, &broadcastaddress);
+ SZ_Clear(&net_message);
+
+ // search LAN for DarkPlaces servers
+ NetConn_WriteString(cl_sockets[i], "\377\377\377\377getinfo", &broadcastaddress);
+
+ // build the getservers message to send to the dpmaster master servers
+ dpsnprintf(request, sizeof(request), "\377\377\377\377getservers %s %u empty full\x0A", gamename, NET_PROTOCOL_VERSION);
+
+ // search internet
+ for (masternum = 0;sv_masters[masternum].name;masternum++)
{
- masterquerycount++;
- NetConn_WriteString(cl_sockets[i], request, &masteraddress);
+ if (sv_masters[masternum].string && LHNETADDRESS_FromString(&masteraddress, sv_masters[masternum].string, DPMASTER_PORT) && LHNETADDRESS_GetAddressType(&masteraddress) == LHNETADDRESS_GetAddressType(LHNET_AddressFromSocket(cl_sockets[i])))
+ {
+ masterquerycount++;
+ NetConn_WriteString(cl_sockets[i], request, &masteraddress);
+ }
}
}
+ }
+ }
- // only query QuakeWorld servers when in GAME_NORMAL mode as that
- // is all QuakeWorld is designed for, we don't want QuakeWorld
- // servers showing up when running another game (not even the
- // mission packs, as if a QuakeWorld server was using their data
- // you could still play with -game hipnotic rather than -hipnotic)
- if (gamemode == GAME_NORMAL)
+ // only query QuakeWorld servers when the user wants to
+ if (queryqw)
+ {
+ for (i = 0;i < cl_numsockets;i++)
+ {
+ if (cl_sockets[i])
{
// build the getservers message to send to the qwmaster master servers
// note this has no -1 prefix, and the trailing nul byte is sent
serverlist_sortdescending = false;
if (m_state != m_slist) {
Con_Print("Sending requests to master servers\n");
- ServerList_QueryList();
+ ServerList_QueryList(true, false);
+ serverlist_consoleoutput = true;
+ Con_Print("Listening for replies...\n");
+ } else
+ ServerList_QueryList(true, false);
+}
+
+void Net_SlistQW_f(void)
+{
+ ServerList_ResetMasks();
+ serverlist_sortbyfield = SLIF_PING;
+ serverlist_sortdescending = false;
+ if (m_state != m_slist) {
+ Con_Print("Sending requests to master servers\n");
+ ServerList_QueryList(false, true);
serverlist_consoleoutput = true;
Con_Print("Listening for replies...\n");
} else
- ServerList_QueryList();
+ ServerList_QueryList(false, true);
}
void NetConn_Init(void)
lhnetaddress_t tempaddress;
netconn_mempool = Mem_AllocPool("network connections", 0, NULL);
Cmd_AddCommand("net_stats", Net_Stats_f, "print network statistics");
- Cmd_AddCommand("net_slist", Net_Slist_f, "query master series and print all server information");
+ Cmd_AddCommand("net_slist", Net_Slist_f, "query dp master servers and print all server information");
+ Cmd_AddCommand("net_slistqw", Net_SlistQW_f, "query qw master servers and print all server information");
Cmd_AddCommand("heartbeat", Net_Heartbeat_f, "send a heartbeat to the master server (updates your server information)");
Cvar_RegisterVariable(&net_slist_queriespersecond);
Cvar_RegisterVariable(&net_slist_queriesperframe);