From 62d36cede8538a307e7929d074a7379acd191678 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Wed, 27 May 2015 08:46:12 +0000 Subject: [PATCH] Extend S_UpgradeFormat so that "filename.ext" first searches for "filename_ext.flac" and "filename_ext.ogg" before "filename.flac" and "filename.ogg". This fixes DUKETEAM playing grabbag.ogg instead of grabbag_voc.ogg when Megaton paths have been detected. git-svn-id: https://svn.eduke32.com/eduke32@5251 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/common.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/polymer/eduke32/source/common.c b/polymer/eduke32/source/common.c index 3bb22142b..aaf605a21 100644 --- a/polymer/eduke32/source/common.c +++ b/polymer/eduke32/source/common.c @@ -1078,10 +1078,14 @@ int32_t S_UpgradeFormat(const char *fn, char searchfirst) Bstrcpy(testfn, fn); extension = Bstrrchr(testfn, '.'); - if (extension) + if (extension != NULL) { + char * const fn_end = Bstrrchr(testfn, '\0'); + *extension = '_'; + #ifdef HAVE_FLAC - Bstrcpy(extension, ".flac"); + char const * const extFLAC = ".flac"; + Bstrcpy(fn_end, extFLAC); fp = kopen4loadfrommod(testfn, searchfirst); if (fp >= 0) { @@ -1091,7 +1095,28 @@ int32_t S_UpgradeFormat(const char *fn, char searchfirst) #endif #ifdef HAVE_VORBIS - Bstrcpy(extension, ".ogg"); + char const * const extOGG = ".ogg"; + Bstrcpy(fn_end, extOGG); + fp = kopen4loadfrommod(testfn, searchfirst); + if (fp >= 0) + { + Bfree(testfn); + return fp; + } +#endif + +#ifdef HAVE_FLAC + Bstrcpy(extension, extFLAC); + fp = kopen4loadfrommod(testfn, searchfirst); + if (fp >= 0) + { + Bfree(testfn); + return fp; + } +#endif + +#ifdef HAVE_VORBIS + Bstrcpy(extension, extOGG); fp = kopen4loadfrommod(testfn, searchfirst); if (fp >= 0) {