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

Modified Files:
	data.c defaults.c feature.c local.c map.c option.c short.c 
	socket.c 
Log Message:
Added new entries to torp and plasma struct, t_clear and pt_clear, to mark an
exploding plasma or torp as needing to be freed once its explosion cycle is
over.  Covers the case where a torp explodes, but the free packet is lost.
Previously, the torp would never clear until it was no longer in the local
map range.
If weaponsOnMap option is on, internal timer to determine when it's safe to
expire weapons is moved to map draw routine.  Fixes problem where
observers who are not locked onto anyone but still getting weapons drawn
on map would have problems with weapons (like phasers) not expiring
correctly due to packet loss enemy torps which are off local screen are no
longer automatically freed (since this data is now sent for observers).  Also
changed exploding torps to use the time of explosion cycle rather than an
arbitrary timer of 100 for expiry.
Added support for SHOW_CLOAKERS feature packet.
New netrekrc option "showCloakers: (on)/off" to show other cloakers on
tactical, only works if server has the new feature packet SHOW_CLOAKERS
on.

Index: map.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/map.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- map.c	3 Apr 2007 00:36:32 -0000	1.39
+++ map.c	4 Apr 2007 04:06:38 -0000	1.40
@@ -1116,7 +1116,7 @@
         }
     }
 
-    /* Draw weapons */
+    /* Draw (and expire) weapons */
     if (weaponsOnMap)
     {
         register int h;
@@ -1135,6 +1135,17 @@
             
             /* phasers */
             ph = &phasers[j->p_no];
+
+            if ((ph->ph_updateFuse -= weaponUpdate) == 0)
+            {
+                /* Expire the phaser */
+                ph->ph_status = PHFREE;
+#ifdef SOUND
+                ph->sound_phaser = 0;
+#endif
+                ph->ph_fuse = 0;
+            }
+
             if (ph->ph_status != PHFREE &&
                (j->p_status == PALIVE || j->p_status == PEXPLODE || j->p_status == PDEAD) &&
                !(j->p_x < 0 || j->p_x > GWIDTH))
@@ -1187,6 +1198,30 @@
                     continue;
                 if (k->t_x < 0 || k->t_y < 0)
                     continue;
+
+                /* Age a torp only if some weapon has been updated
+                 * (eg this is not a pause). */
+                if ((k->t_updateFuse -= weaponUpdate) == 0)
+                {
+                    if (k->t_status != TEXPLODE || k->t_clear == 1)
+                    {
+                        /* Expire the torp */
+#if 0
+                        fputs ("[torp]", stderr);
+                        fflush (stderr);
+#endif
+                        k->t_status = TFREE;
+                        j->p_ntorp--;
+                        continue;
+                    }
+                    else
+                    {
+                        /* Leave the torp to explode on its own */
+                        k->t_updateFuse = BMP_TORPDET_FRAMES * server_ups / 10;
+                        k->t_clear = 1;
+                    }
+                }
+
                 dx = k->t_x * WINSIDE / GWIDTH;
                 dy = k->t_y * WINSIDE / GWIDTH;
 
@@ -1220,6 +1255,28 @@
                     continue;
                 if (pt->pt_x < 0 || pt->pt_y < 0)
                     continue;
+                    
+                if ((pt->pt_updateFuse -= weaponUpdate) == 0)
+                {
+                    if (pt->pt_status != PTEXPLODE || pt->pt_clear == 1)
+                    {
+                        /* Expire the plasma */
+#if 0
+                        fputs ("[plasma]", stderr);
+                        fflush (stderr);
+#endif
+                        pt->pt_status = PTFREE;
+                        players[pt->pt_owner].p_nplasmatorp--;
+                        continue;
+                    }
+                    else
+                    {
+                        /* Leave the plasma to explode on its own */
+                        pt->pt_updateFuse = BMP_TORPDET_FRAMES * server_ups / 10;
+                        pt->pt_clear = 1;
+                    }
+                }
+
                 dx = pt->pt_x * WINSIDE / GWIDTH;
                 dy = pt->pt_y * WINSIDE / GWIDTH;
 
@@ -1251,6 +1308,8 @@
             }
         }
     }
