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

Modified Files:
	data.c defaults.c enter.c newwin.c option.c playerlist.c 
	rotate.c 
Log Message:
New option autoRotate to make it so teams are always on left hand side of galaxy.  Upon
entering game, a new function, rotateTeams(), is called if autoRotate is set.  It aligns the 
teams so they are on the left side of map, then calls a new function, rotateGalaxy(), to perform
the galactic rotation.  This function is placed in rotate.c and is the code formerly in option.c
to perform galaxy rotations via the options menu (this method still works).
Fix so geno bitmap doesn't get overwritten by MOTD if window is minimized/moved.

Index: rotate.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/rotate.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- rotate.c	7 May 2006 16:59:27 -0000	1.2
+++ rotate.c	21 Feb 2007 15:17:08 -0000	1.3
@@ -13,6 +13,7 @@
 #include "struct.h"
 #include "data.h"
 #include "packets.h"
+#include "map.h"
 #include "proto.h"
 
 #ifdef ROTATERACE
@@ -85,4 +86,61 @@
     }
 }
 
+void
+rotateGalaxy (void)
+{
+    register i;
+    register struct planet *l;
+    register struct player *j;
+
+    redrawall = 1;
+    reinitPlanets = 1;
+
+    for (i = 0, l = planets; i < MAXPLANETS; i++, l++)
+    {
+        if (rotate)
+        {
+            rotate_deg = -old_rotate_deg + rotate * 64;
+            rotate_coord (&l->pl_x, &l->pl_y, rotate_deg, GWIDTH / 2,
+                          GWIDTH / 2);
+            rotate_deg = rotate * 64;
+        }
+        else
+        {
+            rotate_deg = -old_rotate_deg;
+            rotate_coord (&l->pl_x, &l->pl_y, rotate_deg, GWIDTH / 2,
+                          GWIDTH / 2);
+            rotate_deg = 0;
+        }
+    }
+
+    /* we could wait for the server to do this but looks better if we
+     * do it now. */
+    for (i = 0, j = players; i < MAXPLAYER; i++, j++)
+    {
+        if (j->p_status != PALIVE)
+            continue;
+        if (rotate)
+        {
+            rotate_deg = -old_rotate_deg + rotate * 64;
+            rotate_coord (&j->p_x, &j->p_y, rotate_deg,
+                          GWIDTH / 2, GWIDTH / 2);
+            rotate_dir (&j->p_dir, rotate_deg);
+
+            rotate_deg = rotate * 64;
+        }
+        else
+        {
+            rotate_deg = -old_rotate_deg;
+            rotate_coord (&j->p_x, &j->p_y, rotate_deg,
+                          GWIDTH / 2, GWIDTH / 2);
+            rotate_dir (&j->p_dir, rotate_deg);
+            rotate_deg = 0;
+        }
+    }
+    /* phasers/torps/etc .. wait for server */
+
+    old_rotate = rotate;
+    old_rotate_deg = rotate_deg;
+}
 #endif

Index: newwin.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/newwin.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- newwin.c	31 Jan 2007 07:06:37 -0000	1.46
+++ newwin.c	21 Feb 2007 15:17:06 -0000	1.47
@@ -1659,7 +1659,8 @@
             }
             else if (event.Window == w)
             {
-                showMotdWin (w, line);
+            	if (me->p_whydead != KWINNER && me->p_whydead != KGENOCIDE)
+                    showMotdWin (w, line);
             }
             else if (event.Window == helpWin)
 #ifdef RECORDGAME

Index: enter.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/enter.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- enter.c	7 May 2006 16:59:27 -0000	1.3
+++ enter.c	21 Feb 2007 15:17:06 -0000	1.4
@@ -31,6 +31,10 @@
 void
 enter (void)
 {
+#ifdef ROTATERACE
+    if (autoRotate)   
+        rotateTeams();
+#endif
     drawTstats ();
     delay = 0;
 }
@@ -98,6 +102,81 @@
     }
 }
 
