#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)
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);
}
void target_music_kill()
{
- for(self = world; (self = find(self, classname, "target_music")); )
- {
- self.volume = 0;
- if(self.targetname == "")
- target_music_sendto(MSG_ALL, 1);
- else
- target_music_sendto(MSG_ALL, 0);
- }
+ FOREACH_ENTITY_CLASS("target_music", true, {
+ it.volume = 0;
+ if (it.targetname == "")
+ WITHSELF(it, target_music_sendto(MSG_ALL, 1));
+ else
+ WITHSELF(it, target_music_sendto(MSG_ALL, 0));
+ });
}
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)
{
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)
{
_sound(it, CH_BGM_SINGLE, "", vol, ATTEN_NONE);
it.lastvol = vol;
}
- ));
+ });
music_trigger = world;
bgmtime = (best) ? getsoundtime(best, CH_BGM_SINGLE) : gettime(GETTIME_CDTRACK);
}
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)