Duke3D/Sound: Add a hack to the previous commit so that Megaton's grabbag.voc will still upgrade to music/grabbag_voc.ogg, but its subway.voc will no longer upgrade to music/subway.ogg.

git-svn-id: https://svn.eduke32.com/eduke32@5446 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2015-11-25 12:08:10 +00:00
parent 26aca9b291
commit 6cb925a95d
5 changed files with 11 additions and 10 deletions

View file

@ -1059,7 +1059,7 @@ static int32_t S_TryFormats(char const * const testfn, char * const fn_suffix, c
return -1; return -1;
} }
static int32_t S_TryExtensionReplacements(char const * const testfn, char const searchfirst) static int32_t S_TryExtensionReplacements(char const * const testfn, char const searchfirst, uint8_t const ismusic)
{ {
char * extension = Bstrrchr(testfn, '.'); char * extension = Bstrrchr(testfn, '.');
char * const fn_end = Bstrchr(testfn, '\0'); char * const fn_end = Bstrchr(testfn, '\0');
@ -1079,6 +1079,7 @@ static int32_t S_TryExtensionReplacements(char const * const testfn, char const
} }
// ex: grabbag.mid --> grabbag.* // ex: grabbag.mid --> grabbag.*
if (ismusic) // this conditional is a hack so that subway.voc does not upgrade to Megaton's music/subway.ogg
{ {
int32_t const fp = S_TryFormats(testfn, extension, searchfirst); int32_t const fp = S_TryFormats(testfn, extension, searchfirst);
if (fp >= 0) if (fp >= 0)
@ -1088,7 +1089,7 @@ static int32_t S_TryExtensionReplacements(char const * const testfn, char const
return -1; return -1;
} }
int32_t S_OpenAudio(const char *fn, char searchfirst) int32_t S_OpenAudio(const char *fn, char searchfirst, uint8_t const ismusic)
{ {
int32_t const origfp = kopen4loadfrommod(fn, searchfirst); int32_t const origfp = kopen4loadfrommod(fn, searchfirst);
char const * const origparent = origfp != -1 ? kfileparent(origfp) : NULL; char const * const origparent = origfp != -1 ? kfileparent(origfp) : NULL;
@ -1100,7 +1101,7 @@ int32_t S_OpenAudio(const char *fn, char searchfirst)
// ex: ./grabbag.mid // ex: ./grabbag.mid
{ {
Bstrcpy(testfn, fn); Bstrcpy(testfn, fn);
int32_t const fp = S_TryExtensionReplacements(testfn, searchfirst); int32_t const fp = S_TryExtensionReplacements(testfn, searchfirst, 1);
if (fp >= 0) if (fp >= 0)
{ {
Bfree(testfn); Bfree(testfn);
@ -1118,7 +1119,7 @@ int32_t S_OpenAudio(const char *fn, char searchfirst)
uint32_t namelength = origparentextension != NULL ? origparentextension - origparent : origparentlength; uint32_t namelength = origparentextension != NULL ? origparentextension - origparent : origparentlength;
Bsprintf(testfn, "music/%.*s/%s", namelength, origparent, fn); Bsprintf(testfn, "music/%.*s/%s", namelength, origparent, fn);
int32_t const fp = S_TryExtensionReplacements(testfn, searchfirst); int32_t const fp = S_TryExtensionReplacements(testfn, searchfirst, ismusic);
if (fp >= 0) if (fp >= 0)
{ {
Bfree(testfn); Bfree(testfn);
@ -1131,7 +1132,7 @@ int32_t S_OpenAudio(const char *fn, char searchfirst)
// ex: ./music/grabbag.mid // ex: ./music/grabbag.mid
{ {
Bsprintf(testfn, "music/%s", fn); Bsprintf(testfn, "music/%s", fn);
int32_t const fp = S_TryExtensionReplacements(testfn, searchfirst); int32_t const fp = S_TryExtensionReplacements(testfn, searchfirst, ismusic);
if (fp >= 0) if (fp >= 0)
{ {
Bfree(testfn); Bfree(testfn);

View file

@ -128,7 +128,7 @@ extern void G_LoadLookups(void);
////////// //////////
extern int32_t S_OpenAudio(const char *fn, char searchfirst); extern int32_t S_OpenAudio(const char *fn, char searchfirst, uint8_t ismusic);
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -284,7 +284,7 @@ static int32_t G_CacheSound(uint32_t num)
if (EDUKE32_PREDICT_FALSE(!g_sounds[num].filename)) return 0; if (EDUKE32_PREDICT_FALSE(!g_sounds[num].filename)) return 0;
int32_t fp = S_OpenAudio(g_sounds[num].filename, g_loadFromGroupOnly); int32_t fp = S_OpenAudio(g_sounds[num].filename, g_loadFromGroupOnly, 0);
if (EDUKE32_PREDICT_FALSE(fp == -1)) if (EDUKE32_PREDICT_FALSE(fp == -1))
{ {
// OSD_Printf(OSDTEXT_RED "Sound %s(#%d) not found!\n",g_sounds[num].filename,num); // OSD_Printf(OSDTEXT_RED "Sound %s(#%d) not found!\n",g_sounds[num].filename,num);

View file

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

View file

@ -134,7 +134,7 @@ int32_t S_LoadSound(uint32_t num)
return 0; return 0;
} }
int32_t fp = S_OpenAudio(g_sounds[num].filename, 0); int32_t fp = S_OpenAudio(g_sounds[num].filename, 0, 0);
if (fp == -1) if (fp == -1)
{ {
OSD_Printf(OSDTEXT_RED "Sound %s(#%d) not found!\n",g_sounds[num].filename,num); OSD_Printf(OSDTEXT_RED "Sound %s(#%d) not found!\n",g_sounds[num].filename,num);