]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/triggers/target/music.qc
Merge branch 'master' into terencehill/min_spec_time
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / target / music.qc
index 7abcd67403391fb821bbdfd45ff02de704dc5664..7ec3351381b6265b0d24e4e16c02caa80d32fe2d 100644 (file)
@@ -1,7 +1,9 @@
+#include "music.qh"
 #if defined(CSQC)
 #elif defined(MENUQC)
 #elif defined(SVQC)
     #include <common/constants.qh>
+    #include <common/net_linked.qh>
     #include <server/constants.qh>
     #include <server/defs.qh>
 #endif
@@ -11,6 +13,9 @@ REGISTER_NET_LINKED(ENT_CLIENT_TRIGGER_MUSIC)
 
 #ifdef SVQC
 
+IntrusiveList g_targetmusic_list;
+STATIC_INIT(g_targetmusic_list) { g_targetmusic_list = IL_NEW(); }
+
 // values:
 //   volume
 //   noise
@@ -36,7 +41,8 @@ void target_music_reset(entity this)
 }
 void target_music_kill()
 {
-       FOREACH_ENTITY_CLASS("target_music", true, {
+       IL_EACH(g_targetmusic_list, true,
+       {
                it.volume = 0;
         if (it.targetname == "")
             target_music_sendto(it, MSG_ALL, 1);
@@ -64,6 +70,7 @@ spawnfunc(target_music)
        this.reset = target_music_reset;
        if(!this.volume)
                this.volume = 1;
+       IL_PUSH(g_targetmusic_list, this);
        if(this.targetname == "")
                target_music_sendto(this, MSG_INIT, 1);
        else
@@ -71,7 +78,7 @@ spawnfunc(target_music)
 }
 void TargetMusic_RestoreGame()
 {
-       FOREACH_ENTITY_CLASS("target_music", true,
+       IL_EACH(g_targetmusic_list, true,
        {
                if(it.targetname == "")
                        target_music_sendto(it, MSG_INIT, 1);
@@ -96,28 +103,20 @@ bool trigger_music_SendEntity(entity this, entity to, float sf)
        WriteByte(MSG_ENTITY, sf);
        if(sf & 4)
        {
-               WriteCoord(MSG_ENTITY, this.origin.x);
-               WriteCoord(MSG_ENTITY, this.origin.y);
-               WriteCoord(MSG_ENTITY, this.origin.z);
+               WriteVector(MSG_ENTITY, this.origin);
        }
        if(sf & 1)
        {
                if(this.model != "null")
                {
                        WriteShort(MSG_ENTITY, this.modelindex);
-                       WriteCoord(MSG_ENTITY, this.mins.x);
-                       WriteCoord(MSG_ENTITY, this.mins.y);
-                       WriteCoord(MSG_ENTITY, this.mins.z);
-                       WriteCoord(MSG_ENTITY, this.maxs.x);
-                       WriteCoord(MSG_ENTITY, this.maxs.y);
-                       WriteCoord(MSG_ENTITY, this.maxs.z);
+                       WriteVector(MSG_ENTITY, this.mins);
+                       WriteVector(MSG_ENTITY, this.maxs);
                }
                else
                {
                        WriteShort(MSG_ENTITY, 0);
-                       WriteCoord(MSG_ENTITY, this.maxs.x);
-                       WriteCoord(MSG_ENTITY, this.maxs.y);
-                       WriteCoord(MSG_ENTITY, this.maxs.z);
+                       WriteVector(MSG_ENTITY, this.maxs);
                }
                WriteByte(MSG_ENTITY, this.volume * 255.0);
                WriteByte(MSG_ENTITY, this.fade_time * 16.0);
@@ -223,7 +222,7 @@ void Net_TargetMusic()
                _sound(e, CH_BGM_SINGLE, e.noise, 0, ATTEN_NONE);
                if(getsoundtime(e, CH_BGM_SINGLE) < 0)
                {
-                       LOG_TRACEF("Cannot initialize sound %s\n", e.noise);
+                       LOG_TRACEF("Cannot initialize sound %s", e.noise);
                        strunzone(e.noise);
                        e.noise = string_null;
                }
@@ -273,28 +272,20 @@ NET_HANDLE(ENT_CLIENT_TRIGGER_MUSIC, bool isnew)
        int f = ReadByte();
        if(f & 4)
        {
-               this.origin_x = ReadCoord();
-               this.origin_y = ReadCoord();
-               this.origin_z = ReadCoord();
+               this.origin = ReadVector();
        }
        if(f & 1)
        {
                this.modelindex = ReadShort();
                if(this.modelindex)
                {
-                       this.mins_x = ReadCoord();
-                       this.mins_y = ReadCoord();
-                       this.mins_z = ReadCoord();
-                       this.maxs_x = ReadCoord();
-                       this.maxs_y = ReadCoord();
-                       this.maxs_z = ReadCoord();
+                       this.mins = ReadVector();
+                       this.maxs = ReadVector();
                }
                else
                {
                        this.mins    = '0 0 0';
-                       this.maxs_x = ReadCoord();
-                       this.maxs_y = ReadCoord();
-                       this.maxs_z = ReadCoord();
+                       this.maxs = ReadVector();
                }
 
                this.volume = ReadByte() / 255.0;
@@ -310,7 +301,7 @@ NET_HANDLE(ENT_CLIENT_TRIGGER_MUSIC, bool isnew)
                        _sound(this, CH_BGM_SINGLE, this.noise, 0, ATTEN_NONE);
                        if(getsoundtime(this, CH_BGM_SINGLE) < 0)
                        {
-                               LOG_TRACEF("Cannot initialize sound %s\n", this.noise);
+                               LOG_TRACEF("Cannot initialize sound %s", this.noise);
                                strunzone(this.noise);
                                this.noise = string_null;
                        }