+#ifdef ROTATERACE
+/******************************************************************************/
+/***  rotateTeams()                                                         ***/
+/***  Place 2 largest teams on left hand side of galaxy                     ***/
+/******************************************************************************/
+void
+rotateTeams (void)
+{
+    int i;
+    int playercount = 0;
+    int largestteam = -1, nextlargestteam= -1;
+    int largestteamcount = 0, nextlargestteamcount = 0;
+
+    /* Find the 2 largest teams (hopefully) */
+    for (i = 0; i < 4; i++)
+    {
+        if ((playercount = realNumShips(1 << i)) == 0)
+            continue;
+        if (playercount > largestteamcount)
+        {
+            nextlargestteam = largestteam;
+            nextlargestteamcount = largestteamcount;
+            largestteam = i;
+            largestteamcount = playercount;
+        }
+        else if (playercount > nextlargestteamcount)
+        {
+            nextlargestteam = i;
+            nextlargestteamcount = playercount;
+        }
+    }
+    /* Server empty or only 1 team? Don't rotate. */
+    if (largestteam < 0 || nextlargestteam < 0)
+        return;
+
+    /* 2 largest teams are diagonal (possible before T mode), i.e. FED-KLI
+       or ROM-ORI?  Don't rotate.  Team order is FED ROM KLI ORI */
+    if ((largestteam - nextlargestteam) == 2 || (largestteam - nextlargestteam) == -2)
+        return;
+    
+    /* Determine how many degrees needed to rotate galaxy so both teams
+       on left side of the map, and set global rotate value accordingly */
+    switch (largestteam)
+    {
+        case 0: /* FED */
+            if (nextlargestteam == 3) /* FED-ORI */
+               rotate = 1;
+            break;
+        case 1: /* ROM */
+            if (nextlargestteam == 2) /* ROM-KLI */
+                rotate = 3;
+            break;
+        case 2: /* KLI */
+            if (nextlargestteam == 1) /* KLI-ROM */
+                rotate = 3;
+            else if (nextlargestteam == 3) /* KLI-ORI */
+                rotate = 2;
+            break;
+        case 3: /* ORI */
+            if (nextlargestteam == 1) /* ORI-FED */
+                rotate = 1;
+            else if (nextlargestteam == 2) /* ORI-KLI */
+                rotate = 2;
+            break;
+        default:
+            break;
+    }
+    
+    /* Perform rotation if necessary */
+    if (rotate != old_rotate)
+        rotateGalaxy();
+    return;
+}
+#endif
+
 /******************************************************************************/
 /***  drawTstats()                                                          ***/
 /******************************************************************************/

Index: playerlist.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/playerlist.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- playerlist.c	21 Feb 2007 11:43:38 -0000	1.9
+++ playerlist.c	21 Feb 2007 15:17:07 -0000	1.10
@@ -1141,7 +1141,7 @@
         case 'K':              /* Kills */
             if (*(ptr + 1) >= '0' && *(ptr + 1) <= '2')
             {
-            	if (j->p_kills == 0.00 && playerListBlankZeroKills)
+                if (j->p_kills == 0.00 && playerListBlankZeroKills)
                 {
                     if (*(ptr + 1) == '0')
                         format (buffPoint, "   ", 3, 0);

Index: defaults.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/defaults.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- defaults.c	21 Feb 2007 11:43:38 -0000	1.41
+++ defaults.c	21 Feb 2007 15:17:05 -0000	1.42
@@ -66,6 +66,14 @@
             NULL
         }
     },
