Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
random: Implemented Win32 version
[xestiacalendar/.git] / source / common / random.cpp
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
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