]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Sounds: revert to engine networking
authorTimePath <andrew.hardaker1995@gmail.com>
Sun, 28 Feb 2016 04:47:34 +0000 (15:47 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Sun, 28 Feb 2016 04:57:17 +0000 (15:57 +1100)
qcsrc/common/effects/qc/globalsound.qc
qcsrc/common/effects/qc/globalsound.qh

index 1d634f6e51e48ae150008aa1931cdfee2bd34244..f13b231042d41fccbd9d265611e6ca04182b38b6 100644 (file)
        REGISTER_NET_TEMP(globalsound)
        REGISTER_NET_TEMP(playersound)
 
+       string GlobalSound_sample(string pair, float r);
+
        #ifdef SVQC
+               /** Use new sound handling. TODO: use when sounds play correctly on clients */
+               bool autocvar_g_debug_globalsounds = false;
                /**
                 * @param from the source entity, its position is sent
                 * @param gs the global sound def
                {
                        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);
                {
                        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);
@@ -60,8 +90,6 @@
                }
        #endif
 
-       string GlobalSound_sample(string pair, float r);
-
        #ifdef CSQC
 
                NET_HANDLE(globalsound, bool isnew)
                fclose(fh);
        }
 
-       #ifdef CSQC
+       //#ifdef CSQC
 
                .string GetPlayerSoundSampleField(string type)
                {
 
                void ClearPlayerSounds(entity this)
                {
-                       FOREACH(PlayerSounds, true, LAMBDA(
+                       FOREACH(PlayerSounds, true, {
                                .string fld = it.m_playersoundfld;
                                if (this.(fld))
-       {
-               strunzone(this.(fld));
-               this.(fld) = string_null;
-       }
-                                                             ));
+                               {
+                                       strunzone(this.(fld));
+                                       this.(fld) = string_null;
+                               }
+                       });
                }
 
                bool LoadPlayerSounds(entity this, string f, bool strict)
                        LoadPlayerSounds(this, get_model_datafilename(this.model, 0, "sounds"), true);
                }
 
-       #endif
+       //#endif
 
        #ifdef SVQC
 
index 1c2aa64612a089652596da6014814890d752de1f..22e04e94a7f6d77a0b5324968cd027de24fe1909 100644 (file)
@@ -108,13 +108,13 @@ REGISTER_GLOBALSOUND(FALL_METAL, "misc/metalhitground 4")
 
 bool GetPlayerSoundSampleField_notFound;
 void PrecachePlayerSounds(string f);
-#ifdef CSQC
+//#ifdef CSQC
        .string GetVoiceMessageSampleField(string type);
        .string GetPlayerSoundSampleField(string type);
        void ClearPlayerSounds(entity this);
        float LoadPlayerSounds(entity this, string f, bool strict);
        void UpdatePlayerSounds(entity this);
-#endif
+//#endif
 
 #ifdef SVQC