Don't allow Ogg Vorbis or FLAC files to be defined from def if the binary was built without the proper libraries.

git-svn-id: https://svn.eduke32.com/eduke32@4949 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2015-01-25 12:18:11 +00:00
parent b6d625b202
commit 7c800f6631

View file

@ -9255,16 +9255,29 @@ static void G_ShowDebugHelp(void)
#endif #endif
} }
static int32_t S_DefineAudioIfSupported(char **fn, const char *name)
{
#if !defined HAVE_FLAC || !defined HAVE_VORBIS
const char *extension = Bstrrchr(name, '.');
# if !defined HAVE_FLAC
if (!Bstrcasecmp(extension, ".flac"))
return -2;
# endif
# if !defined HAVE_VORBIS
if (!Bstrcasecmp(extension, ".ogg"))
return -2;
# endif
#endif
realloc_copy(fn, name);
return 0;
}
static int32_t S_DefineSound(int32_t ID, const char *name) static int32_t S_DefineSound(int32_t ID, const char *name)
{ {
if ((unsigned)ID >= MAXSOUNDS) if ((unsigned)ID >= MAXSOUNDS)
return 1; return -1;
realloc_copy(&g_sounds[ID].filename, name); return S_DefineAudioIfSupported(&g_sounds[ID].filename, name);
// S_LoadSound(ID);
return 0;
} }
// Returns: // Returns:
@ -9295,9 +9308,7 @@ static int32_t S_DefineMusic(const char *ID, const char *name)
return -1; return -1;
} }
realloc_copy(&MapInfo[sel].musicfn, name); return S_DefineAudioIfSupported(&MapInfo[sel].musicfn, name);
return 0;
} }
static int32_t parsedefinitions_game(scriptfile *script, int32_t preload); static int32_t parsedefinitions_game(scriptfile *script, int32_t preload);
@ -9612,7 +9623,7 @@ static int32_t parsedefinitions_game(scriptfile *script, int32_t preload)
if (check_file_exist(fn)) if (check_file_exist(fn))
break; break;
if (S_DefineSound(num,fn)) if (S_DefineSound(num,fn) == -1)
initprintf("Error: invalid sound ID on line %s:%d\n", script->filename, scriptfile_getlinum(script,tinttokptr)); initprintf("Error: invalid sound ID on line %s:%d\n", script->filename, scriptfile_getlinum(script,tinttokptr));
} }
} }