/* ================== WinMain ================== */ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { char cwd[MAX_OSPATH]; // int startTime, endTime; // should never get a previous instance in Win32 if ( hPrevInstance ) { return 0; } g_wv.hInstance = hInstance; Q_strncpyz( sys_cmdline, lpCmdLine, sizeof( sys_cmdline ) ); // done before Com/Sys_Init since we need this for error output Sys_CreateConsole(); // no abort/retry/fail errors SetErrorMode( SEM_FAILCRITICALERRORS ); // get the initial time base Sys_Milliseconds(); Sys_InitStreamThread(); Com_Init( sys_cmdline ); QuickMemTest(); _getcwd (cwd, sizeof(cwd)); Com_Printf("Working directory: %s\n", cwd); // hide the early console since we've reached the point where we // have a working graphics subsystems if ( !com_viewlog->integer ) { Sys_ShowConsole( 0, qfalse ); } // main game loop while( 1 ) { // if not running as a game client, sleep a bit if ( g_wv.isMinimized ) { Sleep( 5 ); } // set low precision every frame, because some system calls // reset it arbitrarily // _controlfp( _PC_24, _MCW_PC ); // startTime = Sys_Milliseconds(); // make sure mouse and joystick are only called once a frame IN_Frame(); // run the game Com_Frame(); // endTime = Sys_Milliseconds(); // totalMsec += endTime - startTime; // countMsec++; } // never gets here }
int main ( int argc, char **argv ) { char commandLine[ MAX_STRING_CHARS ] = { 0 }; // int startTime, endTime; SET_CRT_DEBUG_FIELD( _CRTDBG_LEAK_CHECK_DF ); // _CrtSetBreakAlloc(34804); Sys_CreateConsole(); // no abort/retry/fail errors SetErrorMode( SEM_FAILCRITICALERRORS ); // get the initial time base Sys_Milliseconds(); Sys_SetBinaryPath( Sys_Dirname( argv[ 0 ] ) ); Sys_SetDefaultInstallPath( DEFAULT_BASEDIR ); // Concatenate the command line for passing to Com_Init for( int i = 1; i < argc; i++ ) { const bool containsSpaces = (strchr(argv[i], ' ') != NULL); if (containsSpaces) Q_strcat( commandLine, sizeof( commandLine ), "\"" ); Q_strcat( commandLine, sizeof( commandLine ), argv[ i ] ); if (containsSpaces) Q_strcat( commandLine, sizeof( commandLine ), "\"" ); Q_strcat( commandLine, sizeof( commandLine ), " " ); } Com_Init( commandLine ); QuickMemTest(); // hide the early console since we've reached the point where we // have a working graphics subsystems if ( !com_viewlog->integer ) { Sys_ShowConsole( 0, qfalse ); } // main game loop while( 1 ) { // if not running as a game client, sleep a bit if ( g_wv.isMinimized ) { Sleep( 5 ); } #ifdef _DEBUG if (!g_wv.activeApp) { Sleep(50); } #endif // _DEBUG // make sure mouse and joystick are only called once a frame IN_Frame(); // run the game Com_Frame(); } }