port over "sfxfree" from srb2
didnt feel like cherry picking this since we have most of this already - https://git.do.srb2.org/STJr/SRB2/-/commit/5f8671b1002eea61c1e7e00a9b91f30d732ce261 this means sound test wont have a gaziliion thok sounds anymore, aswell as S_AddSoundFx doesent have to iterate through a huuuuuge list of sounds each time a sound is getting added (if not a skinsound) which might speed up addon load a bit
This commit is contained in:
1 parent
84a9129185
commit
b18994dcc2
3 files changed
+35
-24
No files matched your search
+4
-2
@@ -4980,13 +4980,15 @@ static void Gravity_OnChange(void)
|
||||
|
||||
static void SoundTest_OnChange(void)
|
||||
{
|
||||
INT32 sfxfreeint = (INT32)sfxfree;
|
||||
|
||||
if (cv_soundtest.value < 0)
|
||||
{
|
||||
CV_SetValue(&cv_soundtest, NUMSFX-1);
|
||||
CV_SetValue(&cv_soundtest, sfxfreeint-1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cv_soundtest.value >= NUMSFX)
|
||||
if (cv_soundtest.value >= sfxfreeint)
|
||||
{
|
||||
CV_SetValue(&cv_soundtest, 0);
|
||||
return;
|
||||
|
||||
+30
-22
@@ -1007,39 +1007,47 @@ 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, slot;
|
||||
sfxenum_t i;
|
||||
|
||||
if (skinsound)
|
||||
slot = sfx_skinsoundslot0;
|
||||
else
|
||||
slot = sfx_freeslot0;
|
||||
|
||||
const int precache = S_CacheSound();
|
||||
|
||||
for (i = slot; i < NUMSFX; i++)
|
||||
{
|
||||
if (!S_sfx[i].priority)
|
||||
for (i = sfx_skinsoundslot0; 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].lumpnum = LUMPERROR;
|
||||
S_sfx[i].length = 0;
|
||||
S_sfx[i].skinsound = -1;
|
||||
if (S_sfx[i].priority)
|
||||
continue;
|
||||
|
||||
if (precache == SOUNDCACHE_PRECACHE)
|
||||
S_sfx[i].data = I_GetSfx(&S_sfx[i]);
|
||||
else
|
||||
S_sfx[i].data = NULL;
|
||||
|
||||
return i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
i = sfxfree;
|
||||
|
||||
if (i < NUMSFX)
|
||||
{
|
||||
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].lumpnum = LUMPERROR;
|
||||
S_sfx[i].length = 0;
|
||||
S_sfx[i].skinsound = -1;
|
||||
|
||||
if (S_CacheSound() == SOUNDCACHE_PRECACHE)
|
||||
S_sfx[i].data = I_GetSfx(&S_sfx[i]);
|
||||
else
|
||||
S_sfx[i].data = NULL;
|
||||
|
||||
if (!skinsound)
|
||||
sfxfree++;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
I_Error("Out of Sound Freeslots while allocating \"%s\"\nLoad less addons to fix this.", name);
|
||||
return 0;
|
||||
|
||||
@@ -1051,6 +1051,7 @@ 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
|
||||
Reference in new issue
Block a user