]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Global sounds: register
authorTimePath <andrew.hardaker1995@gmail.com>
Sat, 7 Nov 2015 10:02:40 +0000 (21:02 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Sat, 7 Nov 2015 10:02:40 +0000 (21:02 +1100)
qcsrc/common/monsters/sv_monsters.qc
qcsrc/common/physics.qc
qcsrc/server/cl_player.qc
qcsrc/server/cl_player.qh
qcsrc/server/defs.qh
qcsrc/server/miscfunctions.qc
qcsrc/server/sv_main.qc

index 2b55d423ed2b3e3e41554976c539635cec609cb9..31e5d2784f5b2a460df6512412d214595d2873ad 100644 (file)
@@ -346,7 +346,7 @@ void Monster_Sound(.string samplefield, float sound_delay, float delaytoo, float
        if(delaytoo)
        if(time < self.msound_delay)
                return; // too early
-       GlobalSound(self.(samplefield), chan, VOICETYPE_PLAYERSOUND);
+       _GlobalSound(self.(samplefield), chan, VOICETYPE_PLAYERSOUND);
 
        self.msound_delay = time + sound_delay;
 }
index 755fc0aca0e32b9c91adb972736932cc95e4f0a1..b01efd32bdeb09be654c10603164697bbd7d9642 100644 (file)
@@ -1115,9 +1115,9 @@ void PM_check_hitground()
                        if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS))
                        {
                                if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS)
-                                       GlobalSound(globalsound_metalfall, CH_PLAYER, VOICETYPE_PLAYERSOUND);
+                                       GlobalSound(GS_FALL_METAL, CH_PLAYER, VOICETYPE_PLAYERSOUND);
                                else
-                                       GlobalSound(globalsound_fall, CH_PLAYER, VOICETYPE_PLAYERSOUND);
+                                       GlobalSound(GS_FALL, CH_PLAYER, VOICETYPE_PLAYERSOUND);
                        }
                }
        }
index bf808d8e3d41c822e16e1d5ecd11aaea7b8fb55b..cd1ce6901584266f0f8f52c1e5864fb19ef1a94e 100644 (file)
@@ -960,7 +960,7 @@ int Say(entity source, float teamsay, entity privatesay, string msgin, bool floo
        return ret;
 }
 
-float GetVoiceMessageVoiceType(string type)
+int GetVoiceMessageVoiceType(string type)
 {
        if (type == "taunt") return VOICETYPE_TAUNT;
        if (type == "teamshoot") return VOICETYPE_LASTATTACKER;
@@ -1166,7 +1166,7 @@ void FakeGlobalSound(string sample, int chan, int voicetype)
        }
 }
 
-void GlobalSound(string sample, int chan, int voicetype)
+void _GlobalSound(string sample, int chan, int voicetype)
 {
        SELFPARAM();
        if (sample == "") return;
@@ -1238,10 +1238,10 @@ void GlobalSound(string sample, int chan, int voicetype)
        }
 }
 
-void PlayerSound(.string samplefield, float chan, float voicetype)
+void PlayerSound(.string samplefield, int chan, float voicetype)
 {
        SELFPARAM();
-       GlobalSound(this.(samplefield), chan, voicetype);
+       _GlobalSound(this.(samplefield), chan, voicetype);
 }
 
 void VoiceMessage(string type, string msg)
@@ -1258,7 +1258,7 @@ void VoiceMessage(string type, string msg)
        int flood = Say(this, ownteam, world, msg, true);
        void(string sample, int chan, int voicetype) f;
        f = (IS_SPEC(this) || IS_OBSERVER(this) || flood < 0) ? FakeGlobalSound
-               : (flood > 0) ? GlobalSound
+               : (flood > 0) ? _GlobalSound
                : func_null;
        if (f) f(this.(sample), CH_VOICE, voicetype);
 }
index 83ca3282f6fbac9979ed8d7154142a53a4c8e2f1..ef27f6a636ec6ecccbe102ba405cb842e90f8aaa 100644 (file)
@@ -94,8 +94,31 @@ void ClearPlayerSounds(entity this);
 float LoadPlayerSounds(string f, bool strict);
 void UpdatePlayerSounds(entity this);
 void FakeGlobalSound(string sample, float chan, float voicetype);
