From: ehofman Date: Sat, 30 Apr 2005 09:59:12 +0000 (+0000) Subject: Add a seed function that gives the same random seed within a ten minute period of... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=f9cbf8361dd8cbc24e077d667f83dcf91a8ade67;p=simgear.git Add a seed function that gives the same random seed within a ten minute period of time. This should be useful for synchronizing display systems. --- diff --git a/simgear/math/sg_random.c b/simgear/math/sg_random.c index adac20cb..c602bb53 100644 --- a/simgear/math/sg_random.c +++ b/simgear/math/sg_random.c @@ -134,6 +134,13 @@ void sg_srandom_time() { init_genrand(time(NULL)); } +// Seed the random number generater with time() in 10 minute intervals +// so we get the same sequence within 10 minutes interval. +// This is useful for synchronizing two display systems. +void sg_srandom_time_10() { + init_genrand(time(NULL) / 600); +} + // Seed the random number generater with your own seed so can set up // repeatable randomization. diff --git a/simgear/math/sg_random.h b/simgear/math/sg_random.h index aaea0c45..6d993296 100644 --- a/simgear/math/sg_random.h +++ b/simgear/math/sg_random.h @@ -40,6 +40,13 @@ extern "C" { */ void sg_srandom_time(); +/** + * Seed the random number generater with time() in 10 minute intervals + * so we get the same sequence within 10 minutes interval. + * This is useful for synchronizing two display systems. + */ +void sg_srandom_time_10(); + /** * Seed the random number generater with your own seed so can set up * repeatable randomization.