- #ifdef SVQC
- /**
- * @param from the source entity, its position is sent
- * @param gs the global sound def
- * @param r a random number in 0..1
- */
- void globalsound(int channel, entity from, entity gs, float r, int chan, float vol, float atten)
- {
- if (channel == MSG_ONE && !IS_REAL_CLIENT(msg_entity)) return;
- WriteHeader(channel, globalsound);
- WriteByte(channel, gs.m_id);
- WriteByte(channel, r * 255);
- WriteByte(channel, etof(from));
- WriteByte(channel, fabs(chan));
- WriteByte(channel, floor(vol * 255));
- WriteByte(channel, floor(atten * 64));
+ string GlobalSound_sample(string pair, float r);
+
+ #ifdef SVQC
+ /**
+ * @param from the source entity, its position is sent
+ * @param gs the global sound def
+ * @param r a random number in 0..1
+ */
+ void globalsound(int channel, entity from, entity gs, float r, int chan, float _vol, float _atten)
+ {
+ //assert(IS_PLAYER(from), eprint(from));
+ if (channel == MSG_ONE && !IS_REAL_CLIENT(msg_entity)) return;
+ if (!autocvar_g_debug_globalsounds) {
+ string sample = GlobalSound_sample(gs.m_globalsoundstr, r);
+ switch (channel) {
+ case MSG_ONE:
+ soundto(channel, from, chan, sample, _vol, _atten);
+ break;
+ case MSG_ALL:
+ _sound(from, chan, sample, _vol, _atten);
+ break;
+ }
+ return;
+ }
+ WriteHeader(channel, globalsound);
+ WriteByte(channel, gs.m_id);
+ WriteByte(channel, r * 255);
+ WriteByte(channel, etof(from));
+ WriteByte(channel, chan);
+ WriteByte(channel, floor(_vol * 255));
+ WriteByte(channel, floor(_atten * 64));
+ entcs_force_origin(from);