-void GlobalSound(string sample, float chan, float voicetype);
+void _GlobalSound(string sample, float chan, float voicetype);
+#define GlobalSound(def, chan, voicetype) _GlobalSound((def).m_globalsoundstr, chan, voicetype)
 void PlayerSound(.string samplefield, float chan, float voicetype);
 void VoiceMessage(string type, string msg);
 
+.string m_globalsoundstr;
+REGISTRY(GlobalSounds, BITS(8) - 1)
+#define GlobalSounds_from(i) _GlobalSounds_from(i, NULL)
+#define REGISTER_GLOBALSOUND(id, str) \
+       REGISTER(RegisterGlobalSounds, GS, GlobalSounds, id, m_id, new(GlobalSound)) \
+       { \
+               make_pure(this); \
+               this.m_globalsoundstr = str; \
+       }
+REGISTER_REGISTRY(RegisterGlobalSounds)
+REGISTRY_SORT(GlobalSounds, 0)
+REGISTRY_CHECK(GlobalSounds)
+PRECACHE(GlobalSounds)
+{
+       FOREACH(GlobalSounds, true, LAMBDA(PrecacheGlobalSound(it.m_globalsoundstr)));
+}
+
+REGISTER_GLOBALSOUND(STEP, "misc/footstep0 6")
+REGISTER_GLOBALSOUND(STEP_METAL, "misc/metalfootstep0 6")
+REGISTER_GLOBALSOUND(FALL, "misc/hitground 4")
+REGISTER_GLOBALSOUND(FALL_METAL, "misc/metalhitground 4")
+
 #endif
index 2a4c939668148ef98489dacb848d57849b770293..64157162cc0deb72ab2651435ddcff1faf5ac771 100644 (file)
@@ -303,11 +303,6 @@ float tracebox_hits_trigger_hurt(vector start, vector mi, vector ma, vector end)
 
 float next_pingtime;
 
-string globalsound_fall;
-string globalsound_metalfall;
-string globalsound_step;
-string globalsound_metalstep;
-
 const float VOICETYPE_PLAYERSOUND = 10;
 const float VOICETYPE_TEAMRADIO = 11;
 const float VOICETYPE_LASTATTACKER = 12;
index 2f459c35fcc839cdbf61a5b4bd1fed0deaa7023f..2b00fbffa04615cdf09bce81658ff57cd1d644a1 100644 (file)
@@ -964,16 +964,6 @@ void precache()
                precache_playermodels(autocvar_sv_defaultplayermodel);
     }
 
-    if (g_footsteps)
-    {
-        PrecacheGlobalSound((globalsound_step = "misc/footstep0 6"));
-        PrecacheGlobalSound((globalsound_metalstep = "misc/metalfootstep0 6"));
-    }
-
-    // gore and miscellaneous sounds
-    PrecacheGlobalSound((globalsound_fall = "misc/hitground 4"));
-    PrecacheGlobalSound((globalsound_metalfall = "misc/metalhitground 4"));
-
 #if 0
     // Disabled this code because it simply does not work (e.g. ignores bgmvolume, overlaps with "cd loop" controlled tracks).
 
index 09c9263d7d6753f8cb1261394f3cca1e60953840..0d5fa234f974ebe6bbdd10c7fc2cb35e36d2c9c4 100644 (file)
@@ -159,9 +159,9 @@ void CreatureFrame ()
                                        if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS))
                                        {
                                                if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS)
-                                                       GlobalSound(globalsound_metalstep, CH_PLAYER, VOICETYPE_PLAYERSOUND);
+                                                       GlobalSound(GS_STEP_METAL, CH_PLAYER, VOICETYPE_PLAYERSOUND);
                                                else
-                                                       GlobalSound(globalsound_step, CH_PLAYER, VOICETYPE_PLAYERSOUND);
+                                                       GlobalSound(GS_STEP, CH_PLAYER, VOICETYPE_PLAYERSOUND);
                                        }
                                }
                        }