diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2023-08-05 13:24:30 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2023-08-05 14:30:34 -0700 |
commit | 99f05d9a964629d51f0d42e69ab546b8ae04fc75 (patch) | |
tree | bd8ea9e5523b3f509e918a2e17f071d2d5be05db /src/modules/compose | |
parent | b212a43bb2d4eed6780cc93394fa566a09018a68 (diff) |
modules/{compose,montage,rtv}: exclude builtins
Basically everywhere the
TIL_MODULE_HERMETIC|TIL_MODULE_EXPERIMENTAL exclusions were being
applied needed TIL_MODULE_BUILTIN added.
Mostly this is to prevent randomizers from tripping over builtins
in the available modules lists they draw from.
Because builtins aren't visually interesting by themselves, and
in some cases don't currently even have a means of being
randomized properly like ref's path setting.
This wasn't needed previously since builtins were kept off the
modules list altogether. But since 1a6210be that changed and
they must be explicitly filtered by flag instead.
Note I deliberately left the rkt case with just a TODO comment.
It's not a randomizer situation, and it might be acceptable to
let rkt just show everything all the time in the module lists.
That whole situation there is for advanced users.
Also note that without this, rtv et al would easily trigger an
assert on NULL setup due to the "none" builtin. Since there's
still work to be done there in callers properly handling NULL
@res_setup on a successful finalize. But this commit mitigates
that by avoiding the builtins in the randomizers.
Diffstat (limited to 'src/modules/compose')
-rw-r--r-- | src/modules/compose/compose.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/modules/compose/compose.c b/src/modules/compose/compose.c index 5420cc3..4c6e0f5 100644 --- a/src/modules/compose/compose.c +++ b/src/modules/compose/compose.c @@ -149,11 +149,12 @@ static char * compose_random_layers_setting(unsigned seed) size_t n_modules, n_rand_overlays, n_overlayable = 0, n_unusable = 0, base_idx; char *layers = NULL; const til_module_t **modules; + unsigned unusable_flags = (TIL_MODULE_HERMETIC | TIL_MODULE_EXPERIMENTAL | TIL_MODULE_BUILTIN); til_get_modules(&modules, &n_modules); for (size_t i = 0; i < n_modules; i++) { - if ((modules[i]->flags & (TIL_MODULE_HERMETIC | TIL_MODULE_EXPERIMENTAL)) || + if ((modules[i]->flags & unusable_flags) || modules[i] == &compose_module) { n_unusable++; @@ -166,7 +167,7 @@ static char * compose_random_layers_setting(unsigned seed) base_idx = rand_r(&seed) % (n_modules - (n_overlayable + n_unusable)); for (size_t i = 0, j = 0; !layers && i < n_modules; i++) { - if ((modules[i]->flags & (TIL_MODULE_HERMETIC | TIL_MODULE_EXPERIMENTAL)) || + if ((modules[i]->flags & unusable_flags) || modules[i] == &compose_module) continue; @@ -187,7 +188,7 @@ static char * compose_random_layers_setting(unsigned seed) size_t rand_idx = rand_r(&seed) % n_overlayable; for (size_t i = 0, j = 0; i < n_modules; i++) { - if ((modules[i]->flags & (TIL_MODULE_HERMETIC | TIL_MODULE_EXPERIMENTAL)) || + if ((modules[i]->flags & unusable_flags) || modules[i] == &compose_module) continue; |