hedgewars/uSound.pas
changeset 351 29bc9c36ad5f
parent 287 b0eef98928f8
child 355 40c68869899e
--- a/hedgewars/uSound.pas	Thu Jan 18 20:29:28 2007 +0000
+++ b/hedgewars/uSound.pas	Sun Jan 21 19:51:02 2007 +0000
@@ -24,7 +24,7 @@
 procedure InitSound;
 procedure ReleaseSound;
 procedure SoundLoad;
-procedure PlaySound(snd: TSound; const infinite: boolean = false);
+procedure PlaySound(snd: TSound; infinite: boolean);
 procedure PlayMusic;
 procedure StopSound(snd: TSound);
 function  ChangeVolume(voldelta: integer): integer;
@@ -63,26 +63,26 @@
 
 procedure SoundLoad;
 var i: TSound;
-    s: string;
+    s: array[byte] of char;
 begin
 if not isSoundEnabled then exit;
 for i:= Low(TSound) to High(TSound) do
     begin
     s:= Pathz[Soundz[i].Path] + '/' + Soundz[i].FileName;
-    WriteToConsole(msgLoading + s + ' ');
-    Soundz[i].id:= Mix_LoadWAV_RW(SDL_RWFromFile(PChar(s), 'rb'), 1);
+    WriteToConsole(msgLoading + string(s) + ' ');
+    Soundz[i].id:= Mix_LoadWAV_RW(SDL_RWFromFile(@s, 'rb'), 1);
     TryDo(Soundz[i].id <> nil, msgFailed, true);
     WriteLnToConsole(msgOK);
     end;
 
 s:= PathPrefix + '/Music/kahvi140a_alexander_chereshnev-illusion.ogg';
-WriteToConsole(msgLoading + s + ' ');
-Mus:= Mix_LoadMUS(PChar(s));
+WriteToConsole(msgLoading + string(s) + ' ');
+Mus:= Mix_LoadMUS(@s);
 TryDo(Mus <> nil, msgFailed, false);
 WriteLnToConsole(msgOK)
 end;
 
-procedure PlaySound(snd: TSound; const infinite: boolean = false);
+procedure PlaySound(snd: TSound; infinite: boolean);
 var loops: integer;
 begin
 if not isSoundEnabled then exit;
@@ -107,16 +107,14 @@
 function ChangeVolume(voldelta: integer): integer;
 begin
 if not isSoundEnabled then
-   begin
-   Result:= 0;
-   exit
-   end;
+   exit(0);
+
 inc(Volume, voldelta);
 if Volume < 0 then Volume:= 0;
 Mix_Volume(-1, Volume);
 Volume:= Mix_Volume(-1, -1);
 Mix_VolumeMusic(Volume * 3 div 8);
-Result:= Volume * 100 div MIX_MAX_VOLUME
+ChangeVolume:= Volume * 100 div MIX_MAX_VOLUME
 end;
 
 end.