]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sys_win.c
reenabled loading plaques (and cleaned up that code a lot)
[xonotic/darkplaces.git] / sys_win.c
index 1327b35d728b6f1886cf9c00c7c4bf12add168ac..10226f3a577659386859f2b1e8d380915e468fd8 100644 (file)
--- a/sys_win.c
+++ b/sys_win.c
@@ -36,48 +36,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 int                    starttime;
 qboolean       ActiveApp, Minimized;
 
-qboolean                       isDedicated;
 static qboolean                sc_return_on_enter = false;
 HANDLE                         hinput, houtput;
 
-static char                    *tracking_tag = "Clams & Mooses";
+//static char                  *tracking_tag = "Clams & Mooses";
 
 static HANDLE  tevent;
 static HANDLE  hFile;
 static HANDLE  heventParent;
 static HANDLE  heventChild;
 
-volatile int                                   sys_checksum;
-
-
-/*
-================
-Sys_PageIn
-================
-*/
-/*
-void Sys_PageIn (void *ptr, int size)
-{
-       byte    *x;
-       int             m, n;
-
-// touch all the memory to make sure it's there. The 16-page skip is to
-// keep Win 95 from thinking we're trying to page ourselves in (we are
-// doing that, of course, but there's no reason we shouldn't)
-       x = (byte *)ptr;
-
-       for (n=0 ; n<4 ; n++)
-       {
-               for (m=0 ; m<(size - 16 * 0x1000) ; m += 4)
-               {
-                       sys_checksum += *(int *)&x[m];
-                       sys_checksum += *(int *)&x[m + 16 * 0x1000];
-               }
-       }
-}
-*/
-
-
 /*
 ===============================================================================
 
@@ -103,10 +71,10 @@ int                findhandle (void)
 
 /*
 ================
-filelength
+Sys_FileLength
 ================
 */
-int filelength (QFile *f)
+int Sys_FileLength (QFile *f)
 {
        int             pos;
        int             end;
@@ -137,7 +105,7 @@ int Sys_FileOpenRead (char *path, int *hndl)
        {
                sys_handles[i] = f;
                *hndl = i;
-               retval = filelength(f);
+               retval = Sys_FileLength(f);
        }
 
        return retval;
@@ -231,7 +199,7 @@ void Sys_Error (char *error, ...)
        vsprintf (text, error, argptr);
        va_end (argptr);
 
-       if (isDedicated)
+       if (cls.state == ca_dedicated)
        {
                va_start (argptr, error);
                vsprintf (text, error, argptr);
@@ -248,8 +216,7 @@ void Sys_Error (char *error, ...)
                starttime = Sys_DoubleTime ();
                sc_return_on_enter = true;      // so Enter will get us out of here
 
-               while (!Sys_ConsoleInput () &&
-                               ((Sys_DoubleTime () - starttime) < CONSOLE_ERROR_TIMEOUT))
+               while (!Sys_ConsoleInput () && ((Sys_DoubleTime () - starttime) < CONSOLE_ERROR_TIMEOUT))
                {
                }
        }
@@ -261,13 +228,11 @@ void Sys_Error (char *error, ...)
                {
                        in_sys_error0 = 1;
                        VID_SetDefaultMode ();
-                       MessageBox(NULL, text, "Quake Error",
-                                          MB_OK | MB_SETFOREGROUND | MB_ICONSTOP);
+                       MessageBox(NULL, text, "Quake Error", MB_OK | MB_SETFOREGROUND | MB_ICONSTOP);
                }
                else
                {
-                       MessageBox(NULL, text, "Double Quake Error",
-                                          MB_OK | MB_SETFOREGROUND | MB_ICONSTOP);
+                       MessageBox(NULL, text, "Double Quake Error", MB_OK | MB_SETFOREGROUND | MB_ICONSTOP);
                }
        }
 
@@ -287,22 +252,6 @@ void Sys_Error (char *error, ...)
        exit (1);
 }
 
