|
|
@ -1,4 +1,4 @@
|
|
|
|
/* $Id: netsrvlist.c,v 1.12 2005/03/28 02:48:34 stpohle Exp $
|
|
|
|
/* $Id: netsrvlist.c,v 1.13 2005/03/28 16:38:35 stpohle Exp $
|
|
|
|
* netsrvlist.c - shows a list of possible servers.*/
|
|
|
|
* netsrvlist.c - shows a list of possible servers.*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "basic.h"
|
|
|
|
#include "basic.h"
|
|
|
@ -21,6 +21,7 @@ struct __srvlst_entry {
|
|
|
|
int maxplayers;
|
|
|
|
int maxplayers;
|
|
|
|
int curplayers;
|
|
|
|
int curplayers;
|
|
|
|
int ai_family;
|
|
|
|
int ai_family;
|
|
|
|
|
|
|
|
int ping;
|
|
|
|
char comment[32];
|
|
|
|
char comment[32];
|
|
|
|
} srvlst_dat[MAX_SRVLIST];
|
|
|
|
} srvlst_dat[MAX_SRVLIST];
|
|
|
|
int srvlst_cnt = 0;
|
|
|
|
int srvlst_cnt = 0;
|
|
|
@ -28,7 +29,7 @@ int srvlst_cnt = 0;
|
|
|
|
/* will build up our srvlst list with
|
|
|
|
/* will build up our srvlst list with
|
|
|
|
* all servers we have in there */
|
|
|
|
* all servers we have in there */
|
|
|
|
void srvlist_rebuildlist () {
|
|
|
|
void srvlist_rebuildlist () {
|
|
|
|
int ogclst, i;
|
|
|
|
int ogclst, i, j;
|
|
|
|
char txt1[255];
|
|
|
|
char txt1[255];
|
|
|
|
char txt2[255];
|
|
|
|
char txt2[255];
|
|
|
|
|
|
|
|
|
|
|
@ -41,31 +42,36 @@ void srvlist_rebuildlist () {
|
|
|
|
srvlst_dat[i].version[0] = 0;
|
|
|
|
srvlst_dat[i].version[0] = 0;
|
|
|
|
srvlst_dat[i].gamename[0] = 0;
|
|
|
|
srvlst_dat[i].gamename[0] = 0;
|
|
|
|
srvlst_dat[i].comment[0] = 0;
|
|
|
|
srvlst_dat[i].comment[0] = 0;
|
|
|
|
|
|
|
|
srvlst_dat[i].ping = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
srvlst_cnt = 0;
|
|
|
|
srvlst_cnt = 0;
|
|
|
|
|
|
|
|
|
|
|
|
/* add broadcasted list */
|
|
|
|
/* add broadcasted list (j == LAN GAME) */
|
|
|
|
for (i = 0; i < BC_MAXENTRYS; i++) {
|
|
|
|
for (j = 1; j >= 0; j--) for (i = 0; i < BC_MAXENTRYS; i++) {
|
|
|
|
if (broadcast_list[i].host[0] != 0) {
|
|
|
|
if (broadcast_list[i].host[0] != 0 && broadcast_list[i].lan == j) {
|
|
|
|
strncpy (srvlst_dat[srvlst_cnt].host, broadcast_list[i].host, LEN_SERVERNAME);
|
|
|
|
strncpy (srvlst_dat[srvlst_cnt].host, broadcast_list[i].host, LEN_SERVERNAME);
|
|
|
|
strncpy (srvlst_dat[srvlst_cnt].port, broadcast_list[i].port, LEN_PORT);
|
|
|
|
strncpy (srvlst_dat[srvlst_cnt].port, broadcast_list[i].port, LEN_PORT);
|
|
|
|
strncpy (srvlst_dat[srvlst_cnt].version, broadcast_list[i].version, LEN_VERSION);
|
|
|
|
strncpy (srvlst_dat[srvlst_cnt].version, broadcast_list[i].version, LEN_VERSION);
|
|
|
|
strncpy (srvlst_dat[srvlst_cnt].gamename, broadcast_list[i].gamename, LEN_GAMENAME);
|
|
|
|
strncpy (srvlst_dat[srvlst_cnt].gamename, broadcast_list[i].gamename, LEN_GAMENAME);
|
|
|
|
srvlst_dat[srvlst_cnt].ai_family = bman.net_ai_family;
|
|
|
|
srvlst_dat[srvlst_cnt].ai_family = bman.net_ai_family;
|
|
|
|
|
|
|
|
if (broadcast_list[i].lan)
|
|
|
|
sprintf (srvlst_dat[srvlst_cnt].comment, "LAN");
|
|
|
|
sprintf (srvlst_dat[srvlst_cnt].comment, "LAN");
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
sprintf (srvlst_dat[srvlst_cnt].comment, "Inet");
|
|
|
|
srvlst_cnt++;
|
|
|
|
srvlst_cnt++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* add the OpenGameCache Entrys */
|
|
|
|
/* add the OpenGameCache Entrys which are not in the broadcasted list */
|
|
|
|
if (bman.notifygamemaster) {
|
|
|
|
if (bman.notifygamemaster) {
|
|
|
|
for (ogclst = 0; (ogclst < MAX_OGC_ENTRYS && srvlst_cnt < MAX_SRVLIST); ogclst++)
|
|
|
|
for (ogclst = 0; (ogclst < MAX_OGC_ENTRYS && srvlst_cnt < MAX_SRVLIST); ogclst++)
|
|
|
|
if (ogc_array[ogclst].serial != -1) {
|
|
|
|
if ((ogc_array[ogclst].serial != -1) && (broadcast_find (ogc_array[ogclst].host, ogc_array[ogclst].port) == -1)) {
|
|
|
|
srvlst_dat[srvlst_cnt].host[0] = 0;
|
|
|
|
srvlst_dat[srvlst_cnt].host[0] = 0;
|
|
|
|
srvlst_dat[srvlst_cnt].port[0] = 0;
|
|
|
|
srvlst_dat[srvlst_cnt].port[0] = 0;
|
|
|
|
srvlst_dat[srvlst_cnt].version[0] = 0;
|
|
|
|
srvlst_dat[srvlst_cnt].version[0] = 0;
|
|
|
|
srvlst_dat[srvlst_cnt].gamename[0] = 0;
|
|
|
|
srvlst_dat[srvlst_cnt].gamename[0] = 0;
|
|
|
|
|
|
|
|
srvlst_dat[srvlst_cnt].ping = -2;
|
|
|
|
|
|
|
|
|
|
|
|
srvlst_dat[srvlst_cnt].ai_family = ogc_array[ogclst].ai_family;
|
|
|
|
srvlst_dat[srvlst_cnt].ai_family = ogc_array[ogclst].ai_family;
|
|
|
|
strncpy (srvlst_dat[srvlst_cnt].host,ogc_array[ogclst].host, LEN_SERVERNAME);
|
|
|
|
strncpy (srvlst_dat[srvlst_cnt].host,ogc_array[ogclst].host, LEN_SERVERNAME);
|
|
|
@ -81,11 +87,18 @@ void srvlist_rebuildlist () {
|
|
|
|
|
|
|
|
|
|
|
|
/* make the list viewable */
|
|
|
|
/* make the list viewable */
|
|
|
|
for (i = 0; i < srvlst_cnt; i++) {
|
|
|
|
for (i = 0; i < srvlst_cnt; i++) {
|
|
|
|
|
|
|
|
if (srvlst_dat[i].ping == -2)
|
|
|
|
|
|
|
|
txt2[0] = 0;
|
|
|
|
|
|
|
|
else if (srvlst_dat[i].ping == -1)
|
|
|
|
|
|
|
|
sprintf (txt2, "NoCon");
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
sprintf (txt2, "%dms", srvlst_dat[i].ping);
|
|
|
|
|
|
|
|
|
|
|
|
if (srvlst_dat[i].gamename[0] != 0) /* gamename is present */
|
|
|
|
if (srvlst_dat[i].gamename[0] != 0) /* gamename is present */
|
|
|
|
sprintf (txt1, "%-28s %-11s %-4s", srvlst_dat[i].gamename, srvlst_dat[i].version, srvlst_dat[i].comment);
|
|
|
|
sprintf (txt1, "%-20s %5s %-11s %-4s", srvlst_dat[i].gamename, txt2, srvlst_dat[i].version, srvlst_dat[i].comment);
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
sprintf (txt2, "%s:%s", srvlst_dat[i].host, srvlst_dat[i].port);
|
|
|
|
sprintf (txt1, "%s:%s", srvlst_dat[i].host, srvlst_dat[i].port);
|
|
|
|
sprintf (txt1, "%-28s %-11s %-4s", txt2, srvlst_dat[i].version, srvlst_dat[i].comment);
|
|
|
|
sprintf (txt1, "%-20s %5s %-11s %-4s", txt1,txt2, srvlst_dat[i].version, srvlst_dat[i].comment);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
strncpy (srvlst_text[i].text, txt1, LEN_CHARENTRY);
|
|
|
|
strncpy (srvlst_text[i].text, txt1, LEN_CHARENTRY);
|
|
|
|
}
|
|
|
|
}
|
|
|
|