]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sys_shared.c
Merge remote branch 'origin/master' into akari/irc
[xonotic/darkplaces.git] / sys_shared.c
index 4ed624e461afa78057d462689d0e0dde7c04f85a..bb6ce36bff76923f8f86178285578a92cfbdf061 100644 (file)
@@ -1,14 +1,14 @@
+#ifdef WIN32
+# ifndef DONT_USE_SETDLLDIRECTORY
+#  define _WIN32_WINNT 0x0502
+# endif
+#endif
+
 #include "quakedef.h"
 
 #define SUPPORTDLL
 
 #ifdef WIN32
-# ifdef _WIN64
-#  ifndef _WIN32_WINNT
-#   define _WIN32_WINNT 0x0502
-#  endif
-   // for SetDllDirectory
-# endif
 # include <windows.h>
 # include <mmsystem.h> // timeGetTime
 # include <time.h> // localtime
@@ -133,13 +133,15 @@ notfound:
        {
                Con_DPrintf (" \"%s\"", dllnames[i]);
 #ifdef WIN32
-# ifdef _WIN64
+# ifndef DONT_USE_SETDLLDIRECTORY
+#  ifdef _WIN64
                SetDllDirectory("bin64");
+#  else
+               SetDllDirectory("bin32");
+#  endif
 # endif
                dllhandle = LoadLibrary (dllnames[i]);
-# ifdef _WIN64
-               SetDllDirectory(NULL);
-# endif
+               // no need to unset this - we want ALL dlls to be loaded from there, anyway
 #else
                dllhandle = dlopen (dllnames[i], RTLD_LAZY | RTLD_GLOBAL);
 #endif
@@ -261,7 +263,7 @@ static cvar_t sys_usequeryperformancecounter = {CVAR_SAVE, "sys_usequeryperforma
 static cvar_t sys_useclockgettime = {CVAR_SAVE, "sys_useclockgettime", "0", "use POSIX clock_gettime function (which has issues if the system clock speed is far off, as it can't get fixed by NTP) for timing rather than gettimeofday (which has issues if the system time is stepped by ntpdate, or apparently on some Xen installations)"};
 #endif
 
-static unsigned long benchmark_time;
+static double benchmark_time; // actually always contains an integer amount of milliseconds, will eventually "overflow"
 
 void Sys_Init_Commands (void)
 {
@@ -289,8 +291,11 @@ double Sys_DoubleTime(void)
        double newtime;
        if(sys_usenoclockbutbenchmark.integer)
        {
+               double old_benchmark_time = benchmark_time;
                benchmark_time += 1;
-               return ((double) benchmark_time) / 1e6;
+               if(benchmark_time == old_benchmark_time)
+                       Sys_Error("sys_usenoclockbutbenchmark cannot run any longer, sorry");
+               return benchmark_time * 0.000001;
        }
 
        // first all the OPTIONAL timers
@@ -415,7 +420,13 @@ void Sys_Sleep(int microseconds)
        double t = 0;
        if(sys_usenoclockbutbenchmark.integer)
        {
-               benchmark_time += microseconds;
+               if(microseconds)
+               {
+                       double old_benchmark_time = benchmark_time;
+                       benchmark_time += microseconds;
+                       if(benchmark_time == old_benchmark_time)
+                               Sys_Error("sys_usenoclockbutbenchmark cannot run any longer, sorry");
+               }
                return;
        }
        if(sys_debugsleep.integer)