soundlib selection in config file wasn't working
When there was more than one option #define'd selection was not working correctly.
This commit is contained in:
@@ -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 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 set_voice(struct monst *, int32_t, int32_t, int32_t) NO_NNARGS;
|
||||||
extern void sound_speak(const char *) NO_NNARGS;
|
extern void sound_speak(const char *) NO_NNARGS;
|
||||||
|
extern enum soundlib_ids soundlib_id_from_opt(char *);
|
||||||
|
|
||||||
/* ### sp_lev.c ### */
|
/* ### sp_lev.c ### */
|
||||||
|
|
||||||
|
|||||||
@@ -3741,8 +3741,11 @@ optfn_soundlib(
|
|||||||
*/
|
*/
|
||||||
if ((op = string_for_env_opt(allopt[optidx].name, opts, FALSE))
|
if ((op = string_for_env_opt(allopt[optidx].name, opts, FALSE))
|
||||||
!= empty_optstr) {
|
!= empty_optstr) {
|
||||||
|
enum soundlib_ids option_id;
|
||||||
|
|
||||||
get_soundlib_name(soundlibbuf, WINTYPELEN);
|
get_soundlib_name(soundlibbuf, WINTYPELEN);
|
||||||
|
option_id = soundlib_id_from_opt(op);
|
||||||
|
gc.chosen_soundlib = option_id;
|
||||||
assign_soundlib(gc.chosen_soundlib);
|
assign_soundlib(gc.chosen_soundlib);
|
||||||
} else
|
} else
|
||||||
return optn_err;
|
return optn_err;
|
||||||
|
|||||||
15
src/sounds.c
15
src/sounds.c
@@ -1879,6 +1879,21 @@ get_soundlib_name(char *dest, int maxlen)
|
|||||||
*dest = '\0';
|
*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
|
* The default sound interface
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user