summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/checkers/checkers.c6
-rw-r--r--src/modules/compose/compose.c12
-rw-r--r--src/modules/montage/montage.c2
-rw-r--r--src/modules/rtv/rtv.c2
4 files changed, 11 insertions, 11 deletions
diff --git a/src/modules/checkers/checkers.c b/src/modules/checkers/checkers.c
index 8b30445..7eee608 100644
--- a/src/modules/checkers/checkers.c
+++ b/src/modules/checkers/checkers.c
@@ -100,7 +100,7 @@ static til_module_context_t * checkers_create_context(unsigned seed, unsigned ti
const til_module_t *module = ctxt->setup.fill_module;
til_setup_t *module_setup = NULL;
- (void) til_module_randomize_setup(module, &module_setup, NULL);
+ (void) til_module_randomize_setup(module, seed, &module_setup, NULL);
/* since checkers is already threaded, create an n_cpus=1 context per-cpu */
for (unsigned i = 0; i < n_cpus; i++) /* TODO: errors */
@@ -236,7 +236,7 @@ static void checkers_render_fragment(til_module_context_t *context, unsigned tic
/* TODO: migrate to libtil */
-static char * checkers_random_color(void)
+static char * checkers_random_color(unsigned seed)
{
/* til should probably have a common randomize color helper for this with a large collection of
* reasonable colors, and maybe even have themed palettes one can choose from... */
@@ -250,7 +250,7 @@ static char * checkers_random_color(void)
"#ff00ff",
};
- return strdup(colors[rand() % nelems(colors)]);
+ return strdup(colors[seed % nelems(colors)]);
}
diff --git a/src/modules/compose/compose.c b/src/modules/compose/compose.c
index bd34405..ed0ed1c 100644
--- a/src/modules/compose/compose.c
+++ b/src/modules/compose/compose.c
@@ -86,7 +86,7 @@ static til_module_context_t * compose_create_context(unsigned seed, unsigned tic
til_setup_t *layer_setup = NULL;
layer_module = til_lookup_module(((compose_setup_t *)setup)->layers[i]);
- (void) til_module_randomize_setup(layer_module, &layer_setup, NULL);
+ (void) til_module_randomize_setup(layer_module, rand_r(&seed), &layer_setup, NULL);
ctxt->layers[i].module = layer_module;
(void) til_module_create_context(layer_module, rand_r(&seed), ticks, 0, layer_setup, &ctxt->layers[i].module_ctxt);
@@ -99,7 +99,7 @@ static til_module_context_t * compose_create_context(unsigned seed, unsigned tic
til_setup_t *texture_setup = NULL;
ctxt->texture.module = til_lookup_module(((compose_setup_t *)setup)->texture);
- (void) til_module_randomize_setup(ctxt->texture.module, &texture_setup, NULL);
+ (void) til_module_randomize_setup(ctxt->texture.module, rand_r(&seed), &texture_setup, NULL);
(void) til_module_create_context(ctxt->texture.module, rand_r(&seed), ticks, 0, texture_setup, &ctxt->texture.module_ctxt);
til_setup_free(texture_setup);
@@ -165,7 +165,7 @@ static void compose_prepare_frame(til_module_context_t *context, unsigned ticks,
/* return a randomized valid layers= setting */
-static char * compose_random_layers_setting(void)
+static char * compose_random_layers_setting(unsigned seed)
{
size_t n_modules, n_rand_overlays, n_overlayable = 0, base_idx;
char *layers = NULL;
@@ -178,7 +178,7 @@ static char * compose_random_layers_setting(void)
n_overlayable++;
}
- base_idx = rand() % (n_modules - n_overlayable);
+ base_idx = rand_r(&seed) % (n_modules - n_overlayable);
for (size_t i = 0, j = 0; !layers && i < n_modules; i++) {
if (modules[i]->flags & TIL_MODULE_OVERLAYABLE)
continue;
@@ -192,9 +192,9 @@ static char * compose_random_layers_setting(void)
* sometimes interesting. Maybe another module flag is necessary for indicating
* manifold-appropriate overlays.
*/
- n_rand_overlays = 1 + (rand() % (n_overlayable - 1));
+ n_rand_overlays = 1 + (rand_r(&seed) % (n_overlayable - 1));
for (size_t n = 0; n < n_rand_overlays; n++) {
- size_t rand_idx = rand() % n_overlayable;
+ 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_OVERLAYABLE))
diff --git a/src/modules/montage/montage.c b/src/modules/montage/montage.c
index 820e67d..7991e3f 100644
--- a/src/modules/montage/montage.c
+++ b/src/modules/montage/montage.c
@@ -89,7 +89,7 @@ static til_module_context_t * montage_create_context(unsigned seed, unsigned tic
const til_module_t *module = ctxt->modules[i];
til_setup_t *setup = NULL;
- (void) til_module_randomize_setup(module, &setup, NULL);
+ (void) til_module_randomize_setup(module, rand_r(&seed), &setup, NULL);
/* FIXME errors */
(void) til_module_create_context(module, rand_r(&seed), ticks, 1, setup, &ctxt->contexts[i]);
diff --git a/src/modules/rtv/rtv.c b/src/modules/rtv/rtv.c
index 97c7a67..9714368 100644
--- a/src/modules/rtv/rtv.c
+++ b/src/modules/rtv/rtv.c
@@ -170,7 +170,7 @@ static void setup_next_channel(rtv_context_t *ctxt, unsigned ticks)
char *settings_as_arg = NULL;
txt_t *caption;
- (void) til_module_randomize_setup(ctxt->channel->module, &ctxt->channel->module_setup, &settings_as_arg);
+ (void) til_module_randomize_setup(ctxt->channel->module, rand_r(&ctxt->til_module_context.seed), &ctxt->channel->module_setup, &settings_as_arg);
caption = txt_newf("Title: %s%s%s\nDescription: %s%s%s",
ctxt->channel->module->name,
ctxt->channel->module->author ? "\nAuthor: " : "",
© All Rights Reserved