]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sys_sdl.c
com_list: Fix spacing. No code changes
[xonotic/darkplaces.git] / sys_sdl.c
index 8667f7222333d81848d6497458d12ab27f097827..50cca9d99d5688c2e3442caf963f04e8bfbcfe3a 100644 (file)
--- a/sys_sdl.c
+++ b/sys_sdl.c
@@ -1,3 +1,4 @@
+#include "darkplaces.h"
 
 #ifdef WIN32
 #include <io.h>
@@ -23,8 +24,6 @@
 #endif
 #endif
 
-#include "quakedef.h"
-
 sys_t sys;
 
 // =======================================================================
@@ -43,7 +42,7 @@ void Sys_Shutdown (void)
        SDL_Quit();
 }
 
-static qboolean nocrashdialog;
+static qbool nocrashdialog;
 void Sys_Error (const char *error, ...)
 {
        va_list argptr;
@@ -63,7 +62,7 @@ void Sys_Error (const char *error, ...)
        if(!nocrashdialog)
                SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Engine Error", string, NULL);
 
-       Host_Shutdown ();
+       //Host_Shutdown ();
        exit (1);
 }
 
@@ -104,61 +103,58 @@ void Sys_PrintToTerminal(const char *text)
 
 char *Sys_ConsoleInput(void)
 {
-//     if (cls.state == ca_dedicated)
-       {
-               static char text[MAX_INPUTLINE];
-               int len = 0;
+       static char text[MAX_INPUTLINE];
+       int len = 0;
 #ifdef WIN32
-               int c;
+       int c;
 
-               // read a line out
-               while (_kbhit ())
+       // read a line out
+       while (_kbhit ())
+       {
+               c = _getch ();
+               _putch (c);
+               if (c == '\r')
+               {
+                       text[len] = 0;
+                       _putch ('\n');
+                       len = 0;
+                       return text;
+               }
+               if (c == 8)
                {
-                       c = _getch ();
-                       _putch (c);
-                       if (c == '\r')
+                       if (len)
                        {
+                               _putch (' ');
+                               _putch (c);
+                               len--;
                                text[len] = 0;
-                               _putch ('\n');
-                               len = 0;
-                               return text;
-                       }
-                       if (c == 8)
-                       {
-                               if (len)
-                               {
-                                       _putch (' ');
-                                       _putch (c);
-                                       len--;
-                                       text[len] = 0;
-                               }
-                               continue;
                        }
-                       text[len] = c;
-                       len++;
-                       text[len] = 0;
-                       if (len == sizeof (text))
-                               len = 0;
+                       continue;
                }
+               text[len] = c;
+               len++;
+               text[len] = 0;
+               if (len == sizeof (text))
+                       len = 0;
+       }
 #else
-               fd_set fdset;
-               struct timeval timeout;
-               FD_ZERO(&fdset);
-               FD_SET(0, &fdset); // stdin
-               timeout.tv_sec = 0;
-               timeout.tv_usec = 0;
-               if (select (1, &fdset, NULL, NULL, &timeout) != -1 && FD_ISSET(0, &fdset))
+       fd_set fdset;
+       struct timeval timeout;
+       FD_ZERO(&fdset);
+       FD_SET(0, &fdset); // stdin
+       timeout.tv_sec = 0;
+       timeout.tv_usec = 0;
+       if (select (1, &fdset, NULL, NULL, &timeout) != -1 && FD_ISSET(0, &fdset))
+       {
+               len = read (0, text, sizeof(text));
+               if (len >= 1)
                {
-                       len = read (0, text, sizeof(text));
-                       if (len >= 1)
-                       {
-                               // rip off the \n and terminate
-                               text[len-1] = 0;
-                               return text;
-                       }
+                       // rip off the \n and terminate
+                       text[len-1] = 0;
+                       return text;
                }
-#endif
        }
+#endif
        return NULL;
 }
 
@@ -202,13 +198,13 @@ int main (int argc, char *argv[])
        Sys_ProvideSelfFD();
 
        // COMMANDLINEOPTION: -nocrashdialog disables "Engine Error" crash dialog boxes
-       if(!COM_CheckParm("-nocrashdialog"))
+       if(!Sys_CheckParm("-nocrashdialog"))
                nocrashdialog = false;
        // COMMANDLINEOPTION: sdl: -noterminal disables console output on stdout
-       if(COM_CheckParm("-noterminal"))
+       if(Sys_CheckParm("-noterminal"))
                sys.outfd = -1;
        // COMMANDLINEOPTION: sdl: -stderr moves console output to stderr
-       else if(COM_CheckParm("-stderr"))
+       else if(Sys_CheckParm("-stderr"))
                sys.outfd = 2;
        else
                sys.outfd = 1;
@@ -220,6 +216,9 @@ int main (int argc, char *argv[])
        // we don't know which systems we'll want to init, yet...
        SDL_Init(0);
 
+       // used by everything
+       Memory_Init();
+
        Host_Main();
 
        Sys_Quit(0);
@@ -227,7 +226,7 @@ int main (int argc, char *argv[])
        return 0;
 }
 
-qboolean sys_supportsdlgetticks = true;
+qbool sys_supportsdlgetticks = true;
 unsigned int Sys_SDL_GetTicks (void)
 {
        return SDL_GetTicks();