From 6cb925a95db44f3a4ea4e4237d49f3da2b75f47d Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Wed, 25 Nov 2015 12:08:10 +0000 Subject: [PATCH] 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 --- polymer/eduke32/source/common.c | 11 ++++++----- polymer/eduke32/source/common_game.h | 2 +- polymer/eduke32/source/premap.c | 2 +- polymer/eduke32/source/sounds.c | 4 ++-- polymer/eduke32/source/sounds_mapster32.c | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/polymer/eduke32/source/common.c b/polymer/eduke32/source/common.c index a7d33764c..c0b08d4b1 100644 --- a/polymer/eduke32/source/common.c +++ b/polymer/eduke32/source/common.c @@ -1059,7 +1059,7 @@ static int32_t S_TryFormats(char const * const testfn, char * const fn_suffix, c 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 * 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.* + 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); if (fp >= 0) @@ -1088,7 +1089,7 @@ static int32_t S_TryExtensionReplacements(char const * const testfn, char const 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); 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 { Bstrcpy(testfn, fn); - int32_t const fp = S_TryExtensionReplacements(testfn, searchfirst); + int32_t const fp = S_TryExtensionReplacements(testfn, searchfirst, 1); if (fp >= 0) { Bfree(testfn); @@ -1118,7 +1119,7 @@ int32_t S_OpenAudio(const char *fn, char searchfirst) uint32_t namelength = origparentextension != NULL ? origparentextension - origparent : origparentlength; 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) { Bfree(testfn); @@ -1131,7 +1132,7 @@ int32_t S_OpenAudio(const char *fn, char searchfirst) // ex: ./music/grabbag.mid { 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) { Bfree(testfn); diff --git a/polymer/eduke32/source/common_game.h b/polymer/eduke32/source/common_game.h index c25fa3a55..8da598f66 100644 --- a/polymer/eduke32/source/common_game.h +++ b/polymer/eduke32/source/common_game.h @@ -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 } diff --git a/polymer/eduke32/source/premap.c b/polymer/eduke32/source/premap.c index 256bdd7d6..482224b51 100644 --- a/polymer/eduke32/source/premap.c +++ b/polymer/eduke32/source/premap.c @@ -284,7 +284,7 @@ static int32_t G_CacheSound(uint32_t num) 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)) { // OSD_Printf(OSDTEXT_RED "Sound %s(#%d) not found!\n",g_sounds[num].filename,num); diff --git a/polymer/eduke32/source/sounds.c b/polymer/eduke32/source/sounds.c index 24f5a31b0..e7f438851 100644 --- a/polymer/eduke32/source/sounds.c +++ b/polymer/eduke32/source/sounds.c @@ -186,7 +186,7 @@ int32_t S_PlayMusic(const char *fn) if (!ud.config.MusicToggle || fn == NULL) return 0; - int32_t fp = S_OpenAudio(fn, 0); + int32_t fp = S_OpenAudio(fn, 0, 1); if (EDUKE32_PREDICT_FALSE(fp < 0)) { 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; } - 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)) { OSD_Printf(OSDTEXT_RED "Sound %s(#%d) not found!\n",g_sounds[num].filename,num); diff --git a/polymer/eduke32/source/sounds_mapster32.c b/polymer/eduke32/source/sounds_mapster32.c index cb7770bbb..166a396e6 100644 --- a/polymer/eduke32/source/sounds_mapster32.c +++ b/polymer/eduke32/source/sounds_mapster32.c @@ -134,7 +134,7 @@ int32_t S_LoadSound(uint32_t num) 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) { OSD_Printf(OSDTEXT_RED "Sound %s(#%d) not found!\n",g_sounds[num].filename,num);