]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/sounds/sound.qh
Merge branch 'master' into terencehill/dynamic_hud
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / sounds / sound.qh
index 7e9ba263240f759de67320a778bbc9137612edea..a462861f29b8401452b3c1d75becd2a4de24e555 100644 (file)
@@ -76,7 +76,6 @@ const float VOL_BASEVOICE = 1.0;
                        auto = true; \
                        __chan = fabs(__chan); \
                        entity tmp = __e = new(csqc_autochannel); \
-                       make_pure(tmp); \
                        tmp.think = SUB_Remove_self; \
                        tmp.nextthink = time + soundlength(__samp); \
                } \
@@ -105,35 +104,28 @@ CLASS(Sound, Object)
        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)