X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fsynfig%2Fguid.cpp;h=db0e149844acf158093b5065c2066d8f4e834b95;hb=4cd211467061154545ef7b5f5617dce7b177bf16;hp=a2a4ac4ce2239158e49e2ce935bdc827565a8f15;hpb=cc54c38609ee9745ad678e5e9b9d7d2912be9c95;p=synfig.git diff --git a/synfig-core/trunk/src/synfig/guid.cpp b/synfig-core/trunk/src/synfig/guid.cpp index a2a4ac4..db0e149 100644 --- a/synfig-core/trunk/src/synfig/guid.cpp +++ b/synfig-core/trunk/src/synfig/guid.cpp @@ -6,6 +6,7 @@ ** ** \legal ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2007 Chris Moore ** ** This package is free software; you can redistribute it and/or ** modify it under the terms of the GNU General Public License as @@ -33,6 +34,7 @@ #endif #include "guid.h" +#include "quick_rng.h" #include #include #include @@ -76,50 +78,6 @@ using namespace synfig; /* === M E T H O D S ======================================================= */ -// A fast 32-bit linear congruential random number generator -class quick_rng -{ - unsigned long next; -public: - quick_rng(unsigned long seed=0):next(seed) { } - - void set_seed(unsigned long x) - { - next=x; - } - - unsigned long i32() - { - static const unsigned long a(1664525); - static const unsigned long c(1013904223); - - return next=next*a+c; - } - - unsigned long i16() - { - return i32()>>16; - } - - float f() - { - static const float m(int(65535)); - - return float(i16())/m; - } - - unsigned long operator()(const unsigned long& m) - { - if(m==65536) - return i16(); - else - if(m<=65536) - return i16()%m; - else - return i32()%m; - } -}; - #define GUID_RNG quick_rng //#define GUID_RNG subtractive_rng @@ -134,7 +92,7 @@ static void (*get_rand_long_long)(uint64_t&)=_set_up_rand_long_long; static void _set_up_rand_long_long(uint64_t &x) { #ifdef _DEBUG - synfig::info("Starting up GUID system..."); + // synfig::info("Starting up GUID system..."); #endif _a=GUID_RNG(time(0)+clock()); _b=GUID_RNG(clock()); @@ -172,7 +130,7 @@ static void (*get_rand_long_long)(uint64_t&)=_set_up_rand_long_long; static void _set_up_rand_long_long(uint64_t &x) { #ifdef _DEBUG - synfig::info("Starting up GUID system..."); + // synfig::info("Starting up GUID system..."); #endif rand_fd=open("/dev/urandom",O_RDONLY); get_rand_long_long=_get_rand_long_long;