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

Modified Files:
	dashboard3.c local.c sound.c 
Log Message:
Some sound bug fixes, also fixed LAB dashboard for observers with armies/kills not being displayed.

Index: local.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/local.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- local.c	26 Apr 2006 02:04:24 -0000	1.9
+++ local.c	26 Apr 2006 15:54:04 -0000	1.10
@@ -512,7 +512,7 @@
                         angle = (int)(atan2(newdy, newdx)*180/XPI);
                         angle = 270 - angle;
                         // At short distances, don't use angular sound
-                        if (distance < 10)
+                        if (distance < SCALE/2)
                             Play_Sound(CLOAKED_WAV);
                         else
                             Play_Sound_Loc(CLOAKED_WAV, angle, distance);
@@ -550,13 +550,15 @@
                         angle = (int)(atan2(newdy, newdx)*180/XPI);
                         angle = 270 - angle;
                         // At short distances, don't use angular sound
-                        if (distance < 10)
+                        if (distance < SCALE/2)
                             Play_Sound(UNCLOAK_WAV);
                         else
                             Play_Sound_Loc(UNCLOAK_WAV, angle, distance);
+      
+                            
                     }
                     else    // Kill any channels with CLOAKED_WAV on them (group 1)
-			Mix_HaltGroup(1);
+		        Mix_HaltGroup(1);
 
                 }
                 else
@@ -771,14 +773,22 @@
                 if ((sound_flags & PFSHIELD) && !(j->p_flags & PFSHIELD))
                 {
                     if (newSound)
-                        Play_Sound(SHIELD_DOWN_WAV);
+                    {
+                        // Kill any channels with SHIELD_UP/DOWN_WAV on them (group 4)
+			Mix_HaltGroup(4);
+		        Play_Sound(SHIELD_DOWN_WAV);
+		    }
                     else
                         Play_Sound(SHIELD_DOWN_SOUND);
                 }
                 if (!(sound_flags & PFSHIELD) && (j->p_flags & PFSHIELD))
                 {
                     if (newSound)
-                        Play_Sound(SHIELD_UP_WAV);
+                    {
+                        // Kill any channels with SHIELD_UP/DOWN_WAV on them (group 4)
+			Mix_HaltGroup(4);
+			Play_Sound(SHIELD_UP_WAV);
+		    }
                     else
                         Play_Sound(SHIELD_UP_SOUND);
                 }
@@ -952,7 +962,7 @@
                         angle = (int)(atan2(newdy, newdx)*180/XPI);
                         angle = 270 - angle;
                         // At short distances, don't use angular sound
-                        if (distance < 10)
+                        if (distance < SCALE/2)
                             Play_Sound(EXPLOSION_OTHER_WAV);
                         else
                             Play_Sound_Loc(EXPLOSION_OTHER_WAV, angle, distance);
@@ -1028,7 +1038,7 @@
                         angle = (int)(atan2(newdy, newdx)*180/XPI);
                         angle = 270 - angle;
                         // At short distances, don't use angular sound
-                        if (distance < 10)
+                        if (distance < SCALE/2)
                             Play_Sound(PHASER_OTHER_WAV);
                         else
                             Play_Sound_Loc(PHASER_OTHER_WAV, angle, distance);
@@ -1531,7 +1541,7 @@
                         angle = (int)(atan2(newdy, newdx)*180/XPI);
                         angle = 270 - angle;
                         // At short distances, don't use angular sound
-                        if (distance < 10)
+                        if (distance < SCALE/2)
                             Play_Sound(TORP_HIT_WAV);
                         else
                             Play_Sound_Loc(TORP_HIT_WAV, angle, distance);
@@ -1777,7 +1787,7 @@
                     angle = (int)(atan2(newdy, newdx)*180/XPI);
                     angle = 270 - angle;
                     // At short distances, don't use angular sound
-                    if (distance < 10)
+                    if (distance < SCALE/2)
                         Play_Sound(PLASMA_HIT_WAV);
                     else
                         Play_Sound_Loc(PLASMA_HIT_WAV, angle, distance);
