]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/sounds/sound.qh
Merge branch 'master' into terencehill/tooltips_cleanup
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / sounds / sound.qh
1 #ifndef SOUND_H
2 #define SOUND_H
3
4 // Play all sounds via sound7, for access to the extra channels.
5 // Otherwise, channels 8 to 15 would be blocked for a weird QW feature.
6 #ifdef SVQC
7     #define _sound(e, c, s, v, a) do { \
8         entity __e = e; \
9         if (!sound_allowed(MSG_BROADCAST, __e)) break; \
10         sound7(__e, c, s, v, a, 0, 0); \
11     } while (0)
12 #else
13     #define _sound(e, c, s, v, a) sound7(e, c, s, v, a, 0, 0)
14 #endif
15 #define sound(e, c, s, v, a) _sound(e, c, s.sound_str(), v, a)
16
17 CLASS(Sound, Object)
18     ATTRIB(Sound, m_id, int, 0)
19     ATTRIB(Sound, sound_str, string(), func_null)
20     CONSTRUCTOR(Sound, string() path)
21     {
22         CONSTRUCT(Sound);
23         this.sound_str = path;
24     }
25     METHOD(Sound, sound_precache, void(entity this)) {
26         string s = this.sound_str();
27         if (s && s != "" && !fexists(strcat("sound/", s))) {
28             LOG_WARNINGF("Missing sound: \"%s\"\n", s);
29             return;
30         }
31         LOG_TRACEF("precache_sound(\"%s\")\n", s);
32         precache_sound(s);
33     }
34 ENDCLASS(Sound)
35
36 #endif