//----------------------------------------------------------------------------- // Purpose: Message pump when running stand-alone //----------------------------------------------------------------------------- void CEngineAPI::PumpMessages() { MSG msg; while ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } // Get input from attached devices g_pInputSystem->PollInputState(); if ( IsX360() ) { // handle Xbox system messages XBX_ProcessEvents(); } // NOTE: Under some implementations of Win9x, // dispatching messages can cause the FPU control word to change if ( IsPC() ) { SetupFPUControlWord(); } game->DispatchAllStoredGameMessages(); if ( IsPC() ) { EatTextModeKeyPresses(); } }
//----------------------------------------------------------------------------- // Init, shutdown //----------------------------------------------------------------------------- InitReturnVal_t CEngineAPI::Init() { InitReturnVal_t nRetVal = BaseClass::Init(); if ( nRetVal != INIT_OK ) return nRetVal; m_bRunningSimulation = false; // Initialize the FPU control word #if !defined( SWDS ) && !defined( _X360 ) _asm { fninit } #endif SetupFPUControlWord(); // This creates the videomode singleton object, it doesn't depend on the registry VideoMode_Create(); // Initialize the editor hwnd to render into m_hEditorHWnd = NULL; // One-time setup // FIXME: OnStartup + OnShutdown should be removed + moved into the launcher // or the launcher code should be merged into the engine into the code in OnStartup/OnShutdown if ( !OnStartup( m_StartupInfo.m_pInstance, m_StartupInfo.m_pInitialMod ) ) { return HandleSetModeError(); } return INIT_OK; }
//----------------------------------------------------------------------------- // Purpose: Message pump when running stand-alone //----------------------------------------------------------------------------- void CEngineAPI::PumpMessagesEditMode( bool &bIdle, long &lIdleCount ) { MSG msg; if ( bIdle && !g_pHammer->HammerOnIdle( lIdleCount++ ) ) { bIdle = false; } // Get input from attached devices g_pInputSystem->PollInputState(); while ( PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) ) { if ( msg.message == WM_QUIT ) { eng->SetQuitting( IEngine::QUIT_TODESKTOP ); break; } if ( !g_pHammer->HammerPreTranslateMessage(&msg) ) { TranslateMessage(&msg); DispatchMessage(&msg); } // Reset idle state after pumping idle message. if ( g_pHammer->HammerIsIdleMessage(&msg) ) { bIdle = true; lIdleCount = 0; } } // NOTE: Under some implementations of Win9x, // dispatching messages can cause the FPU control word to change SetupFPUControlWord(); game->DispatchAllStoredGameMessages(); }
unsigned __stdcall CThread::ThreadProc(LPVOID pv) { #ifdef _LINUX ThreadInit_t *pInit = (ThreadInit_t *)pv; #else std::auto_ptr<ThreadInit_t> pInit((ThreadInit_t *)pv); #endif #ifdef _X360 // Make sure all threads are consistent w.r.t floating-point math SetupFPUControlWord(); #endif CThread *pThread = pInit->pThread; g_pCurThread = pThread; g_pCurThread->m_pStackBase = AlignValue( &pThread, 4096 ); pInit->pThread->m_result = -1; try { *(pInit->pfInitSuccess) = pInit->pThread->Init(); } catch (...) { *(pInit->pfInitSuccess) = false; #ifdef _WIN32 pInit->pInitCompleteEvent->Set(); #endif throw; } bool bInitSuccess = *(pInit->pfInitSuccess); #ifdef _WIN32 pInit->pInitCompleteEvent->Set(); #endif if (!bInitSuccess) return 0; if ( !Plat_IsInDebugSession() && (pInit->pThread->m_flags & SUPPORT_STOP_PROTOCOL) ) { try { pInit->pThread->m_result = pInit->pThread->Run(); } catch (...) { } } else { pInit->pThread->m_result = pInit->pThread->Run(); } pInit->pThread->OnExit(); g_pCurThread = NULL; #ifdef _WIN32 AUTO_LOCK( pThread->m_Lock ); CloseHandle( pThread->m_hThread ); pThread->m_hThread = NULL; #endif pThread->m_threadId = 0; return pInit->pThread->m_result; }