void CL_Shutdown(void) { static qboolean isdown = false; if (isdown) { printf("recursive shutdown\n"); return; } isdown = true; CL_WriteConfiguration(); Key_WriteConsoleHistory(); #ifdef CDA CDAudio_Shutdown(); #endif #ifdef OGG OGG_Stop(); #endif S_Shutdown(); IN_Shutdown(); VID_Shutdown(); }
/* ============ VID_CheckChanges This function gets called once just before drawing each frame, and it's sole purpose in life is to check to see if any of the video mode parameters have changed, and if they have to update the rendering DLL and/or video mode to match. ============ */ void VID_CheckChanges (void) { if ( vid_restart ) { cl.force_refdef = true; // can't use a paused refdef S_StopAllSounds(); /* ** refresh has changed */ vid_fullscreen->modified = true; cl.refresh_prepped = false; cls.disable_screen = true; VID_Shutdown(); Com_Printf( "--------- [Loading Renderer] ---------\n" ); vid_active = true; if ( R_Init( 0, 0 ) == -1 ) { R_Shutdown(); Com_Error (ERR_FATAL, "Couldn't initialize renderer!"); } Com_Printf( "------------------------------------\n"); vid_restart = false; cls.disable_screen = false; IN_Activate(false); IN_Activate(true); } }
/* =============== 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(); } }
/* =============== 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 CL_Shutdown(void) { static qboolean isdown = false; if (isdown) { printf("recursive shutdown\n"); return; } isdown = true; #ifdef USE_CURL CL_HTTP_Cleanup(true); #endif CL_WriteConfiguration(); Key_WriteConsoleHistory(); OGG_Stop(); S_Shutdown(); IN_Shutdown(); 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(); CDAudio_Shutdown(); NET_Shutdown(); BGM_Shutdown(); S_Shutdown(); IN_Shutdown(); if (cls.state != ca_dedicated) { VID_Shutdown(); } }
/* ================================================== Ulozeni obsahu konzoly na disk a uklid po chybe ================================================== */ static void CO_ErrorHandler (const char *str) { P_DeInit (); VID_Shutdown (); CO_DeInit (); SDL_Quit (); }
/* =============== 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) { Con_Print("recursive shutdown\n"); return; } if (setjmp(host_abortframe)) { Con_Print("aborted the quitting frame?!?\n"); return; } isdown = true; // be quiet while shutting down S_StopAllSounds(); // disconnect client from server if active CL_Disconnect(); // shut down local server if active Host_ShutdownServer (); // Shutdown menu if(MR_Shutdown) MR_Shutdown(); // AK shutdown PRVM // AK hmm, no PRVM_Shutdown(); yet CL_Gecko_Shutdown(); CL_Video_Shutdown(); Host_SaveConfig(); CDAudio_Shutdown (); S_Terminate (); Curl_Shutdown (); NetConn_Shutdown (); //PR_Shutdown (); if (cls.state != ca_dedicated) { R_Modules_Shutdown(); VID_Shutdown(); Thread_Shutdown(); } Cmd_Shutdown(); Key_Shutdown(); CL_Shutdown(); Sys_Shutdown(); Log_Close(); Crypto_Shutdown(); FS_Shutdown(); Con_Shutdown(); Memory_Shutdown(); }
qboolean VID_LoadRefresh(void) { // If the refresher is already active // we'll shut it down VID_Shutdown(); // Log it! Com_Printf("----- refresher initialization -----\n"); // Get refresher API exports //R_GetRefAPI(); /* Init IN (Mouse) */ in_state.IN_CenterView_fp = IN_CenterView; in_state.Key_Event_fp = Do_Key_Event; in_state.viewangles = cl.viewangles; in_state.in_strafe_state = &in_strafe.state; in_state.in_speed_state = &in_speed.state; // Initiate the input backend IN_BackendInit (&in_state); // Initiate keyboard at the input backend IN_KeyboardInit (Do_Key_Event); Key_ClearStates(); // Declare the refresher as active ref_active = true; char reason[4096]; // Initiate the refresher if (R_Init(0, 0, reason) == -1) { VID_Shutdown(); // Isn't that just too bad? :( return false; } Com_Printf("------------------------------------\n\n"); return true; }
void I_Error (char *error, ...) { va_list argptr; char string[1024]; fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY); va_start (argptr,error); vsprintf (string,error,argptr); va_end (argptr); fprintf(stderr, "Error: %s\n", string); S_Shutdown(); VID_Shutdown(); exit(-1); }
void Sys_Error (const char *error, ...) { va_list argptr; char text[MAX_INPUTLINE]; static int in_sys_error0 = 0; static int in_sys_error1 = 0; static int in_sys_error2 = 0; static int in_sys_error3 = 0; va_start (argptr, error); dpvsnprintf (text, sizeof (text), error, argptr); va_end (argptr); Con_Printf ("Quake Error: %s\n", text); // close video so the message box is visible, unless we already tried that if (!in_sys_error0 && cls.state != ca_dedicated) { in_sys_error0 = 1; VID_Shutdown(); } if (!in_sys_error3 && cls.state != ca_dedicated) { in_sys_error3 = true; MessageBox(NULL, text, "Quake Error", MB_OK | MB_SETFOREGROUND | MB_ICONSTOP); } if (!in_sys_error1) { in_sys_error1 = 1; Host_Shutdown (); } // shut down QHOST hooks if necessary if (!in_sys_error2) { in_sys_error2 = 1; Sys_Shutdown (); } exit (1); }
/* =============== 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(); }
static void VID_Restart_f(void) { extern void GFX_Init(void); extern void ReloadPaletteAndColormap(void); qbool old_con_suppress; if (!host_initialized) { // sanity Com_Printf("Can't do %s yet\n", Cmd_Argv(0)); return; } VID_Shutdown(); ReloadPaletteAndColormap(); // keys can get stuck because SDL2 doesn't send keyup event when the video system is down Key_ClearStates(); VID_Init(host_basepal); // force models to reload (just flush, no actual loading code here) Cache_Flush(); // shut up warnings during GFX_Init(); old_con_suppress = con_suppress; con_suppress = (developer.value ? false : true); // reload 2D textures, particles textures, some other textures and gfx.wad GFX_Init(); // reload skins Skin_Skins_f(); con_suppress = old_con_suppress; // we need done something like for map reloading, for example reload textures for brush models R_NewMap(true); // force all cached models to be loaded, so no short HDD lag then u walk over level and discover new model Mod_TouchModels(); // window may be re-created, so caption need to be forced to update CL_UpdateCaption(true); }
/* ================================================== Vstupni bod aplikace ================================================== */ int main (int argc, char *argv[]) { // Inicializace CO_Init (); VID_Init (); P_Init (); // Predani kontroly aplikaci P_Main (); // Deinicializace P_DeInit (); VID_Shutdown (); CO_DeInit (); SDL_Quit (); return 0; }
void VID_SetMode(int ModeValue) { if (Vid.BackBuffer) { VID_Shutdown(); } WindowWidth = modelist[ModeValue].width; WindowHeight = modelist[ModeValue].height; Vid.BufferHeight = 240; Vid.BufferWidth = 320; Vid.BytesPerPixel = 4; if (modelist[ModeValue].type == MS_WINDOWED) { VID_SetWindowedMode(ModeValue); } else { VID_SetFullscreenMode(ModeValue); } // Show the window ShowWindow(MainWindow, SW_SHOWDEFAULT); // define our bit map info BitMapInfo.bmiHeader.biSize = sizeof(BitMapInfo.bmiHeader); BitMapInfo.bmiHeader.biWidth = Vid.BufferWidth; BitMapInfo.bmiHeader.biHeight = -Vid.BufferHeight; // put the origin in the top left corner BitMapInfo.bmiHeader.biPlanes = 1; BitMapInfo.bmiHeader.biBitCount = 8 * Vid.BytesPerPixel; BitMapInfo.bmiHeader.biCompression = BI_RGB; Vid.BackBuffer = malloc(Vid.BufferWidth * Vid.BufferHeight * Vid.BytesPerPixel); CharData = COM_FindFile("gfx/menuplyr.lmp", &CharLength); }
void VID_SetMode(int ModeValue) { if (BackBuffer) { VID_Shutdown(); } WindowWidth = ModeList[ModeValue].width; WindowHeight = ModeList[ModeValue].height; BufferHeight = WindowHeight; BufferWidth = WindowWidth; if (ModeList[ModeValue].type == MS_WINDOWED) { VID_SetWindowedMode(ModeValue); } else { VID_SetFullscrenMode(ModeValue); } ShowWindow(MainWindow, SW_SHOWDEFAULT); HDC DeviceContext = GetDC(MainWindow); PatBlt(DeviceContext, 0, 0, BufferWidth, BufferHeight, BLACKNESS); ReleaseDC(MainWindow, DeviceContext); // define our bitmap info BitMapInfo.bmiHeader.biSize = sizeof(BitMapInfo.bmiHeader); BitMapInfo.bmiHeader.biWidth = BufferWidth; BitMapInfo.bmiHeader.biHeight = -BufferHeight; BitMapInfo.bmiHeader.biPlanes = 1; BitMapInfo.bmiHeader.biBitCount = 8 * BytesPerPixel; BitMapInfo.bmiHeader.biCompression = BI_RGB; BackBuffer = malloc(BufferWidth * BufferHeight * BytesPerPixel); }
static DWORD Sys_ExceptionHandler( DWORD exceptionCode, LPEXCEPTION_POINTERS exceptionInfo ) { STACKFRAME stackFrame; PCONTEXT context; SYMBOL_INFO *symbol; int count, ret; DWORD64 offset; BYTE buffer[sizeof( SYMBOL_INFO ) + 256 - 1]; IMAGEHLP_MODULE moduleInfo; char path[MAX_PATH]; char execdir[MAX_PATH]; char *p; HMODULE helpModule, shellModule; SYSTEMTIME systemTime; static char *monthNames[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; OSVERSIONINFO vinfo; #ifndef DEDICATED_ONLY VID_Shutdown(); #endif ret = MessageBox( NULL, APPLICATION " has encountered an unhandled exception and needs to be terminated.\n" "Would you like to generate a crash report?", "Unhandled Exception", MB_ICONERROR|MB_YESNO ); if( ret == IDNO ) { return EXCEPTION_CONTINUE_SEARCH; } helpModule = LoadLibrary( "dbghelp.dll" ); if( !helpModule ) { return EXCEPTION_CONTINUE_SEARCH; } #define GPA( x, y ) \ do { \ p ## y = ( x )GetProcAddress( helpModule, #y ); \ if( !p ## y ) { \ FreeLibrary(helpModule); \ return EXCEPTION_CONTINUE_SEARCH; \ } \ } while( 0 ) GPA( SETSYMOPTIONS, SymSetOptions ); GPA( SYMGETMODULEINFO, SymGetModuleInfo ); GPA( SYMCLEANUP, SymCleanup ); GPA( SYMINITIALIZE, SymInitialize ); GPA( ENUMERATELOADEDMODULES, EnumerateLoadedModules ); GPA( STACKWALK, StackWalk ); GPA( SYMFROMADDR, SymFromAddr ); GPA( SYMFUNCTIONTABLEACCESS, SymFunctionTableAccess ); GPA( SYMGETMODULEBASE, SymGetModuleBase ); pSymSetOptions( SYMOPT_LOAD_ANYTHING|SYMOPT_DEBUG|SYMOPT_FAIL_CRITICAL_ERRORS ); processHandle = GetCurrentProcess(); threadHandle = GetCurrentThread(); GetModuleFileName( NULL, execdir, sizeof( execdir ) - 1 ); execdir[sizeof( execdir ) - 1] = 0; p = strrchr( execdir, '\\' ); if( p ) { *p = 0; } GetSystemTime( &systemTime ); Com_sprintf( path, sizeof( path ), "%s\\" APPLICATION "_CrashReport.txt", execdir ); crashReport = fopen( path, "a" ); if( !crashReport ) { return EXCEPTION_CONTINUE_SEARCH; } pSymInitialize( processHandle, execdir, TRUE ); fprintf( crashReport, "Crash report generated %s %u %u, %02u:%02u:%02u UTC\n", monthNames[systemTime.wMonth % 12], systemTime.wDay, systemTime.wYear, systemTime.wHour, systemTime.wMinute, systemTime.wSecond ); fprintf( crashReport, "by " APPLICATION " v" VERSION ", built " __DATE__", " __TIME__ "\n" ); vinfo.dwOSVersionInfoSize = sizeof( vinfo ); if( GetVersionEx( &vinfo ) ) { fprintf( crashReport, "\nWindows version: %u.%u (build %u) %s\n", vinfo.dwMajorVersion, vinfo.dwMinorVersion, vinfo.dwBuildNumber, vinfo.szCSDVersion ); } strcpy( moduleName, "unknown" ); context = exceptionInfo->ContextRecord; fprintf( crashReport, "\nLoaded modules:\n" ); pEnumerateLoadedModules( processHandle, EnumModulesCallback, ( PVOID )context->Eip ); fprintf( crashReport, "\nException information:\n" ); fprintf( crashReport, "Code: %08x\n", exceptionCode ); fprintf( crashReport, "Address: %08x (%s)\n", context->Eip, moduleName ); fprintf( crashReport, "\nThread context:\n" ); fprintf( crashReport, "EIP: %08x EBP: %08x ESP: %08x\n", context->Eip, context->Ebp, context->Esp ); fprintf( crashReport, "EAX: %08x EBX: %08x ECX: %08x\n", context->Eax, context->Ebx, context->Ecx ); fprintf( crashReport, "EDX: %08x ESI: %08x EDI: %08x\n", context->Edx, context->Esi, context->Edi ); memset( &stackFrame, 0, sizeof( stackFrame ) ); stackFrame.AddrPC.Offset = context->Eip; stackFrame.AddrPC.Mode = AddrModeFlat; stackFrame.AddrFrame.Offset = context->Ebp; stackFrame.AddrFrame.Mode = AddrModeFlat; stackFrame.AddrStack.Offset = context->Esp; stackFrame.AddrStack.Mode = AddrModeFlat; fprintf( crashReport, "\nStack trace:\n" ); count = 0; symbol = ( SYMBOL_INFO * )buffer; symbol->SizeOfStruct = sizeof( *symbol ); symbol->MaxNameLen = 256; while( pStackWalk( IMAGE_FILE_MACHINE_I386, processHandle, threadHandle, &stackFrame, context, NULL, pSymFunctionTableAccess, pSymGetModuleBase, NULL ) ) { fprintf( crashReport, "%d: %08x %08x %08x %08x ", count, stackFrame.Params[0], stackFrame.Params[1], stackFrame.Params[2], stackFrame.Params[3] ); moduleInfo.SizeOfStruct = sizeof( moduleInfo ); if( pSymGetModuleInfo( processHandle, stackFrame.AddrPC.Offset, &moduleInfo ) ) { if( moduleInfo.SymType != SymNone && moduleInfo.SymType != SymExport && pSymFromAddr( processHandle, stackFrame.AddrPC.Offset, &offset, symbol ) ) { fprintf( crashReport, "%s!%s+%#x\n", moduleInfo.ModuleName, symbol->Name, offset ); } else { fprintf( crashReport, "%s!%#x\n", moduleInfo.ModuleName, stackFrame.AddrPC.Offset ); } } else { fprintf( crashReport, "%#x\n", stackFrame.AddrPC.Offset ); } count++; } fclose( crashReport ); shellModule = LoadLibrary( "shell32.dll" ); if( shellModule ) { pShellExecute = ( SHELLEXECUTE )GetProcAddress( shellModule, "ShellExecuteA" ); if( pShellExecute ) { pShellExecute( NULL, "open", path, NULL, execdir, SW_SHOW ); } } pSymCleanup( processHandle ); ExitProcess( 1 ); return EXCEPTION_CONTINUE_SEARCH; }
void host_shutdown(void) { VID_Shutdown(); COM_FileShutdown(); }
/* =============== 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) { Con_Print("recursive shutdown\n"); return; } if (setjmp(host_abortframe)) { Con_Print("aborted the quitting frame?!?\n"); return; } isdown = true; // be quiet while shutting down S_StopAllSounds(); // end the server thread if (svs.threaded) SV_StopThread(); // disconnect client from server if active CL_Disconnect(); // shut down local server if active SV_LockThreadMutex(); Host_ShutdownServer (); SV_UnlockThreadMutex(); #ifdef CONFIG_MENU // Shutdown menu if(MR_Shutdown) MR_Shutdown(); #endif // AK shutdown PRVM // AK hmm, no PRVM_Shutdown(); yet CL_Video_Shutdown(); IRC_Shutdown(); Host_SaveConfig(); #ifdef CONFIG_CD CDAudio_Shutdown (); #endif S_Terminate (); Curl_Shutdown (); NetConn_Shutdown (); //PR_Shutdown (); if (cls.state != ca_dedicated) { R_Modules_Shutdown(); VID_Shutdown(); } SV_StopThread(); Thread_Shutdown(); Cmd_Shutdown(); Key_Shutdown(); CL_Shutdown(); Sys_Shutdown(); Log_Close(); Crypto_Shutdown(); Host_UnlockSession(); S_Shutdown(); Con_Shutdown(); Memory_Shutdown(); }
static qboolean BuildXImages(int w, int h) { int i; if(DefaultDepth(vidx11_display, vidx11_screen) != 32 && DefaultDepth(vidx11_display, vidx11_screen) != 24) { Con_Printf("Sorry, we only support 24bpp and 32bpp modes\n"); VID_Shutdown(); return false; } // match to dpsoftrast's specs if(vidx11_visual->red_mask != 0x00FF0000) { Con_Printf("Sorry, we only support BGR visuals\n"); VID_Shutdown(); return false; } if(vidx11_visual->green_mask != 0x0000FF00) { Con_Printf("Sorry, we only support BGR visuals\n"); VID_Shutdown(); return false; } if(vidx11_visual->blue_mask != 0x000000FF) { Con_Printf("Sorry, we only support BGR visuals\n"); VID_Shutdown(); return false; } if(vidx11_shmevent >= 0) { for(i = 0; i < 2; ++i) { vidx11_shminfo[i].shmid = -1; vidx11_ximage[i] = XShmCreateImage(vidx11_display, vidx11_visual, DefaultDepth(vidx11_display, vidx11_screen), ZPixmap, NULL, &vidx11_shminfo[i], w, h); if(!vidx11_ximage[i]) { Con_Printf("Failed to get an XImage segment\n"); VID_Shutdown(); return false; } if(vidx11_ximage[i]->bytes_per_line != w * 4) { Con_Printf("Sorry, we only support linear pixel layout\n"); VID_Shutdown(); return false; } vidx11_shminfo[i].shmid = shmget(IPC_PRIVATE, vidx11_ximage[i]->bytes_per_line * vidx11_ximage[i]->height, IPC_CREAT|0777); if(vidx11_shminfo[i].shmid < 0) { Con_Printf("Failed to get a shm segment\n"); VID_Shutdown(); return false; } vidx11_shminfo[i].shmaddr = vidx11_ximage[i]->data = shmat(vidx11_shminfo[i].shmid, NULL, 0); if(!vidx11_shminfo[i].shmaddr) { Con_Printf("Failed to get a shm segment addresst\n"); VID_Shutdown(); return false; } vidx11_shminfo[i].readOnly = True; XShmAttach(vidx11_display, &vidx11_shminfo[i]); } } else { for(i = 0; i < 1; ++i) // we only need one buffer if we don't use Xshm { char *p = calloc(4, w * h); vidx11_shminfo[i].shmid = -1; vidx11_ximage[i] = XCreateImage(vidx11_display, vidx11_visual, DefaultDepth(vidx11_display, vidx11_screen), ZPixmap, 0, (char*)p, w, h, 8, 0); if(!vidx11_ximage[i]) { Con_Printf("Failed to get an XImage segment\n"); VID_Shutdown(); return false; } if(vidx11_ximage[i]->bytes_per_line != w * 4) { Con_Printf("Sorry, we only support linear pixel layout\n"); VID_Shutdown(); return false; } } } return true; }
void Host_Shutdown(void) { VID_Shutdown(); }