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

Modified Files:
	local.c map.c 
Log Message:
New netrekrc macro.
Found a bug that has been around for a long time, with phasers and
short packets.  On a phaser hit, target's x/y is not sent (it IS with long
packets though).  In the case where the target is no longer visibile
while the phaser cycle is still active (i.e. you die while phasering and
the person who killed you is no longer galactically visible to your team),
the target's x/y is set to -10000,-10000 and the phaser is seen to draw
across the local screen.  And with the addition of drawing weapons
on the galaxy map, the bug was evident there as well.  Solution is to
set phaser target location to self location (i.e. make phaser length 0),
if target location is out of bounds.

Index: local.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/local.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -d -r1.79 -r1.80
--- local.c	25 Mar 2007 22:20:53 -0000	1.79
+++ local.c	28 Mar 2007 11:17:57 -0000	1.80
@@ -1488,11 +1488,25 @@
                     ty = (php->ph_y - me->p_y) / SCALE + WINSIDE / 2;
                 }
                 else
-                {               /* Start point is dx, dy */
-                    tx = (players[php->ph_target].p_x - me->p_x) /
-                        SCALE + WINSIDE / 2;
-                    ty = (players[php->ph_target].p_y - me->p_y) /
-                        SCALE + WINSIDE / 2;
+                {
+                    /* Start point is dx, dy.  With short packets, target
+                       dx, dy not sent, and thus can be out of galaxy bounds
+                       in certain cases.  For example, if you die while phasering,
+                       and your target's ship is no longer visible to your team.
+                       Best solution seems to be to not draw the phaser by setting
+                       phaser length to 0. */
+                    if (players[php->ph_target].p_x < 0 || players[php->ph_target].p_y < 0)
+                    {
+                        tx = WINSIDE / 2;
+                        ty = WINSIDE / 2;
+                    }
+                    else
+                    {
+                        tx = (players[php->ph_target].p_x - me->p_x) /
+                            SCALE + WINSIDE / 2;
+                        ty = (players[php->ph_target].p_y - me->p_y) /
+                            SCALE + WINSIDE / 2;
+                    }
                 }
 
 

Index: map.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/map.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- map.c	21 Mar 2007 23:59:50 -0000	1.35
+++ map.c	28 Mar 2007 11:17:58 -0000	1.36
@@ -1120,8 +1120,17 @@
                         ty = ph->ph_y * WINSIDE / GWIDTH;
                         break;
                     default:
-                        tx = players[ph->ph_target].p_x * WINSIDE / GWIDTH;
-                        ty = players[ph->ph_target].p_y * WINSIDE / GWIDTH;
+                        /* Don't draw phasers to ships out of galactic bounds */
+                        if (players[ph->ph_target].p_x < 0 || players[ph->ph_target].p_y < 0)
+                        {
+                            tx = dx;
+                            ty = dy;
+                        }
+                        else
+                        {
+                            tx = players[ph->ph_target].p_x * WINSIDE / GWIDTH;
+                            ty = players[ph->ph_target].p_y * WINSIDE / GWIDTH;
+                        }
                         break;
                 }
                 W_MakeLine(mapw, dx, dy, tx, ty, phaserColor(ph));