-void Sys_Printf (char *fmt, ...)
-{
-       va_list         argptr;
-       char            text[1024];
-       DWORD           dummy;
-       
-       if (isDedicated)
-       {
-               va_start (argptr,fmt);
-               vsprintf (text, fmt, argptr);
-               va_end (argptr);
-
-               WriteFile(houtput, text, strlen (text), &dummy, NULL);  
-       }
-}
-
 void Sys_Quit (void)
 {
 
@@ -311,7 +260,7 @@ void Sys_Quit (void)
        if (tevent)
                CloseHandle (tevent);
 
-       if (isDedicated)
+       if (cls.state == ca_dedicated)
                FreeConsole ();
 
 // shut down QHOST hooks if necessary
@@ -419,13 +368,13 @@ double Sys_DoubleTime (void)
 
 char *Sys_ConsoleInput (void)
 {
-       static char     text[256];
-       static int              len;
-       INPUT_RECORD    recs[1024];
-       int             dummy;
-       int             ch, numread, numevents;
+       static char text[256];
+       static int len;
+       INPUT_RECORD recs[1024];
+       int ch;
+       DWORD numread, numevents, dummy;
 
-       if (!isDedicated)
+       if (cls.state != ca_dedicated)
                return NULL;
 
 
@@ -553,7 +502,7 @@ static char *empty_string = "";
 
 int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
 {
-       double                  time, oldtime, newtime/*, timediff*/;
+       double                  oldtime, newtime;
        MEMORYSTATUS    lpBuffer;
        static  char    cwd[1024];
        int                             t;
@@ -599,7 +548,7 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin
                                *lpCmdLine = 0;
                                lpCmdLine++;
                        }
-                       
+
                }
        }
 
@@ -610,37 +559,19 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin
        host_parms.argc = com_argc;
        host_parms.argv = com_argv;
 
-       isDedicated = (COM_CheckParm ("-dedicated") != 0);
-
-// take the greater of all the available memory or half the total memory,
-// but at least 8 Mb and no more than 16 Mb, unless they explicitly
-// request otherwise
-       /*
-       host_parms.memsize = lpBuffer.dwAvailPhys;
-
-       if (host_parms.memsize < MINIMUM_WIN_MEMORY)
-               host_parms.memsize = MINIMUM_WIN_MEMORY;
-
-       if (host_parms.memsize < (lpBuffer.dwTotalPhys >> 1))
-               host_parms.memsize = lpBuffer.dwTotalPhys >> 1;
-
-       if (host_parms.memsize > MAXIMUM_WIN_MEMORY)
-               host_parms.memsize = MAXIMUM_WIN_MEMORY;
-       */
-
-//     Sys_PageIn (parms.membase, parms.memsize);
+       Sys_Shared_EarlyInit();
 
        tevent = CreateEvent(NULL, false, false, NULL);
 
        if (!tevent)
                Sys_Error ("Couldn't create event");
 
-       if (isDedicated)
+       // LordHavoc: can't check cls.state because it hasn't been initialized yet
+       // if (cls.state == ca_dedicated)
+       if (COM_CheckParm("-dedicated"))
        {
                if (!AllocConsole ())
-               {
                        Sys_Error ("Couldn't create dedicated server console");
-               }
 
                hinput = GetStdHandle (STD_INPUT_HANDLE);
                houtput = GetStdHandle (STD_OUTPUT_HANDLE);
@@ -651,13 +582,13 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin
                        if (t < com_argc)
                                hFile = (HANDLE)atoi (com_argv[t+1]);
                }
-                       
+
                if ((t = COM_CheckParm ("-HPARENT")) > 0)
                {
                        if (t < com_argc)
                                heventParent = (HANDLE)atoi (com_argv[t+1]);
                }
-                       
+
                if ((t = COM_CheckParm ("-HCHILD")) > 0)
                {
                        if (t < com_argc)
@@ -679,32 +610,29 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin
        timeBeginPeriod (1);
 #endif
 
-       Sys_Printf ("Host_Init\n");
        Host_Init ();
 
+       Sys_Shared_LateInit();
+
        oldtime = Sys_DoubleTime ();
 
     /* main window message loop */
        while (1)
        {
-               if (!isDedicated)
+               if (cls.state != ca_dedicated)
                {
                // yield the CPU for a little while when paused, minimized, or not the focus
-                       if ((cl.paused && (!ActiveApp && !DDActive)) || Minimized)
+                       if ((cl.paused && !ActiveApp) || Minimized)
                        {
                                SleepUntilInput (PAUSE_SLEEP);
                                scr_skipupdate = 1;             // no point in bothering to draw
                        }
-                       else if (!ActiveApp && !DDActive)
-                       {
+                       else if (!ActiveApp)
                                SleepUntilInput (NOT_FOCUS_SLEEP);
-                       }
-
-                       newtime = Sys_DoubleTime ();
-                       time = newtime - oldtime;
                }
 
-               Host_Frame (time);
+               newtime = Sys_DoubleTime ();
+               Host_Frame (newtime - oldtime);
                oldtime = newtime;
        }