From 10abb9d21239ca148743599c748675663dd58ae2 Mon Sep 17 00:00:00 2001 From: TimeServ Date: Sun, 26 Feb 2006 09:37:55 +0000 Subject: [PATCH] fixed issues with http masters in server browser, add http://www.gameaholic.com/servers/qspy-quakeworld to master list git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2031 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/cl_master.h | 3 +- engine/client/net_master.c | 60 +++++++++++++++++++++++++++++++------- 2 files changed, 52 insertions(+), 11 deletions(-) diff --git a/engine/client/cl_master.h b/engine/client/cl_master.h index 4747fb6f8..d991a66be 100644 --- a/engine/client/cl_master.h +++ b/engine/client/cl_master.h @@ -12,7 +12,8 @@ //despite not supporting nq or q2, we still load them. We just filter them. This is to make sure we properly write the listing files. enum { MT_BAD, //this would be an error - MT_MASTERHTTP, //an http/ftp based master server + MT_MASTERHTTP, //an http/ftp based master server with NQ servers + MT_MASTERHTTPQW,//an http/ftp based master server with QW servers MT_BCASTQW, //-1status MT_BCASTQ2, //-1status MT_BCASTQ3, diff --git a/engine/client/net_master.c b/engine/client/net_master.c index cffc47ebe..eeb30014b 100644 --- a/engine/client/net_master.c +++ b/engine/client/net_master.c @@ -523,18 +523,24 @@ void Master_AddMaster (char *address, int type, char *description) master = mast; } -void Master_AddMasterHTTP (char *address, int servertype, char *description) +void Master_AddMasterHTTP (char *address, int mastertype, char *description) { master_t *mast; + int servertype; + + if (mastertype == MT_MASTERHTTPQW) + servertype = 0; + else + servertype = SS_NETQUAKE; for (mast = master; mast; mast = mast->next) { - if (!strcmp(mast->address, address) && mast->type == MT_MASTERHTTP) //already exists. + if (!strcmp(mast->address, address) && mast->type == mastertype) //already exists. return; } mast = Z_Malloc(sizeof(master_t)+strlen(description)+1+strlen(address)+1); mast->address = mast->name + strlen(description)+1; - mast->type = MT_MASTERHTTP; + mast->type = mastertype; mast->servertype = servertype; strcpy(mast->name, description); strcpy(mast->address, address); @@ -606,6 +612,10 @@ qboolean Master_LoadMasterList (char *filename, int defaulttype, int depth) servertype = MT_MASTERQ2; else if (!strcmp(com_token, "master:q3")) servertype = MT_MASTERQ3; + else if (!strcmp(com_token, "master:http")) + servertype = MT_MASTERHTTP; + else if (!strcmp(com_token, "master:httpqw")) + servertype = MT_MASTERHTTPQW; else if (!strcmp(com_token, "master")) //any other sort of master, assume it's a qw master. servertype = MT_MASTERQW; @@ -661,7 +671,18 @@ qboolean Master_LoadMasterList (char *filename, int defaulttype, int depth) Con_Printf("Failed to resolve address - \"%s\"\n", line); } else - Master_AddMaster(line, servertype, name); + { + switch (servertype) + { + case MT_MASTERHTTP: + case MT_MASTERHTTPQW: + Master_AddMasterHTTP(line, servertype, name); + break; + default: + Master_AddMaster(line, servertype, name); + } + + } } VFS_CLOSE(f); @@ -933,7 +954,7 @@ void SListOptionChanged(serverinfo_t *newserver) } #ifdef WEBCLIENT -void MasterInfo_ProcessHTTP(char *name, qboolean success) +void MasterInfo_ProcessHTTP(char *name, qboolean success, int type) { netadr_t adr; char *s; @@ -973,7 +994,7 @@ void MasterInfo_ProcessHTTP(char *name, qboolean success) info = Z_Malloc(sizeof(serverinfo_t)); info->adr = adr; info->sends = 1; - info->special = SS_NETQUAKE; + info->special = type; info->refreshtime = 0; sprintf(info->name, "%s", NET_AdrToString(info->adr)); @@ -985,6 +1006,17 @@ void MasterInfo_ProcessHTTP(char *name, qboolean success) FS_Remove(name, FS_GAME); } + +// wrapper functions for the different server types +void MasterInfo_ProcessHTTPNQ(char *name, qboolean success) +{ + MasterInfo_ProcessHTTP(name, success, SS_NETQUAKE); +} + +void MasterInfo_ProcessHTTPQW(char *name, qboolean success) +{ + MasterInfo_ProcessHTTP(name, success, 0); +} #endif //don't try sending to servers we don't support @@ -1055,11 +1087,14 @@ void MasterInfo_Request(master_t *mast, qboolean evenifwedonthavethefiles) NET_SendPollPacket (6, "query", mast->adr); break; #endif - case MT_MASTERHTTP: #ifdef WEBCLIENT - HTTP_CL_Get(mast->address, va("master_%i_%i.tmp", mastersequence++, mast->servertype), MasterInfo_ProcessHTTP); -#endif + case MT_MASTERHTTP: + HTTP_CL_Get(mast->address, va("master_%i_%i.tmp", mastersequence++, mast->servertype), MasterInfo_ProcessHTTPNQ); break; + case MT_MASTERHTTPQW: + HTTP_CL_Get(mast->address, va("master_%i_%i.tmp", mastersequence++, mast->servertype), MasterInfo_ProcessHTTPQW); + break; +#endif } } @@ -1097,6 +1132,9 @@ void MasterInfo_WriteServers(void) case MT_MASTERHTTP: typename = "master:http"; break; + case MT_MASTERHTTPQW: + typename = "master:httpqw"; + break; case MT_BCASTQW: typename = "bcast:qw"; break; @@ -1174,6 +1212,7 @@ void MasterInfo_Begin(void) // if (q1servers) //qw master servers { + Master_AddMasterHTTP("http://www.gameaholic.com/servers/qspy-quakeworld", MT_MASTERHTTPQW, "gameaholic's QW master"); Master_AddMaster("192.246.40.37:27000", MT_MASTERQW, "id Limbo"); Master_AddMaster("192.246.40.37:27002", MT_MASTERQW, "id CTF"); Master_AddMaster("192.246.40.37:27003", MT_MASTERQW, "id TeamFortress"); @@ -1196,7 +1235,7 @@ void MasterInfo_Begin(void) // if (q1servers) //nq master servers { - Master_AddMasterHTTP("http://www.gameaholic.com/servers/qspy-quake",SS_NETQUAKE, "gameaholic's NQ master"); + Master_AddMasterHTTP("http://www.gameaholic.com/servers/qspy-quake", MT_MASTERHTTP, "gameaholic's NQ master"); Master_AddMaster("255.255.255.255:26000", MT_BCASTNQ, "Nearby Quake1 servers"); Master_AddMaster("ghdigital.com:27950", MT_MASTERDP, "DarkPlaces Master 1"); @@ -1220,6 +1259,7 @@ void MasterInfo_Begin(void) } } + for (mast = master; mast; mast=mast->next) { MasterInfo_Request(mast, false);