+#ifdef ROTATERACE
+    {"autoRotate", &autoRotate, RC_BOOL,
+        {
+            "Automatically rotate galaxy so teams are on left side of map",
+            NULL
+        }
+    },
+#endif
     {"baseUdpLocalPort", &baseUdpLocalPort, RC_INT,
         {
             "Base UDP local port",
@@ -1564,6 +1572,7 @@
     redrawDelay = intDefault ("redrawDelay", redrawDelay);
     planetHighlighting = booleanDefault ("planetHighlighting", planetHighlighting);
     rotatePlanets = booleanDefault ("rotatePlanets", rotatePlanets);
+    autoRotate = booleanDefault ("autoRotate", autoRotate);
     logging = booleanDefault ("logging", logging);
     maxScrollLines = intDefault ("maxScrollLines", maxScrollLines);
     if (maxScrollLines > 500)

Index: data.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/data.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- data.c	21 Feb 2007 11:43:38 -0000	1.49
+++ data.c	21 Feb 2007 15:17:05 -0000	1.50
@@ -128,9 +128,11 @@
 int promoted = 0;
 
 #ifdef ROTATERACE
+int autoRotate = 0;
 int rotate = 0;
 int rotate_deg = 0;
-
+int old_rotate = 0;
+int old_rotate_deg = 0;
 #endif
 
 int loginAccept = -1;

Index: option.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/option.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- option.c	21 Feb 2007 11:43:38 -0000	1.25
+++ option.c	21 Feb 2007 15:17:07 -0000	1.26
@@ -25,10 +25,6 @@
 
 int notdone;                    /* not done flag */
 
-#ifdef ROTATERACE
-static int old_rotate, old_rotate_deg;
-#endif
-
 static int lastUpdateSpeed = 10;
 static char newkeys[14];
 
@@ -293,6 +289,7 @@
     {1, "", &agriColor, 0, 0, 0, agricolormess, NULL},
     {1, "", &showLock, 0, 0, 0, lockoptions, NULL},
 #ifdef ROTATERACE
+    {1, "autorotate galaxy", &autoRotate, 0, 0, 0, NULL, NULL},
     {1, "", &rotate, 0, 0, 0, rotatemess, NULL},
 #endif
     {1, "done", &notdone, 0, 0, 0, NULL, NULL},
@@ -788,63 +785,8 @@
         }
 #ifdef ROTATERACE
         else if (rotate != old_rotate)
-        {
-            register i;
-            register struct planet *l;
-            register struct player *j;
-
-            redrawall = 1;
-            reinitPlanets = 1;
-
-            for (i = 0, l = planets; i < MAXPLANETS; i++, l++)
-            {
-                if (rotate)
-                {
-                    rotate_deg = -old_rotate_deg + rotate * 64;
-                    rotate_coord (&l->pl_x, &l->pl_y, rotate_deg, GWIDTH / 2,
-                                  GWIDTH / 2);
-                    rotate_deg = rotate * 64;
-                }
-                else
-                {
-                    rotate_deg = -old_rotate_deg;
-                    rotate_coord (&l->pl_x, &l->pl_y, rotate_deg, GWIDTH / 2,
-                                  GWIDTH / 2);
-                    rotate_deg = 0;
-                }
-            }
-
-            /* we could wait for the server to do this but looks better if we
-             * do it now. */
-            for (i = 0, j = players; i < MAXPLAYER; i++, j++)
-            {
-                if (j->p_status != PALIVE)
-                    continue;
-                if (rotate)
-                {
-                    rotate_deg = -old_rotate_deg + rotate * 64;
-                    rotate_coord (&j->p_x, &j->p_y, rotate_deg,
-                                  GWIDTH / 2, GWIDTH / 2);
-                    rotate_dir (&j->p_dir, rotate_deg);
-
-                    rotate_deg = rotate * 64;
-                }
-                else
-                {
-                    rotate_deg = -old_rotate_deg;
-                    rotate_coord (&j->p_x, &j->p_y, rotate_deg,
-                                  GWIDTH / 2, GWIDTH / 2);
-                    rotate_dir (&j->p_dir, rotate_deg);
-                    rotate_deg = 0;
-                }
-            }
-            /* phasers/torps/etc .. wait for server */
-
-            old_rotate = rotate;
-            old_rotate_deg = rotate_deg;
-        }
+            rotateGalaxy();
 #endif
-
     }