]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
changed Sys_Sleep from (void) to (int milliseconds), now wastes a lot less cpu time...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 1 Feb 2004 22:30:51 +0000 (22:30 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 1 Feb 2004 22:30:51 +0000 (22:30 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@3847 d7cf8633-e32d-0410-b094-e92efae38249

cl_parse.c
host.c
sys.h
sys_linux.c
sys_sdl.c
sys_win.c

index 9095337523c72768012e9046beb604c2653a9e2f..dfe44a9876b55c6c3745dfcadebdd95fbccb74fa 100644 (file)
@@ -206,7 +206,7 @@ void CL_KeepaliveMessage (void)
                MSG_WriteChar(&msg, svc_nop);
                NetConn_SendUnreliableMessage(cls.netcon, &msg);
                // try not to utterly crush the computer with work, that's just rude
                MSG_WriteChar(&msg, svc_nop);
                NetConn_SendUnreliableMessage(cls.netcon, &msg);
                // try not to utterly crush the computer with work, that's just rude
-               Sys_Sleep();
+               Sys_Sleep(1);
        }
 }
 
        }
 }
 
diff --git a/host.c b/host.c
index f1943a74f3dd380a4688ce81adc9181da3011105..09683f911428e8a1e8a976b0e44d1fced119068a 100644 (file)
--- a/host.c
+++ b/host.c
@@ -577,7 +577,7 @@ qboolean Host_FilterTime (double time)
                {
                        // don't totally hog the CPU
                        if (timeleft >= 0.02)
                {
                        // don't totally hog the CPU
                        if (timeleft >= 0.02)
-                               Sys_Sleep();
+                               Sys_Sleep(timeleft * 1000 - 5);
                        return false;
                }
        }
                        return false;
                }
        }
diff --git a/sys.h b/sys.h
index 6b38df3ebd361e1eb395e5400acf25f783f2b8d8..73e2da0dae09eb547ee9bba8ef362b237a7f0446 100644 (file)
--- a/sys.h
+++ b/sys.h
@@ -67,7 +67,7 @@ double Sys_DoubleTime (void);
 
 char *Sys_ConsoleInput (void);
 
 
 char *Sys_ConsoleInput (void);
 
-void Sys_Sleep (void);
+void Sys_Sleep(int milliseconds);
 // called to yield for a little bit so as
 // not to hog cpu when paused or debugging
 
 // called to yield for a little bit so as
 // not to hog cpu when paused or debugging
 
index 728ff5fd57bde6bdc2f91bbefa569d1e9bd07c95..c61e01b77ea8c9edd8733c09151fdb13b7ad33b0 100644 (file)
@@ -194,12 +194,14 @@ char *Sys_ConsoleInput(void)
        return NULL;
 }
 
        return NULL;
 }
 
-void Sys_Sleep(void)
+void Sys_Sleep(int milliseconds)
 {
 {
+       if (milliseconds < 1)
+               milliseconds = 1;
 #ifdef WIN32
 #ifdef WIN32
-       Sleep (1);
+       Sleep(milliseconds);
 #else
 #else
-       usleep(1);
+       usleep(milliseconds * 1000);
 #endif
 }
 
 #endif
 }
 
index bb2364946286aba5870f15f0f0d63e16409f2d87..9c7571671333698f9a4ea910f1e529bb9b809e41 100644 (file)
--- a/sys_sdl.c
+++ b/sys_sdl.c
@@ -195,13 +195,11 @@ char *Sys_ConsoleInput(void)
        return NULL;
 }
 
        return NULL;
 }
 
-void Sys_Sleep(void)
+void Sys_Sleep(int milliseconds)
 {
 {
-#ifdef WIN32
-       Sleep (1);
-#else
-       usleep(1);
-#endif
+       if (milliseconds < 1)
+               milliseconds = 1;
+       SDL_Delay(milliseconds);
 }
 
 int SDL_main (int argc, char *argv[])
 }
 
 int SDL_main (int argc, char *argv[])
index 34f82380330afe6abc830bd18d617b3bb0fc4a13..f3ea0e28ccc078cdde8151418aacb57bd10a693e 100644 (file)
--- a/sys_win.c
+++ b/sys_win.c
@@ -271,9 +271,11 @@ char *Sys_ConsoleInput (void)
        return NULL;
 }
 
        return NULL;
 }
 
-void Sys_Sleep (void)
+void Sys_Sleep(int milliseconds)
 {
 {
-       Sleep (1);
+       if (milliseconds < 1)
+               milliseconds = 1;
+       Sleep(milliseconds);
 }
 
 
 }