Sound Shaders: Exit out when we attempt to play a shader that hasn't been

precached.
This commit is contained in:
Marco Cawthorne 2021-03-13 04:24:53 +01:00
parent 923f0f424b
commit b49815872c
2 changed files with 23 additions and 3 deletions

View file

@ -440,6 +440,11 @@ initents(void)
precache_sound("items/flashlight1.wav");
precache_sound("common/null.wav");
Sound_Precache("player.gasplight");
Sound_Precache("player.gaspheavy");
Sound_Precache("player.waterenter");
Sound_Precache("player.waterexit");
Game_InitRules();
Game_Worldspawn();
Decals_Init();

View file

@ -276,9 +276,14 @@ Sound_Play(entity target, int chan, string shader)
int sample;
flag = 0;
sample = (int)hash_get(g_hashsounds, shader);
sample = (int)hash_get(g_hashsounds, shader, -1);
if (sample < 0) {
#ifdef SERVER
error(sprintf("Sound_Speak: shader %s is not precached (SERVER)\n", shader));
#else
error(sprintf("Sound_Speak: shader %s is not precached (CLIENT)\n", shader));
#endif
return;
}
@ -379,9 +384,14 @@ Sound_PlayAt(vector pos, string shader)
int sample;
flag = 0;
sample = (int)hash_get(g_hashsounds, shader);
sample = (int)hash_get(g_hashsounds, shader, -1);
if (sample < 0) {
#ifdef SERVER
error(sprintf("Sound_Speak: shader %s is not precached (SERVER)\n", shader));
#else
error(sprintf("Sound_Speak: shader %s is not precached (CLIENT)\n", shader));
#endif
return;
}
@ -481,9 +491,14 @@ Sound_Speak(entity target, string shader)
int flag;
int sample;
sample = (int)hash_get(g_hashsounds, shader);
sample = (int)hash_get(g_hashsounds, shader, -1);
if (sample < 0) {
#ifdef SERVER
error(sprintf("Sound_Speak: shader %s is not precached (SERVER)\n", shader));
#else
error(sprintf("Sound_Speak: shader %s is not precached (CLIENT)\n", shader));
#endif
return;
}