]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/triggers/target/music.qc
Merge branch 'master' into terencehill/dynamic_hud
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / target / music.qc
index 7f97668c88dfbaac8ffd0a4ebf2537f394270e9b..1873d64a07be516e9e387fe1a52737d6ab80f8b0 100644 (file)
@@ -1,9 +1,9 @@
 #if defined(CSQC)
 #elif defined(MENUQC)
 #elif defined(SVQC)
-    #include "../../constants.qh"
-    #include "../../../server/constants.qh"
-    #include "../../../server/defs.qh"
+    #include <common/constants.qh>
+    #include <server/constants.qh>
+    #include <server/defs.qh>
 #endif
 
 REGISTER_NET_TEMP(TE_CSQC_TARGET_MUSIC)
@@ -23,7 +23,7 @@ REGISTER_NET_LINKED(ENT_CLIENT_TRIGGER_MUSIC)
 void target_music_sendto(float to, float is)
 {SELFPARAM();
        WriteHeader(to, TE_CSQC_TARGET_MUSIC);
-       WriteShort(to, num_for_edict(self));
+       WriteShort(to, etof(self));
        WriteByte(to, self.volume * 255.0 * is);
        WriteByte(to, self.fade_time * 16.0);
        WriteByte(to, self.fade_rate * 16.0);
@@ -36,6 +36,7 @@ void target_music_reset(entity this)
 }
 void target_music_kill()
 {
+    SELFPARAM();
        for(self = world; (self = find(self, classname, "target_music")); )
        {
                self.volume = 0;
@@ -54,8 +55,10 @@ void target_music_use()
                msg_entity = activator;
                target_music_sendto(MSG_ONE, 1);
        }
-       entity head;
-       FOR_EACH_SPEC(head) if(head.enemy == activator) { msg_entity = head; target_music_sendto(MSG_ONE, 1); }
+       FOREACH_CLIENT(IS_SPEC(it) && it.enemy == activator, {
+               msg_entity = it;
+               target_music_sendto(MSG_ONE, 1);
+       });
 }
 spawnfunc(target_music)
 {
@@ -166,7 +169,7 @@ void TargetMusic_Advance()
        entity best = music_default;
        if (music_target && time < music_target.lifetime) best = music_target;
        if (music_trigger) best = music_trigger;
-       LL_EACH(TargetMusic_list, it.noise, LAMBDA(
+       LL_EACH(TargetMusic_list, it.noise, {
                const float vol0 = (getsoundtime(it, CH_BGM_SINGLE) >= 0) ? it.lastvol : -1;
                if (it == best)
                {
@@ -187,7 +190,7 @@ void TargetMusic_Advance()
                                _sound(it, CH_BGM_SINGLE, "", vol, ATTEN_NONE);
                        it.lastvol = vol;
                }
-       ));
+       });
        music_trigger = world;
        bgmtime = (best) ? getsoundtime(best, CH_BGM_SINGLE) : gettime(GETTIME_CDTRACK);
 }
@@ -208,11 +211,10 @@ void Net_TargetMusic()
        const string noi = ReadString();
 
        entity e = NULL;
-       LL_EACH(TargetMusic_list, it.count == id, LAMBDA(e = it; break));
+       LL_EACH(TargetMusic_list, it.count == id, { e = it; break; });
        if (!e)
        {
-               LL_PUSH(TargetMusic_list, e = new(TargetMusic));
-               make_pure(e);
+               LL_PUSH(TargetMusic_list, e = new_pure(TargetMusic));
                e.count = id;
        }
        if(e.noise != noi)