/* ============= 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 (); }
void QDECL Com_Error( int code, const char *fmt, ... ) { va_list argptr; // when we are running automated scripts, make sure we // know if anything failed if ( com_buildScript && com_buildScript->integer ) { code = ERR_FATAL; } if ( com_errorEntered ) { Sys_Error( "recursive error after: %s", com_errorMessage ); } com_errorEntered = qtrue; //reset some game stuff here // SCR_UnprecacheScreenshot(); va_start (argptr,fmt); Q_vsnprintf (com_errorMessage, sizeof(com_errorMessage), fmt, argptr); va_end (argptr); if ( code != ERR_DISCONNECT ) { Cvar_Get("com_errorMessage", "", CVAR_ROM); //give com_errorMessage a default so it won't come back to life after a resetDefaults Cvar_Set("com_errorMessage", com_errorMessage); } SG_Shutdown(); // close any file pointers if ( code == ERR_DISCONNECT ) { SV_Shutdown("Disconnect", qtrue); CL_Disconnect(); CL_FlushMemory(); CL_StartHunkUsers(); com_errorEntered = qfalse; throw ("DISCONNECTED\n"); } else if ( code == ERR_DROP ) { // If loading/saving caused the crash/error - delete the temp file SG_WipeSavegame("current"); // delete file SV_Shutdown (va("Server crashed: %s\n", com_errorMessage), qtrue); CL_Disconnect(); CL_FlushMemory(); CL_StartHunkUsers(); Com_Printf (S_COLOR_RED"********************\n"S_COLOR_MAGENTA"ERROR: %s\n"S_COLOR_RED"********************\n", com_errorMessage); com_errorEntered = qfalse; throw ("DROPPED\n"); } else { CL_Shutdown (); SV_Shutdown (va(S_COLOR_RED"Server fatal crashed: %s\n", com_errorMessage), qtrue); } Com_Shutdown (); Sys_Error ("%s", com_errorMessage); }
/** * @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(); }
void NORETURN QDECL Com_Error( int code, const char *fmt, ... ) { va_list argptr; static int lastErrorTime; static int errorCount; int currentTime; if ( com_errorEntered ) { Sys_Error( "recursive error after: %s", com_errorMessage ); } com_errorEntered = qtrue; // when we are running automated scripts, make sure we // know if anything failed if ( com_buildScript && com_buildScript->integer ) { code = ERR_FATAL; } // if we are getting a solid stream of ERR_DROP, do an ERR_FATAL currentTime = Sys_Milliseconds(); if ( currentTime - lastErrorTime < 100 ) { if ( ++errorCount > 3 ) { code = ERR_FATAL; } } else { errorCount = 0; } lastErrorTime = currentTime; #ifdef JK2_MODE SCR_UnprecacheScreenshot(); #endif va_start (argptr,fmt); Q_vsnprintf (com_errorMessage, sizeof(com_errorMessage), fmt, argptr); va_end (argptr); if ( code != ERR_DISCONNECT ) { Cvar_Get("com_errorMessage", "", CVAR_ROM); //give com_errorMessage a default so it won't come back to life after a resetDefaults Cvar_Set("com_errorMessage", com_errorMessage); } SG_Shutdown(); // close any file pointers if ( code == ERR_DISCONNECT || code == ERR_DROP ) { throw code; } else { SV_Shutdown (va("Server fatal crashed: %s\n", com_errorMessage)); CL_Shutdown (); } Com_Shutdown (); Sys_Error ("%s", com_errorMessage); }
/* * @brief Catch kernel interrupts and dispatch the appropriate exit routine. */ void Sys_Signal(int32_t s) { switch (s) { case SIGINT: case SIGTERM: #ifndef _WIN32 case SIGHUP: case SIGQUIT: #endif Com_Shutdown("Received signal %d, quitting...\n", s); break; default: Com_Error(ERR_FATAL, "Received signal %d\n", s); break; } }
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; }
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; }
void Shutdown(bool error, Str::StringRef message) override { TRY_SHUTDOWN( SV_Shutdown(error ? Str::Format("Server fatal crashed: %s\n", message).c_str() : Str::Format("%s\n", message).c_str()) ); TRY_SHUTDOWN(Com_Shutdown()); }
static void Quit_f(void) { Com_Shutdown("Server quit\n"); }