ref: 59aad53bbde97e75e06717ea1b49bd3c92941b83
parent: 96495a0ac6e1663ef0a6b137a24f73d46a039e52
author: Simon Howard <fraggle@gmail.com>
date: Sun Jan 8 12:52:16 EST 2006
Seed the M_Random random number generator from the system time to give it some more randomness. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 272
--- a/src/m_random.c
+++ b/src/m_random.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: m_random.c 8 2005-07-23 16:44:57Z fraggle $
+// $Id: m_random.c 272 2006-01-08 17:52:16Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -22,6 +22,10 @@
// 02111-1307, USA.
//
// $Log$
+// Revision 1.3 2006/01/08 17:52:16 fraggle
+// Seed the M_Random random number generator from the system time to give
+// it some more randomness.
+//
// Revision 1.2 2005/07/23 16:44:56 fraggle
// Update copyright to GNU GPL
//
@@ -34,9 +38,12 @@
//
//-----------------------------------------------------------------------------
-static const char rcsid[] = "$Id: m_random.c 8 2005-07-23 16:44:57Z fraggle $";
+static const char rcsid[] = "$Id: m_random.c 272 2006-01-08 17:52:16Z fraggle $";
+#include <time.h>
+#include "m_random.h"
+
//
// M_Random
// Returns a 0-255 number
@@ -81,7 +88,11 @@
void M_ClearRandom (void)
{
- rndindex = prndindex = 0;
+ prndindex = 0;
+
+ // Seed the M_Random counter from the system time
+
+ rndindex = time(NULL) & 0xff;
}