diff --git a/src/game/g_sound.pas b/src/game/g_sound.pas
index 074d037c29da38b5f77c4652b71665fa08d382ed..ad514c197fdea6e31142abb975bf88d571a4ef54 100644 (file)
--- a/src/game/g_sound.pas
+++ b/src/game/g_sound.pas
+(* 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
function SetByName(SN: String): Boolean;
function SetCoords(X, Y: Integer; Volume: Single): Boolean;
- property Loop: Boolean read FLoop write FLoop;
+ property Loop: Boolean read FMusic write FMusic;
property Name: String read FName;
end;
implementation
uses
- e_log, SysUtils, g_console, g_options, WADEDITOR,
- g_game, g_basic, g_items, g_map, fmod, fmodtypes, Math,
+ e_log, SysUtils, g_console, g_options, wadreader,
+ g_game, g_basic, g_items, g_map, Math,
g_language;
type
for a := 0 to High(SoundArray) do
if SoundArray[a].Name = SoundName then
begin
- Result := e_PlaySoundVolume(SoundArray[a].ID, gSoundLevel/255.0);
+ Result := (e_PlaySoundVolume(SoundArray[a].ID, gSoundLevel/255.0) >= 0);
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;
for a := 0 to High(SoundArray) do
if SoundArray[a].Name = SoundName then
begin
- Result := e_PlaySoundPanVolume(SoundArray[a].ID, Pan, Volume * (gSoundLevel/255.0));
+ Result := (e_PlaySoundPanVolume(SoundArray[a].ID, Pan, Volume * (gSoundLevel/255.0)) >= 0);
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;
Pan, Vol: Single;
begin
if PlaySoundAt(X, Y, Pan, Vol) then
- Result := e_PlaySoundPanVolume(ID, Pan, Vol * (gSoundLevel/255.0))
+ Result := (e_PlaySoundPanVolume(ID, Pan, Vol * (gSoundLevel/255.0)) >= 0)
else
Result := False;
end;
if SoundArray[a].Name = SoundName then
begin
if PlaySoundAt(X, Y, Pan, Vol) then
- Result := e_PlaySoundPanVolume(SoundArray[a].ID,
- Pan, Vol * (gSoundLevel/255.0));
+ Result := (e_PlaySoundPanVolume(SoundArray[a].ID, Pan, Vol * (gSoundLevel/255.0)) >= 0);
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;
function g_Sound_CreateWAD(var ID: DWORD; Resource: string; isMusic: Boolean = False): Boolean;
var
- WAD: TWADEditor_1;
- FileName,
- SectionName,
- ResourceName: string;
+ WAD: TWADFile;
+ FileName: string;
SoundData: Pointer;
ResLength: Integer;
ok: Boolean;
ok := False;
// e_WriteLog('Loading sound: ' + Resource, MSG_NOTIFY);
- g_ProcessResourceStr(Resource, FileName, SectionName, ResourceName);
+ FileName := g_ExtractWadName(Resource);
- WAD := TWADEditor_1.Create();
+ 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
FreeMem(SoundData);
end
else
- e_WriteLog(Format('WAD Reader error: %s', [WAD.GetLastErrorStr]), MSG_WARNING);
+ begin
+ //e_WriteLog(Format('WAD Reader error: %s', [WAD.GetLastErrorStr]), MSG_WARNING);
+ end;
WAD.Free();
-
- if not ok then
+ if (not ok) then
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;
var
- WAD: TWADEditor_1;
- FileName, SectionName, ResourceName: string;
+ WAD: TWADFile;
+ FileName: string;
SoundData: Pointer;
ResLength: Integer;
find_id: DWORD;
ok := False;
// e_WriteLog('Loading sound: ' + Resource, MSG_NOTIFY);
- g_ProcessResourceStr(Resource, FileName, SectionName, ResourceName);
+ FileName := g_ExtractWadName(Resource);
find_id := FindSound();
- WAD := TWADEditor_1.Create();
+ 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
FreeMem(SoundData);
end
else
- e_WriteLog(Format('WAD Reader error: %s', [WAD.GetLastErrorStr]), MSG_WARNING);
+ begin
+ //e_WriteLog(Format('WAD Reader error: %s', [WAD.GetLastErrorStr]), MSG_WARNING);
+ end;
WAD.Free();
-
- if not ok then
+ if (not ok) then
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;