Ejemplo n.º 1
0
/*
===============
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" );
}
Ejemplo n.º 2
0
/*
===============
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" );
}
Ejemplo n.º 3
0
/*
===============
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");
};