X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=sys_win.c;h=c0ae22af3006c3230409385a0cc0dbb763e418b1;hb=a2b6b8b4a5a6a290544403a06e2c0c8388e89d66;hp=4fa62ee06cc5e4c6186ffc1fdab6fb02019e6452;hpb=0e936f973c3dcb7f74691912db3ad85e8805ccf1;p=xonotic%2Fdarkplaces.git diff --git a/sys_win.c b/sys_win.c index 4fa62ee0..c0ae22af 100644 --- a/sys_win.c +++ b/sys_win.c @@ -108,7 +108,7 @@ void Sys_PrintToTerminal(const char *text) DWORD dummy; extern HANDLE houtput; if (cls.state == ca_dedicated) - WriteFile(houtput, text, strlen (text), &dummy, NULL); + WriteFile(houtput, text, (DWORD) strlen(text), &dummy, NULL); } /* @@ -157,7 +157,12 @@ double Sys_DoubleTime (void) LARGE_INTEGER PerformanceCount; if (!QueryPerformanceFrequency (&PerformanceFreq)) - Sys_Error ("No hardware timer available"); + { + Con_Printf ("No hardware timer available"); + // fall back to timeGetTime + Cvar_SetValueQuick(&sys_usetimegettime, true); + return Sys_DoubleTime(); + } QueryPerformanceCounter (&PerformanceCount); #ifdef __BORLANDC__ @@ -279,7 +284,7 @@ char *Sys_GetClipboardData (void) if ((hClipboardData = GetClipboardData (CF_TEXT)) != 0) { - if ((cliptext = GlobalLock (hClipboardData)) != 0) + if ((cliptext = GlobalLock (hClipboardData)) != 0) { data = malloc (GlobalSize(hClipboardData)+1); strcpy (data, cliptext); @@ -291,6 +296,60 @@ char *Sys_GetClipboardData (void) return data; } +void Sys_InitConsole (void) +{ + int t; + + // initialize the windows dedicated server console if needed + tevent = CreateEvent(NULL, false, false, NULL); + + if (!tevent) + Sys_Error ("Couldn't create event"); + + // 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); + +#ifdef WIN64 +#define atoi _atoi64 +#endif + // give QHOST a chance to hook into the console + if ((t = COM_CheckParm ("-HFILE")) > 0) + { + 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) + heventChild = (HANDLE)atoi (com_argv[t+1]); + } + + InitConProc (hFile, heventParent, heventChild); + } + +// because sound is off until we become active + S_BlockSound (); +} + +void Sys_Init_Commands (void) +{ + Cvar_RegisterVariable(&sys_usetimegettime); +} + /* ============================================================================== @@ -313,7 +372,6 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin { double frameoldtime, framenewtime; MEMORYSTATUS lpBuffer; - int t; /* previous instances do not exist in Win32 */ if (hPrevInstance) @@ -365,56 +423,10 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin } } - Sys_Shared_EarlyInit(); - - Cvar_RegisterVariable(&sys_usetimegettime); - - tevent = CreateEvent(NULL, false, false, NULL); - - if (!tevent) - Sys_Error ("Couldn't create event"); - - // 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); - - // give QHOST a chance to hook into the console - if ((t = COM_CheckParm ("-HFILE")) > 0) - { - 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) - heventChild = (HANDLE)atoi (com_argv[t+1]); - } - - InitConProc (hFile, heventParent, heventChild); - } - -// because sound is off until we become active - S_BlockSound (); - Host_Init (); - Sys_Shared_LateInit(); - frameoldtime = Sys_DoubleTime (); - + /* main window message loop */ while (1) {