// Otherwise, channels 8 to 15 would be blocked for a weird QW feature.
#ifdef SVQC
#define _sound(e, c, s, v, a) \
- do \
+ MACRO_BEGIN \
{ \
entity __e = e; \
- if (!sound_allowed(MSG_BROADCAST, __e)) break; \
- sound7(__e, c, s, v, a, 0, 0); \
- } \
- while (0)
+ if (sound_allowed(MSG_BROADCAST, __e)) \
+ sound7(__e, c, s, v, a, 0, 0); \
+ } MACRO_END
#else
#define _sound(e, c, s, v, a) sound7(e, c, s, v, a, 0, 0)
#endif
* @param sf
*/
#define sound8(e, o, chan, samp, vol, atten, speed, sf) \
- do \
+ MACRO_BEGIN \
{ \
entity __e; \
int __chan = chan; \
auto = true; \
__chan = fabs(__chan); \
entity tmp = __e = new(csqc_autochannel); \
- make_pure(tmp); \
tmp.think = SUB_Remove_self; \
tmp.nextthink = time + soundlength(__samp); \
} \
setorigin(__e, o); \
setsize(__e, '0 0 0', '0 0 0'); \
sound7(__e, __chan, __samp, vol, atten, speed, sf); \
- if (auto) break; \
- setorigin(__e, old_origin); \
- setsize(__e, old_mins, old_maxs); \
- } \
- while (0)
+ if (!auto) \
+ { \
+ setorigin(__e, old_origin); \
+ setsize(__e, old_mins, old_maxs); \
+ } \
+ } MACRO_END
CLASS(Sound, Object)
ATTRIB(Sound, m_id, int, 0)
string _Sound_fixpath(string base)
{
if (base == "") return string_null;
+#ifdef SVQC
+ return strcat(base, ".wav"); // let the client engine decide
+#else
#define extensions(x) \
x(wav) \
x(ogg) \
x(flac) \
/**/
- string relative;
- #define tryext(ext) { if (fexists(strcat("sound/", relative = strcat(base, "." #ext)))) break; }
- do
- {
- extensions(tryext);
-#undef tryext
-#undef extensions
- LOG_WARNINGF("Missing sound: \"%s\"\n", strcat("sound/", base));
-#ifdef CSQC
- return string_null;
-#endif
- }
- while (0);
-#ifdef SVQC
- return strcat(base, ".wav"); // let the client engine decide
-#else
- return relative;
+ #define tryext(ext) { string s = strcat(base, "." #ext); if (fexists(strcat("sound/", s))) return s; }
+ extensions(tryext);
+ LOG_WARNINGF("Missing sound: \"%s\"\n", strcat("sound/", base));
+ #undef tryext
+ #undef extensions
+ return string_null;
#endif
}
- METHOD(Sound, sound_precache, void(entity this))
+ METHOD(Sound, sound_precache, void(Sound this))
{
+ TC(Sound, this);
string s = Sound_fixpath(this);
if (!s) return;
- LOG_TRACEF("precache_sound(\"%s\")\n", s);
+ LOG_DEBUGF("precache_sound(\"%s\")\n", s);
precache_sound(s);
}
ENDCLASS(Sound)