Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
random: Implemented Win32 version
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Mon, 17 Jul 2017 19:50:24 +0000 (20:50 +0100)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Mon, 17 Jul 2017 19:50:24 +0000 (20:50 +0100)
source/common/random.cpp
source/common/random.h

index ff0b619..40316c6 100644 (file)
 using namespace std;
 
 int GenerateRandomNumber(int powerOf){
-       
+#if defined(WIN32)
+
+       // Seed the randomiser!
+
+       srand(time(0));
+
+       int powerOfCalculation = (int)pow(2, (double)powerOf);
+       int randomNumber = rand() % powerOfCalculation;
+
+#else 
        // Get four bytes from /dev/urandom.
        
        int randomData = 0;
@@ -41,7 +50,7 @@ int GenerateRandomNumber(int powerOf){
        
        int powerOfCalculation = (int)pow(2, (double)powerOf);
        int randomNumber = rand() % powerOfCalculation;
+#endif
        
        return randomNumber;
-       
 }
\ No newline at end of file
index a931eeb..390d9af 100644 (file)
 #include <iostream>
 #include <fstream>
 
+#if defined(WIN32)
+#include <stdlib.h>
+#include <time.h>
+#endif
+
 int GenerateRandomNumber(int powerOf);
 
 #endif
\ No newline at end of file
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy