diff --git a/include/extern.h b/include/extern.h index 760ad30e2..e3e0ac152 100644 --- a/include/extern.h +++ b/include/extern.h @@ -2932,6 +2932,7 @@ extern char *get_sound_effect_filename(int32_t seidint, extern char *base_soundname_to_filename(char *, char *, size_t, int32_t) NONNULLARG1; extern void set_voice(struct monst *, int32_t, int32_t, int32_t) NO_NNARGS; extern void sound_speak(const char *) NO_NNARGS; +extern enum soundlib_ids soundlib_id_from_opt(char *); /* ### sp_lev.c ### */ diff --git a/src/options.c b/src/options.c index 30d7709f4..b8b192fd2 100644 --- a/src/options.c +++ b/src/options.c @@ -3741,8 +3741,11 @@ optfn_soundlib( */ if ((op = string_for_env_opt(allopt[optidx].name, opts, FALSE)) != empty_optstr) { + enum soundlib_ids option_id; get_soundlib_name(soundlibbuf, WINTYPELEN); + option_id = soundlib_id_from_opt(op); + gc.chosen_soundlib = option_id; assign_soundlib(gc.chosen_soundlib); } else return optn_err; diff --git a/src/sounds.c b/src/sounds.c index 5a5e9fd66..9ca6b199d 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -1879,6 +1879,21 @@ get_soundlib_name(char *dest, int maxlen) *dest = '\0'; } +enum soundlib_ids +soundlib_id_from_opt(char *op) +{ + int idx; + struct sound_procs *defproc = &nosound_procs, + *sp = 0; + + for (idx = 0; idx < SIZE(soundlib_choices); ++idx) { + sp = soundlib_choices[idx].sndprocs; + if (!strcmp(sp->soundname, op)) + return sp->soundlib_id; + } + return defproc->soundlib_id; +} + /* * The default sound interface *