/* * Both client and server can use this, and it will * do the apropriate things. */ void Com_Quit(void) { Com_Printf("\n----------- shutting down ----------\n"); SV_Shutdown("Server quit\n", false); Sys_Quit(); }
/* ================ Sys_Error ================ */ void Sys_Error (const char *error, ...) { static qbool inerror = false; va_list argptr; char text[1024]; sv_error = true; if (inerror) Sys_Exit (1); inerror = true; va_start (argptr,error); vsnprintf (text, sizeof(text), error, argptr); va_end (argptr); if (!(int)sys_nostdout.value) Sys_Printf ("ERROR: %s\n", text); if (logs[ERROR_LOG].sv_logfile) { SV_Write_Log (ERROR_LOG, 1, va ("ERROR: %s\n", text)); // fclose (logs[ERROR_LOG].sv_logfile); } // FIXME: hack - checking SV_Shutdown with net_socket set in -1 NET_Shutdown if (svs.socketip != -1) SV_Shutdown (va("ERROR: %s\n", text)); if ((int)sys_restart_on_error.value) Sys_Quit (true); Sys_Exit (1); }
void SV_Quit_f (void) { SV_FinalMessage ("server shutdown\n"); Con_Printf ("Shutting down.\n"); SV_Shutdown (); Sys_Quit (); }
void Sys_Error (char *error, ...) { va_list argptr; printf ("Sys_Error: "); va_start (argptr,error); vprintf (error,argptr); va_end (argptr); printf ("\n"); printf("Press START to exit"); while(1){ hidScanInput(); u32 kDown = hidKeysDown(); if (kDown & KEY_START) break; } if(hostInitialized) Sys_Quit(); else { gfxExit(); exit (0); } }
static void HandleEvents() { SDL_Event event; while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_QUIT: Sys_Quit(); break; case SDL_WINDOWEVENT: window_event(&event.window); break; case SDL_KEYDOWN: case SDL_KEYUP: keyb_event(&event.key); break; case SDL_MOUSEMOTION: if (mouse_active && !SDL_GetRelativeMouseMode()) { mx = old_x - event.motion.x; my = old_y - event.motion.y; old_x = event.motion.x; old_y = event.motion.y; SDL_WarpMouseInWindow(sdl_window, glConfig.vidWidth / 2, glConfig.vidHeight / 2); } break; case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: mouse_button_event(&event.button); break; case SDL_MOUSEWHEEL: mouse_wheel_event(&event.wheel); break; } } }
void Host_Quit() { CL_Disconnect (); Host_ShutdownServer(false); Sys_Quit (); }
void Demo_StopPlayback(void) { //float diff; if(!playback) return; Con_Message("Demo was %.2f seconds (%i tics) long.", (DEMOTIC - demoStartTic) / (float) TICSPERSEC, DEMOTIC - demoStartTic); playback = false; lzClose(playdemo); playdemo = 0; fieldOfView = startFOV; Net_StopGame(); /* if(ArgCheck("-timedemo")) { diff = Sys_GetSeconds() - netConnectTime; if(!diff) diff = 1; // Print summary and exit. Con_Message("Timedemo results: %i game tics in %.1f seconds", r_framecounter, diff); Con_Message("%f FPS", r_framecounter / diff); Sys_Quit(); } */ // "Play demo once" mode? if(CommandLine_Check("-playdemo")) Sys_Quit(); }
long _stdcall Sys_Crash( PEXCEPTION_POINTERS pInfo ) { // save config if( host.state != HOST_CRASHED ) { // check to avoid recursive call error_on_exit = true; host.crashed = true; if( host.type == HOST_NORMAL ) CL_Crashed(); // tell client about crash else host.state = HOST_CRASHED; Msg( "Sys_Crash: call %p at address %p\n", pInfo->ExceptionRecord->ExceptionAddress, pInfo->ExceptionRecord->ExceptionCode ); if( host.developer <= 0 ) { // no reason to call debugger in release build - just exit Sys_Quit(); return EXCEPTION_CONTINUE_EXECUTION; } // all other states keep unchanged to let debugger find bug Con_DestroyConsole(); } if( host.oldFilter ) return host.oldFilter( pInfo ); return EXCEPTION_CONTINUE_EXECUTION; }
/* * Com_Quit * * Both client and server can use this, and it will * do the apropriate things. */ void Com_Quit( void ) { if( dynvars_initialized ) { dynvar_t *quit = Dynvar_Lookup( "quit" ); if( quit ) { // wsw : aiwa : added "quit" event for pluggable clean-up (e.g. IRC shutdown) Dynvar_CallListeners( quit, NULL ); } Dynvar_Destroy( quit ); } SV_Shutdown( "Server quit\n" ); CL_Shutdown(); MM_Shutdown(); if( log_file ) { FS_FCloseFile( log_file ); log_file = 0; } Sys_Quit(); }
/* ================ Sys_Break same as Error ================ */ void Sys_Break( const char *error, ... ) { va_list argptr; char text[MAX_SYSPATH]; if( host.state == HOST_ERR_FATAL ) return; // don't multiple executes error_on_exit = true; host.state = HOST_ERR_FATAL; va_start( argptr, error ); Q_vsprintf( text, error, argptr ); va_end( argptr ); if( host.type == HOST_NORMAL ) { if( host.hWnd ) ShowWindow( host.hWnd, SW_HIDE ); VID_RestoreGamma(); } if( host.type != HOST_NORMAL || host.developer > 0 ) { Con_ShowConsole( true ); Con_DisableInput(); // disable input line for dedicated server Sys_Print( text ); Sys_WaitForQuit(); } else { Con_ShowConsole( false ); MSGBOX( text ); } Sys_Quit(); }
static void bi_Menu_Quit (progs_t *pr) { if (con_data.quit) con_data.quit (); Sys_Quit (); }
static void CL_Quit_f (void) { if (!con_module) Sys_Printf ("I hope you wanted to quit\n"); CL_Disconnect (); Sys_Quit (); }
/* ================== idCommonLocal::Quit ================== */ void idCommonLocal::Quit() { // don't try to shutdown if we are in a recursive error if ( !com_errorEntered ) { Shutdown(); } Sys_Quit(); }
/* ============= Com_Quit_f Both client and server can use this, and it will do the apropriate things. ============= */ void Com_Quit_f( void ) { // don't try to shutdown if we are in a recursive error if ( !com_errorEntered ) { SV_Shutdown ("Server quit\n"); CL_Shutdown (); Com_Shutdown (); } Sys_Quit (); }
/* CL_Quit_f */ void CL_Quit_f (void) { if (confirm_quit->int_val) { M_Menu_Quit_f (); return; } CL_Disconnect (); Sys_Quit (); }
/* ================== CL_Quit_f ================== */ void CL_Quit_f (void) { if (1 /* key_dest != key_console */ /* && cls.state != ca_dedicated */) { //M_Menu_Quit_f (); return; } CL_Disconnect (); Sys_Quit (); }
void Host_Quit_f (void) { if (!con_module) Sys_Printf ("I hope you wanted to quit\n"); CL_Disconnect (); Host_ShutdownServer (false); Sys_Quit (); }
/* ================== idCommonLocal::FatalError Dump out of the game to a system dialog ================== */ void idCommonLocal::FatalError( const char *fmt, ... ) { va_list argptr; if ( com_productionMode.GetInteger() == 3 ) { Sys_Quit(); } // if we got a recursive error, make it fatal if ( com_errorEntered ) { // if we are recursively erroring while exiting // from a fatal error, just kill the entire // process immediately, which will prevent a // full screen rendering window covering the // error dialog Sys_Printf( "FATAL: recursed fatal error:\n%s\n", errorMessage ); va_start( argptr, fmt ); idStr::vsnPrintf( errorMessage, sizeof(errorMessage), fmt, argptr ); va_end( argptr ); errorMessage[sizeof(errorMessage)-1] = '\0'; Sys_Printf( "%s\n", errorMessage ); // write the console to a log file? Sys_Quit(); } com_errorEntered = ERP_FATAL; va_start( argptr, fmt ); idStr::vsnPrintf( errorMessage, sizeof(errorMessage), fmt, argptr ); va_end( argptr ); errorMessage[sizeof(errorMessage)-1] = '\0'; if ( cvarSystem->GetCVarBool( "r_fullscreen" ) ) { cmdSystem->BufferCommandText( CMD_EXEC_NOW, "vid_restart partial windowed\n" ); } Sys_SetFatalError( errorMessage ); Sys_Error( "%s", errorMessage ); }
//Used to properly exit the game when closing it from the home menu static void sysAptHook(APT_HookType hook, void* param) { switch (hook) { case APTHOOK_ONEXIT: Sys_Quit(); break; default: break; } }
/* ============= Com_Quit Both client and server can use this, and it will do the apropriate things. ============= */ void Com_Quit (void) { SV_Shutdown ("Server quit\n", false); CL_Shutdown (); if (logfile) { fclose (logfile); logfile = NULL; } Sys_Quit (); }
void Host_Quit_f (void) { if (key_dest != key_console && cls.state != ca_dedicated) { M_Menu_Quit_f (); return; } CL_Disconnect (); Host_ShutdownServer(false); Sys_Quit (); }
void Host_Quit (void) { // execute user's trigger TP_ExecTrigger ("f_exit"); Cbuf_Execute(); // save config (conditional) Config_QuitSave(); // turn off Host_Shutdown (); Sys_Quit (); }
void Sys_SendKeyEvents( void ) { MSG msg; while( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE )) { if( !GetMessage( &msg, NULL, 0, 0 )) Sys_Quit (); TranslateMessage( &msg ); DispatchMessage( &msg ); } }
static void VID_ProcessPendingAsyncEvents (void) { // Collapsed / expanded if (AsyncEvent_Collapsed != vid_hidden) { vid_hidden = !vid_hidden; VID_AppFocusChanged(!vid_hidden); } // Closed if (AsyncEvent_Quitting) Sys_Quit(0); }
void Host_Quit_f (void) { if (Key_GetDest() != key_console && /* quit without asking if we aren't connected -- Steve */ /* cls.state != ca_dedicated */ cls.state == ca_connected) { M_Menu_Quit_f (); return; } CL_Disconnect (); Host_ShutdownServer(false); Sys_Quit (); }
/* * Sys_Signal * * Catch kernel interrupts and dispatch the appropriate exit routine. */ void Sys_Signal(int s) { switch (s) { case SIGHUP: case SIGINT: case SIGQUIT: case SIGTERM: Com_Print("Received signal %d, quitting...\n", s); Sys_Quit(); break; default: Sys_Backtrace(); Sys_Error("Received signal %d.\n", s); break; } }
/* ================ Sys_SendKeyEvents Send Key_Event calls ================ */ void Sys_SendKeyEvents (void) { MSG msg; while (PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE)) { if (!GetMessage (&msg, NULL, 0, 0)) Sys_Quit (); sys_msg_time = (double)msg.time; TranslateMessage (&msg); DispatchMessage (&msg); } // grab frame time sys_frame_time = (double)timeGetTime(); // FIXME: should this be at start? }
/** * @brief Dispatch window messages */ static void Sys_ConsoleLoop (bool error) { MSG msg; while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { if (!GetMessage(&msg, NULL, 0, 0)) { if (error) ExitProcess(1); else Sys_Quit(); } TranslateMessage(&msg); DispatchMessage(&msg); } }
/* ================ Sys_Error NOTE: we must prepare engine to shutdown before call this ================ */ void Sys_Error( const char *format, ... ) { va_list argptr; char text[MAX_SYSPATH]; DEBUG_BREAK; if( host.state == HOST_ERR_FATAL ) return; // don't execute more than once // make sure that console received last message if( host.change_game ) Sys_Sleep( 200 ); error_on_exit = true; host.state = HOST_ERR_FATAL; va_start( argptr, format ); Q_vsprintf( text, format, argptr ); va_end( argptr ); SV_SysError( text ); if( !Host_IsDedicated() ) { #ifdef XASH_SDL if( host.hWnd ) SDL_HideWindow( host.hWnd ); #endif VID_RestoreGamma(); } if( host.developer > 0 ) { Con_ShowConsole( true ); Con_DisableInput(); // disable input line for dedicated server Sys_Print( text ); // print error message MSGBOX( text ); Sys_WaitForQuit(); } else { Con_ShowConsole( false ); MSGBOX( text ); } Sys_Quit(); }
static long _stdcall Con_WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch( uMsg ) { case WM_ACTIVATE: if( LOWORD( wParam ) != WA_INACTIVE ) SetFocus( s_wcd.hwndInputLine ); break; case WM_CLOSE: if( host.state == HOST_ERR_FATAL ) { // send windows message PostQuitMessage( 0 ); } else Sys_Quit(); // otherwise return 0; case WM_CTLCOLORSTATIC: if((HWND)lParam == s_wcd.hwndBuffer ) { SetBkColor((HDC)wParam, RGB( 0x90, 0x90, 0x90 )); SetTextColor((HDC)wParam, RGB( 0xff, 0xff, 0xff )); return (long)s_wcd.hbrEditBackground; } break; case WM_COMMAND: if( wParam == SUBMIT_ID ) { SendMessage( s_wcd.hwndInputLine, WM_CHAR, 13, 0L ); SetFocus( s_wcd.hwndInputLine ); } break; case WM_HOTKEY: switch( LOWORD( wParam )) { case QUIT_ON_ESCAPE_ID: PostQuitMessage( 0 ); break; } break; case WM_CREATE: s_wcd.hbrEditBackground = CreateSolidBrush( RGB( 0x90, 0x90, 0x90 )); break; } return DefWindowProc( hWnd, uMsg, wParam, lParam ); }