X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=sys_win.c;h=8ae3bbe9d239a791189e0a74d078917c33941b09;hb=4f7008d99f1bcc33a7cf34cc11345ac253a19bc4;hp=4adaf69287e3d34e6e6e70266a953da764bb6e1e;hpb=43ccc403e08b7b72eb687f2d3700e14ea078d30a;p=xonotic%2Fdarkplaces.git diff --git a/sys_win.c b/sys_win.c index 4adaf692..8ae3bbe9 100644 --- a/sys_win.c +++ b/sys_win.c @@ -19,16 +19,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // sys_win.c -- Win32 system interface code -#include "quakedef.h" #include #include +#include #ifdef SUPPORTDIRECTX #include #endif -#include "errno.h" + +#include "qtypes.h" + +#include "quakedef.h" +#include #include "resource.h" #include "conproc.h" -#include "direct.h" HANDLE hinput, houtput; @@ -39,6 +42,7 @@ static HANDLE heventParent; static HANDLE heventChild; #endif +sys_t sys; /* =============================================================================== @@ -61,7 +65,7 @@ void Sys_Error (const char *error, ...) dpvsnprintf (text, sizeof (text), error, argptr); va_end (argptr); - Con_Printf ("Quake Error: %s\n", text); + Con_Printf(CON_ERROR "Engine Error: %s\n", text); // close video so the message box is visible, unless we already tried that if (!in_sys_error0 && cls.state != ca_dedicated) @@ -73,13 +77,13 @@ void Sys_Error (const char *error, ...) if (!in_sys_error3 && cls.state != ca_dedicated) { in_sys_error3 = true; - MessageBox(NULL, text, "Quake Error", MB_OK | MB_SETFOREGROUND | MB_ICONSTOP); + MessageBox(NULL, text, "Engine Error", MB_OK | MB_SETFOREGROUND | MB_ICONSTOP); } if (!in_sys_error1) { in_sys_error1 = 1; - Host_Shutdown (); + //Host_Shutdown (); } // shut down QHOST hooks if necessary @@ -131,25 +135,16 @@ char *Sys_ConsoleInput (void) for ( ;; ) { if (!GetNumberOfConsoleInputEvents (hinput, &numevents)) - { - cls.state = ca_disconnected; Sys_Error ("Error getting # of console events (error code %x)", (unsigned int)GetLastError()); - } if (numevents <= 0) break; if (!ReadConsoleInput(hinput, recs, 1, &numread)) - { - cls.state = ca_disconnected; Sys_Error ("Error reading console input (error code %x)", (unsigned int)GetLastError()); - } if (numread != 1) - { - cls.state = ca_disconnected; Sys_Error ("Couldn't read console input (error code %x)", (unsigned int)GetLastError()); - } if (recs[0].EventType == KEY_EVENT) { @@ -237,11 +232,11 @@ void Sys_InitConsole (void) houtput = GetStdHandle (STD_OUTPUT_HANDLE); hinput = GetStdHandle (STD_INPUT_HANDLE); - // LordHavoc: can't check cls.state because it hasn't been initialized yet + // LadyHavoc: can't check cls.state because it hasn't been initialized yet // if (cls.state == ca_dedicated) - if (COM_CheckParm("-dedicated")) + if (Sys_CheckParm("-dedicated")) { - //if ((houtput == 0) || (houtput == INVALID_HANDLE_VALUE)) // LordHavoc: on Windows XP this is never 0 or invalid, but hinput is invalid + //if ((houtput == 0) || (houtput == INVALID_HANDLE_VALUE)) // LadyHavoc: on Windows XP this is never 0 or invalid, but hinput is invalid { if (!AllocConsole ()) Sys_Error ("Couldn't create dedicated server console (error code %x)", (unsigned int)GetLastError()); @@ -257,22 +252,22 @@ void Sys_InitConsole (void) #define atoi _atoi64 #endif // give QHOST a chance to hook into the console - if ((t = COM_CheckParm ("-HFILE")) > 0) + if ((t = Sys_CheckParm ("-HFILE")) > 0) { - if (t < com_argc) - hFile = (HANDLE)atoi (com_argv[t+1]); + if (t < sys.argc) + hFile = (HANDLE)atoi (sys.argv[t+1]); } - if ((t = COM_CheckParm ("-HPARENT")) > 0) + if ((t = Sys_CheckParm ("-HPARENT")) > 0) { - if (t < com_argc) - heventParent = (HANDLE)atoi (com_argv[t+1]); + if (t < sys.argc) + heventParent = (HANDLE)atoi (sys.argv[t+1]); } - if ((t = COM_CheckParm ("-HCHILD")) > 0) + if ((t = Sys_CheckParm ("-HCHILD")) > 0) { - if (t < com_argc) - heventChild = (HANDLE)atoi (com_argv[t+1]); + if (t < sys.argc) + heventChild = (HANDLE)atoi (sys.argv[t+1]); } InitConProc (hFile, heventParent, heventChild); @@ -317,12 +312,12 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin program_name[sizeof(program_name)-1] = 0; GetModuleFileNameA(NULL, program_name, sizeof(program_name) - 1); - com_argc = 1; - com_argv = argv; + sys.argc = 1; + sys.argv = argv; argv[0] = program_name; // FIXME: this tokenizer is rather redundent, call a more general one - while (*lpCmdLine && (com_argc < MAX_NUM_ARGVS)) + while (*lpCmdLine && (sys.argc < MAX_NUM_ARGVS)) { while (*lpCmdLine && ISWHITESPACE(*lpCmdLine)) lpCmdLine++; @@ -334,16 +329,16 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin { // quoted string lpCmdLine++; - argv[com_argc] = lpCmdLine; - com_argc++; + argv[sys.argc] = lpCmdLine; + sys.argc++; while (*lpCmdLine && (*lpCmdLine != '\"')) lpCmdLine++; } else { // unquoted word - argv[com_argc] = lpCmdLine; - com_argc++; + argv[sys.argc] = lpCmdLine; + sys.argc++; while (*lpCmdLine && !ISWHITESPACE(*lpCmdLine)) lpCmdLine++; } @@ -357,8 +352,13 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin Sys_ProvideSelfFD(); + // used by everything + Memory_Init(); + Host_Main(); + Sys_Quit(0); + /* return success of application */ return true; } @@ -377,8 +377,8 @@ int main (int argc, const char* argv[]) program_name[sizeof(program_name)-1] = 0; GetModuleFileNameA(NULL, program_name, sizeof(program_name) - 1); - com_argc = argc; - com_argv = argv; + sys.argc = argc; + sys.argv = argv; Host_Main(); @@ -386,7 +386,7 @@ int main (int argc, const char* argv[]) } #endif -qboolean sys_supportsdlgetticks = false; +qbool sys_supportsdlgetticks = false; unsigned int Sys_SDL_GetTicks (void) { Sys_Error("Called Sys_SDL_GetTicks on non-SDL target");