WriteByte(channel, gs.m_id);
WriteByte(channel, r * 255);
WriteByte(channel, etof(from));
- WriteByte(channel, fabs(chan));
+ WriteByte(channel, chan);
WriteByte(channel, floor(vol * 255));
WriteByte(channel, floor(atten * 64));
entcs_force_origin(from);
WriteByte(channel, ps.m_id);
WriteByte(channel, r * 255);
WriteByte(channel, etof(from));
- WriteByte(channel, fabs(chan));
+ WriteByte(channel, chan);
WriteByte(channel, floor(vol * 255));
WriteByte(channel, floor(atten * 64));
entcs_force_origin(from);
int who = ReadByte();
entity e = entcs_receiver(who - 1);
int chan = ReadByte();
+ chan = (chan & BIT(7) ? -1 : 1) * (chan & BITS(7));
float vol = ReadByte() / 255;
float atten = ReadByte() / 64;
vector o;
}
else
{
- LOG_WARNINGF("Missing entcs data for player %d\n", who);
// Can this happen?
- entity e = new(globalsound);
- e.origin = o;
+ LOG_WARNINGF("Missing entcs data for player %d\n", who);
sound8(e, o, chan, sample, vol, atten, 0, 0);
- remove(e); // debug with: e.think = SUB_Remove; e.nextthink = time + 1;
}
return true;
}
string s = e.(ps.m_playersoundfld);
string sample = GlobalSound_sample(s, r);
int chan = ReadByte();
+ chan = (chan & BIT(7) ? -1 : 1) * (chan & BITS(7));
float vol = ReadByte() / 255;
float atten = ReadByte() / 64;
vector o;
}
else
{
- LOG_WARNINGF("Missing entcs data for player %d\n", who);
// Can this happen?
- entity e = new(playersound);
- e.origin = o;
+ LOG_WARNINGF("Missing entcs data for player %d\n", who);
sound8(e, o, chan, sample, vol, atten, 0, 0);
- remove(e); // debug with: e.think = SUB_Remove; e.nextthink = time + 1;
}
return true;
}
#define sound8(e, o, chan, samp, vol, atten, speed, sf) \
do \
{ \
- entity __e = e; \
+ entity __e; \
+ int __chan = chan; \
+ string __samp = samp; \
+ bool auto = false; \
+ if (__chan > 0) __e = e; \
+ else \
+ { \
+ auto = true; \
+ __chan = fabs(__chan); \
+ entity tmp = __e = new(csqc_autochannel); \
+ make_pure(tmp); \
+ tmp.think = SUB_Remove_self; \
+ tmp.nextthink = time + soundlength(__samp); \
+ } \
vector old_origin = __e.origin; \
vector old_mins = __e.mins; \
vector old_maxs = __e.maxs; \
setorigin(__e, o); \
setsize(__e, '0 0 0', '0 0 0'); \
- sound7(__e, chan, samp, vol, atten, speed, sf); \
+ sound7(__e, __chan, __samp, vol, atten, speed, sf); \
+ if (auto) break; \
setorigin(__e, old_origin); \
setsize(__e, old_mins, old_maxs); \
} \