DEADSOFTWARE

added libsocket and updated watt32, but network still not work
[d2df-sdl.git] / src / game / g_sound.pas
index 0632efdfe9904859d6accc8222abd3e3e1e28363..ad514c197fdea6e31142abb975bf88d571a4ef54 100644 (file)
@@ -1,4 +1,19 @@
-{$MODE DELPHI}
+(* 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * 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 ../shared/a_modes.inc}
 unit g_sound;
 
 interface
@@ -124,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;
@@ -142,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;
@@ -253,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;
@@ -281,9 +296,7 @@ end;
 function g_Sound_CreateWAD(var ID: DWORD; Resource: string; isMusic: Boolean = False): Boolean;
 var
   WAD: TWADFile;
-  FileName,
-  SectionName,
-  ResourceName: string;
+  FileName: string;
   SoundData: Pointer;
   ResLength: Integer;
   ok: Boolean;
@@ -292,12 +305,12 @@ begin
   ok := False;
 
   // e_WriteLog('Loading sound: ' + Resource, MSG_NOTIFY);
-  g_ProcessResourceStr(Resource, FileName, SectionName, ResourceName);
+  FileName := g_ExtractWadName(Resource);
 
   WAD := TWADFile.Create();
   WAD.ReadFile(FileName);
 
-  if WAD.GetResource(SectionName, ResourceName, SoundData, ResLength) then
+  if WAD.GetResource(g_ExtractFilePathName(Resource), SoundData, ResLength) then
     begin
       if e_LoadSoundMem(SoundData, ResLength, ID, isMusic) then
         ok := True
@@ -314,9 +327,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;
@@ -326,7 +339,7 @@ end;
 function g_Sound_CreateWADEx(SoundName: ShortString; Resource: string; isMusic: Boolean = False): Boolean;
 var
   WAD: TWADFile;
-  FileName, SectionName, ResourceName: string;
+  FileName: string;
   SoundData: Pointer;
   ResLength: Integer;
   find_id: DWORD;
@@ -336,14 +349,14 @@ begin
   ok := False;
 
   // e_WriteLog('Loading sound: ' + Resource, MSG_NOTIFY);
-  g_ProcessResourceStr(Resource, FileName, SectionName, ResourceName);
+  FileName := g_ExtractWadName(Resource);
 
   find_id := FindSound();
 
   WAD := TWADFile.Create();
   WAD.ReadFile(FileName);
 
-  if WAD.GetResource(SectionName, ResourceName, SoundData, ResLength) then
+  if WAD.GetResource(g_ExtractFilePathName(Resource), SoundData, ResLength) then
     begin
       if e_LoadSoundMem(SoundData, ResLength, SoundArray[find_id].ID, isMusic) then
         begin
@@ -364,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;