diff --git a/src/d_netcmd.c b/src/d_netcmd.c index b507edd99..67b875617 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -5347,14 +5347,13 @@ static void Gravity_OnChange(void) static void SoundTest_OnChange(void) { - INT32 sfxfreeint = (INT32)sfxfree; if (cv_soundtest.value < 0) { - CV_SetValue(&cv_soundtest, sfxfreeint-1); + CV_SetValue(&cv_soundtest, NUMSFX-1); return; } - if (cv_soundtest.value >= sfxfreeint) + if (cv_soundtest.value >= NUMSFX) { CV_SetValue(&cv_soundtest, 0); return; diff --git a/src/sounds.c b/src/sounds.c index 820e75cd1..d949c27ab 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -1007,44 +1007,34 @@ void S_InitRuntimeSounds (void) } } -sfxenum_t sfxfree = sfx_freeslot0; - // Add a new sound fx into a free sfx slot. // sfxenum_t S_AddSoundFx(const char *name, boolean singular, INT32 flags, boolean skinsound) { - sfxenum_t i; + sfxenum_t i, slot; if (skinsound) - { - for (i = sfx_skinsoundslot0; i < NUMSFX; i++) - { - if (S_sfx[i].priority) - continue; - break; - } - } + slot = sfx_skinsoundslot0; else - i = sfxfree; + slot = sfx_freeslot0; - if (i < NUMSFX) + for (i = slot; i < NUMSFX; i++) { - strncpy(freeslotnames[i-sfx_freeslot0], name, 6); - S_sfx[i].singularity = singular; - S_sfx[i].priority = 60; - S_sfx[i].pitch = flags; - S_sfx[i].volume = -1; - S_sfx[i].lumpnum = LUMPERROR; - S_sfx[i].skinsound = -1; - S_sfx[i].usefulness = -1; + if (!S_sfx[i].priority) + { + strncpy(freeslotnames[i-sfx_freeslot0], name, 6); + S_sfx[i].singularity = singular; + S_sfx[i].priority = 60; + S_sfx[i].pitch = flags; + S_sfx[i].volume = -1; + S_sfx[i].lumpnum = LUMPERROR; + S_sfx[i].skinsound = -1; + S_sfx[i].usefulness = -1; - /// \todo if precached load it here - S_sfx[i].data = NULL; - - if (!skinsound) - sfxfree++; - - return i; + /// \todo if precached load it here + S_sfx[i].data = NULL; + return i; + } } I_Error("Out of Sound Freeslots while allocating \"%s\"\nLoad less addons to fix this.", name); return 0; diff --git a/src/sounds.h b/src/sounds.h index a8f683e32..6621dc6bf 100644 --- a/src/sounds.h +++ b/src/sounds.h @@ -1057,7 +1057,6 @@ typedef enum void S_InitRuntimeSounds(void); sfxenum_t S_AddSoundFx(const char *name, boolean singular, INT32 flags, boolean skinsound); -extern sfxenum_t sfxfree; // sound test and slotting void S_RemoveSoundFx(sfxenum_t id); #endif