@@ -2156,7 +2166,7 @@
             Play_Sound(FIRE_TORP_WAV);
         if (sound_other_torps < num_other_torps)
         {
-            if (other_torp_dist < 10)
+            if (other_torp_dist < SCALE/2)
                 Play_Sound(OTHER_FIRE_TORP_WAV);
             else
                 Play_Sound_Loc(OTHER_FIRE_TORP_WAV, other_torp_angle, other_torp_dist);
@@ -2165,7 +2175,7 @@
             Play_Sound(FIRE_PLASMA_WAV);
         if (sound_other_plasmas < num_other_plasmas)
         {
-            if (other_plasma_dist < 10)
+            if (other_plasma_dist < SCALE/2)
                 Play_Sound(OTHER_FIRE_PLASMA_WAV);
             else
                 Play_Sound_Loc(OTHER_FIRE_PLASMA_WAV, other_plasma_angle, other_plasma_dist);

Index: dashboard3.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/dashboard3.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- dashboard3.c	12 Apr 2006 04:20:03 -0000	1.2
+++ dashboard3.c	26 Apr 2006 15:54:04 -0000	1.3
@@ -342,53 +342,32 @@
     static float old_kills = -1;
     int cur_max, cur_arm, label_len;
     char label[32];
-
-
-    if (me->p_ship.s_type == ASSAULT)
-    {
-        cur_arm = (int) (3 * me->p_kills);
-    }
+    float kills; 
+        
+    if ((me->p_flags & (PFPLOCK | PFOBSERV)) == (PFPLOCK | PFOBSERV))
+        kills = players[me->p_playerl].p_kills;
     else
-    {
-        cur_arm = (int) (2 * me->p_kills);
-    }
+        kills = me->p_kills;
 
-    if (cur_arm < 0)
-    {
-        cur_arm = 0;
-    }
-    else if ((cur_arm > me->p_ship.s_maxarmies) ||
-             (me->p_ship.s_type == STARBASE))
-    {
-        cur_arm = me->p_ship.s_maxarmies;
-    }
+    if (fr)
+        W_ClearWindow (tstatw);
 
+    db_flags (fr);
+
+    /* TIMER */
+    db_timer (fr, WINSIDE - 12 * W_Textwidth, 32);
+        
     // SRS - inserted some additional casts to clear up compiler warnings
     cur_max = (int) ((me->p_ship.s_maxspeed + 2) -
                      ((me->p_ship.s_maxspeed + 1) *
                       ((float) me->p_damage /
                        (float) (me->p_ship.s_maxdamage))));
 
-
     if (cur_max < 0)
-    {
         cur_max = 0;
-    }
     else if (cur_max > me->p_ship.s_maxspeed)
-    {
         cur_max = me->p_ship.s_maxspeed;
-    }
-
-    if (fr)
-    {
-        W_ClearWindow (tstatw);
-    }
-
-    db_flags (fr);
-
-    /* TIMER */
-    db_timer (fr, WINSIDE - 12 * W_Textwidth, 32);
-
+    
     if (fr || (me->p_speed != old_spd) || (old_cur_max != cur_max))
     {
         db_bar ("Spd", 2, 2, 75, 25,
@@ -487,7 +466,17 @@
             }
         }
     }
-
+    
+    if (me->p_ship.s_type == ASSAULT)
+        cur_arm = (((kills * 3) > me->p_ship.s_maxarmies) ?
+                   me->p_ship.s_maxarmies : (int) (kills * 3));
+    else if (me->p_ship.s_type == STARBASE)
+        cur_arm = me->p_ship.s_maxarmies;
+    else
+        cur_arm = (((kills * 2) > me->p_ship.s_maxarmies) ?
+                   me->p_ship.s_maxarmies : (int) (kills * 2));
+    
+        
     if (fr || (old_arm != me->p_armies) || (old_cur_arm != cur_arm))
     {
         W_ClearArea (tstatw, 402, 2, 98, W_Textheight);
@@ -524,11 +513,11 @@
         }
     }
 
-    if (fr || (old_kills != me->p_kills))
+    if (fr || (old_kills != kills))
     {
         W_ClearArea (tstatw, 402, 4 + W_Textheight, 98, W_Textheight);
 
-        if (me->p_kills > 0.0)
+        if (kills > 0.0)
         {
             label[0] = ' ';
             label[1] = 'K';
@@ -538,7 +527,7 @@
             label[5] = 's';
             label[6] = ':';
             label[7] = ' ';
-            label_len = 8 + db_ftoa (&label[8], me->p_kills);
+            label_len = 8 + db_ftoa (&label[8], kills);
 
             if (cur_arm > 4)
             {
@@ -560,7 +549,7 @@
             }
         }
 
-        old_kills = me->p_kills;
+        old_kills = kills;
     }
 
     old_spd = me->p_speed;

Index: sound.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/sound.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- sound.c	26 Apr 2006 02:04:24 -0000	1.5
+++ sound.c	26 Apr 2006 15:54:04 -0000	1.6
@@ -215,10 +215,16 @@
 	    return;
 
         if ((type >= NUM_WAVES) || (type < 0))
+        {
             LineToConsole("Invalid sound type %d\n", type);
+            return;
+        }
 
         if ((channel = Mix_PlayChannel(-1, newsounds[type], 0)) < 0)
+        {
             LineToConsole("Mix_PlayChannel: %s\n", Mix_GetError());
+            return;
+        }
             
         Group_Sound(type, channel);
     }
@@ -252,7 +258,10 @@
         return;
 
     if ((type >= NUM_WAVES) || (type < 0))
+    {
         LineToConsole("Invalid sound type %d\n", type);
+        return;
+    }
 
     if ((channel = Mix_PlayChannel(-1, newsounds[type], 0)) < 0)
     {
@@ -266,7 +275,10 @@
     	distance = 255;
     // Adjust volume with distance and angle
     if (Mix_SetPosition(channel, angle, distance) == 0)
+    {
         LineToConsole("Mix_SetPosition: %s\n", Mix_GetError());
+        return;
+    }
         
     Group_Sound(type, channel);
     return;
@@ -280,6 +292,7 @@
     // group 1 = cloaked_wav
     // group 2 = warning_wav
     // group 3 = red_alert_wav
+    // group 4 = shield_down_wav and shield_up_wav
     switch(type)
     {
     	case CLOAKED_WAV:
@@ -294,6 +307,15 @@
             if(!Mix_GroupChannel(channel,3))
                 LineToConsole("Mix_GroupChannel: %s\n", Mix_GetError());
             break;
+        case SHIELD_UP_WAV:
+        case SHIELD_DOWN_WAV:
+            if(!Mix_GroupChannel(channel,4))
+                LineToConsole("Mix_GroupChannel: %s\n", Mix_GetError());
+            break;
+        default: // Reset tag
+            if(!Mix_GroupChannel(channel,-1))
+                LineToConsole("Mix_GroupChannel: %s\n", Mix_GetError());
+            break;
     }
 }