Wolfos

Untitled

Mar 5th, 2014
488
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.54 KB | None | 0 0
  1. int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) {
  2.  
  3.     const HCURSOR hcurSave = ::SetCursor( LoadCursor( 0, IDC_WAIT ) );
  4.  
  5.     Sys_SetPhysicalWorkMemory( 192 << 20, 1024 << 20 );
  6.  
  7.     Sys_GetCurrentMemoryStatus( exeLaunchMemoryStats );
  8.  
  9. #if 0
  10.     DWORD handler = (DWORD)_except_handler;
  11.     __asm
  12.     {                           // Build EXCEPTION_REGISTRATION record:
  13.         push    handler         // Address of handler function
  14.         push    FS:[0]          // Address of previous handler
  15.         mov     FS:[0],ESP      // Install new EXECEPTION_REGISTRATION
  16.     }
  17. #endif
  18.  
  19.     win32.hInstance = hInstance;
  20.     idStr::Copynz( sys_cmdline, lpCmdLine, sizeof( sys_cmdline ) );
  21.  
  22.     // done before Com/Sys_Init since we need this for error output
  23.     Sys_CreateConsole();
  24.  
  25.     // no abort/retry/fail errors
  26.     SetErrorMode( SEM_FAILCRITICALERRORS );
  27.  
  28.     for ( int i = 0; i < MAX_CRITICAL_SECTIONS; i++ ) {
  29.         InitializeCriticalSection( &win32.criticalSections[i] );
  30.     }
  31.  
  32.     // get the initial time base
  33.     Sys_Milliseconds();
  34.  
  35. #ifdef DEBUG
  36.     // disable the painfully slow MS heap check every 1024 allocs
  37.     _CrtSetDbgFlag( 0 );
  38. #endif
  39.  
  40. //  Sys_FPU_EnableExceptions( TEST_FPU_EXCEPTIONS );
  41.     Sys_FPU_SetPrecision( FPU_PRECISION_DOUBLE_EXTENDED );
  42.  
  43.     common->Init( 0, NULL, lpCmdLine );
  44.  
  45. #if TEST_FPU_EXCEPTIONS != 0
  46.     common->Printf( Sys_FPU_GetState() );
  47. #endif
  48.  
  49. #ifndef ID_DEDICATED
  50.     if ( win32.win_notaskkeys.GetInteger() ) {
  51.         DisableTaskKeys( TRUE, FALSE, /*( win32.win_notaskkeys.GetInteger() == 2 )*/ FALSE );
  52.     }
  53. #endif
  54.  
  55.     Sys_StartAsyncThread();
  56.  
  57.     // hide or show the early console as necessary
  58.     if ( win32.win_viewlog.GetInteger() || com_skipRenderer.GetBool() || idAsyncNetwork::serverDedicated.GetInteger() ) {
  59.         Sys_ShowConsole( 1, true );
  60.     } else {
  61.         Sys_ShowConsole( 0, false );
  62.     }
  63.  
  64. #ifdef SET_THREAD_AFFINITY
  65.     // give the main thread an affinity for the first cpu
  66.     SetThreadAffinityMask( GetCurrentThread(), 1 );
  67. #endif
  68.  
  69.     ::SetCursor( hcurSave );
  70.  
  71.     // Launch the script debugger
  72.     if ( strstr( lpCmdLine, "+debugger" ) ) {
  73.         // DebuggerClientInit( lpCmdLine );
  74.         return 0;
  75.     }
  76.  
  77.     ::SetFocus( win32.hWnd );
  78.  
  79.     // main game loop
  80.     while( 1 ) {
  81.  
  82.         Win_Frame();
  83.  
  84. #ifdef DEBUG
  85.         Sys_MemFrame();
  86. #endif
  87.  
  88.         // set exceptions, even if some crappy syscall changes them!
  89.         Sys_FPU_EnableExceptions( TEST_FPU_EXCEPTIONS );
  90.  
  91. #ifdef ID_ALLOW_TOOLS
  92.         if ( com_editors ) {
  93.             if ( com_editors & EDITOR_GUI ) {
  94.                 // GUI editor
  95.                 GUIEditorRun();
  96.             } else if ( com_editors & EDITOR_RADIANT ) {
  97.                 // Level Editor
  98.                 RadiantRun();
  99.             }
  100.             else if (com_editors & EDITOR_MATERIAL ) {
  101.                 //BSM Nerve: Add support for the material editor
  102.                 MaterialEditorRun();
  103.             }
  104.             else {
  105.                 if ( com_editors & EDITOR_LIGHT ) {
  106.                     // in-game Light Editor
  107.                     LightEditorRun();
  108.                 }
  109.                 if ( com_editors & EDITOR_SOUND ) {
  110.                     // in-game Sound Editor
  111.                     SoundEditorRun();
  112.                 }
  113.                 if ( com_editors & EDITOR_DECL ) {
  114.                     // in-game Declaration Browser
  115.                     DeclBrowserRun();
  116.                 }
  117.                 if ( com_editors & EDITOR_AF ) {
  118.                     // in-game Articulated Figure Editor
  119.                     AFEditorRun();
  120.                 }
  121.                 if ( com_editors & EDITOR_PARTICLE ) {
  122.                     // in-game Particle Editor
  123.                     ParticleEditorRun();
  124.                 }
  125.                 if ( com_editors & EDITOR_SCRIPT ) {
  126.                     // in-game Script Editor
  127.                     ScriptEditorRun();
  128.                 }
  129.                 if ( com_editors & EDITOR_PDA ) {
  130.                     // in-game PDA Editor
  131.                     PDAEditorRun();
  132.                 }
  133.             }
  134.         }
  135. #endif
  136.         // run the game
  137.         common->Frame();
  138.     }
  139.  
  140.     // never gets here
  141.     return 0;
  142. }
Advertisement
Add Comment
Please, Sign In to add comment