/* * Writes key bindings and archived cvars to config.cfg */ void CL_WriteConfiguration(void) { FILE *f; char path[MAX_OSPATH]; if (cls.state == ca_uninitialized) { return; } Com_sprintf(path, sizeof(path), "%s/config.cfg", FS_Gamedir()); f = Q_fopen(path, "w"); if (!f) { Com_Printf("Couldn't write config.cfg.\n"); return; } fprintf(f, "// generated by quake, do not modify\n"); Key_WriteBindings(f); fflush(f); fclose(f); Cvar_WriteVariables(path); }
/* =============== Host_WriteConfiguration Writes key bindings and archived cvars to config.cfg =============== */ void Host_WriteConfiguration (void) { FILE *f; // dedicated servers initialize the host but don't parse and set the // config.cfg cvars if (host_initialized & !isDedicated) { const char* path = va("%s/config.cfg",com_gamedir); #ifdef FLASH f = as3OpenWriteFile(path); #else f = fopen (path, "w"); #endif if (!f) { Con_Printf ("Couldn't write config.cfg.\n"); return; } Key_WriteBindings (f); Cvar_WriteVariables (f); fclose (f); #ifdef FLASH as3UpdateFileSharedObject(path); #endif } }
/** * @brief Saves configuration file and shuts the client systems down * @todo this is a callback from @c Sys_Quit and @c Com_Error. It would be better * to run quit through here before the final handoff to the sys code. * @sa Sys_Quit * @sa CL_Init */ void CL_Shutdown (void) { if (isdown) { printf("recursive shutdown\n"); return; } isdown = true; /* remove cvar feedback */ for (const cvar_t* var = Cvar_GetFirst(); var; var = var->next) { if (var->flags & CVAR_R_CONTEXT) Cvar_UnRegisterChangeListener(var->name, CL_RContextCvarChange); if (var->flags & CVAR_R_IMAGES) Cvar_UnRegisterChangeListener(var->name, CL_RImagesCvarChange); } GAME_SetMode(nullptr); GAME_UnloadGame(); CL_HTTP_Cleanup(); Irc_Shutdown(); Con_SaveConsoleHistory(); Key_WriteBindings("keys.cfg"); S_Shutdown(); R_Shutdown(); UI_Shutdown(); CIN_Shutdown(); SEQ_Shutdown(); GAME_Shutdown(); CL_LanguageShutdown(); TOTD_Shutdown(); SCR_Shutdown(); }
/* =============== Host_WriteConfig Writes key bindings and archived cvars to config.cfg =============== */ void Host_WriteConfig( void ) { kbutton_t *mlook, *jlook; file_t *f; if( !clgame.hInstance ) return; MsgDev( D_NOTE, "Host_WriteConfig()\n" ); f = FS_Open( "config.cfg", "w", false ); if( f ) { FS_Printf( f, "//=======================================================================\n"); FS_Printf( f, "//\t\t\tCopyright XashXT Group %s ©\n", Q_timestamp( TIME_YEAR_ONLY )); FS_Printf( f, "//\t\t\tconfig.cfg - archive of cvars\n" ); FS_Printf( f, "//=======================================================================\n" ); Key_WriteBindings( f ); Cmd_WriteVariables( f ); mlook = (kbutton_t *)clgame.dllFuncs.KB_Find( "in_mlook" ); jlook = (kbutton_t *)clgame.dllFuncs.KB_Find( "in_jlook" ); if( mlook && ( mlook->state & 1 )) FS_Printf( f, "+mlook\n" ); if( jlook && ( jlook->state & 1 )) FS_Printf( f, "+jlook\n" ); FS_Printf( f, "exec userconfig.cfg" ); FS_Close( f ); } else MsgDev( D_ERROR, "Couldn't write config.cfg.\n" ); }
/** * Writes key bindings and archived cvars to config.cfg * * Note: Dedicated servers don't parse and set the config.cfg cvars */ void Host_WriteConfiguration(void) { if (host_initialized & !isDedicated) { int handle = SystemFileManager::FileOpenWrite(va("%s/config.cfg", com_gamedir)); Key_WriteBindings(handle); CVar::writeVariables(handle); SystemFileManager::FileClose(handle); } }
/* =============== Host_WriteConfig Writes key bindings and archived cvars to config file =============== */ void CConfigFile::WriteToFile(const char *filename) { /* idFile *pConfigFile = mpFileSystem->OpenFileWrite(filename); if(!f) { DevMsg(eMsgType_Error, "Couldn't write %s\n", filename); return; }; idKeyInput::WriteBindings(f); cvarSystem->WriteFlaggedVariables(CVAR_ARCHIVE, "set", f); fileSystem->CloseFile(f); */ // Dedicated servers initialize the host but don't parse and set the config.cfg cvars if(isDedicated) return; if(!clgame.hInstance) return; if(!host_initializeed) return; DevMsg(eMsgType_Note, "Host_WriteConfig()"); file_t *pConfigFile = mpFileSystem->Open("config.cfg", "w", false); if(pConfigFile) { mpFileSystem->Printf(pConfigFile, "//=======================================================================\n"); mpFileSystem->Printf(pConfigFile, "//\t\t\tCopyright %s ©\n", Q_timestamp(TIME_YEAR_ONLY)); mpFileSystem->Printf(pConfigFile, "//\t\t\tconfig.cfg - archive of cvars\n"); mpFileSystem->Printf(pConfigFile, "//=======================================================================\n"); Key_WriteBindings(pConfigFile); Cmd_WriteVariables(pConfigFile); kbutton_t *mlook = (kbutton_t*)mpClientInput->KB_Find("in_mlook"); kbutton_t *jlook = (kbutton_t*)mpClientInput->KB_Find("in_jlook"); if(mlook && (mlook->state & 1)) mpFileSystem->Printf(pConfigFile, "+mlook\n"); if(jlook && (jlook->state & 1)) mpFileSystem->Printf(pConfigFile, "+jlook\n"); mpFileSystem->Printf(pConfigFile, "exec userconfig.cfg"); mpFileSystem->Close(pConfigFile); } else DevMsg(eMsgType_Error, "Couldn't write config.cfg\n"); };
/* =============== Host_WriteConfig Writes key bindings and archived cvars to config.cfg =============== */ void Host_WriteConfig( void ) { kbutton_t *mlook, *jlook; file_t *f; // if client not loaded, client cvars will lost if( !clgame.hInstance ) { MsgDev( D_NOTE, "Client not loaded, skipping config save!\n" ); return; } MsgDev( D_NOTE, "Host_WriteConfig()\n" ); f = FS_Open( "config.cfg", "w", true ); if( f ) { FS_Printf( f, "//=======================================================================\n"); FS_Printf( f, "//\t\t\tCopyright XashXT Group %s ©\n", Q_timestamp( TIME_YEAR_ONLY )); FS_Printf( f, "//\t\t\tconfig.cfg - archive of cvars\n" ); FS_Printf( f, "//=======================================================================\n" ); Cmd_WriteVariables( f ); FS_Printf( f, "exec keyboard.cfg\n" ); FS_Printf( f, "exec userconfig.cfg\n" ); FS_Close( f ); } else MsgDev( D_ERROR, "Couldn't write config.cfg.\n" ); if( cls.initialized && ( cls.keybind_changed || !FS_FileExists( "keyboard.cfg", true ) ) ) { f = FS_Open( "keyboard.cfg", "w", true ); if( f ) { FS_Printf( f, "//=======================================================================\n"); FS_Printf( f, "//\t\t\tCopyright XashXT Group %s ©\n", Q_timestamp( TIME_YEAR_ONLY )); FS_Printf( f, "//\t\t\tkeyboard.cfg - archive of keybindings\n" ); FS_Printf( f, "//=======================================================================\n" ); Key_WriteBindings( f ); mlook = (kbutton_t *)clgame.dllFuncs.KB_Find( "in_mlook" ); jlook = (kbutton_t *)clgame.dllFuncs.KB_Find( "in_jlook" ); if( mlook && ( mlook->state & 1 )) FS_Printf( f, "+mlook\n" ); if( jlook && ( jlook->state & 1 )) FS_Printf( f, "+jlook\n" ); FS_Close( f ); } else MsgDev( D_ERROR, "Couldn't write keyboard.cfg.\n" ); } else MsgDev( D_NOTE, "Keyboard configuration not changed\n" ); }
/* <35df2> ../engine/host.c:516 */ void Host_WriteCustomConfig(void) { #ifndef SWDS FILE *f; kbutton_t *ml; kbutton_t *jl; #endif char configname[261]; Q_snprintf(configname, 257, "%s", Cmd_Args()); if (Q_strstr(configname, "..") || !Q_stricmp(configname, "config") || !Q_stricmp(configname, "autoexec") || !Q_stricmp(configname, "listenserver") || !Q_stricmp(configname, "server") || !Q_stricmp(configname, "userconfig")) { Con_Printf("skipping writecfg output, invalid filename given\n"); } #ifndef SWDS else { if (host_initialized && g_pcls.state != ca_dedicated) { if (Key_CountBindings() < 2) Con_Printf("skipping config.cfg output, no keys bound\n"); else { Q_strcat(configname, ".cfg"); f = FS_OpenPathID(configname, "w", "GAMECONFIG"); if (!f) { Con_Printf("Couldn't write %s.\n", configname); return; } FS_FPrintf(f, "unbindall\n"); Key_WriteBindings(f); Cvar_WriteVariables(f); Info_WriteVars(f); ml = ClientDLL_FindKey("in_mlook"); jl = ClientDLL_FindKey("in_jlook"); if (ml && ml->state & 1) FS_FPrintf(f, "+mlook\n"); if (jl && jl->state & 1) FS_FPrintf(f, "+jlook\n"); FS_Close(f); Con_Printf("%s successfully created!\n", configname); } } } #endif // SWDS }
/** * @sa Com_WriteConfigToFile */ static void Key_WriteBindings_f (void) { char filename[MAX_QPATH]; if (Cmd_Argc() != 2) { Com_Printf("Usage: %s <filename>\n", Cmd_Argv(0)); return; } Q_strncpyz(filename, Cmd_Argv(1), sizeof(filename)); Com_DefaultExtension(filename, sizeof(filename), ".cfg"); Key_WriteBindings(filename); }
void Com_WriteConfigToFile( const char *filename ) { fileHandle_t f; f = FS_FOpenFileWrite( filename ); if ( !f ) { Com_Printf ("Couldn't write %s.\n", filename ); return; } FS_Printf (f, "// generated by OpenJK SP, do not modify\n"); Key_WriteBindings (f); Cvar_WriteVariables (f); FS_FCloseFile( f ); }
/* =============== Host_WriteConfiguration Writes key bindings and archived cvars to config.cfg =============== */ void Host_WriteConfiguration(void) { FILE *f; f = fopen(va("%s/config.cfg", com_gamedir), "w"); if (!f) { Con_Printf("Couldn't write config.cfg.\n"); return; } Key_WriteBindings(f); Cvar_WriteVariables(f); fclose(f); }
/* =============== Host_WriteConfiguration Writes key bindings and archived cvars to config.cfg =============== */ void Host_WriteConfiguration (void) { FILE *f; // dedicated servers initialize the host but don't parse and set the // config.cfg cvars if (host_initialized & !isDedicated) { f = fopen (va("%s/config.cfg", com_gamedir), "w"); if (!f) { Con_Printf ("Couldn't write config.cfg.\n"); return; } VID_SyncCvars (); //johnfitz -- write actual current mode to config file, in case cvars were messed with Key_WriteBindings (f); Cvar_WriteVariables (f); //johnfitz -- extra commands to preserve state fprintf (f, "vid_restart\n"); if (in_mlook.state & 1) fprintf (f, "+mlook\n"); //johnfitz fclose (f); //johnfitz -- also save fitzquake.rc #if 0 f = fopen (va("%s/fitzquake.rc", GAMENAME), "w"); //always save in id1 if (!f) { Con_Printf ("Couldn't write fitzquake.rc.\n"); return; } Cvar_WriteVariables (f); fprintf (f, "vid_restart\n"); if (in_mlook.state & 1) fprintf (f, "+mlook\n"); fclose (f); #endif //johnfitz } }
void CL_WriteConfig (char *name) { qfile_t *f; f = FS_Open ("config.cfg", "wb", false, false); if (!f) { Com_Printf ("Couldn't write %s.\n", name); return; } FS_Printf (f, "// Generated by " PROGRAM "\n"); FS_Printf (f, "\n// Key bindings\n"); Key_WriteBindings (f); FS_Printf (f, "\n// Variables\n"); Cvar_WriteVariables (f); FS_Printf (f, "\n// Aliases\n"); Cmd_WriteAliases (f); FS_Close (f); }
/* =============== Host_WriteConfiguration Writes key bindings and archived cvars to config.cfg =============== */ void Host_WriteConfiguration (void) { FILE *f; // dedicated servers initialize the host but don't parse and set the // config.cfg cvars if (host_initialized & !isDedicated) { f = fopen (va("%s/config.cfg",com_gamedir), "w"); if (!f) { Con_Printf ("Couldn't write config.cfg.\n"); return; } Key_WriteBindings (f); Cvar_WriteVariables (f); fclose (f); } }
/* =============== Host_SaveConfig_f Writes key bindings and archived cvars to config.cfg =============== */ static void Host_SaveConfig_to(const char *file) { qfile_t *f; // dedicated servers initialize the host but don't parse and set the // config.cfg cvars // LordHavoc: don't save a config if it crashed in startup if (host_framecount >= 3 && cls.state != ca_dedicated && !COM_CheckParm("-benchmark") && !COM_CheckParm("-capturedemo")) { f = FS_OpenRealFile(file, "wb", false); if (!f) { Con_Printf("Couldn't write %s.\n", file); return; } Key_WriteBindings (f); Cvar_WriteVariables (f); FS_Close (f); } }
/* =============== Host_WriteConfiguration Writes key bindings and archived cvars to config.cfg =============== */ void Host_WriteConfiguration(void) { FILE *f; // dedicated servers initialize the host but don't parse and set the // config.cfg cvars if (host_initialized & !isDedicated) { f = fopen(va("%s/config.cfg", com_savedir), "w"); if (!f) { Con_Printf("Couldn't write config.cfg.\n"); return; } Key_WriteBindings(f); Cvar_WriteVariables(f); /* Save the mlook state (rarely used as an actual key binding) */ if (in_mlook.state & 1) fprintf(f, "+mlook\n"); fclose(f); } }
/* =============== Host_WriteConfiguration Writes key bindings and archived cvars to config.cfg =============== */ void Host_WriteConfiguration (void) { FILE *f; // dedicated servers initialize the host but don't parse and set the // config.cfg cvars if (host_initialized) { f = fopen (va("%s/config.cfg",com_gamedir), "w"); if (!f) { Sys_Error ("Couldn't write config.cfg.\n"); return; } fprintf(f, "//=====================================\n"); fprintf(f, "//Generated by %s, do not modify!\n", ENGINE_NAME); fprintf(f, "//=====================================\n\n"); Key_WriteBindings (f); Cvar_WriteVariables (f); fclose (f); } }
/* <35dc8> ../engine/host.c:409 */ void Host_WriteConfiguration(void) { #ifndef SWDS FILE *f; kbutton_t *ml; kbutton_t *jl; qboolean bSetFileToReadOnly; char nameBuf[4096]; if (!host_initialized || g_pcls.state == ca_dedicated) return; #ifdef _WIN32 Sys_GetRegKeyValue("Software\\Valve\\Steam", "rate", rate_.string); if (cl_name.string && Q_stricmp(cl_name.string, "unnamed") && Q_stricmp(cl_name.string, "player") && Q_strlen(cl_name.string)) Sys_GetRegKeyValue("Software\\Valve\\Steam", "LastGameNameUsed", cl_name.string); #else SetRateRegistrySetting(rate_.string); #endif // _WIN32 if (Key_CountBindings() <= 1) { Con_Printf("skipping config.cfg output, no keys bound\n"); return; } bSetFileToReadOnly = FALSE; f = FS_OpenPathID("config.cfg", "w", "GAMECONFIG"); if (!f) { if (!developer.value || !FS_FileExists("../goldsrc/dev_build_all.bat")) { if (FS_GetLocalPath("config.cfg", nameBuf, sizeof(nameBuf))) { bSetFileToReadOnly = TRUE; chmod(nameBuf, S_IREAD|S_IWRITE); } f = FS_OpenPathID("config.cfg", "w", "GAMECONFIG"); if (!f) { Con_Printf("Couldn't write config.cfg.\n"); return; } } } FS_FPrintf(f, "// This file is overwritten whenever you change your user settings in the game.\n"); FS_FPrintf(f, "// Add custom configurations to the file \"userconfig.cfg\".\n\n"); FS_FPrintf(f, "unbindall\n"); Key_WriteBindings(f); Cvar_WriteVariables(f); Info_WriteVars(f); ml = ClientDLL_FindKey("in_mlook"); jl = ClientDLL_FindKey("in_jlook"); if (ml && (ml->state & 1)) FS_FPrintf(f, "+mlook\n"); if (jl && (jl->state & 1)) FS_FPrintf(f, "+jlook\n"); FS_FPrintf(f, "exec userconfig.cfg\n"); FS_Close(f); if (bSetFileToReadOnly) { FS_GetLocalPath("config.cfg", nameBuf, sizeof(nameBuf)); chmod(nameBuf, S_IREAD); } #endif // SWDS }