summaryrefslogtreecommitdiff
path: root/src/modules/rkt
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/rkt')
-rw-r--r--src/modules/rkt/rkt.c18
-rw-r--r--src/modules/rkt/rkt.h1
-rw-r--r--src/modules/rkt/rkt_scener.c16
3 files changed, 11 insertions, 24 deletions
diff --git a/src/modules/rkt/rkt.c b/src/modules/rkt/rkt.c
index 45073ef..c84b6ce 100644
--- a/src/modules/rkt/rkt.c
+++ b/src/modules/rkt/rkt.c
@@ -266,7 +266,7 @@ static til_module_context_t * rkt_create_context(const til_module_t *module, til
til_stream_set_hooks(stream, &rkt_stream_hooks, ctxt);
for (size_t i = 0; i < ctxt->n_scenes; i++) {
- if (til_module_create_context(s->scenes[i].module, stream, rand_r(&seed), ticks, 0, s->scenes[i].setup, &ctxt->scenes[i].module_ctxt) < 0)
+ if (til_module_create_context(s->scenes[i].setup->creator, stream, rand_r(&seed), ticks, 0, s->scenes[i].setup, &ctxt->scenes[i].module_ctxt) < 0)
return til_module_context_free(&ctxt->til_module_context);
}
@@ -649,23 +649,17 @@ static int rkt_setup(const til_settings_t *settings, til_setting_t **res_setting
setup->n_scenes = n_scenes;
for (size_t i = 0; til_settings_get_value_by_idx(scenes_settings, i, &scene_setting); i++) {
- const char *scene_module_name = til_settings_get_value_by_idx(scene_setting->value_as_nested_settings, 0, NULL);
- const til_module_t *scene_module = til_lookup_module(scene_module_name);
-
- if (!scene_module || !strcmp(scene_module_name, "rkt")) {
- til_setup_free(&setup->til_setup);
-
- return -EINVAL;
- }
-
- r = til_module_setup_finalize(scene_module, scene_setting->value_as_nested_settings, &setup->scenes[i].setup);
+ r = rkt_scene_module_setup(scene_setting->value_as_nested_settings,
+ res_setting,
+ res_desc,
+ &setup->scenes[i].setup); /* XXX: note no res_setup, must defer finalize */
if (r < 0) {
til_setup_free(&setup->til_setup);
return r;
}
- setup->scenes[i].module = scene_module;
+ assert(r == 0); /* the settings should be complete by now, so this is unexpected */
}
setup->base = strdup(base);
diff --git a/src/modules/rkt/rkt.h b/src/modules/rkt/rkt.h
index e5ed4dc..cff768c 100644
--- a/src/modules/rkt/rkt.h
+++ b/src/modules/rkt/rkt.h
@@ -36,7 +36,6 @@ typedef struct rkt_context_t {
} rkt_context_t;
typedef struct rkt_setup_scene_t {
- const til_module_t *module;
til_setup_t *setup; /* Baked setup as-configured via setup. */
} rkt_setup_scene_t;
diff --git a/src/modules/rkt/rkt_scener.c b/src/modules/rkt/rkt_scener.c
index c272caa..dfe22b1 100644
--- a/src/modules/rkt/rkt_scener.c
+++ b/src/modules/rkt/rkt_scener.c
@@ -1160,8 +1160,6 @@ int rkt_scener_update(rkt_context_t *ctxt)
}
{ /* finalize setup, create context, expand context scenes or replace existing */
- const char *module_name;
- const til_module_t *module;
til_module_context_t *module_ctxt;
til_setup_t *setup;
rkt_scene_t *new_scenes;
@@ -1172,15 +1170,11 @@ int rkt_scener_update(rkt_context_t *ctxt)
* and it's time to bake the setup and create the context,
* adding the rkt_scene_t instance corresponding to the settings.
*/
- module_name = til_settings_get_value_by_idx(scener->new_scene.settings, 0, NULL);
- if (!module_name) /* FIXME TODO we should probably un-add the scene from scenes_settings??? */
- return rkt_scener_err_close(scener, EINVAL); /* this really shouldn't happen */
- module = til_lookup_module(module_name);
- if (!module) /* FIXME TODO we should probably un-add the scene from scenes_settings??? */
- return rkt_scener_err_close(scener, EINVAL); /* this really shouldn't happen */
-
- r = til_module_setup_finalize(module, scener->new_scene.settings, &setup);
+ r = rkt_scene_module_setup(scener->new_scene.settings,
+ &scener->new_scene.cur_setting,
+ &scener->new_scene.cur_desc,
+ &setup);
if (r < 0) { /* FIXME TODO we should probably un-add the scene from scenes_settings??? */
if (r != -EINVAL)
return rkt_scener_err_close(scener, r);
@@ -1196,7 +1190,7 @@ int rkt_scener_update(rkt_context_t *ctxt)
}
/* have baked setup @ setup, create context using it */
- r = til_module_create_context(module,
+ r = til_module_create_context(setup->creator,
ctxt->til_module_context.stream,
rand_r(&ctxt->til_module_context.seed), /* FIXME TODO seeds need work (make reproducible) */
ctxt->til_module_context.last_ticks,
© All Rights Reserved