void Sys_InitConsole (void) { #ifdef QHOST int t; // initialize the windows dedicated server console if needed tevent = CreateEvent(NULL, false, false, NULL); if (!tevent) Sys_Error ("Couldn't create event"); #endif houtput = GetStdHandle (STD_OUTPUT_HANDLE); hinput = GetStdHandle (STD_INPUT_HANDLE); // LordHavoc: can't check cls.state because it hasn't been initialized yet // if (cls.state == ca_dedicated) if (COM_CheckParm("-dedicated")) { //if ((houtput == 0) || (houtput == INVALID_HANDLE_VALUE)) // LordHavoc: 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()); houtput = GetStdHandle (STD_OUTPUT_HANDLE); hinput = GetStdHandle (STD_INPUT_HANDLE); } if ((houtput == 0) || (houtput == INVALID_HANDLE_VALUE)) Sys_Error ("Couldn't create dedicated server console"); #ifdef QHOST #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); #endif } // because sound is off until we become active S_BlockSound (); }
/* ================ Sys_Init ================ */ void Sys_Init (void) { OSVERSIONINFO vinfo; #if 0 // allocate a named semaphore on the client so the // front end can tell if it is alive // mutex will fail if semephore already exists qwclsemaphore = CreateMutex( NULL, /* Security attributes */ 0, /* owner */ "qwcl"); /* Semaphore name */ if (!qwclsemaphore) Sys_Error ("QWCL is already running on this system"); CloseHandle (qwclsemaphore); qwclsemaphore = CreateSemaphore( NULL, /* Security attributes */ 0, /* Initial count */ 1, /* Maximum count */ "qwcl"); /* Semaphore name */ #endif timeBeginPeriod( 1 ); vinfo.dwOSVersionInfoSize = sizeof(vinfo); if (!GetVersionEx (&vinfo)) Sys_Error ("Couldn't get OS info"); if (vinfo.dwMajorVersion < 4) Sys_Error ("Quake2 requires windows version 4 or greater"); if (vinfo.dwPlatformId == VER_PLATFORM_WIN32s) Sys_Error ("Quake2 doesn't run on Win32s"); else if ( vinfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ) s_win95 = true; if (dedicated->value) { if (!AllocConsole ()) Sys_Error ("Couldn't create dedicated server console"); hinput = GetStdHandle (STD_INPUT_HANDLE); houtput = GetStdHandle (STD_OUTPUT_HANDLE); // let QHOST hook in InitConProc (argc, argv); } }
/* * Sys_Init */ void Sys_Init( void ) { timeBeginPeriod( 1 ); Sys_InitTime(); Sys_InitThreads(); if( dedicated->integer ) { SetPriorityClass( GetCurrentProcess(), HIGH_PRIORITY_CLASS ); if( !AllocConsole() ) Sys_Error( "Couldn't create dedicated server console" ); // let QHOST hook in InitConProc( argc, argv ); } }