rnd-20080802-1-src
[rocksndiamonds.git] / src / libgame / misc.c
index 8ff6a458b32682b374d43d994572d03a4eb8177b..5e4b9310bc4701f9921603fa1b353a94398462d9 100644 (file)
@@ -337,13 +337,26 @@ unsigned int init_random_number(int nr, long seed)
 {
   if (seed == NEW_RANDOMIZE)
   {
-#if defined(TARGET_SDL)
-    seed = (long)SDL_GetTicks();
-#else
+    /* default random seed */
+    seed = (long)time(NULL);                   // seconds since the epoch
+
+#if !defined(PLATFORM_WIN32)
+    /* add some more randomness */
     struct timeval current_time;
 
     gettimeofday(&current_time, NULL);
-    seed = (long)current_time.tv_usec;
+
+    seed += (long)current_time.tv_usec;                // microseconds since the epoch
+#endif
+
+#if defined(TARGET_SDL)
+    /* add some more randomness */
+    seed += (long)SDL_GetTicks();              // milliseconds since SDL init
+#endif
+
+#if 1
+    /* add some more randomness */
+    seed += GetSimpleRandom(1000000);
 #endif
   }
 
@@ -664,6 +677,7 @@ void GetOptions(char *argv[], void (*print_usage_function)(void))
   options.network = FALSE;
   options.verbose = FALSE;
   options.debug = FALSE;
+  options.debug_x11_sync = FALSE;
 
 #if !defined(PLATFORM_UNIX)
   if (*options_left == NULL)   /* no options given -- enable verbose mode */
@@ -789,6 +803,10 @@ void GetOptions(char *argv[], void (*print_usage_function)(void))
     {
       options.debug = TRUE;
     }
+    else if (strncmp(option, "-debug-x11-sync", option_len) == 0)
+    {
+      options.debug_x11_sync = TRUE;
+    }
     else if (strncmp(option, "-execute", option_len) == 0)
     {
       if (option_arg == NULL)
@@ -1595,6 +1613,24 @@ boolean get_boolean_from_string(char *s)
   return result;
 }
 
+int get_switch3_from_string(char *s)
+{
+  char *s_lower = getStringToLower(s);
+  int result = FALSE;
+
+  if (strEqual(s_lower, "true") ||
+      strEqual(s_lower, "yes") ||
+      strEqual(s_lower, "on") ||
+      get_integer_from_string(s) == 1)
+    result = TRUE;
+  else if (strEqual(s_lower, "auto"))
+    result = AUTO;
+
+  free(s_lower);
+
+  return result;
+}
+
 
 /* ------------------------------------------------------------------------- */
 /* functions for generic lists                                               */
@@ -2671,6 +2707,12 @@ void LoadArtworkConfig(struct ArtworkListInfo *artwork_info)
     /* first look for special artwork configured in level series config */
     filename_base = getCustomArtworkLevelConfigFilename(artwork_info->type);
 
+#if 0
+    printf("::: filename_base == '%s' [%s, %s]\n", filename_base,
+          leveldir_current->graphics_set,
+          leveldir_current->graphics_path);
+#endif
+
     if (fileExists(filename_base))
       LoadArtworkConfigFromFilename(artwork_info, filename_base);
   }