DEADSOFTWARE

can load non-looping music; fixed looping ROUNDMUS
[d2df-sdl.git] / src / game / g_sound.pas
index a3ef547a60254c6e46fba00506768e11e5e0f4cd..094df0f80756b710312f6c19dfdb4b1aec05e99c 100644 (file)
@@ -1,4 +1,4 @@
-(* Copyright (C)  DooM 2D:Forever Developers
+(* Copyright (C)  Doom 2D: Forever Developers
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *)
-{$INCLUDE g_amodes.inc}
+{$INCLUDE ../shared/a_modes.inc}
 unit g_sound;
 
 interface
@@ -71,9 +71,9 @@ function g_Sound_PlayAt(ID: DWORD; X, Y: Integer): Boolean;
 function g_Sound_PlayExAt(SoundName: ShortString; X, Y: Integer): Boolean;
 
 function g_Sound_CreateWAD(var ID: DWORD; Resource: string; isMusic: Boolean = False): Boolean;
-function g_Sound_CreateWADEx(SoundName: ShortString; Resource: string; isMusic: Boolean = False): Boolean;
+function g_Sound_CreateWADEx(SoundName: ShortString; Resource: string; isMusic: Boolean = False; ForceNoLoop: Boolean = False): Boolean;
 function g_Sound_CreateFile(var ID: DWORD; FileName: string; isMusic: Boolean = False): Boolean;
-function g_Sound_CreateFileEx(SoundName: ShortString; FileName: string; isMusic: Boolean = False): Boolean;
+function g_Sound_CreateFileEx(SoundName: ShortString; FileName: string; isMusic: Boolean = False; ForceNoLoop: Boolean = False): Boolean;
 
 procedure g_Sound_Delete(SoundName: ShortString);
 function g_Sound_Exists(SoundName: string): Boolean;
@@ -139,7 +139,7 @@ begin
       Exit;
     end;
 
-  e_WriteLog(Format(_lc[I_GAME_ERROR_SOUND], [SoundName]), MSG_WARNING);
+  e_WriteLog(Format(_lc[I_GAME_ERROR_SOUND], [SoundName]), TMsgType.Warning);
 end;
 
 function g_Sound_PlayExPanVolume(SoundName: ShortString; Pan: Single; Volume: Single): Boolean;
@@ -157,7 +157,7 @@ begin
       Exit;
     end;
 
-  e_WriteLog(Format(_lc[I_GAME_ERROR_SOUND], [SoundName]), MSG_WARNING);
+  e_WriteLog(Format(_lc[I_GAME_ERROR_SOUND], [SoundName]), TMsgType.Warning);
 end;
 
 function PlaySoundAt(X, Y: Integer; var Pan: Single; var Volume: Single; InVolume: Single = 1.0): Boolean;
@@ -268,7 +268,7 @@ begin
       Exit;
     end;
 
-  e_WriteLog(Format(_lc[I_GAME_ERROR_SOUND], [SoundName]), MSG_WARNING);
+  e_WriteLog(Format(_lc[I_GAME_ERROR_SOUND], [SoundName]), TMsgType.Warning);
 end;
 
 function g_Sound_CreateFile(var ID: DWORD; FileName: string; isMusic: Boolean = False): Boolean;
@@ -276,7 +276,7 @@ begin
   Result := e_LoadSound(FileName, ID, isMusic);
 end;
 
-function g_Sound_CreateFileEx(SoundName: ShortString; FileName: string; isMusic: Boolean = False): Boolean;
+function g_Sound_CreateFileEx(SoundName: ShortString; FileName: string; isMusic: Boolean = False; ForceNoLoop: Boolean = False): Boolean;
 var
   find_id: DWORD;
 begin
@@ -284,7 +284,7 @@ begin
 
   find_id := FindSound();
 
-  if not e_LoadSound(FileName, SoundArray[find_id].ID, isMusic) then
+  if not e_LoadSound(FileName, SoundArray[find_id].ID, isMusic, ForceNoLoop) then
     Exit;
 
   SoundArray[find_id].Name := SoundName;
@@ -327,16 +327,16 @@ begin
   begin
 {$IFNDEF HEADLESS}
     if isMusic then
-      e_WriteLog(Format('Error loading music %s', [Resource]), MSG_WARNING)
+      e_WriteLog(Format('Error loading music %s', [Resource]), TMsgType.Warning)
     else
-      e_WriteLog(Format('Error loading sound %s', [Resource]), MSG_WARNING);
+      e_WriteLog(Format('Error loading sound %s', [Resource]), TMsgType.Warning);
     Exit;
 {$ENDIF}
   end;
   Result := True;
 end;
 
-function g_Sound_CreateWADEx(SoundName: ShortString; Resource: string; isMusic: Boolean = False): Boolean;
+function g_Sound_CreateWADEx(SoundName: ShortString; Resource: string; isMusic: Boolean = False; ForceNoLoop: Boolean = False): Boolean;
 var
   WAD: TWADFile;
   FileName: string;
@@ -358,7 +358,7 @@ begin
 
   if WAD.GetResource(g_ExtractFilePathName(Resource), SoundData, ResLength) then
     begin
-      if e_LoadSoundMem(SoundData, ResLength, SoundArray[find_id].ID, isMusic) then
+      if e_LoadSoundMem(SoundData, ResLength, SoundArray[find_id].ID, isMusic, ForceNoLoop) then
         begin
           SoundArray[find_id].Name := SoundName;
           SoundArray[find_id].IsMusic := isMusic;
@@ -377,9 +377,9 @@ begin
   begin
 {$IFNDEF HEADLESS}
     if isMusic then
-      e_WriteLog(Format('Error loading music %s', [Resource]), MSG_WARNING)
+      e_WriteLog(Format('Error loading music %s', [Resource]), TMsgType.Warning)
     else
-      e_WriteLog(Format('Error loading sound %s', [Resource]), MSG_WARNING);
+      e_WriteLog(Format('Error loading sound %s', [Resource]), TMsgType.Warning);
     Exit;
 {$ENDIF}
   end;