]> git.jsancho.org Git - lugaru.git/blobdiff - Source/Sounds.cpp
Moved Account::active in Account class. Maybe it should be changed for a method and...
[lugaru.git] / Source / Sounds.cpp
index 6e1a75faab99912d8aad9c094b9ccfe641c7a2eb..735d93975fc58780c86bb929177a9378158a9a48 100644 (file)
@@ -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 <http://www.gnu.org/licenses/>.
 #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);
 }
-