]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
HAHA, they not work...
authorRudolf Polzer <divverent@alientrap.org>
Thu, 6 May 2010 06:11:15 +0000 (08:11 +0200)
committerRudolf Polzer <divverent@alientrap.org>
Thu, 6 May 2010 06:11:15 +0000 (08:11 +0200)
qcsrc/client/Main.qc
qcsrc/client/View.qc
qcsrc/client/target_music.qc
qcsrc/server/target_music.qc

index 985bcc7eacc9ab0cbac6aff21bbe43b71f90fb7e..ddff8e18fe033bdb84048936d44853d2e1a9d1c3 100644 (file)
@@ -902,6 +902,7 @@ void(float bIsNewEntity) CSQC_Ent_Update =
                case ENT_CLIENT_TUBANOTE: Ent_TubaNote(bIsNewEntity); break;
                case ENT_CLIENT_WARPZONE: WarpZone_Read(bIsNewEntity); break;
                case ENT_CLIENT_WARPZONE_CAMERA: WarpZone_Camera_Read(bIsNewEntity); break;
+               case ENT_CLIENT_TRIGGER_MUSIC: Ent_ReadTriggerMusic(); break;
                default:
                        error(strcat("unknown entity type in CSQC_Ent_Update: ", ftos(self.enttype), "\n"));
                        break;
@@ -1231,6 +1232,10 @@ float CSQC_Parse_TempEntity()
                // NOTE: Could just do return instead of break...
        switch(nTEID)
        {
+               case TE_CSQC_TARGET_MUSIC:
+                       Net_TargetMusic();
+                       bHandled = true;
+                       break;
                case TE_CSQC_PICTURE:
                        Net_MapVote_Picture();
                        bHandled = true;
index c5c4c7093f64f3c586043cd77287215e2659ab70..afa884df1ea055a8a1c578d16243e5f3811b9431 100644 (file)
@@ -413,6 +413,7 @@ void CSQC_UpdateView(float w, float h)
        }
 #endif
 
+       TargetMusic_Advance();
        Fog_Force();
 
        drawframetime = max(0.000001, time - drawtime);
index 58649bf1fa6cc7291eeefb6257f2dfb63b4d3096..7de32b50791a29aa2106f538a8cdeb426d48de07 100644 (file)
@@ -4,7 +4,7 @@ entity music_trigger;
 
 .float state;
 
-void Net_AdvanceMusic()
+void TargetMusic_Advance()
 {
        // run AFTER all the thinks!
        entity best, e;
@@ -29,12 +29,14 @@ void Net_AdvanceMusic()
                {
                        // decrease volume
                        if(e.fade_rate > 0)
-                               e.state = max(1, e.state - frametime / e.fade_rate);
+                               e.state = max(0, e.state - frametime / e.fade_rate);
                        else
                                e.state = 0;
                }
                if(e.state != s0)
+               {
                        sound(e, CHAN_VOICE, "", e.volume * e.state, ATTN_NONE);
+               }
        }
        music_trigger = world;
 }
@@ -42,7 +44,7 @@ void Net_AdvanceMusic()
 void Net_TargetMusic()
 {
        float vol, fai, fao, tim, id;
-       string noi;
+       string noi, s;
        entity e;
 
        id = ReadShort();
@@ -61,10 +63,15 @@ void Net_TargetMusic()
        {
                e = spawn();
                e.enttype = ENT_CLIENT_TRIGGER_MUSIC;
-               if(e.noise)
-                       strunzone(e.noise);
-               e.noise = strzone(noi);
-               sound(e, CHAN_VOICE, self.noise, 0, ATTN_NONE);
+       }
+       s = e.noise;
+       if(e.noise)
+               strunzone(e.noise);
+       e.noise = strzone(noi);
+       if(e.noise != s)
+       {
+               precache_sound(e.noise);
+               sound(e, CHAN_VOICE, e.noise, 0, ATTN_NONE);
        }
        e.volume = vol;
        e.fade_time = fai;
@@ -86,7 +93,9 @@ void Net_TargetMusic()
 void Ent_TriggerMusic_Think()
 {
        if(WarpZoneLib_BoxTouchesBrush(view_origin, view_origin, self, world))
+       {
                music_trigger = self;
+       }
        self.nextthink = time;
 }
 
@@ -100,6 +109,7 @@ void Ent_TriggerMusic_Remove()
 void Ent_ReadTriggerMusic()
 {
        float f;
+       string s;
        f = ReadByte();
        if(f & 4)
        {
@@ -130,11 +140,19 @@ void Ent_ReadTriggerMusic()
                self.volume = ReadByte() / 255.0;
                self.fade_time = ReadByte() / 16.0;
                self.fade_rate = ReadByte() / 16.0;
+               s = self.noise;
                if(self.noise)
                        strunzone(self.noise);
                self.noise = strzone(ReadString());
+               if(self.noise != s)
+               {
+                       precache_sound(self.noise);
+                       sound(self, CHAN_VOICE, self.noise, 0, ATTN_NONE);
+               }
        }
 
+       setorigin(self, self.origin);
+       setsize(self, self.mins, self.maxs);
        self.cnt = 1;
        self.think = Ent_TriggerMusic_Think;
        self.nextthink = time;
index a17cc41805e8626cb0131379635158a3d805f93e..75f77acf53b77beb9e0fc9274dcabec0f8c3307c 100644 (file)
@@ -10,6 +10,7 @@
 // when targetname is not set, THIS ONE is default
 void target_music_sendto(float to, float is)
 {
+       WriteByte(to, SVC_TEMPENTITY);
        WriteByte(to, TE_CSQC_TARGET_MUSIC);
        WriteShort(to, num_for_edict(self));
        WriteByte(to, self.volume * 255.0 * is);
@@ -51,7 +52,7 @@ void spawnfunc_target_music()
 // when triggered, it is disabled/enabled for everyone
 float trigger_music_SendEntity(entity to, float sf)
 {
-       WriteByte(MSG_ENTITY, TE_CSQC_TARGET_MUSIC);
+       WriteByte(MSG_ENTITY, ENT_CLIENT_TRIGGER_MUSIC);
        sf &~= 0x80;
        if(self.cnt)
                sf |= 0x80;