Prevent loading already loaded sounds
authorunC0Rr
Wed, 28 Aug 2019 15:59:36 +0200
changeset 15379 f3ad47f4f245
parent 15378 5e2b9740086f
child 15380 37b632d38f14
Prevent loading already loaded sounds
hedgewars/uSound.pas
--- a/hedgewars/uSound.pas	Wed Aug 28 13:20:10 2019 +0300
+++ b/hedgewars/uSound.pas	Wed Aug 28 15:59:36 2019 +0200
@@ -574,7 +574,7 @@
 
 function PlaySoundV(snd: TSound; voicepack: PVoicepack; keepPlaying, ignoreMask, soundAsMusic: boolean): boolean;
 var s: shortstring;
-tempSnd: TSound;
+tempSnd, loadSnd: TSound;
 rwops: PSDL_RWops;
 begin
     PlaySoundV:= false;
@@ -591,24 +591,26 @@
         begin
         if (voicepack^.chunks[snd] = nil) and (Soundz[snd].Path = ptVoices) and (Soundz[snd].FileName <> '') then
             begin
-            s:= cPathz[Soundz[snd].Path] + '/' + voicepack^.name + '/' + Soundz[snd].FileName;
+            loadSnd:= snd;
+            s:= cPathz[Soundz[loadSnd].Path] + '/' + voicepack^.name + '/' + Soundz[loadSnd].FileName;
+
             // Fallback taunts
             if (not pfsExists(s)) then
                 begin
                 tempSnd := GetFallbackV(snd);
                 if tempSnd <> sndNone then
                     begin
-                    snd := tempSnd;
-                    LastVoice.snd := tempSnd;
+                    loadSnd := tempSnd;
+                    //LastVoice.snd := tempSnd;
                     end;
-                s:= cPathz[Soundz[snd].Path] + '/' + voicepack^.name + '/' + Soundz[snd].FileName;
+                s:= cPathz[Soundz[loadSnd].Path] + '/' + voicepack^.name + '/' + Soundz[loadSnd].FileName;
                 end;
-            WriteToConsole(msgLoading + s + ' ');
+            WriteToConsole(msgLoading + s + ' ... ');
             rwops := rwopsOpenRead(s);
 
             if rwops = nil then
                 begin
-                s:= cPathz[Soundz[snd].AltPath] + '/' + Soundz[snd].FileName;
+                s:= cPathz[Soundz[loadSnd].AltPath] + '/' + Soundz[loadSnd].FileName;
                 WriteToConsole(msgLoading + s + ' ... ');
                 rwops := rwopsOpenRead(s);
                 end;
@@ -627,7 +629,7 @@
         if (defVoicepack^.chunks[snd] = nil) and (Soundz[snd].Path <> ptVoices) and (Soundz[snd].FileName <> '') then
             begin
             s:= cPathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName;
-            WriteToConsole(msgLoading + s + ' ');
+            WriteToConsole(msgLoading + s + ' ... ');
             rwops := rwopsOpenRead(s);
 
             if rwops = nil then