X-Git-Url: http://git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=blobdiff_plain;f=sys_win.c;h=f0f3045dfc25437039eeea09cabdb3fee83f8ad6;hp=02be56b4393be41479467a02d3c7910a99f982f2;hb=da29a8beeb35293e2fd38b51883c91b5cf4cf4ad;hpb=182f5dd46097dc11b3643dc2376b4dd6a4fa42c7 diff --git a/sys_win.c b/sys_win.c index 02be56b4..f0f3045d 100644 --- a/sys_win.c +++ b/sys_win.c @@ -21,15 +21,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "quakedef.h" #include +#include #include #include "errno.h" #include "resource.h" #include "conproc.h" #include "direct.h" -extern void S_BlockSound (void); - -cvar_t sys_usetimegettime = {CVAR_SAVE, "sys_usetimegettime", "1"}; +cvar_t sys_usetimegettime = {CVAR_SAVE, "sys_usetimegettime", "1", "use windows timeGetTime function (which has issues on some motherboards) for timing rather than QueryPerformanceCounter timer (which has issues on multicore/multiprocessor machines and processors which are designed to conserve power)"}; HANDLE hinput, houtput; @@ -50,7 +49,7 @@ SYSTEM IO void Sys_Error (const char *error, ...) { va_list argptr; - char text[1024]; + char text[MAX_INPUTLINE]; static int in_sys_error0 = 0; static int in_sys_error1 = 0; static int in_sys_error2 = 0; @@ -108,7 +107,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 +156,12 @@ double Sys_DoubleTime (void) LARGE_INTEGER PerformanceCount; if (!QueryPerformanceFrequency (&PerformanceFreq)) - Sys_Error ("No hardware timer available"); + { + Con_Printf ("No hardware timer available\n"); + // fall back to timeGetTime + Cvar_SetValueQuick(&sys_usetimegettime, true); + return Sys_DoubleTime(); + } QueryPerformanceCounter (&PerformanceCount); #ifdef __BORLANDC__ @@ -191,7 +195,7 @@ double Sys_DoubleTime (void) char *Sys_ConsoleInput (void) { - static char text[256]; + static char text[MAX_INPUTLINE]; static int len; INPUT_RECORD recs[1024]; int ch; @@ -281,7 +285,7 @@ char *Sys_GetClipboardData (void) { if ((cliptext = GlobalLock (hClipboardData)) != 0) { - data = malloc (GlobalSize(hClipboardData)+1); + data = Z_Malloc (GlobalSize(hClipboardData)+1); strcpy (data, cliptext); GlobalUnlock (hClipboardData); } @@ -293,6 +297,8 @@ char *Sys_GetClipboardData (void) void Sys_InitConsole (void) { + int t; + // initialize the windows dedicated server console if needed tevent = CreateEvent(NULL, false, false, NULL); @@ -309,6 +315,9 @@ void Sys_InitConsole (void) 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) { @@ -360,9 +369,7 @@ char program_name[MAX_OSPATH]; int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { - double frameoldtime, framenewtime; MEMORYSTATUS lpBuffer; - int t; /* previous instances do not exist in Win32 */ if (hPrevInstance) @@ -414,17 +421,7 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin } } - Host_Init (); - - frameoldtime = Sys_DoubleTime (); - - /* main window message loop */ - while (1) - { - framenewtime = Sys_DoubleTime (); - Host_Frame (framenewtime - frameoldtime); - frameoldtime = framenewtime; - } + Host_Main(); /* return success of application */ return true;