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

Modified Files:
	defaults.c parsemeta.c sound.c 
Log Message:
Minor formatting fixes.
Moved sound mixer error message to a DEBUG only statement.
Added new tracking variable metaPartition to make sure metaserver doesn't try to display
more lines than the window has allocated, in the case where 2nd or subsequent metaserver
packets provide additional servers.  If there are too many servers, metawindow closes,
is redefined, and relaunched.

Index: parsemeta.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/parsemeta.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- parsemeta.c	13 Dec 2006 00:00:00 -0000	1.21
+++ parsemeta.c	13 Dec 2006 03:14:54 -0000	1.22
@@ -110,6 +110,8 @@
 int metaHeight = 0;			/* The number of list lines.	*/
 char *metaWindowName;			/* The window's name.           */
 int statusLevel;
+static int metaPartition = 0;		/* Cutoff line at which servers end,
+					   and bottom headers begin */
 
 #ifdef METAPING
 u_short metaPing_procId = 0;		/* Process id helps identify own ping replies */
@@ -760,6 +762,20 @@
     /* if this is the first call, return on first reply, for sizing list */
     if (x == -1 && isawsomething) return 1;
 
+    /* Check window size now that we have received multiple metaserver packets */
+    if (type == 1 && num_servers >= metaPartition) 
+    {
+    	/* Metaserver window too small, restart it */
+        LineToConsole("Resizing metaserver window, standby.\n");
+        metaHeight = num_servers + 7;
+        metaPartition = metaHeight - 3;
+        W_UnmapWindow (metaWin);
+        metaWin = W_MakeMenu ("MetaServer List", 0, 0, 80, metaHeight, NULL, 2);
+        W_SetWindowKeyDownHandler (metaWin, metaaction);
+        W_SetWindowButtonHandler (metaWin, metaaction);
+        metawindow();
+    }
+
     /* if we have seen the same number of replies to what we sent, end */
     if (sent == seen) return 1;
   }
@@ -775,7 +791,7 @@
 
   /* overwrite existing file if possible */
   if (metaUDPCache && !findfile(metaUDPCache, cacheFileName))
-      strcpy(cacheFileName, metaUDPCache);
+      strncpy(cacheFileName, metaUDPCache, PATH_MAX);
 
   if (metaUDPCache)
   {
@@ -1069,7 +1085,7 @@
     }
 
     if (metaCache && !findfile (metaCache, cacheFileName))
-        strcpy (cacheFileName, metaCache);      /* overwrite existing file if possible */
+        strncpy (cacheFileName, metaCache, PATH_MAX);      /* overwrite existing file if possible */
 
     if (metaCache)
     {
@@ -1267,14 +1283,16 @@
 	        /* Allocate 4 spots for header/refresh/quit/link, and 8 server slots */
 	        metaHeight = num_servers + 12;
 	    }
+            metaPartition = metaHeight - 3;
             return;
 	    break;
         case 2:
 	    if (ReadFromCache() || ReadFromMeta()) 
 	    {
                 /* Allocate 3 spots for header/quit/link */
-	        metaHeight = num_servers + 3;
-	        return;
+                metaHeight = num_servers + 3;
+                metaPartition = metaHeight - 2;
+                return;
 	    }
 	    terminate(0);
 	    break;
@@ -1283,6 +1301,7 @@
             {
                 /* Allocate 3 spots for header/quit/link */
                 metaHeight = num_servers + 3;
+                metaPartition = metaHeight - 2;
                 return;
             }
 	    terminate(0);
@@ -1416,7 +1435,7 @@
     /* can't say a thing if line is beyond server list */
     if (i >= num_servers) {
         /* but we can at least blank the line shown */
-        if (i < metaHeight-3)
+        if (i < metaPartition)
             W_WriteText(metaWin, 0, i+1, color, "", 0, 0);
         return;
     }
@@ -1812,13 +1831,13 @@
 	u_char  VIHL;			// Version and IHL
 	u_char	TOS;			// Type Of Service
 	short	TotLen;			// Total Length
-	short	ID;				// Identification
+	short	ID;			// Identification
 	short	FlagOff;		// Flags and Fragment Offset
 	u_char	TTL;			// Time To Live
 	u_char	Protocol;		// Protocol
 	u_short	Checksum;		// Checksum
-	struct	in_addr iaSrc;	// Internet Address - Source
-	struct	in_addr iaDst;	// Internet Address - Destination
+	struct	in_addr iaSrc;		// Internet Address - Source
+	struct	in_addr iaDst;		// Internet Address - Destination
 }IPHDR, *PIPHDR;
 
 
@@ -1828,7 +1847,7 @@
 	u_char	Type;			// Type
 	u_char	Code;			// Code
 	u_short	Checksum;		// Checksum
-	u_short	ID;				// Identification
+	u_short	ID;			// Identification
 	u_short	Seq;			// Sequence
 	char	Data;			// Data
 }ICMPHDR, *PICMPHDR;
@@ -1897,7 +1916,7 @@
 	 */
 	sum = (sum >> 16) + (sum & 0xffff);	/* add hi 16 to low 16 */
 	sum += (sum >> 16);			/* add carry */
-	answer = (unsigned short) (~sum);				/* truncate to 16 bits */
+	answer = (unsigned short) (~sum);	/* truncate to 16 bits */
 	return (answer);
 }
 

Index: defaults.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/defaults.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- defaults.c	13 Dec 2006 00:00:00 -0000	1.36
+++ defaults.c	13 Dec 2006 03:14:53 -0000	1.37
@@ -2022,7 +2022,7 @@
             strcpy (macroKey, "TAB");
         else if (mystats->st_keymap[155] == 'X')
             strcpy (macroKey, "ESC");
-	else if (mystats->st_keymap[56] == 'X')
+        else if (mystats->st_keymap[56] == 'X')
             strcpy (macroKey, "X");
     }
 

Index: sound.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/sound.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- sound.c	20 Sep 2006 13:04:53 -0000	1.18
+++ sound.c	13 Dec 2006 03:14:55 -0000	1.19
@@ -247,7 +247,10 @@
 
         if ((channel = Mix_PlayChannel(-1, newsounds[type], 0)) < 0)
         {
+#if DEBUG
+            /* Frequent occurence is more than 16 channels playing sound */
             LineToConsole("Mix_PlayChannel: %s\n", Mix_GetError());
+#endif
             return;
         }
             
@@ -290,8 +293,8 @@
 
     if ((channel = Mix_PlayChannel(-1, newsounds[type], 0)) < 0)
     {
-            LineToConsole("Mix_PlayChannel: %s\n", Mix_GetError());
-            return;
+        LineToConsole("Mix_PlayChannel: %s\n", Mix_GetError());
+        return;
     }
     /* Make sure distance in boundary range that function accepts */
     if (distance < 0)
@@ -303,7 +306,7 @@
         // Adjust volume with distance and angle
         if (Mix_SetPosition(channel, angle, distance) == 0)
         {
-           LineToConsole("Mix_SetPosition: %s\n", Mix_GetError());
+            LineToConsole("Mix_SetPosition: %s\n", Mix_GetError());
             return;
         }
     }
@@ -312,7 +315,7 @@
         // Adjust volume with distance
         if (Mix_SetDistance(channel, distance) == 0)
         {
-           LineToConsole("Mix_SetDistance: %s\n", Mix_GetError());
+            LineToConsole("Mix_SetDistance: %s\n", Mix_GetError());
             return;
         }
     }