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

Modified Files:
	cowmain.c enter.c local.c short.c socket.c 
Log Message:
Proper solution to longstanding issue of how to handle phaser sounds.  New variable in struct phaser
that toggles on when phaser packet is received, to indicate that phaser needs to have the sound played.
Prior methods of phaser sounds had issues with cloakers, observers, etc.

Index: cowmain.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/cowmain.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- cowmain.c	1 Feb 2007 00:10:28 -0000	1.21
+++ cowmain.c	25 Feb 2007 00:19:00 -0000	1.22
@@ -1073,7 +1073,7 @@
         /* `=' style update to get the kills in the playerlist right */
         sendUdpReq (COMM_UPDATE);
 #endif
-        /* Send request for updatesPerSec.  New servers now support 10 u/s */
+        /* Send request for updatesPerSec.  New servers now support 50 u/s */
         sendUpdatePacket (1000000 / updatesPerSec);
 
         isFirstEntry = 0;

Index: local.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/local.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- local.c	24 Feb 2007 10:19:55 -0000	1.57
+++ local.c	25 Feb 2007 00:19:00 -0000	1.58
@@ -37,8 +37,6 @@
 #endif
 static int planet_frame = 0;
 #ifdef SOUND
-static int sound_phaser = 0;
-static int sound_other_phaser = 0;
 static int sound_torps = 0;
 static int sound_other_torps = 0;
 static int num_other_torps = 0;
@@ -1249,17 +1247,9 @@
             }
 #endif
 
-            /* When cloaked, stop here.  But need to reset the sound_phaser counter
-               to 0, otherwise other people's phaser sounds don't play while you are
-               cloaked.  Not necessary to check against phaser PHFREE status.*/
+            /* When cloaked, stop here. */
             if (j->p_flags & PFCLOAK)
-            {
-#ifdef SOUND
-                if (myPlayer(j) || isObsLockPlayer(j))
-                    sound_phaser = 0;
-#endif
                 continue;
-            }
 
             {
                 int color = playerColor (j);
@@ -1437,7 +1427,7 @@
         {
 
 #ifdef SOUND
-            if (!sound_phaser)
+            if (php->sound_phaser)
             {           
                 if (newSound)
                 {
@@ -1474,7 +1464,7 @@
                     Play_Sound((myPlayer(j) || isObsLockPlayer(j))
                                ? PHASER_SOUND : OTHER_PHASER_SOUND);
                 
-                sound_phaser++;
+                php->sound_phaser = 0;
             }
 #endif
 
@@ -1482,6 +1472,9 @@
             {
                 /* Expire the phaser */
                 php->ph_status = PHFREE;
+#ifdef SOUND
+                php->sound_phaser = 0;
+#endif
             }
             else
             {
@@ -1699,11 +1692,6 @@
             }
         }
 
-#ifdef SOUND
-        else if (myPlayer(j) || isObsLockPlayer(j))
-            sound_phaser = 0;
-#endif
-
         /* ATM - show tractor/pressor beams (modified by James Collins) */
         /* showTractorPressor is a variable set by xtrekrc. */
 

Index: enter.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/enter.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- enter.c	21 Feb 2007 15:17:06 -0000	1.4
+++ enter.c	25 Feb 2007 00:19:00 -0000	1.5
@@ -78,7 +78,12 @@
         torps[i].t_owner = (short) (i / MAXTORP);
     }
     for (i = 0; i < MAXPLAYER; i++)
+    {
         phasers[i].ph_status = PHFREE;
+#ifdef SOUND
+        phasers[i].sound_phaser = 0;
+#endif
+    }
 
     for (i = 0; i < MAXPLAYER * MAXPLASMA; i++)
     {

Index: short.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/short.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- short.c	23 Feb 2007 13:43:57 -0000	1.13
+++ short.c	25 Feb 2007 00:19:00 -0000	1.14
@@ -2003,8 +2003,12 @@
     phas->ph_y = y;
     phas->ph_target = (short) target;
     phas->ph_fuse = 0;
+#ifdef SOUND
+    phas->sound_phaser = 1;
+#endif
+    /* normalized fuses */
     phas->ph_updateFuse = PHASER_UPDATE_FUSE * server_ups / 10;
-    phas->ph_maxfuse = (players[pnum].p_ship.s_phaserfuse * updatesPerSec) / 10;
+    phas->ph_maxfuse = (players[pnum].p_ship.s_phaserfuse * server_ups) / 10;
 
 #ifdef ROTATERACE
     if (rotate)

Index: socket.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/socket.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- socket.c	23 Feb 2007 13:43:57 -0000	1.17
+++ socket.c	25 Feb 2007 00:19:00 -0000	1.18
@@ -1607,10 +1607,13 @@
     phas->ph_x = ntohl (packet->x);
     phas->ph_y = ntohl (packet->y);
     phas->ph_target = (short) (ntohl (packet->target));
-    phas->ph_fuse = 0;          /* NEW */
+    phas->ph_fuse = 0;
+#ifdef SOUND
+    phas->sound_phaser = 1;
+#endif
+    /* normalized fuses */
     phas->ph_updateFuse = PHASER_UPDATE_FUSE * server_ups / 10;
-    /* normalized maxfuse */
-    phas->ph_maxfuse = (players[packet->pnum].p_ship.s_phaserfuse * updatesPerSec) / 10;
+    phas->ph_maxfuse = (players[packet->pnum].p_ship.s_phaserfuse * server_ups) / 10;
 
 #ifdef ROTATERACE
     if (rotate)