From: TimePath Date: Wed, 2 Dec 2015 00:11:16 +0000 (+1100) Subject: Sound8: potentially fix player sound issue X-Git-Tag: xonotic-v0.8.2~1589 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=2418cbad2a4cf59c458d9ac8b57e5adc3eb7e5ce;p=xonotic%2Fxonotic-data.pk3dir.git Sound8: potentially fix player sound issue --- diff --git a/qcsrc/common/effects/qc/globalsound.qc b/qcsrc/common/effects/qc/globalsound.qc index 674ca8461..c474f3b7e 100644 --- a/qcsrc/common/effects/qc/globalsound.qc +++ b/qcsrc/common/effects/qc/globalsound.qc @@ -25,7 +25,7 @@ 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); @@ -47,7 +47,7 @@ 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); @@ -70,6 +70,7 @@ 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; @@ -85,12 +86,9 @@ } 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; } @@ -105,6 +103,7 @@ 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; @@ -120,12 +119,9 @@ } 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; } diff --git a/qcsrc/common/sounds/sound.qh b/qcsrc/common/sounds/sound.qh index 503290b6c..60b1c4c4b 100644 --- a/qcsrc/common/sounds/sound.qh +++ b/qcsrc/common/sounds/sound.qh @@ -67,13 +67,27 @@ const float VOL_BASEVOICE = 1.0; #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); \ } \