From: Rudolf Polzer Date: Thu, 6 May 2010 06:11:15 +0000 (+0200) Subject: HAHA, they not work... X-Git-Tag: xonotic-v0.1.0preview~640^2~18 X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=commitdiff_plain;h=03c6f7285271ef87a883907532cc0bd7d28d728c HAHA, they not work... --- diff --git a/qcsrc/client/Main.qc b/qcsrc/client/Main.qc index 985bcc7ea..ddff8e18f 100644 --- a/qcsrc/client/Main.qc +++ b/qcsrc/client/Main.qc @@ -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; diff --git a/qcsrc/client/View.qc b/qcsrc/client/View.qc index c5c4c7093..afa884df1 100644 --- a/qcsrc/client/View.qc +++ b/qcsrc/client/View.qc @@ -413,6 +413,7 @@ void CSQC_UpdateView(float w, float h) } #endif + TargetMusic_Advance(); Fog_Force(); drawframetime = max(0.000001, time - drawtime); diff --git a/qcsrc/client/target_music.qc b/qcsrc/client/target_music.qc index 58649bf1f..7de32b507 100644 --- a/qcsrc/client/target_music.qc +++ b/qcsrc/client/target_music.qc @@ -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; diff --git a/qcsrc/server/target_music.qc b/qcsrc/server/target_music.qc index a17cc4180..75f77acf5 100644 --- a/qcsrc/server/target_music.qc +++ b/qcsrc/server/target_music.qc @@ -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;