]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sys_linux.c
Removed the functions "S_RawSamples_*" and "S_ResampleBuffer16Stereo". They're useles...
[xonotic/darkplaces.git] / sys_linux.c
index 084eb0402cb7ad0b0112c3f85aa5f63ab0b92a62..ed68eec91fdb44c7e7f63865f037b40c49d16c63 100644 (file)
@@ -43,7 +43,7 @@ void Sys_Error (const char *error, ...)
 #endif
 
        va_start (argptr,error);
-       vsprintf (string,error,argptr);
+       vsnprintf (string, sizeof (string), error, argptr);
        va_end (argptr);
        fprintf(stderr, "Error: %s\n", string);
 
@@ -51,7 +51,7 @@ void Sys_Error (const char *error, ...)
        exit (1);
 }
 
-void Sys_Print(const char *text)
+void Sys_PrintToTerminal(const char *text)
 {
        printf("%s", text);
 }
@@ -139,7 +139,7 @@ char *Sys_ConsoleInput(void)
        if (cls.state == ca_dedicated)
        {
                static char text[256];
-               int len = 0;
+               static int len = 0;
 #ifdef WIN32
                int c;
 
@@ -147,30 +147,30 @@ char *Sys_ConsoleInput(void)
                while (_kbhit ())
                {
                        c = _getch ();
-                       putch (c);
                        if (c == '\r')
                        {
-                               text[len] = 0;
+                               text[len] = '\0';
                                putch ('\n');
                                len = 0;
                                return text;
                        }
-                       if (c == 8)
+                       if (c == '\b')
                        {
                                if (len)
                                {
+                                       putch (c);
                                        putch (' ');
                                        putch (c);
                                        len--;
-                                       text[len] = 0;
                                }
                                continue;
                        }
-                       text[len] = c;
-                       len++;
-                       text[len] = 0;
-                       if (len == sizeof (text))
-                               len = 0;
+                       if (len < sizeof (text) - 1)
+                       {
+                               putch (c);
+                               text[len] = c;
+                               len++;
+                       }
                }
 #else
                fd_set fdset;
@@ -194,12 +194,14 @@ char *Sys_ConsoleInput(void)
        return NULL;
 }
 
-void Sys_Sleep(void)
+void Sys_Sleep(int milliseconds)
 {
+       if (milliseconds < 1)
+               milliseconds = 1;
 #ifdef WIN32
-       Sleep (1);
+       Sleep(milliseconds);
 #else
-       usleep(1);
+       usleep(milliseconds * 1000);
 #endif
 }