-float music_disabled;
-entity music_default;
-entity music_target;
-entity music_trigger;
-
-.float state;
-.float lastvol;
+#include "target_music.qh"
void TargetMusic_Advance()
{
for(e = world; (e = findfloat(e, enttype, ENT_CLIENT_TRIGGER_MUSIC)); ) if(e.noise)
{
vol0 = e.lastvol;
- if(getsoundtime(e, CHAN_VOICE) < 0)
+ if(getsoundtime(e, CH_BGM_SINGLE) < 0)
{
vol0 = -1;
}
if(vol != vol0)
{
if(vol0 < 0)
- sound(e, CHAN_VOICE, e.noise, vol, ATTN_NONE); // restart
+ sound(e, CH_BGM_SINGLE, e.noise, vol, ATTEN_NONE); // restart
else
- sound(e, CHAN_VOICE, "", vol, ATTN_NONE);
+ sound(e, CH_BGM_SINGLE, "", vol, ATTEN_NONE);
e.lastvol = vol;
}
}
music_trigger = world;
if(best)
- bgmtime = getsoundtime(best, CHAN_VOICE);
+ bgmtime = getsoundtime(best, CH_BGM_SINGLE);
else
bgmtime = gettime(GETTIME_CDTRACK);
}
void Net_TargetMusic()
{
- float vol, fai, fao, tim, id;
- string noi;
- entity e;
-
- id = ReadShort();
- vol = ReadByte() / 255.0;
- fai = ReadByte() / 16.0;
- fao = ReadByte() / 16.0;
- tim = ReadByte();
- noi = ReadString();
+ int id = ReadShort();
+ float vol = ReadByte() / 255.0;
+ float fai = ReadByte() / 16.0;
+ float fao = ReadByte() / 16.0;
+ float tim = ReadByte();
+ string noi = ReadString();
+ entity e;
for(e = world; (e = findfloat(e, enttype, ENT_CLIENT_TRIGGER_MUSIC)); )
{
if(e.count == id)
strunzone(e.noise);
e.noise = strzone(noi);
precache_sound(e.noise);
- sound(e, CHAN_VOICE, e.noise, 0, ATTN_NONE);
- if(getsoundtime(e, CHAN_VOICE) < 0)
+ sound(e, CH_BGM_SINGLE, e.noise, 0, ATTEN_NONE);
+ if(getsoundtime(e, CH_BGM_SINGLE) < 0)
{
- print(sprintf(_("Cannot initialize sound %s\n"), e.noise));
+ dprintf("Cannot initialize sound %s\n", e.noise);
strunzone(e.noise);
e.noise = string_null;
}
if(!music_disabled)
{
e.state = 2;
+ cvar_settemp("music_playlist_index", "-1"); // don't use playlists
localcmd("cd stop\n"); // just in case
music_disabled = 1;
}
void Ent_ReadTriggerMusic()
{
- float f;
- string s;
- f = ReadByte();
+ int f = ReadByte();
if(f & 4)
{
self.origin_x = ReadCoord();
self.volume = ReadByte() / 255.0;
self.fade_time = ReadByte() / 16.0;
self.fade_rate = ReadByte() / 16.0;
- s = self.noise;
+ string 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);
- if(getsoundtime(self, CHAN_VOICE) < 0)
+ sound(self, CH_BGM_SINGLE, self.noise, 0, ATTEN_NONE);
+ if(getsoundtime(self, CH_BGM_SINGLE) < 0)
{
- print(sprintf(_("Cannot initialize sound %s\n"), self.noise));
+ dprintf("Cannot initialize sound %s\n", self.noise);
strunzone(self.noise);
self.noise = string_null;
}