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

Modified Files:
	data.c defaults.c local.c map.c mswindow.c option.c 
Log Message:
Added drawRange option to show range at which enemies can see you.
The extent of range is calculated identical to the server.  Planets within
the range of the circle are flagged as needing redraws.
Added a new flag to W_WriteCircle function to indicate whether to draw
the circle dashed or not.

Index: mswindow.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/mswindow.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- mswindow.c	17 Mar 2007 17:12:09 -0000	1.47
+++ mswindow.c	19 Mar 2007 00:05:13 -0000	1.48
@@ -3302,6 +3302,7 @@
                     int y,
                     int r,
                     int highlight,
+                    int dashed,
                     W_Color color)
 {
     DBHEADER_VOID;
@@ -3315,7 +3316,10 @@
         RealizePalette (hdc);
     }
 
-    SelectObject (hdc, colortable[color].pen);
+    if (dashed)
+        SelectObject (hdc, colortable[color].dashedpen);
+    else
+        SelectObject (hdc, colortable[color].pen);
     SelectObject (hdc, GetStockObject (NULL_BRUSH));
 
     Ellipse (hdc, x - r, y - r, x + r, y + r);

Index: local.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/local.c,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -d -r1.77 -r1.78
--- local.c	18 Mar 2007 01:46:50 -0000	1.77
+++ local.c	19 Mar 2007 00:05:13 -0000	1.78
@@ -1158,7 +1158,7 @@
             {
             	if (myPlayer(j))
             	{
-                    W_WriteCircle(w, WINSIDE/2, WINSIDE/2, DETDIST/SCALE, 0, W_Red);         
+                    W_WriteCircle(w, WINSIDE/2, WINSIDE/2, DETDIST/SCALE, 0, 0, W_Red);         
                     clearzone[0][clearcount] = WINSIDE/2 - (DETDIST/SCALE);
                     clearzone[1][clearcount] = WINSIDE/2 - (DETDIST/SCALE);
                     clearzone[2][clearcount] = 2*DETDIST/SCALE + 1;
@@ -1220,7 +1220,7 @@
             {
             	if (myPlayer(j) || isObsLockPlayer(j))
             	{
-                    W_WriteCircle(w, WINSIDE/2, WINSIDE/2, SHOTRANGE/SCALE, 0, W_Grey);         
+                    W_WriteCircle(w, WINSIDE/2, WINSIDE/2, SHOTRANGE/SCALE, 0, 0, W_Grey);         
                     clearzone[0][clearcount] = WINSIDE/2 - (SHOTRANGE/SCALE);
                     clearzone[1][clearcount] = WINSIDE/2 - (SHOTRANGE/SCALE);
                     clearzone[2][clearcount] = 2*SHOTRANGE/SCALE + 1;

Index: option.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/option.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- option.c	17 Mar 2007 23:16:19 -0000	1.38
+++ option.c	19 Mar 2007 00:05:13 -0000	1.39
@@ -397,6 +397,7 @@
 #endif
     {1, "omit team letter on map", &omitTeamLetter, 0, 0, 0, NULL, NULL},
     {1, "draw view box on map", &viewBox, 0, 0, 0, NULL, NULL},
+    {1, "draw detect limits on map", &viewRange, 0, 0, 0, NULL, NULL},
     {1, "draw stars on local", &showStars, 0, 0, 0, NULL, NULL},
     {1, "draw warp streaks", &warpStreaks, 0, 0, 0, NULL, NULL},
     {1, "alert on extra border(s)", &extraAlertBorder, 0, 0, 0, NULL, NULL},

Index: data.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/data.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -d -r1.67 -r1.68
--- data.c	18 Mar 2007 01:46:50 -0000	1.67
+++ data.c	19 Mar 2007 00:05:13 -0000	1.68
@@ -781,6 +781,7 @@
 
 int omitTeamLetter = 0;
 int viewBox = 1;
+int viewRange = 1;
 
 struct stringlist *defaults = NULL;
 

Index: map.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/map.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- map.c	18 Mar 2007 19:04:11 -0000	1.31
+++ map.c	19 Mar 2007 00:05:13 -0000	1.32
@@ -61,6 +61,8 @@
 static int mclearpoint[2][(MAXTORP + 1) * MAXPLAYER];
 static int mclearacount; 	/* For torp explosions, plasmas, and plasma explosions */
 static int mcleararea[4][(MAXTORP + 1) * MAXPLAYER + (MAXPLASMA + 1) * MAXPLAYER];
+static int mclearx, mcleary, mclearr;	/* x,y,radius for range circle */
+static int mclearccount;
 
 /*
  *  Global Variables:
@@ -625,7 +627,7 @@
 #endif
         if (planetHighlighting && (l->pl_info & me->p_team)) /* Draw halo */
             W_WriteCircle(mapw, dx, dy, BMP_MPLANET_WIDTH / 2,
-                          l->pl_armies > 4 ? 1 : 0, planetColor(l));
+                          l->pl_armies > 4 ? 1 : 0, 0, planetColor(l));
 
         if ((l->pl_flags & PLAGRI) && (l->pl_info & me->p_team))
         {
@@ -1025,6 +1027,47 @@
 #ifdef BEEPLITE
 	}
 #endif
+
+	/* Draw range circle */
+	if (viewRange && (myPlayer(j) || isObsLockPlayer(j)))
+        {
+        /* Orbitting any non-owned planet gets you seen,
+           so don't draw the circle */
+          if ((j->p_flags & PFORBIT) &&
+          (planets[j->p_planet].pl_owner != j->p_team)) ;
+          else
+          {
+            struct planet *pl;
+            int pRadius;
+            int planx, plany;
+            int distx, disty;
+            int rad;
+
+#ifdef BEEPLITE
+            pRadius = 3 * BMP_MPLANET_WIDTH / 5;
+#else
+            pRadius = BMP_MPLANET_WIDTH / 2;
+#endif
+            rad = (j->p_flags & PFCLOAK) ? MAXDISTCLOAK : MAXDISTVIS;
+            W_WriteCircle(mapw, dx, dy, rad, 0, 1, W_White);
+            mclearx = dx;
+            mcleary = dy;
+            mclearr = rad;
+            mclearccount++;
+            for (pl = planets + MAXPLANETS - 1; pl >= planets; --pl)
+            {
+                /* Redraw check - redraw all planets in range.  Have to
+                   adjust distance to account for planet radius and text
+                   of planet name */
+                planx = pl->pl_x * WINSIDE / GWIDTH;
+                plany = pl->pl_y * WINSIDE / GWIDTH;
+                distx = ABS(planx - dx) - pRadius - W_Textwidth;
+                disty = ABS(plany - dy) - pRadius - W_Textheight;
+                if (distx*distx + disty*disty < (rad*rad))
+                    pl->pl_flags |= PLREDRAW;
+            }
+          }
+        }
     }
 
     /* Draw weapons */
@@ -1259,4 +1302,10 @@
     W_MakeLines (mapw, mclearline[0], mclearline[1], mclearline[2],
                      mclearline[3], mclearlcount, backColor);
     mclearlcount = 0;
+    
+    if (mclearccount)
+    {
+        W_WriteCircle(mapw, mclearx, mcleary, mclearr, 0, 1, backColor);
+        mclearccount--;
+    }
 }

Index: defaults.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/defaults.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- defaults.c	15 Mar 2007 16:42:30 -0000	1.58
+++ defaults.c	19 Mar 2007 00:05:13 -0000	1.59
@@ -887,6 +887,12 @@
             NULL
         }
     },
+    {"viewRange", &viewRange, RC_BOOL,
+        {
+            "Show range at which enemies can see you as a circle on map",
+            NULL
+        }
+    },
     {"warnHull", &vary_hull, RC_BOOL,
         {
             "Warn hull state based on damage",
@@ -1615,6 +1621,7 @@
     omitTeamLetter = booleanDefault ("omitTeamLetter", omitTeamLetter);
     beepOnPrivateMessage = booleanDefault ("beepOnPrivateMessage", beepOnPrivateMessage);
     viewBox = booleanDefault ("viewBox", viewBox);
+    viewRange = booleanDefault ("viewRange", viewRange);
     warpStreaks = booleanDefault ("warpStreaks", warpStreaks);
     showStars = booleanDefault ("showStars", showStars);