1
0
Fork 0
forked from fte/fteqw

Don't resolve master servers at startup. This stops huge stalls when you don't have complete internet access (lan games/single player).

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@3123 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2009-02-08 19:05:28 +00:00
parent 32591b4df6
commit 3b402813d8

View file

@ -53,24 +53,30 @@ void SV_PortIPv6_Callback(struct cvar_s *var, char *oldvalue);
void SV_PortIPX_Callback(struct cvar_s *var, char *oldvalue); void SV_PortIPX_Callback(struct cvar_s *var, char *oldvalue);
typedef struct { typedef struct {
int isdp; enum {
MP_NONE,
MP_QUAKEWORLD,
MP_DARKPLACES,
} protocol;
cvar_t cv; cvar_t cv;
qboolean needsresolve; //set any time the cvar is modified
netadr_t adr; netadr_t adr;
} sv_masterlist_t; } sv_masterlist_t;
sv_masterlist_t sv_masterlist[] = { sv_masterlist_t sv_masterlist[] = {
{false, SCVARC("sv_master1", "", SV_Masterlist_Callback)}, {MP_QUAKEWORLD, SCVARC("sv_master1", "", SV_Masterlist_Callback)},
{false, SCVARC("sv_master2", "", SV_Masterlist_Callback)}, {MP_QUAKEWORLD, SCVARC("sv_master2", "", SV_Masterlist_Callback)},
{false, SCVARC("sv_master3", "", SV_Masterlist_Callback)}, {MP_QUAKEWORLD, SCVARC("sv_master3", "", SV_Masterlist_Callback)},
{false, SCVARC("sv_master4", "", SV_Masterlist_Callback)}, {MP_QUAKEWORLD, SCVARC("sv_master4", "", SV_Masterlist_Callback)},
{false, SCVARC("sv_master5", "", SV_Masterlist_Callback)}, {MP_QUAKEWORLD, SCVARC("sv_master5", "", SV_Masterlist_Callback)},
{false, SCVARC("sv_master6", "", SV_Masterlist_Callback)}, {MP_QUAKEWORLD, SCVARC("sv_master6", "", SV_Masterlist_Callback)},
{false, SCVARC("sv_master7", "", SV_Masterlist_Callback)}, {MP_QUAKEWORLD, SCVARC("sv_master7", "", SV_Masterlist_Callback)},
{false, SCVARC("sv_master8", "", SV_Masterlist_Callback)}, {MP_QUAKEWORLD, SCVARC("sv_master8", "", SV_Masterlist_Callback)},
{true, SCVARC("sv_masterextra1", "ghdigital.com", SV_Masterlist_Callback)}, //69.59.212.88 (admin: LordHavoc) {MP_DARKPLACES, SCVARC("sv_masterextra1", "ghdigital.com", SV_Masterlist_Callback)}, //69.59.212.88 (admin: LordHavoc)
{true, SCVARC("sv_masterextra2", "dpmaster.deathmask.net", SV_Masterlist_Callback)}, //209.164.24.243 (admin: Willis) {MP_DARKPLACES, SCVARC("sv_masterextra2", "dpmaster.deathmask.net", SV_Masterlist_Callback)}, //209.164.24.243 (admin: Willis)
{true, SCVARC("sv_masterextra3", "dpmaster.tchr.no", SV_Masterlist_Callback)}, // (admin: tChr) {MP_DARKPLACES, SCVARC("sv_masterextra3", "dpmaster.tchr.no", SV_Masterlist_Callback)}, // (admin: tChr)
{false, SCVAR(NULL, NULL)} {MP_NONE, SCVAR(NULL, NULL)}
}; };
client_t *host_client; // current client client_t *host_client; // current client
@ -3594,7 +3600,6 @@ void SV_InitLocal (void)
void SV_Masterlist_Callback(struct cvar_s *var, char *oldvalue) void SV_Masterlist_Callback(struct cvar_s *var, char *oldvalue)
{ {
int i; int i;
char data[2];
for (i = 0; sv_masterlist[i].cv.name; i++) for (i = 0; sv_masterlist[i].cv.name; i++)
{ {
@ -3611,29 +3616,7 @@ void SV_Masterlist_Callback(struct cvar_s *var, char *oldvalue)
return; return;
} }
if (!NET_StringToAdr(var->string, &sv_masterlist[i].adr)) sv_masterlist[i].needsresolve = true;
{
sv_masterlist[i].adr.port = 0;
Con_Printf ("Couldn't resolve master \"%s\"\n", var->string);
}
else
{
if (sv_masterlist[i].isdp)
{
if (sv_masterlist[i].adr.port == 0)
sv_masterlist[i].adr.port = BigShort (27950);
}
else
{
if (sv_masterlist[i].adr.port == 0)
sv_masterlist[i].adr.port = BigShort (27000);
data[0] = A2A_PING;
data[1] = 0;
if (sv.state)
NET_SendPacket (NS_SERVER, 2, data, sv_masterlist[i].adr);
}
}
} }
/* /*
@ -3656,21 +3639,57 @@ void Master_Heartbeat (void)
if (!sv_public.value) if (!sv_public.value)
return; return;
if (realtime - svs.last_heartbeat < HEARTBEAT_SECONDS) if (realtime-HEARTBEAT_SECONDS - svs.last_heartbeat < HEARTBEAT_SECONDS)
return; // not time to send yet return; // not time to send yet
svs.last_heartbeat = realtime; svs.last_heartbeat = realtime-HEARTBEAT_SECONDS;
svs.heartbeat_sequence++; svs.heartbeat_sequence++;
// send to group master // send to group master
for (i = 0; sv_masterlist[i].cv.name; i++) for (i = 0; sv_masterlist[i].cv.name; i++)
{ {
if (sv_masterlist[i].needsresolve)
{
if (!*sv_masterlist[i].cv.string)
sv_masterlist[i].adr.port = 0;
else if (!NET_StringToAdr(sv_masterlist[i].cv.string, &sv_masterlist[i].adr))
{
sv_masterlist[i].adr.port = 0;
Con_Printf ("Couldn't resolve master \"%s\"\n", sv_masterlist[i].cv.string);
}
else
{
//choose default port
switch (sv_masterlist[i].protocol)
{
case MP_DARKPLACES:
if (sv_masterlist[i].adr.port == 0)
sv_masterlist[i].adr.port = BigShort (27950);
break;
case MP_QUAKEWORLD:
if (sv_masterlist[i].adr.port == 0)
sv_masterlist[i].adr.port = BigShort (27000);
//qw does this for some reason, keep the behaviour even though its unreliable thus pointless
string[0] = A2A_PING;
string[1] = 0;
if (sv.state)
NET_SendPacket (NS_SERVER, 2, string, sv_masterlist[i].adr);
break;
default:
break;
}
}
}
if (sv_masterlist[i].adr.port) if (sv_masterlist[i].adr.port)
{ {
switch(sv_masterlist[i].isdp) switch(sv_masterlist[i].protocol)
{
case MP_QUAKEWORLD:
if (sv_listen_qw.value)
{ {
case false:
if (!madeqwstring) if (!madeqwstring)
{ {
// count active users // count active users
@ -3690,8 +3709,9 @@ void Master_Heartbeat (void)
Con_Printf ("Sending heartbeat to %s\n", NET_AdrToString (adr, sizeof(adr), sv_masterlist[i].adr)); Con_Printf ("Sending heartbeat to %s\n", NET_AdrToString (adr, sizeof(adr), sv_masterlist[i].adr));
NET_SendPacket (NS_SERVER, strlen(string), string, sv_masterlist[i].adr); NET_SendPacket (NS_SERVER, strlen(string), string, sv_masterlist[i].adr);
}
break; break;
case true: case MP_DARKPLACES:
if (sv_listen_dp.value) //set listen to 1 to allow qw connections, 2 to allow nq connections too. if (sv_listen_dp.value) //set listen to 1 to allow qw connections, 2 to allow nq connections too.
{ {
if (sv_reportheartbeats.value) if (sv_reportheartbeats.value)
@ -3703,6 +3723,8 @@ void Master_Heartbeat (void)
} }
} }
break; break;
default:
break;
} }
} }
} }
@ -3755,21 +3777,24 @@ void Master_Shutdown (void)
// send to group master // send to group master
for (i = 0; sv_masterlist[i].cv.name; i++) for (i = 0; sv_masterlist[i].cv.name; i++)
{
if (sv_masterlist[i].adr.port) if (sv_masterlist[i].adr.port)
{ {
switch(sv_masterlist[i].isdp) switch(sv_masterlist[i].protocol)
{ {
case false: case MP_QUAKEWORLD:
if (sv_reportheartbeats.value) if (sv_reportheartbeats.value)
Con_Printf ("Sending heartbeat to %s\n", NET_AdrToString (adr, sizeof(adr), sv_masterlist[i].adr)); Con_Printf ("Sending heartbeat to %s\n", NET_AdrToString (adr, sizeof(adr), sv_masterlist[i].adr));
NET_SendPacket (NS_SERVER, strlen(string), string, sv_masterlist[i].adr); NET_SendPacket (NS_SERVER, strlen(string), string, sv_masterlist[i].adr);
break; break;
case true: //dp has no shutdown
default:
break; break;
} }
} }
} }
}
#define iswhite(c) (c == ' ' || c == INVIS_CHAR1 || c == INVIS_CHAR2 || c == INVIS_CHAR3) #define iswhite(c) (c == ' ' || c == INVIS_CHAR1 || c == INVIS_CHAR2 || c == INVIS_CHAR3)
#define isinvalid(c) (c == '\r' || c == '\n') #define isinvalid(c) (c == '\r' || c == '\n')