/* ================= Sys_Exit Single exit point (regular exit or in case of error) ================= */ static __attribute__ ((noreturn)) void Sys_Exit( int exitCode ) { CON_Shutdown( ); #ifndef DEDICATED #ifndef VCMODS_NOSDL SDL_Quit( ); #endif #endif if( exitCode < 2 ) { // Normal exit char *pidFile = Sys_PIDFileName( ); if( pidFile != NULL ) remove( pidFile ); } NET_Shutdown( ); Sys_PlatformExit( ); exit( exitCode ); }
/* =============== Host_Shutdown FIXME: this is a callback from Sys_Quit and Sys_Error. It would be better to run quit through here before the final handoff to the sys code. =============== */ void Host_Shutdown(void) { static qboolean isdown = false; if (isdown) { printf("recursive shutdown\n"); return; } isdown = true; // keep Con_Printf from trying to update the screen scr_disabled_for_loading = true; Host_WriteConfiguration(); CDAudio_Shutdown(); NET_Shutdown(); BGM_Shutdown(); S_Shutdown(); IN_Shutdown(); if (cls.state != ca_dedicated) { VID_Shutdown(); } }
/* =============== Host_Shutdown FIXME: this is a callback from Sys_Quit and Sys_Error. It would be better to run quit through here before the final handoff to the sys code. =============== */ void Host_Shutdown(void) { static qboolean isdown = false; if (isdown) { printf ("recursive shutdown\n"); return; } isdown = true; // keep Con_Printf from trying to update the screen scr_disabled_for_loading = true; Host_WriteConfiguration (); // jkrige - fmod sound system (music) //CDAudio_Shutdown (); // jkrige - fmod sound system (music) NET_Shutdown (); // jkrige - fmod sound system (system) FMOD_Shutdown(); // jkrige - fmod sound system (system) S_Shutdown(); IN_Shutdown (); if (cls.state != ca_dedicated) { VID_Shutdown(); } }
void Host_Shutdown(void) { static bool isdown = false; if (isdown) { printf("recursive shutdown\n"); return; } isdown = true; // keep Con_Printf from trying to update the screen scr_disabled_for_loading = true; Host_WriteConfiguration(); CDAudio_Shutdown(); NET_Shutdown(); S_Shutdown(); IN_Shutdown(); NN_deinit(); TextureManager::clearAllTextures(); Alias::shutdown(); Cmd::shutdown(); CVar::shutdown(); MemoryObj::Flush(MemoryObj::ZONE); if (cls.state != ca_dedicated) { VID_Shutdown(); } if (con_debuglog) { Con_CloseDebugLog(); } }
/* =============== Host_Shutdown FIXME: this is a callback from Sys_Quit and Sys_Error. It would be better to run quit through here before the final handoff to the sys code. =============== */ void Host_Shutdown(void) { static qboolean isdown = false; if (isdown) { printf ("recursive shutdown\n"); return; } isdown = true; // keep Con_Printf from trying to update the screen scr_disabled_for_loading = true; Host_WriteConfiguration (); #ifdef PROQUAKE_EXTENSION IPLog_WriteLog (); // JPG 1.05 - ip loggging #endif if (con_initialized) History_Shutdown (); CDAudio_Shutdown (); NET_Shutdown (); S_Shutdown(); IN_Shutdown (); if (cls.state != ca_dedicated) { VID_Shutdown(); } }
//FIXME: this is a callback from Sys_Quit and Sys_Error. It would be better //to run quit through here before the final handoff to the sys code. void Host_Shutdown (void) { static qbool isdown = false; if (isdown) { printf ("recursive shutdown\n"); return; } isdown = true; // on low-end systems quit process may last long time (was about 1 minute for me on old compo), // at the same time may repeats repeats repeats some sounds, trying preventing this S_StopAllSounds (true); S_Update (vec3_origin, vec3_origin, vec3_origin, vec3_origin); SV_Shutdown ("Server quit\n"); #if (!defined WITH_PNG_STATIC && !defined WITH_JPEG_STATIC) QLib_Shutdown(); #endif CL_Shutdown (); NET_Shutdown (); Con_Shutdown(); #ifdef WITH_TCL TCL_Shutdown (); #endif }
/** * The suite cleanup function. * Returns zero on success, non-zero otherwise. */ static int UFO_CleanSuiteMapDef (void) { TEST_Shutdown(); NET_Shutdown(); return 0; }
static void qtv_shutdown (void) { NET_Shutdown (); Con_Shutdown (); Cbuf_Delete (qtv_cbuf); Cbuf_ArgsDelete (qtv_args); }
/* ================= Sys_Quit ================= */ void Sys_Quit(void) { NET_Shutdown(); Sys_Exit(0); #if defined (USE_WINDOWS_CONSOLE) Sys_DestroyConsole(); #endif }
/* ================= Sys_Quit ================= */ void Sys_Quit(void) { #ifdef __AROS__ NET_Shutdown(); #endif Sys_Exit(0); #if defined (_WIN32) Sys_DestroyConsole(); #endif }
/** * @brief * @sa Qcommon_Init * @sa Sys_Quit * @note Don't call anything that depends on cvars, command system, or any other * subsystem that is allocated in the mem pools and maybe already freed */ void Qcommon_Shutdown (void) { HTTP_Cleanup(); FS_Shutdown(); Cvar_Shutdown(); Cmd_Shutdown(); NET_Shutdown(); Mem_Shutdown(); Com_Shutdown(); }
/** * @brief Single exit point (regular exit or in case of error) */ static __attribute__ ((noreturn)) void Sys_Exit(int exitCode) { CON_Shutdown(); #ifndef DEDICATED SDL_Quit(); #endif // fail safe: delete PID file on abnormal exit // FIXME: normal exit pid deletion is done in Com_Shutdown // why do we have 2 locations for this job? // ... is this Com or Sys code? if (exitCode > 0) { // Normal exit // com_pidfile does not yet exist on early exit if (Cvar_VariableString("com_pidfile")[0] != '\0') { if (FS_FileExists(Cvar_VariableString("com_pidfile"))) { // FIXME: delete even when outside of homepath if (remove(va("%s%c%s%c%s", Cvar_VariableString("fs_homepath"), PATH_SEP, Cvar_VariableString("fs_game"), PATH_SEP, Cvar_VariableString("com_pidfile"))) != 0) { // This is thrown when game game crashes before PID file is created // f.e. when pak files are missing // FIXME: try to create PID file earlier Com_Printf("Sys_Exit warning - can't delete PID file %s%c%s%c%s\n", Cvar_VariableString("fs_homepath"), PATH_SEP, Cvar_VariableString("fs_game"), PATH_SEP, Cvar_VariableString("com_pidfile")); } else { Com_Printf("PID file removed.\n"); } } else { Com_Printf("Sys_Exit warning - PID file doesn't exist %s%c%s%c%s\n", Cvar_VariableString("fs_homepath"), PATH_SEP, Cvar_VariableString("fs_game"), PATH_SEP, Cvar_VariableString("com_pidfile")); } } else { Com_Printf("Sys_Exit warning no PID file found to remove\n"); } } NET_Shutdown(); exit(exitCode); }
/* =============== Host_Shutdown FIXME: this is a callback from Sys_Quit and Sys_Error. It would be better to run quit through here before the final handoff to the sys code. =============== */ void Host_Shutdown(void) { static qboolean isdown = false; if (isdown) { printf ("recursive shutdown\n"); return; } isdown = true; IPLog_WriteLog (); // JPG 1.05 - ip loggging NET_Shutdown (); }
/* ================ SV_Shutdown Quake calls this before calling Sys_Quit or Sys_Error ================ */ void SV_Shutdown (void) { Master_Shutdown (); if (sv_logfile) { fclose (sv_logfile); sv_logfile = NULL; } if (sv_fraglogfile) { fclose (sv_fraglogfile); sv_logfile = NULL; } NET_Shutdown (); }
/* * Qcommon_Shutdown */ void Qcommon_Shutdown( void ) { static qboolean isdown = qfalse; if( isdown ) { printf( "Recursive shutdown\n" ); return; } isdown = qtrue; Com_ScriptModule_Shutdown(); CM_Shutdown(); Netchan_Shutdown(); NET_Shutdown(); Key_Shutdown(); Steam_UnloadLibrary(); Qcommon_ShutdownCommands(); Memory_ShutdownCommands(); if( log_stats_file ) { FS_FCloseFile( log_stats_file ); log_stats_file = 0; } if( log_file ) { FS_FCloseFile( log_file ); log_file = 0; } logconsole = NULL; FS_Shutdown(); wswcurl_cleanup(); Dynvar_Shutdown(); dynvars_initialized = qfalse; Cvar_Shutdown(); Cmd_Shutdown(); Cbuf_Shutdown(); Memory_Shutdown(); QMutex_Destroy( &com_print_mutex ); QThreads_Shutdown(); }
/* =============== Host_Shutdown FIXME: this is a callback from Sys_Quit and Sys_Error. It would be better to run quit through here before the final handoff to the sys code. =============== */ void Host_Shutdown (void) { static qbool isdown = false; if (isdown) { printf ("recursive shutdown\n"); return; } isdown = true; SV_Shutdown ("Server quit\n"); CL_Shutdown (); NET_Shutdown (); COM_Shutdown (); }
static void NORETURN Sys_Exit( int ex ) { IN_Shutdown(); #ifndef DEDICATED SDL_Quit(); #endif NET_Shutdown(); Sys_PlatformExit(); Com_ShutdownHunkMemory(); Com_ShutdownZoneMemory(); CON_Shutdown(); exit( ex ); }
/* ================ Host_Error This shuts down both the client and server ================ */ void Host_Error (char *error, ...) { va_list argptr; char string[1024]; static qbool inerror = false; if (inerror) Sys_Error ("Host_Error: recursively entered"); inerror = true; Com_EndRedirect (); SCR_EndLoadingPlaque (); va_start (argptr,error); #ifdef _WIN32 _vsnprintf (string, sizeof(string) - 1, error, argptr); string[sizeof(string) - 1] = '\0'; #else vsnprintf (string, sizeof(string), error, argptr); #endif // _WIN32 va_end (argptr); Com_Printf ("\n===========================\n"); Com_Printf ("Host_Error: %s\n",string); Com_Printf ("===========================\n\n"); SV_Shutdown (va("server crashed: %s\n", string)); CL_Disconnect (); CL_HandleHostError (); // stop demo loop if (dedicated) { NET_Shutdown (); COM_Shutdown (); Sys_Error ("%s", string); } if (!host_initialized) Sys_Error ("Host_Error: %s", string); inerror = false; Host_Abort (); }
void TEST_Shutdown (void) { SV_Shutdown("test shutdown", qfalse); FS_Shutdown(); Cmd_Shutdown(); Cvar_Shutdown(); Mem_Shutdown(); Com_Shutdown(); Cbuf_Shutdown(); NET_Shutdown(); com_aliasSysPool = NULL; com_cmdSysPool = NULL; com_cmodelSysPool = NULL; com_cvarSysPool = NULL; com_fileSysPool = NULL; com_genericPool = NULL; }
/* =============== Host_Shutdown FIXME: this is a callback from Sys_Quit and Sys_Error. It would be better to run quit through here before the final handoff to the sys code. =============== */ void Host_Shutdown(void) { static qboolean isdown = false; if (isdown) { printf("recursive shutdown\n"); return; } isdown = true; Host_WriteConfiguration(); CDAudio_Shutdown(); NET_Shutdown(); S_Shutdown(); IN_Shutdown(); if (host_basepal) VID_Shutdown(); }
/* ================= Host_Shutdown ================= */ void EXPORT Host_Shutdown( void ) { if( host.shutdown_issued ) return; host.shutdown_issued = true; switch( host.state ) { case HOST_INIT: case HOST_CRASHED: case HOST_ERR_FATAL: if( host.type == HOST_NORMAL ) MsgDev( D_WARN, "Not shutting down normally (%d), skipping config save!\n", host.state ); if( host.state != HOST_ERR_FATAL) host.state = HOST_SHUTDOWN; break; default: if( host.type == HOST_NORMAL ) { Host_WriteConfig(); IN_TouchWriteConfig(); } host.state = HOST_SHUTDOWN; // prepare host to normal shutdown } if( !host.change_game ) Q_strncpy( host.finalmsg, "Server shutdown", sizeof( host.finalmsg )); Log_Printf( "Server shutdown\n" ); Log_Close(); SV_Shutdown( false ); CL_Shutdown(); Mod_Shutdown(); NET_Shutdown(); HTTP_Shutdown(); Cmd_Shutdown(); Host_FreeCommon(); Con_DestroyConsole(); Sys_RestoreCrashHandler(); }
/* ================= Sys_Exit Single exit point (regular exit or in case of error) ================= */ static __attribute__ ((noreturn)) void Sys_Exit( int exitCode ) { CON_Shutdown( ); #ifndef DEDICATED SDL_Quit( ); #endif if( exitCode < 2 && com_fullyInitialized ) { // Normal exit Sys_RemovePIDFile( FS_GetCurrentGameDir() ); } NET_Shutdown( ); Sys_PlatformExit( ); exit( exitCode ); }
/* ================= Sys_Exit Single exit point (regular exit or in case of error) ================= */ void __attribute__ ((noreturn)) Sys_Exit( int ex ) { CON_Shutdown( ); #ifndef DEDICATED SDL_Quit( ); #endif NET_Shutdown( ); Sys_PlatformExit(); #ifdef NQDEBUG exit( ex ); #else // Cause a backtrace on error exits assert( ex == 0 ); exit( ex ); #endif }
/* ============= Com_Quit Both client and server can use this, and it will do the apropriate things. This function never returns. ============= */ void Com_Quit(const char *reason, error_type_t type) { char buffer[MAX_STRING_CHARS]; char *what = type == ERR_RECONNECT ? "restarted" : "quit"; if (reason && *reason) { Q_snprintf(buffer, sizeof(buffer), "Server %s: %s\n", what, reason); } else { Q_snprintf(buffer, sizeof(buffer), "Server %s\n", what); } SV_Shutdown(buffer, type); CL_Shutdown(); NET_Shutdown(); logfile_close(); FS_Shutdown(); Sys_Quit(); // doesn't get there }
void TEST_Shutdown (void) { PTL_InitStartup(); R_ShutdownImages(); SV_Shutdown("test shutdown", false); FS_Shutdown(); UI_Shutdown(); Cmd_Shutdown(); developer = nullptr; Cvar_Shutdown(); Mem_Shutdown(); Com_Shutdown(); Cbuf_Shutdown(); NET_Shutdown(); com_aliasSysPool = nullptr; com_cmdSysPool = nullptr; com_cmodelSysPool = nullptr; com_cvarSysPool = nullptr; com_fileSysPool = nullptr; com_genericPool = nullptr; }
/* ================= Host_Shutdown ================= */ void EXPORT Host_Shutdown( void ) { if( host.shutdown_issued ) return; host.shutdown_issued = true; if( host.state != HOST_ERR_FATAL ) host.state = HOST_SHUTDOWN; // prepare host to normal shutdown if( !host.change_game ) Q_strncpy( host.finalmsg, "Server shutdown", sizeof( host.finalmsg )); if( host.type == HOST_NORMAL ) Host_WriteConfig(); SV_Shutdown( false ); CL_Shutdown(); Mod_Shutdown(); NET_Shutdown(); Host_FreeCommon(); Con_DestroyConsole(); #ifdef _WIN32 // restore filter if( host.oldFilter ) SetUnhandledExceptionFilter( host.oldFilter ); }
/* ================== NET_Restart_f ================== */ static void NET_Restart_f (){ NET_Shutdown(); NET_Init(); }
void Sys_Error (const char *error, ...) { va_list argptr; char text[1024]; double end; STARTUPINFO startupinfo; PROCESS_INFORMATION processinfo; va_start (argptr,error); vsnprintf (text,sizeof(text)-1, error,argptr); va_end (argptr); // MessageBox(NULL, text, "Error", 0 /* MB_OK */ ); Sys_Printf ("ERROR: %s\n", text); Con_Log(text); NET_Shutdown(); //free sockets and stuff. #ifdef USESERVICE if (asservice) Sys_Quit(); #endif if (COM_CheckParm("-noreset")) { Sys_Quit(); exit(1); } Sys_Printf ("A new server will be started in 10 seconds unless you press a key\n"); //check for a key press, quitting if we get one in 10 secs end = Sys_DoubleTime() + 10; while(Sys_DoubleTime() < end) { Sleep(500); // don't burn up CPU with polling if (_kbhit()) { Sys_Quit(); exit(1); } } Sys_Printf("\nLoading new instance of FTE...\n\n\n"); PR_Deinit(); //this takes a bit more mem Rank_Flush(); #ifndef MINGW fcloseall(); //make sure all files are written. #endif // system("dqwsv.exe"); //spawn a new server to take over. This way, if debugging, then any key will quit, otherwise the server will just spawn a new one. memset(&startupinfo, 0, sizeof(startupinfo)); memset(&processinfo, 0, sizeof(processinfo)); CreateProcess(NULL, GetCommandLine(), NULL, NULL, false, 0, NULL, NULL, &startupinfo, &processinfo); CloseHandle(processinfo.hProcess); CloseHandle(processinfo.hThread); Sys_Quit (); exit (1); // this function is NORETURN type, complains without this }
static void TearDownTestCase() { TEST_Shutdown(); NET_Shutdown(); }
/* ============= Com_Error Both client and server can use this, and it will do the apropriate things. ============= */ void Com_Error(error_type_t code, const char *fmt, ...) { char msg[MAXERRORMSG]; va_list argptr; size_t len; // may not be entered recursively if (com_errorEntered) { #ifdef _DEBUG if (com_debug_break && com_debug_break->integer) { Sys_DebugBreak(); } #endif Sys_Error("recursive error after: %s", com_errorMsg); } com_errorEntered = qtrue; va_start(argptr, fmt); len = Q_vscnprintf(msg, sizeof(msg), fmt, argptr); va_end(argptr); // save error msg // can't print into it directly since it may // overlap with one of the arguments! memcpy(com_errorMsg, msg, len + 1); // fix up drity message buffers MSG_Init(); // abort any console redirects Com_AbortRedirect(); // reset Com_Printf recursion level com_printEntered = 0; X86_POP_FPCW; if (code == ERR_DISCONNECT || code == ERR_RECONNECT) { Com_WPrintf("%s\n", com_errorMsg); SV_Shutdown(va("Server was killed: %s\n", com_errorMsg), code); CL_Disconnect(code); goto abort; } #ifdef _DEBUG if (com_debug_break && com_debug_break->integer) { Sys_DebugBreak(); } #endif // make otherwise non-fatal errors fatal if (com_fatal_error && com_fatal_error->integer) { code = ERR_FATAL; } if (code == ERR_DROP) { Com_EPrintf("********************\n" "ERROR: %s\n" "********************\n", com_errorMsg); SV_Shutdown(va("Server crashed: %s\n", com_errorMsg), ERR_DROP); CL_Disconnect(ERR_DROP); goto abort; } if (com_logFile) { FS_FPrintf(com_logFile, "FATAL: %s\n", com_errorMsg); } SV_Shutdown(va("Server fatal crashed: %s\n", com_errorMsg), ERR_FATAL); CL_Shutdown(); NET_Shutdown(); logfile_close(); FS_Shutdown(); Sys_Error("%s", com_errorMsg); // doesn't get there abort: if (com_logFile) { FS_Flush(com_logFile); } com_errorEntered = qfalse; longjmp(abortframe, -1); }