DEADSOFTWARE

sfs and wad code refactoring: part 1
[d2df-sdl.git] / src / game / g_sound.pas
index b1e09f8b4d91ee642fac286bf529fb0f32ab88c2..48c5167e007b40eea32a13512ee948509a67c847 100644 (file)
@@ -68,7 +68,7 @@ procedure g_Sound_SetupAllVolumes(SoundVol, MusicVol: Byte);
 implementation
 
 uses
-  e_log, SysUtils, g_console, g_options, WADEDITOR,
+  e_log, SysUtils, g_console, g_options, wadreader,
   g_game, g_basic, g_items, g_map, Math,
   g_language;
 
@@ -279,7 +279,7 @@ end;
 
 function g_Sound_CreateWAD(var ID: DWORD; Resource: string; isMusic: Boolean = False): Boolean;
 var
-  WAD: TWADEditor_1;
+  WAD: TWADFile;
   FileName,
   SectionName,
   ResourceName: string;
@@ -293,7 +293,7 @@ begin
   // e_WriteLog('Loading sound: ' + Resource, MSG_NOTIFY);
   g_ProcessResourceStr(Resource, FileName, SectionName, ResourceName);
 
-  WAD := TWADEditor_1.Create();
+  WAD := TWADFile.Create();
   WAD.ReadFile(FileName);
 
   if WAD.GetResource(SectionName, ResourceName, SoundData, ResLength) then
@@ -309,22 +309,22 @@ begin
   end;
 
   WAD.Free();
-{$IFNDEF HEADLESS}
   if (not ok) then
   begin
+{$IFNDEF HEADLESS}
     if isMusic then
       e_WriteLog(Format('Error loading music %s', [Resource]), MSG_WARNING)
     else
       e_WriteLog(Format('Error loading sound %s', [Resource]), MSG_WARNING);
     Exit;
-  end;
 {$ENDIF}
+  end;
   Result := True;
 end;
 
 function g_Sound_CreateWADEx(SoundName: ShortString; Resource: string; isMusic: Boolean = False): Boolean;
 var
-  WAD: TWADEditor_1;
+  WAD: TWADFile;
   FileName, SectionName, ResourceName: string;
   SoundData: Pointer;
   ResLength: Integer;
@@ -339,7 +339,7 @@ begin
 
   find_id := FindSound();
 
-  WAD := TWADEditor_1.Create();
+  WAD := TWADFile.Create();
   WAD.ReadFile(FileName);
 
   if WAD.GetResource(SectionName, ResourceName, SoundData, ResLength) then
@@ -359,16 +359,16 @@ begin
   end;
 
   WAD.Free();
-{$IFNDEF HEADLESS}
   if (not ok) then
   begin
+{$IFNDEF HEADLESS}
     if isMusic then
       e_WriteLog(Format('Error loading music %s', [Resource]), MSG_WARNING)
     else
       e_WriteLog(Format('Error loading sound %s', [Resource]), MSG_WARNING);
     Exit;
-  end;
 {$ENDIF}
+  end;
   Result := True;
 end;