X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FSounds.cpp;h=735d93975fc58780c86bb929177a9378158a9a48;hb=1991e81a5c3bcc9cd0d6d49f56ebd8bcbd76e7b4;hp=6e1a75faab99912d8aad9c094b9ccfe641c7a2eb;hpb=cd043e3f9e26c2b3406b40a354c2840941e9db7f;p=lugaru.git diff --git a/Source/Sounds.cpp b/Source/Sounds.cpp index 6e1a75f..735d939 100644 --- a/Source/Sounds.cpp +++ b/Source/Sounds.cpp @@ -1,5 +1,5 @@ /* -Copyright (C) 2010 - Lugaru authors +Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file) This file is part of Lugaru. @@ -20,9 +20,15 @@ along with Lugaru. If not, see . #include "Quaternions.h" #include "Sounds.h" #include "openal_wrapper.h" +#include "Utils/Folders.h" struct OPENAL_SAMPLE *samp[sounds_count]; +extern XYZ envsound[30]; +extern float envsoundvol[30]; +extern int numenvsounds; +extern float envsoundlife[30]; + int footstepsound, footstepsound2, footstepsound3, footstepsound4; int channels[100]; @@ -52,10 +58,9 @@ static int snd_mode(int snd) void loadAllSounds() { for (int i = 0; i < sounds_count; i++) { - char buf[64]; - snprintf(buf, 64, ":Data:Sounds:%s", sound_data[i]); + std::string buf = std::string("Sounds/") + sound_data[i]; samp[i] = OPENAL_Sample_Load(OPENAL_FREE, - ConvertFileName(buf), + Folders::getResourcePath(buf).c_str(), snd_mode(i), 0, 0); } @@ -69,8 +74,15 @@ void loadAllSounds() OPENAL_Stream_SetMode(samp[i], OPENAL_LOOP_NORMAL); } -void -emit_sound_at(int soundid, const XYZ &pos, float vol) +void addEnvSound(XYZ coords, float vol, float life) +{ + envsound[numenvsounds] = coords; + envsoundvol[numenvsounds] = vol; + envsoundlife[numenvsounds] = life; + numenvsounds++; +} + +void emit_sound_at(int soundid, const XYZ &pos, float vol) { PlaySoundEx (soundid, samp[soundid], NULL, true); OPENAL_3D_SetAttributes_ (channels[soundid], pos, NULL); @@ -78,16 +90,14 @@ emit_sound_at(int soundid, const XYZ &pos, float vol) OPENAL_SetPaused (channels[soundid], false); } -void -emit_sound_np(int soundid, float vol) +void emit_sound_np(int soundid, float vol) { PlaySoundEx (soundid, samp[soundid], NULL, true); OPENAL_SetVolume (channels[soundid], vol); OPENAL_SetPaused (channels[soundid], false); } -void -emit_stream_at(int soundid, const XYZ &pos, float vol) +void emit_stream_at(int soundid, const XYZ &pos, float vol) { PlayStreamEx (soundid, samp[soundid], NULL, true); OPENAL_3D_SetAttributes_ (channels[soundid], pos, NULL); @@ -95,23 +105,19 @@ emit_stream_at(int soundid, const XYZ &pos, float vol) OPENAL_SetPaused (channels[soundid], false); } -void -emit_stream_np(int soundid, float vol) +void emit_stream_np(int soundid, float vol) { PlayStreamEx (soundid, samp[soundid], NULL, true); OPENAL_SetVolume (channels[soundid], vol); OPENAL_SetPaused (channels[soundid], false); } -void -resume_stream(int soundid) +void resume_stream(int soundid) { OPENAL_SetPaused (channels[soundid], false); } -void -pause_sound(int soundid) +void pause_sound(int soundid) { OPENAL_SetPaused (channels[soundid], true); } -