]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Sound8: potentially fix player sound issue
authorTimePath <andrew.hardaker1995@gmail.com>
Wed, 2 Dec 2015 00:11:16 +0000 (11:11 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Wed, 2 Dec 2015 00:11:49 +0000 (11:11 +1100)
qcsrc/common/effects/qc/globalsound.qc
qcsrc/common/sounds/sound.qh

index 674ca846177a900f0ff165f85105f4ae5c475548..c474f3b7ece34c657d955d697d6d795575b957f2 100644 (file)
@@ -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;
                        }
                        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;
                }
index 503290b6c03f916fbd0972eba1f767cef0360e5c..60b1c4c4bf3c433a59548e1f0fb09974276f85c6 100644 (file)
@@ -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); \
        } \