Update of /cvsroot/netrek/client/netrekxp/src
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv27902/src

Modified Files:
	console.c cowmain.c data.c main.c newwin.c parsemeta.c 
Log Message:
This patch merges the COW metaserver code.  It adds a UDP metaserver option, which can be refreshed, that merges data from all known metaservers.  The UPD metaserver can also solicit other servers as if they were a metaserver, and supports the server option to display a comment rather than server name.  There is also support for multicast server packets.

data.h, data.c: Changes default metaserver format from array to comma delimited list
parsemeta.h: Fixes description of parsemeta function
console.c (LineToConsole): Increases buffer size (large error messages like displaying the metaserver packet was causing a buffer overflow)
cowmain.c: Adds support for metatype sysdef option
main.c: Renames old -m option to -M, and adds -m option for UDP metaserver
newwin.c: Changes how metaserver window dimensions are set (slightly wider, height variable)
parsemeta.c: Extensively rewritten.  Highlights include new server fields, bug fixes related to the size/initialization of the comment field, and new metaserver headers based on what optional fields (age, ping) are displayed.  Totally new functions, such as ReadMetasSend, grow, server_find, version_s, version_r, ReadMetasRecv, SaveMetasCache, and LoadMetasCache, have also been added.

Index: newwin.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/newwin.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- newwin.c	9 Jul 2006 08:25:38 -0000	1.42
+++ newwin.c	27 Nov 2006 07:08:41 -0000	1.43
@@ -31,6 +31,7 @@
 #include "proto.h"
 
 extern HINSTANCE MyInstance;
+extern int metaHeight;   /* height of metaserver window */
 
 static int line = 0;
 int MaxMotdLine = 0;
@@ -852,7 +853,7 @@
     W_SetWindowButtonHandler (helpWin, helpaction);
 
 #ifdef META
