/* =============== 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" ); }
void Sys_CloseLog( void ) { char event_name[64]; // continue logged switch( host.state ) { case HOST_CRASHED: Q_strncpy( event_name, "crashed", sizeof( event_name )); break; case HOST_ERR_FATAL: Q_strncpy( event_name, "stopped with error", sizeof( event_name )); break; default: if( !host.change_game ) Q_strncpy( event_name, "stopped", sizeof( event_name )); else Q_strncpy( event_name, host.finalmsg, sizeof( event_name )); break; } if( s_wcd.logfile ) { fprintf( s_wcd.logfile, "\n"); fprintf( s_wcd.logfile, "======================================================================="); fprintf( s_wcd.logfile, "\n\t%s %s at %s\n", s_wcd.title, event_name, Q_timestamp( TIME_FULL )); fprintf( s_wcd.logfile, "======================================================================="); if( host.change_game ) fprintf( s_wcd.logfile, "\n" ); // just for tabulate fclose( s_wcd.logfile ); s_wcd.logfile = NULL; } }
/* =============================================================================== SYSTEM LOG =============================================================================== */ void Sys_InitLog( void ) { const char *mode; if( host.change_game ) mode = "a"; else mode = "w"; // print log to stdout printf( "=================================================================================\n" ); printf( "\t%s (build %i) started at %s\n", s_wcd.title, Q_buildnum(), Q_timestamp( TIME_FULL )); printf( "=================================================================================\n" ); // create log if needed if( s_wcd.log_active ) { s_wcd.logfile = fopen( s_wcd.log_path, mode ); if( !s_wcd.logfile ) MsgDev( D_ERROR, "Sys_InitLog: can't create log file %s\n", s_wcd.log_path ); fprintf( s_wcd.logfile, "=================================================================================\n" ); fprintf( s_wcd.logfile, "\t%s (build %i) started at %s\n", s_wcd.title, Q_buildnum(), Q_timestamp( TIME_FULL )); fprintf( s_wcd.logfile, "=================================================================================\n" ); } }
/* =============== 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" ); }
void Key_EnumCmds_f( void ) { file_t *f; FS_AllowDirectPaths( true ); if( FS_FileExists( "../help.txt", false )) { Msg( "help.txt already exist\n" ); FS_AllowDirectPaths( false ); return; } f = FS_Open( "../help.txt", "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\thelp.txt - xash commands and console variables\n"); FS_Printf( f, "//=======================================================================\n"); FS_Printf( f, "\n\n\t\t\tconsole variables\n\n"); Cvar_LookupVars( 0, NULL, f, Cmd_WriteHelp ); FS_Printf( f, "\n\n\t\t\tconsole commands\n\n"); Cmd_LookupCmds( NULL, f, Cmd_WriteHelp ); FS_Printf( f, "\n\n"); FS_Close( f ); Msg( "help.txt created\n" ); } else MsgDev( D_ERROR, "Couldn't write help.txt.\n"); FS_AllowDirectPaths( false ); }
/* =============== 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_WriteVideoConfig save render variables into video.cfg =============== */ void Host_WriteVideoConfig( void ) { file_t *f; MsgDev( D_NOTE, "Host_WriteVideoConfig()\n" ); f = FS_Open( "video.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\tvideo.cfg - archive of renderer variables\n"); FS_Printf( f, "//=======================================================================\n" ); Cmd_WriteRenderVariables( f ); FS_Close( f ); } else MsgDev( D_ERROR, "can't update video.cfg.\n" ); }
/* =============== Host_WriteOpenGLConfig save opengl variables into opengl.cfg =============== */ void Host_WriteOpenGLConfig( void ) { file_t *f; MsgDev( D_NOTE, "Host_WriteGLConfig()\n" ); f = FS_Open( "opengl.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 opengl.cfg - archive of opengl extension cvars\n"); FS_Printf( f, "//=======================================================================\n" ); Cmd_WriteOpenGLVariables( f ); FS_Close( f ); } else MsgDev( D_ERROR, "can't update opengl.cfg.\n" ); }
/* =============== Host_WriteServerConfig save serverinfo variables into server.cfg (using for dedicated server too) =============== */ void Host_WriteServerConfig( const char *name ) { file_t *f; SV_InitGameProgs(); // collect user variables if(( f = FS_Open( name, "w", false )) != NULL ) { FS_Printf( f, "//=======================================================================\n" ); FS_Printf( f, "//\t\t\tCopyright XashXT Group %s ©\n", Q_timestamp( TIME_YEAR_ONLY )); FS_Printf( f, "//\t\t\tserver.cfg - server temporare config\n" ); FS_Printf( f, "//=======================================================================\n" ); Cmd_WriteServerVariables( f ); FS_Close( f ); } else MsgDev( D_ERROR, "Couldn't write %s.\n", name ); SV_FreeGameProgs(); // release progs with all variables }