X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_sound.pas;h=094df0f80756b710312f6c19dfdb4b1aec05e99c;hb=5ec745243230db4b74820b894755e9f1eab0da4c;hp=b1e09f8b4d91ee642fac286bf529fb0f32ab88c2;hpb=0968d19494ddf24230a822c02acbe3a3334bc3ad;p=d2df-sdl.git diff --git a/src/game/g_sound.pas b/src/game/g_sound.pas index b1e09f8..094df0f 100644 --- a/src/game/g_sound.pas +++ b/src/game/g_sound.pas @@ -1,3 +1,19 @@ +(* 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 . + *) +{$INCLUDE ../shared/a_modes.inc} unit g_sound; interface @@ -55,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; @@ -68,7 +84,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; @@ -123,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; @@ -141,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; @@ -252,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; @@ -260,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 @@ -268,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; @@ -279,10 +295,8 @@ end; 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; @@ -291,12 +305,12 @@ begin 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 @@ -309,23 +323,23 @@ 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) + 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; - end; {$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: TWADEditor_1; - FileName, SectionName, ResourceName: string; + WAD: TWADFile; + FileName: string; SoundData: Pointer; ResLength: Integer; find_id: DWORD; @@ -335,16 +349,16 @@ begin 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 + if e_LoadSoundMem(SoundData, ResLength, SoundArray[find_id].ID, isMusic, ForceNoLoop) then begin SoundArray[find_id].Name := SoundName; SoundArray[find_id].IsMusic := isMusic; @@ -359,16 +373,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) + 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; - end; {$ENDIF} + end; Result := True; end;