Duke3D/Sound: Make kopen4loadfrommod a tail-call from S_UpgradeFormat, rename the function to S_OpenAudio, and replace 4x calls to one and then the other. No functional changes.

git-svn-id: https://svn.eduke32.com/eduke32@5444 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2015-11-25 12:08:04 +00:00
parent af5f47797d
commit fcd7b2e0b1
5 changed files with 13 additions and 44 deletions

View file

@ -1034,8 +1034,7 @@ void G_LoadLookups(void)
kclose(fp);
}
#if defined HAVE_FLAC || defined HAVE_VORBIS
int32_t S_UpgradeFormat(const char *fn, char searchfirst)
int32_t S_OpenAudio(const char *fn, char searchfirst)
{
char *testfn, *extension;
int32_t fp = -1;
@ -1093,6 +1092,5 @@ int32_t S_UpgradeFormat(const char *fn, char searchfirst)
}
Bfree(testfn);
return -1;
return kopen4loadfrommod(fn, searchfirst);
}
#endif

View file

@ -128,9 +128,7 @@ extern void G_LoadLookups(void);
//////////
#if defined HAVE_FLAC || defined HAVE_VORBIS
int32_t S_UpgradeFormat(const char *fn, char searchfirst);
#endif
extern int32_t S_OpenAudio(const char *fn, char searchfirst);
#ifdef __cplusplus
}

View file

@ -280,25 +280,18 @@ static void G_PrecacheSprites(void)
// FIXME: this function is a piece of shit, needs specific sounds listed
static int32_t G_CacheSound(uint32_t num)
{
int16_t fp = -1;
int32_t l;
if (num >= MAXSOUNDS || !ud.config.SoundToggle) return 0;
if (EDUKE32_PREDICT_FALSE(!g_sounds[num].filename)) return 0;
#if defined HAVE_FLAC || defined HAVE_VORBIS
fp = S_UpgradeFormat(g_sounds[num].filename, g_loadFromGroupOnly);
if (fp == -1)
#endif
fp = kopen4loadfrommod(g_sounds[num].filename,g_loadFromGroupOnly);
if (fp == -1)
int32_t fp = S_OpenAudio(g_sounds[num].filename, g_loadFromGroupOnly);
if (EDUKE32_PREDICT_FALSE(fp == -1))
{
// OSD_Printf(OSDTEXT_RED "Sound %s(#%d) not found!\n",g_sounds[num].filename,num);
return 0;
}
l = kfilelength(fp);
int32_t l = kfilelength(fp);
g_sounds[num].soundsiz = l;
if ((ud.level_number == 0 && ud.volume_number == 0 && (num == 189 || num == 232 || num == 99 || num == 233 || num == 17)) ||

View file

@ -186,13 +186,7 @@ int32_t S_PlayMusic(const char *fn)
if (!ud.config.MusicToggle || fn == NULL)
return 0;
int32_t fp;
#if defined HAVE_FLAC || defined HAVE_VORBIS
if ((fp = S_UpgradeFormat(fn, 0)) < 0)
#endif
fp = kopen4loadfrommod(fn, 0);
int32_t fp = S_OpenAudio(fn, 0);
if (EDUKE32_PREDICT_FALSE(fp < 0))
{
OSD_Printf(OSD_ERROR "S_PlayMusic(): error: can't open \"%s\" for playback!\n",fn);
@ -355,20 +349,12 @@ int32_t S_LoadSound(uint32_t num)
return 0;
}
int32_t fp;
#if defined HAVE_FLAC || defined HAVE_VORBIS
fp = S_UpgradeFormat(g_sounds[num].filename, g_loadFromGroupOnly);
if (fp == -1)
#endif
{
fp = kopen4loadfrommod(g_sounds[num].filename,g_loadFromGroupOnly);
int32_t fp = S_OpenAudio(g_sounds[num].filename, g_loadFromGroupOnly);
if (EDUKE32_PREDICT_FALSE(fp == -1))
{
OSD_Printf(OSDTEXT_RED "Sound %s(#%d) not found!\n",g_sounds[num].filename,num);
return 0;
}
}
int32_t l = kfilelength(fp);
g_soundlocks[num] = 200;

View file

@ -125,8 +125,6 @@ void S_SoundShutdown(void)
int32_t S_LoadSound(uint32_t num)
{
int32_t fp = -1, l;
if (!SM32_havesound) return 0;
if (num >= MAXSOUNDS || SoundToggle == 0) return 0;
@ -136,18 +134,14 @@ int32_t S_LoadSound(uint32_t num)
return 0;
}
#if defined HAVE_FLAC || defined HAVE_VORBIS
fp = S_UpgradeFormat(g_sounds[num].filename, 0);
if (fp == -1)
#endif
fp = kopen4loadfrommod(g_sounds[num].filename,0);
int32_t fp = S_OpenAudio(g_sounds[num].filename, 0);
if (fp == -1)
{
OSD_Printf(OSDTEXT_RED "Sound %s(#%d) not found!\n",g_sounds[num].filename,num);
return 0;
}
l = kfilelength(fp);
int32_t l = kfilelength(fp);
g_sounds[num].soundsiz = l;
g_sounds[num].lock = 200;