From 0aba23a14014d84a5ca1e3a2af45608cc9f23044 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Wed, 20 Jul 2022 21:43:03 -0700 Subject: modules/meta2d: more rand()->rand_r() conversions Normalized all the randomizers to use til_module_context.seed while in here. --- src/modules/meta2d/v2f.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/modules/meta2d/v2f.h') diff --git a/src/modules/meta2d/v2f.h b/src/modules/meta2d/v2f.h index 8f51ee0..088772d 100644 --- a/src/modules/meta2d/v2f.h +++ b/src/modules/meta2d/v2f.h @@ -278,19 +278,19 @@ static inline v2f_t * v2f_trilerp(v2f_t *res, const v2f_t *aaa, const v2f_t *aba } -static inline v2f_t _v2f_rand(const v2f_t *min, const v2f_t *max) +static inline v2f_t _v2f_rand(unsigned *seedp, const v2f_t *min, const v2f_t *max) { return (v2f_t){ - .x = min->x + (float)rand() * (1.f/RAND_MAX) * (max->x - min->x), - .y = min->y + (float)rand() * (1.f/RAND_MAX) * (max->y - min->y), + .x = min->x + (float)rand_r(seedp) * (1.f/RAND_MAX) * (max->x - min->x), + .y = min->y + (float)rand_r(seedp) * (1.f/RAND_MAX) * (max->y - min->y), }; } -static inline v2f_t * v2f_rand(v2f_t *res, const v2f_t *min, const v2f_t *max) +static inline v2f_t * v2f_rand(v2f_t *res, unsigned *seedp, const v2f_t *min, const v2f_t *max) { if (_v2f_allocated(&res)) - *res = _v2f_rand(min, max); + *res = _v2f_rand(seedp, min, max); return res; } -- cgit v1.2.1