+ /**
+ * @param from the source entity, its position is sent
+ * @param ps the player sound def
+ * @param r a random number in 0..1
+ */
+ void playersound(int channel, entity from, entity ps, 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) {
+ //UpdatePlayerSounds(from);
+ string s = from.(ps.m_playersoundfld);
+ string sample = GlobalSound_sample(s, 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, playersound);
+ WriteByte(channel, ps.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);
+ vector o = from.origin + 0.5 * (from.mins + from.maxs);
+ WriteCoord(channel, o.x);
+ WriteCoord(channel, o.y);
+ WriteCoord(channel, o.z);
+ }
+ #endif