+    /* Reset weapon update marker */
+    weaponUpdate = 0;
 
     /* Draw the lock symbol (if needed) */
 

Index: local.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/local.c,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -d -r1.84 -r1.85
--- local.c	3 Apr 2007 00:36:32 -0000	1.84
+++ local.c	4 Apr 2007 04:06:37 -0000	1.85
@@ -794,7 +794,7 @@
            the ship drawing code with the goto statement */
         if (j->p_flags & PFCLOAK && (j->p_cloakphase == (cloak_phases - 1)))
         {
-            if (myPlayer (j)
+            if (myPlayer (j) || (showCloakers && F_show_cloakers)
 #ifdef RECORDGAME
                 || playback
 #endif
@@ -1478,14 +1478,17 @@
             }
 #endif
 
-            if ((php->ph_updateFuse -= weaponUpdate) == 0)
+            if (!weaponsOnMap)
             {
-                /* Expire the phaser */
-                php->ph_status = PHFREE;
+                if ((php->ph_updateFuse -= weaponUpdate) == 0)
+                {
+                    /* Expire the phaser */
+                    php->ph_status = PHFREE;
 #ifdef SOUND
-                php->sound_phaser = 0;
+                    php->sound_phaser = 0;
 #endif
-                php->ph_fuse = 0;
+                    php->ph_fuse = 0;
+                }
             }
             else
             {
@@ -1856,26 +1859,29 @@
             --torpCount;
 
 
-            /* Age a torp only if some weapon has been updated
-             * (eg this is not a pause). */
-            if ((k->t_updateFuse -= weaponUpdate) == 0)
+            if (!weaponsOnMap)
             {
-                if (k->t_status != TEXPLODE)
+                /* Age a torp only if some weapon has been updated
+                 * (eg this is not a pause). */
+                if ((k->t_updateFuse -= weaponUpdate) == 0)
                 {
-                    /* Expire the torp */
+                    if (k->t_status != TEXPLODE || k->t_clear == 1)
+                    {
+                        /* Expire the torp */
 #if 0
-                    fputs ("[torp]", stderr);
-                    fflush (stderr);
+                        fputs ("[torp]", stderr);
+                        fflush (stderr);
 #endif
-                    k->t_status = TFREE;
-                    j->p_ntorp--;
-                    continue;
-                }
-                else
-                {
-                    /* Leave the torp to explode on its own */
-
-                    k->t_updateFuse = 100;
+                        k->t_status = TFREE;
+                        j->p_ntorp--;
+                        continue;
+                    }
+                    else
+                    {
+                        /* Leave the torp to explode on its own */
+                        k->t_updateFuse = BMP_TORPDET_FRAMES * server_ups / 10;
+                        k->t_clear = 1;
+                    }
                 }
             }
 
@@ -1883,15 +1889,7 @@
             dy = k->t_y - me->p_y;
 
             if (dx > view || dx < -view || dy > view || dy < -view)
-            {
-                /* Call any torps off screen "free" (if owned by other) */
-                if (k->t_status == TEXPLODE && j != me)
-                {
-                    k->t_status = TFREE;
-                    j->p_ntorp--;
-                }
                 continue;
-            }
 
             dx = dx / SCALE + WINSIDE / 2;
             dy = dy / SCALE + WINSIDE / 2;
@@ -2091,24 +2089,27 @@
         if (pt->pt_owner != me->p_no)
             num_other_plasmas++;
 #endif
-        if ((pt->pt_updateFuse -= weaponUpdate) == 0)
+        if (!weaponsOnMap)
         {
-            if (pt->pt_status != PTEXPLODE)
+            if ((pt->pt_updateFuse -= weaponUpdate) == 0)
             {
-                /* Expire the torp */
-#ifdef DEBUG
-                fputs ("[plasma]", stderr);
-                fflush (stderr);
+                if (pt->pt_status != PTEXPLODE || pt->pt_clear == 1)
+                {
+                    /* Expire the plasma */
+#if 0
+                    fputs ("[plasma]", stderr);
+                    fflush (stderr);
 #endif
-                pt->pt_status = PTFREE;
-                players[pt->pt_owner].p_nplasmatorp--;
-                continue;
-            }
-            else
-            {
-                /* Leave the torp to explode on its own */
-
-                pt->pt_updateFuse = 100;
+                    pt->pt_status = PTFREE;
+                    players[pt->pt_owner].p_nplasmatorp--;
+                    continue;
+                }
+                else
+                {
+                    /* Leave the plasma to explode on its own */
+                    pt->pt_updateFuse = BMP_TORPDET_FRAMES * server_ups / 10;
+                    pt->pt_clear = 1;
+                }
             }
         }
 
@@ -2138,7 +2139,6 @@
         if (pt->pt_status == PTEXPLODE)
         {
             pt->pt_fuse--;
-
             frame = pt->pt_fuse * 10 / server_ups;
 
             if (pt->pt_fuse <= 0)
@@ -2662,7 +2662,8 @@
     DrawTorps ();
     DrawPlasmaTorps ();
 
-    weaponUpdate = 0;
+    if (!weaponsOnMap)
+        weaponUpdate = 0;
     DrawMisc ();
 
 #ifdef RECORDGAME

Index: short.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/short.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- short.c	3 Apr 2007 00:36:32 -0000	1.19
+++ short.c	4 Apr 2007 04:06:38 -0000	1.20
@@ -275,6 +275,7 @@
         /* Updatefuse requires minimum value of 2 to ensure a redraw, updateFuse decremented
         before drawing torp in local.c */
         thetorp->t_updateFuse = MAX(2, TORP_UPDATE_FUSE * server_ups / 10);
+        thetorp->t_clear = 0;
 
         if (bitset & 01)
         {
@@ -1002,6 +1003,7 @@
     	/* Updatefuse requires minimum value of 2 to ensure a redraw, updateFuse decremented
         before drawing torp in local.c */
         thetorp->t_updateFuse = MAX(2, TORP_UPDATE_FUSE * server_ups / 10);
+        thetorp->t_clear = 0;
 
         if (*bitset & 01)
         {

Index: socket.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/socket.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- socket.c	3 Apr 2007 00:36:32 -0000	1.25
+++ socket.c	4 Apr 2007 04:06:38 -0000	1.26
@@ -1213,6 +1213,7 @@
     /* Updatefuse requires minimum value of 2 to ensure a redraw, updateFuse decremented
        before drawing torp in local.c */
     thetorp->t_updateFuse = MAX(2, TORP_UPDATE_FUSE * server_ups / 10);
+    thetorp->t_clear = 0;
 
 
 #ifdef ROTATERACE
@@ -1243,6 +1244,7 @@
     /* Updatefuse requires minimum value of 2 to ensure a redraw, updateFuse decremented
        before drawing torp in local.c */
     thetorp->t_updateFuse = MAX(2, TORP_UPDATE_FUSE * server_ups / 10);
+    thetorp->t_clear = 0;
 
     if (packet->status == TEXPLODE && thetorp->t_status == TFREE)
     {
@@ -1878,6 +1880,7 @@
     /* Updatefuse requires minimum value of 2 to ensure a redraw, updateFuse decremented
        before drawing torp in local.c */
     thetorp->pt_updateFuse = MAX(2, PLASMA_UPDATE_FUSE * server_ups / 10);
+    thetorp->pt_clear = 0;
     if (packet->status == PTEXPLODE && thetorp->pt_status == PTFREE)
     {
         /* FAT: redundant explosion; don't update p_nplasmatorp */
@@ -1925,6 +1928,7 @@
     /* Updatefuse requires minimum value of 2 to ensure a redraw, updateFuse decremented
        before drawing torp in local.c */
     thetorp->pt_updateFuse = MAX(2, PLASMA_UPDATE_FUSE * server_ups / 10);
+    thetorp->pt_clear = 0;
 
 #ifdef ROTATERACE
     if (rotate)

Index: data.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/data.c,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -d -r1.75 -r1.76
--- data.c	3 Apr 2007 00:36:32 -0000	1.75
+++ data.c	4 Apr 2007 04:06:37 -0000	1.76
@@ -57,6 +57,7 @@
 int showdetCircle = 0;          /* Det circle toggles on only when det is hit */
 int puckCircle = 0;             /* Show maximum puck shooting distance on tactical */
 int showArmy = 1;               /* Show army count of planet you are orbiting */
+int showCloakers = 1;           /* Show cloakers on tactical */
 int fastQuit = 0;
 int gen_distress = 0;           /* generic distress/macro
                                  * system support */
@@ -682,6 +683,7 @@
 int F_full_weapon_resolution = 0;
 int F_show_army_count = 0;
 int F_show_other_speed = 0;
+int F_show_cloakers = 0;
 
 #ifdef RECORDGAME
 int F_many_self = 0;

Index: feature.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/feature.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- feature.c	3 Apr 2007 00:36:32 -0000	1.11
+++ feature.c	4 Apr 2007 04:06:37 -0000	1.12
@@ -95,6 +95,7 @@
     {"SHOW_ALL_TRACTORS", &F_show_all_tractors, 'S', 1, 0, 0},
     {"SHOW_ARMY_COUNT", &F_show_army_count, 'S', 1, 0, 0},
     {"SHOW_OTHER_SPEED", &F_show_other_speed, 'S', 1, 0, 0},
+    {"SHOW_CLOAKERS", &F_show_cloakers, 'S', 1, 0, 0},
     {0, 0, 0, 0, 0, 0}
 };
 

Index: option.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/option.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- option.c	3 Apr 2007 00:36:32 -0000	1.43
+++ option.c	4 Apr 2007 04:06:38 -0000	1.44
@@ -279,6 +279,7 @@
     {1, "use warning hull", &vary_hull, 0, 0, 0, NULL, NULL},
     {1, "show my speed on local", &showMySpeed, 0, 0, 0, NULL, NULL},
     {1, "show other's speed on local", &showOtherSpeed, 0, 0, 0, NULL, NULL},
+    {1, "show cloakers on local", &showCloakers, 0, 0, 0, NULL, NULL},
     {1, "show tractor/pressor beams", &showTractorPressor, 0, 0, 0, NULL, NULL},
     {1, "show tractors after lock", &continueTractor, 0, 0, 0, NULL, NULL},
     {1, "show tractor target ID", &tractorID, 0, 0, 0, NULL, NULL},

Index: defaults.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/defaults.c,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -d -r1.66 -r1.67
--- defaults.c	3 Apr 2007 00:36:32 -0000	1.66
+++ defaults.c	4 Apr 2007 04:06:37 -0000	1.67
@@ -630,6 +630,13 @@
             NULL
         }
     },
+    {"showCloakers", &showCloakers, RC_BOOL, 
+        {
+            "Show other cloakers on local",
+            "Server god decides whether to enable it on server",
+            NULL
+        }
+    },
     {"showHints", &showHints, RC_BOOL,
         {
             "Show hints window",
@@ -1704,6 +1711,7 @@
     puckCircle = booleanDefault ("puckCircle", puckCircle);
     puckArrow = booleanDefault ("puckArrow", puckArrow);
     showArmy = intDefault ("showArmy", showArmy);
+    showCloakers = booleanDefault ("showCloakers", showCloakers);
     redrawDelay = intDefault ("redrawDelay", redrawDelay);
     planetHighlighting = booleanDefault ("planetHighlighting", planetHighlighting);
     rotatePlanets = booleanDefault ("rotatePlanets", rotatePlanets);