Re: [AD] srand()

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Eric Botcazou wrote:
> 
> > I think ex12bit.c, ex3buf.c, ex3d.c, exaccel.c, excolmap.c, exflame.c,
> > exscale.c, exscroll.c, exstars.c, exunicod.c, exzbuf.c and demo.c
> > should have a srand(time(NULL)/getpid()/etc) call somewhere.
> 
> Ok for the demo game, not worthwhile for the others.
> And make sure to use ANSI C functions only.
> 
> - Eric

Here is the patch, tested under DJGPP 2.3, MinGW32 and MSVC 6. By the
way, I was thinking about modifying some of the demo source, taking
the "an-explosion-killed-me" feature out, shrinking it a bit, plus
maybe adding circular and sinuidal movement. Suggestions?

And just to prevent spamming the list, how about putting all makefiles
into allegro/mkfiles?

I still think Allegro should have its own portable allegro_seed() and
allegro_random() functions...


--- /cvs/allegro/demo/demo.c	Tue May 14 08:17:14 2002
+++ allegro/demo/demo.c	Wed Aug 28 19:37:08 2002
@@ -18,6 +18,7 @@
 
 #include <string.h>
 #include <stdio.h>
+#include <time.h>
 
 #include "allegro.h"
 #include "demo.h"
@@ -2000,6 +2001,7 @@
 	 jumpstart = TRUE;
    }
 
+   srand(time(NULL));
    if (allegro_init() != 0)
       return 1;
    install_keyboard();


--
Roberto Alfonso (rpgrca@xxxxxxxxxx <> rpgrca@xxxxxxxxxx)
Rhynox, the Noble Rockfriend, Wild Battlerager of the Neidar Clan and
Proficient Blacksmith, rising hero, male dwarf (Genesis is the key)
ICQ: 44361979



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/