Hi,

Here is a patch that replaces rand() calls with arc4random().

Tested on i386 with tuxkart and speed-dreams.

ok's/comments?

Index: Makefile
===================================================================
RCS file: /cvs/ports/devel/plib/Makefile,v
retrieving revision 1.10
diff -u -p -u -p -r1.10 Makefile
--- Makefile    11 Mar 2013 10:50:24 -0000      1.10
+++ Makefile    25 Sep 2013 08:19:34 -0000
@@ -3,7 +3,7 @@
 COMMENT =      suite of portable game libraries
 
 DISTNAME =     plib-1.8.5
-REVISION =     3
+REVISION =     4
 CATEGORIES =   devel games
 
 HOMEPAGE =     http://plib.sourceforge.net/
Index: patches/patch-src_sg_sgPerlinNoise_cxx
===================================================================
RCS file: patches/patch-src_sg_sgPerlinNoise_cxx
diff -N patches/patch-src_sg_sgPerlinNoise_cxx
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_sg_sgPerlinNoise_cxx      25 Sep 2013 08:19:34 -0000
@@ -0,0 +1,20 @@
+--- src/sg/sgPerlinNoise.cxx.orig      Tue Mar 11 03:06:20 2008
++++ src/sg/sgPerlinNoise.cxx   Wed Sep 25 10:09:05 2013
+@@ -54,7 +54,7 @@ static void initPermTable ()
+ 
+   for ( i = 0 ; i < SG_PERLIN_NOISE_WRAP_INDEX ; i++ )
+   {
+-    int j = rand () & SG_PERLIN_NOISE_MOD_MASK ;
++    int j = arc4random () & SG_PERLIN_NOISE_MOD_MASK ;
+ 
+     int temp = permTable [ i ] ;
+     permTable [ i ] = permTable [ j ] ;
+@@ -96,7 +96,7 @@ inline SGfloat dot3 ( SGfloat rx,  SGfloat ry,  SGfloa
+ 
+ inline SGfloat randFloat ()
+ { 
+-  return (SGfloat)(( rand() % ( SG_PERLIN_NOISE_WRAP_INDEX +
++  return (SGfloat)(( arc4random_uniform( SG_PERLIN_NOISE_WRAP_INDEX +
+                               SG_PERLIN_NOISE_WRAP_INDEX ) ) - 
+                               SG_PERLIN_NOISE_WRAP_INDEX ) /
+                               SG_PERLIN_NOISE_WRAP_INDEX ;
Index: patches/patch-src_sl_slMODinst_cxx
===================================================================
RCS file: patches/patch-src_sl_slMODinst_cxx
diff -N patches/patch-src_sl_slMODinst_cxx
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_sl_slMODinst_cxx  25 Sep 2013 08:19:34 -0000
@@ -0,0 +1,20 @@
+--- src/sl/slMODinst.cxx.orig  Tue Mar 11 03:06:24 2008
++++ src/sl/slMODinst.cxx       Wed Sep 25 09:34:41 2013
+@@ -966,7 +966,7 @@ void _MOD_instSetVibratoParams(int d, int depth)
+ 
+ void _MOD_instSetVibratoWave(int type, int noRetrig)
+ {
+-  if (type == 3) type = rand() % 3;
++  if (type == 3) type = arc4random_uniform(3);
+   instp->per.mod.type = type;
+   instp->per.mod.noRetrig = noRetrig;
+ }
+@@ -996,7 +996,7 @@ void _MOD_instSetTremoloParams(int d, int depth)
+ 
+ void _MOD_instSetTremoloWave(int type, int noRetrig)
+ {
+-  if (type == 3) type = rand() % 3;
++  if (type == 3) type = arc4random_uniform(3);
+   instp->vol.mod.type = type;
+   instp->vol.mod.noRetrig = noRetrig;
+ }
Index: patches/patch-src_ssgAux_ssgaFire_cxx
===================================================================
RCS file: patches/patch-src_ssgAux_ssgaFire_cxx
diff -N patches/patch-src_ssgAux_ssgaFire_cxx
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_ssgAux_ssgaFire_cxx       25 Sep 2013 08:19:34 -0000
@@ -0,0 +1,15 @@
+--- src/ssgAux/ssgaFire.cxx.orig       Tue Mar 11 03:06:21 2008
++++ src/ssgAux/ssgaFire.cxx    Wed Sep 25 09:36:53 2013
+@@ -73,10 +73,10 @@ void ssgaFire::reInit ()
+ 
+ void ssgaFire::createParticle ( int idx, ssgaParticle *p )
+ {
+-  float xx = (float)(rand()%1000)/500.0f * radius - radius ;
++  float xx = (float)(arc4random_uniform(1000))/500.0f * radius - radius ;
+   float yy = (float)sqrt ( radius * radius - xx * xx ) ;
+ 
+-  yy = (float)(rand()%1000)/500.0f * yy - yy ;
++  yy = (float)(arc4random_uniform(1000))/500.0f * yy - yy ;
+ 
+   p -> time_to_live = max_ttl ;
+   p -> size = sizeTable [ 0 ] ;
Index: patches/patch-src_ssgAux_ssgaSky_h
===================================================================
RCS file: patches/patch-src_ssgAux_ssgaSky_h
diff -N patches/patch-src_ssgAux_ssgaSky_h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_ssgAux_ssgaSky_h  25 Sep 2013 08:19:34 -0000
@@ -0,0 +1,11 @@
+--- src/ssgAux/ssgaSky.h.orig  Tue Mar 11 03:06:21 2008
++++ src/ssgAux/ssgaSky.h       Wed Sep 25 09:35:54 2013
+@@ -358,7 +358,7 @@ class ssgaSky (public)
+ // return a random number between [0.0, 1.0)
+ inline double ssgaRandom(void)
+ {
+-  return(rand() / (double)RAND_MAX);
++  return(arc4random() / (double)UINT_MAX);
+ }
+ 
+ //#if defined( macintosh )

Reply via email to