]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/sounds/all.qh
Merge branch 'master' into TimePath/stats
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / sounds / all.qh
index 90858f39d7841cf5f2c2f73d0c59fc37a637546f..8225db7368c30f5593c2c1e435897b0123cbb8d5 100644 (file)
@@ -1,56 +1,26 @@
 #ifndef SOUNDS_ALL_H
 #define SOUNDS_ALL_H
 
-#include "../teams.qh"
+#include "sound.qh"
 
-// Play all sounds via sound7, for access to the extra channels.
-// Otherwise, channels 8 to 15 would be blocked for a weird QW feature.
-#ifdef SVQC
-    #define _sound(e, c, s, v, a) do { \
-        entity __e = e; \
-        if (!sound_allowed(MSG_BROADCAST, __e)) break; \
-        sound7(__e, c, s, v, a, 0, 0); \
-    } while (0)
-#else
-    #define _sound(e, c, s, v, a) sound7(e, c, s, v, a, 0, 0)
-#endif
-#define sound(e, c, s, v, a) _sound(e, c, s.sound_str(), v, a)
-// Used in places where a string is required
-#define SND(id) (SND_##id.sound_str())
-
-REGISTRY(Sounds, BIT(8))
-REGISTER_REGISTRY(RegisterSounds)
-
-CLASS(Sound, Object)
-    ATTRIB(Sound, m_id, int, 0)
-    ATTRIB(Sound, sound_str, string(), func_null)
-    CONSTRUCTOR(Sound, string() path)
-    {
-        CONSTRUCT(Sound);
-        this.sound_str = path;
-    }
-    METHOD(Sound, sound_precache, void(entity this)) {
-        string s = this.sound_str();
-        if (s && s != "" && !fexists(strcat("sound/", s))) {
-            LOG_WARNINGF("Missing sound: \"%s\"\n", s);
-            return;
-        }
-        LOG_TRACEF("precache_sound(\"%s\")\n", s);
-        precache_sound(s);
-    }
-ENDCLASS(Sound)
+REGISTRY(Sounds, BITS(8))
+#define Sounds_from(i) _Sounds_from(i, SND_Null)
+REGISTER_REGISTRY(Sounds)
 
 #define SOUND(name, path) \
     string SND_##name##_get() { return path; } \
-    REGISTER(RegisterSounds, SND, Sounds, name, m_id, NEW(Sound, SND_##name##_get))
+    REGISTER(Sounds, SND, name, m_id, NEW(Sound, SND_##name##_get))
 
-STATIC_INIT(RegisterSounds_precache) {
+// Used in places where a string is required
+#define SND(id) Sound_fixpath(SND_##id)
+
+PRECACHE(Sounds) {
     FOREACH(Sounds, true, LAMBDA({
         it.sound_precache(it);
     }));
 }
 
-SOUND(Null, "misc/null.wav");
+SOUND(Null, "misc/null");
 #include "all.inc"
-
+#include "all.qc"
 #endif