aboutsummaryrefslogtreecommitdiffstats
path: root/code/qcommon/common.c
diff options
context:
space:
mode:
authortjw <tjw@edf5b092-35ff-0310-97b2-ce42778d08ea>2007-02-16 23:50:37 +0000
committertjw <tjw@edf5b092-35ff-0310-97b2-ce42778d08ea>2007-02-16 23:50:37 +0000
commit9dbe35a4dd8d5fce96c627f000d15395f32bc55a (patch)
tree3bc0f6b9f85125a426cdc2a290237adc76b1c699 /code/qcommon/common.c
parent9a51af746dd98abd8ca52424a4b78a16e3d98b7b (diff)
downloadioquake3-aero-9dbe35a4dd8d5fce96c627f000d15395f32bc55a.tar.gz
ioquake3-aero-9dbe35a4dd8d5fce96c627f000d15395f32bc55a.zip
* (bug 3019) use the operating system's random number generator if possible
when generating the qkey file git-svn-id: svn://svn.icculus.org/quake3/trunk@1046 edf5b092-35ff-0310-97b2-ce42778d08ea
Diffstat (limited to 'code/qcommon/common.c')
-rw-r--r--code/qcommon/common.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/code/qcommon/common.c b/code/qcommon/common.c
index ca56db0..defb5fa 100644
--- a/code/qcommon/common.c
+++ b/code/qcommon/common.c
@@ -3217,3 +3217,24 @@ void Field_AutoComplete( field_t *field )
Field_CompleteCommand( completionField->buffer, qtrue, qtrue );
}
+
+/*
+==================
+Com_RandomBytes
+
+fills string array with len radom bytes, peferably from the OS randomizer
+==================
+*/
+void Com_RandomBytes( byte *string, int len )
+{
+ int i;
+
+ if( Sys_RandomBytes( string, len ) )
+ return;
+
+ Com_Printf( "Com_RandomBytes: using weak randomization\n" );
+ srand( time( 0 ) );
+ for( i = 0; i < len; i++ )
+ string[i] = (unsigned char)( rand() % 255 );
+}
+