]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
handle the case that a sound cannot start
authorRudolf Polzer <divverent@alientrap.org>
Thu, 6 May 2010 07:17:40 +0000 (09:17 +0200)
committerRudolf Polzer <divverent@alientrap.org>
Thu, 6 May 2010 07:17:40 +0000 (09:17 +0200)
qcsrc/client/target_music.qc
qcsrc/server/g_world.qc
qcsrc/server/target_music.qc

index 03cedcd81085e1f25a713c89b3986d913a882ad7..0d8b1062660862ad4537bac496bfd23dfc5c1dec 100644 (file)
@@ -14,7 +14,7 @@ void TargetMusic_Advance()
                best = music_target;
        if(music_trigger)
                best = music_trigger;
                best = music_target;
        if(music_trigger)
                best = music_trigger;
-       for(e = world; (e = findfloat(e, enttype, ENT_CLIENT_TRIGGER_MUSIC)); )
+       for(e = world; (e = findfloat(e, enttype, ENT_CLIENT_TRIGGER_MUSIC)); ) if(e.noise)
        {
                s0 = e.state;
                if(getsoundtime(e, CHAN_VOICE) < 0)
        {
                s0 = e.state;
                if(getsoundtime(e, CHAN_VOICE) < 0)
@@ -79,6 +79,12 @@ void Net_TargetMusic()
        {
                precache_sound(e.noise);
                sound(e, CHAN_VOICE, e.noise, 0, ATTN_NONE);
        {
                precache_sound(e.noise);
                sound(e, CHAN_VOICE, e.noise, 0, ATTN_NONE);
+               if(getsoundtime(e, CHAN_VOICE) < 0)
+               {
+                       print("Cannot initialize sound ", e.noise, "\n");
+                       strunzone(e.noise);
+                       e.noise = string_null;
+               }
        }
        e.volume = vol;
        e.fade_time = fai;
        }
        e.volume = vol;
        e.fade_time = fai;
@@ -155,6 +161,12 @@ void Ent_ReadTriggerMusic()
                {
                        precache_sound(self.noise);
                        sound(self, CHAN_VOICE, self.noise, 0, ATTN_NONE);
                {
                        precache_sound(self.noise);
                        sound(self, CHAN_VOICE, self.noise, 0, ATTN_NONE);
+                       if(getsoundtime(self, CHAN_VOICE) < 0)
+                       {
+                               print("Cannot initialize sound ", self.noise, "\n");
+                               strunzone(self.noise);
+                               self.noise = string_null;
+                       }
                }
        }
 
                }
        }
 
index 228782748d2aa6fd160719863791434b2fae502e..c815b0815a8539690c0c882f2b0e9b5a7663e6f5 100644 (file)
@@ -2697,6 +2697,7 @@ float RedirectionThink()
        return TRUE;
 }
 
        return TRUE;
 }
 
+void TargetMusic_RestoreGame();
 void RestoreGame()
 {
        // Loaded from a save game
 void RestoreGame()
 {
        // Loaded from a save game
@@ -2710,6 +2711,8 @@ void RestoreGame()
        MapInfo_Enumerate();
        MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 1);
        WeaponStats_Init();
        MapInfo_Enumerate();
        MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 1);
        WeaponStats_Init();
+
+       TargetMusic_RestoreGame();
 }
 
 void SV_Shutdown()
 }
 
 void SV_Shutdown()
index 75f77acf53b77beb9e0fc9274dcabec0f8c3307c..daab6469981c021bf8224e4bf5816a9705876d08 100644 (file)
@@ -42,6 +42,16 @@ void spawnfunc_target_music()
        else
                target_music_sendto(MSG_INIT, 0);
 }
        else
                target_music_sendto(MSG_INIT, 0);
 }
+void TargetMusic_RestoreGame()
+{
+       for(self = world; (self = find(self, classname, "target_music")); )
+       {
+               if(self.targetname == "")
+                       target_music_sendto(MSG_INIT, 1);
+               else
+                       target_music_sendto(MSG_INIT, 0);
+       }
+}
 // values:
 //   volume
 //   noise
 // values:
 //   volume
 //   noise