-    metaWin = W_MakeMenu ("MetaServer List", 0, 0, 72, num_servers + 2,
+    metaWin = W_MakeMenu ("MetaServer List", 0, 0, 80, metaHeight,
                           NULL, 2);
     W_SetWindowKeyDownHandler (metaWin, metaaction);
     W_SetWindowButtonHandler (metaWin, metaaction);

Index: cowmain.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/cowmain.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- cowmain.c	28 May 2006 23:05:12 -0000	1.15
+++ cowmain.c	27 Nov 2006 07:08:41 -0000	1.16
@@ -496,6 +496,10 @@
 
 #ifdef META
 int usemeta = 0;
+int metaType;                 /* which meta to use, UDP, cache, or TCP */
+                              /* can be set in xtrekrc with metaType: */
+                              /* 1 == UDP, 2 == cache, TCP, 3 = TCP, cache */
+#define DEFAULT_METATYPE  3   /* want TCP, cache as the default */
 #endif
 
 /******************************************************************************/
@@ -644,7 +648,13 @@
 
 #ifdef META
     if (usemeta)
-        parsemeta (usemeta);
+    {
+        metaType = intDefault("metaType", usemeta);
+        /* use default metatype for illegal values */
+        if ((metaType < 1) || (metaType > 3))
+            metaType = DEFAULT_METATYPE;
+        parsemeta(metaType);
+    }
 #endif
   
     fed_ship_bmp = "bitmaps/shiplib/fedship.bmp";

Index: main.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/main.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- main.c	10 Aug 2006 10:59:15 -0000	1.10
+++ main.c	27 Nov 2006 07:08:41 -0000	1.11
@@ -67,8 +67,9 @@
     LineToConsole (" [-c]   run players check on the server\n");
 
 #ifdef META
-    LineToConsole (" [-m]   check metaserver for active servers\n");
-    LineToConsole (" [-k]   display known servers\n");
+    LineToConsole (" [-m]   list servers, using UDP/IP to multiple metaservers\n");
+    LineToConsole (" [-M]   list servers, using TCP/IP to single metaserver\n");
+    LineToConsole (" [-k]   list servers from cache generated by -M\n");
 #endif
 
     LineToConsole (" [-D]   output debug info\n");
@@ -214,25 +215,35 @@
                 break;
 
 #ifdef META
-            case 'm':           /* show metaserver window */
+            case 'm':           /* use multiple metaservers by UDP */
                 if (usemeta && usemeta != 1)
                 {
-                    fputs ("The options -k and -m are mutually exclusive\n",
+                    fputs ("The options -k, -m and -M are mutually exclusive\n",
                            stderr);
                     err++;
                 }
                 usemeta = 1;
                 break;
 
-            case 'k':           /* show metacache window */
+            case 'k':           /* use metaserver cache from prior -M usage */
                 if (usemeta && usemeta != 2)
                 {
-                    fputs ("The options -k and -m are mutually exclusive\n",
+                    fputs ("The options -k, -m and -M are mutually exclusive\n",
                            stderr);
                     err++;
                 }
                 usemeta = 2;
                 break;
+
+             case 'M':          /* use single metaserver by TCP */
+                 if (usemeta && usemeta != 3)
+                 {
+                     fputs("The options -k, -m and -M are mutually exclusive\n",
+                           stderr);
+                     err++;
+                 }
+                 usemeta = 3;
+                 break;
 #endif
 
 #ifdef RSA
@@ -377,7 +388,8 @@
         }       /* end while */
     }           /* end for */
 
-    if (!usemeta && !servertmp)  /* no meta type was selected, pick metaserver */
+    if (!usemeta && !servertmp)  /* no meta type was selected, and no server
+                                    specified, so pick metaserver */
         usemeta = 1;
 
     if (usage || err)

Index: data.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/data.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- data.c	20 Sep 2006 13:04:53 -0000	1.41
+++ data.c	27 Nov 2006 07:08:41 -0000	1.42
@@ -228,9 +228,8 @@
 int updatesPerSec = 10;
 
 #ifdef META
-/* Metaservers list */
-char *metaServer[] = {"metaserver.us.netrek.org",
-                      "metaserver2.us.netrek.org"};
+/* Metaservers list - comma delimited  */
+char *metaServer = "metaserver.us.netrek.org, metaserver2.us.netrek.org";
 int metaPort = 3521;
 char *metaCache = NULL;
 #ifdef METAPING

Index: parsemeta.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/parsemeta.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- parsemeta.c	6 Jun 2006 05:14:14 -0000	1.11
+++ parsemeta.c	27 Nov 2006 07:08:41 -0000	1.12
@@ -30,6 +30,8 @@
 /***   06/2003  Erik Hietbrink         Added metaPing option.
 /***                                   Added Connecting Now state.
 /***   
+/***   11/2006  Bill Balcerski	       Merged COW UDP metaserver, server solicitation,
+/**                                    and multicast server packet code
 /******************************************************************************/
 
 #undef DEBUG
@@ -61,34 +63,45 @@
 /* Constants */
 
[...1221 lines suppressed...]
 	fd_set readfds;
 	int nRet;
 
-	// untill I find a better way of killing this thread, only
+	FD_ZERO(&readfds);
+	if (s >= 0) FD_SET(s, &readfds);
+
+	// until I find a better way of killing this thread, only
 	// wait in periods of maximum 250ms. Better for menu responsiveness ;-)
 	if (waittime > 250) waittime = 250;
 
@@ -1151,7 +1849,7 @@
 		}
 
 		// Refresh the displayed ping stats
-		for (i = 0; i < num_servers; ++i) metarefresh(i);
+		for (i = 0; i < num_servers; ++i) metarefresh(i, textColor);
 
 		// Proceed to the next cycle of ping samples
 		idx = (unsigned short) ((idx + 1) % RTT_AVG_BUFLEN);

Index: console.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/console.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- console.c	7 May 2006 16:59:27 -0000	1.2
+++ console.c	27 Nov 2006 07:08:40 -0000	1.3
@@ -53,7 +53,7 @@
 LineToConsole (char * format, ...)
 {
     struct cons_buffer * tmp;     // temporary pointer to our linked list;
-    char str[256];
+    char str[1024];
     DWORD numChars;
     va_list args;