Esempio n. 1
0
/**
 * @brief Generate a list of textures that should have footsteps when walking on them
 * @param[in] filename Add this texture to the list of
 * textures where we should have footstep sounds for
 * @param[in] mipTexIndex The index in the textures array
 * @sa SV_GetFootstepSound
 * @sa Com_GetTerrainType
 */
static void GenerateFootstepList (const char* filename, int mipTexIndex)
{
	if (!config.generateFootstepFile)
		return;

	if (textureref[mipTexIndex].footstepMarked)
		return;

	assert(filename);

	char fileBase[MAX_OSPATH];
	Com_StripExtension(filename, fileBase, sizeof(fileBase));

	ScopedFile f;
	FS_OpenFile(va("%s.footsteps", fileBase), &f, FILE_APPEND);
	if (!f) {
		Com_Printf("Could not open footstep file '%s.footsteps' for writing\n", fileBase);
		config.generateFootstepFile = false;
		return;
	}
#ifdef _WIN32
	FS_Printf(&f, "terrain %s {\n}\n\n", textureref[mipTexIndex].name);
#else
	FS_Printf(&f, "%s\n", textureref[mipTexIndex].name);
#endif
	footstepsCnt++;
	textureref[mipTexIndex].footstepMarked = true;
}
Esempio n. 2
0
/**
 * @brief Generates material files in case the settings can be guessed from map file
 */
static void GenerateMaterialFile (const char* filename, int mipTexIndex, side_t* s)
{
	bool terrainByTexture = false;
	char fileBase[MAX_OSPATH], materialPath[MAX_OSPATH];

	if (!config.generateMaterialFile)
		return;

	/* we already have a material definition for this texture */
	if (textureref[mipTexIndex].materialMarked)
		return;

	assert(filename);

	Com_StripExtension(filename, fileBase, sizeof(fileBase));
	Com_sprintf(materialPath, sizeof(materialPath), "materials/%s.mat", Com_SkipPath(fileBase));

	ScopedFile f;
	FS_OpenFile(materialPath, &f, FILE_APPEND);
	if (!f) {
		Com_Printf("Could not open material file '%s' for writing\n", materialPath);
		config.generateMaterialFile = false;
		return;
	}

	if (strstr(textureref[mipTexIndex].name, "dirt")
	 || strstr(textureref[mipTexIndex].name, "rock")
	 || strstr(textureref[mipTexIndex].name, "grass")) {
		terrainByTexture = true;
	}

	if ((s->contentFlags & CONTENTS_TERRAIN) || terrainByTexture) {
		FS_Printf(&f, "{\n\tmaterial %s\n\t{\n\t\ttexture <fillme>\n\t\tterrain 0 64\n\t\tlightmap\n\t}\n}\n", textureref[mipTexIndex].name);
		textureref[mipTexIndex].materialMarked = true;
		materialsCnt++;
	}

	/* envmap for water surfaces */
	if ((s->contentFlags & CONTENTS_WATER)
	 || strstr(textureref[mipTexIndex].name, "glass")
	 || strstr(textureref[mipTexIndex].name, "window")) {
		FS_Printf(&f, "{\n\tmaterial %s\n\tspecular 2.0\n\t{\n\t\tenvmap 0\n\t}\n}\n", textureref[mipTexIndex].name);
		textureref[mipTexIndex].materialMarked = true;
		materialsCnt++;
	}

	if (strstr(textureref[mipTexIndex].name, "wood")) {
		FS_Printf(&f, "{\n\tmaterial %s\n\tspecular 0.2\n}\n", textureref[mipTexIndex].name);
		textureref[mipTexIndex].materialMarked = true;
		materialsCnt++;
	}

	if (strstr(textureref[mipTexIndex].name, "wall")) {
		FS_Printf(&f, "{\n\tmaterial %s\n\tspecular 0.6\n\tbump 2.0\n}\n", textureref[mipTexIndex].name);
		textureref[mipTexIndex].materialMarked = true;
		materialsCnt++;
	}
}
Esempio n. 3
0
/*
* Key_WriteBindings
* 
* Writes lines containing "bind key value"
*/
void Key_WriteBindings( int file )
{
	int i;

	FS_Printf( file, "unbindall\r\n" );

	for( i = 0; i < 256; i++ )
		if( keybindings[i] && keybindings[i][0] )
			FS_Printf( file, "bind %s \"%s\"\r\n", (i == ';' ? SEMICOLON_BINDNAME : Key_KeynumToString( i )), keybindings[i] );
}
Esempio n. 4
0
/**
 * @sa LoadMapFile
 * @sa FixErrors
 */
void WriteMapFile (const char* filename)
{
	int removed;

	Verb_Printf(VERB_NORMAL, "writing map: '%s'\n", filename);

	ScopedFile f;
	FS_OpenFile(filename, &f, FILE_WRITE);
	if (!f)
		Sys_Error("Could not open %s for writing", filename);

	removed = 0;
	FS_Printf(&f, "\n");
	for (int i = 0; i < num_entities; i++) {
		const entity_t* mapent = &entities[i];
		const epair_t* e = mapent->epairs;

		/* maybe we don't want to write it back into the file */
		if (mapent->skip) {
			removed++;
			continue;
		}
		FS_Printf(&f, "// entity %i\n{\n", i - removed);
		WriteMapEntities(&f, e);

		/* need 2 counters. j counts the brushes in the source entity.
		 * jc counts the brushes written back. they may differ if some are skipped,
		 * eg they are microbrushes */
		int j, jc;
		for (j = 0, jc = 0; j < mapent->numbrushes; j++) {
			const mapbrush_t* brush = &mapbrushes[mapent->firstbrush + j];
			if (brush->skipWriteBack)
				continue;
			WriteMapBrush(brush, jc++, &f);
		}

		/* add brushes from func_groups with single members to worldspawn */
		if (i == 0) {
			int numToAdd;
			mapbrush_t** brushesToAdd = Check_ExtraBrushesForWorldspawn(&numToAdd);
			if (brushesToAdd != nullptr) {
				for (int k = 0; k < numToAdd; k++) {
					if (brushesToAdd[k]->skipWriteBack)
						continue;
					WriteMapBrush(brushesToAdd[k], j++, &f);
				}
				Mem_Free(brushesToAdd);
			}
		}
		FS_Printf(&f, "}\n");
	}

	if (removed)
		Verb_Printf(VERB_NORMAL, "removed %i entities\n", removed);
}
Esempio n. 5
0
/*
============
Key_WriteBindings

Writes lines containing "bind key value"
============
*/
void Key_WriteBindings( fileHandle_t f ) {
	int		i;

	FS_Printf( f, "unbindall" Q_NEWLINE );

	for ( i = 0 ; i < MAX_KEYS ; i++ ) {
		if ( keys[i].binding && keys[i].binding[0] ) {
			FS_Printf( f, "bind %s \"%s\"" Q_NEWLINE, Key_KeynumToString(i), keys[i].binding );
		}
	}
}
Esempio n. 6
0
/*
============
Key_WriteBindings

Writes lines containing "bind key value"
============
*/
void Key_WriteBindings( file_t *f )
{
	int	i;

	if( !f ) return;
	FS_Printf( f, "unbindall\n" );

	for( i = 0; i < 256; i++ )
	{
		if( keys[i].binding && keys[i].binding[0] )
			FS_Printf( f, "bind %s \"%s\"\n", Key_KeynumToString(i), keys[i].binding );
	}
}
Esempio n. 7
0
static void UI_EditorNodeExtractNode (qFILE* file, uiNode_t* node, int depth)
{
	assert(depth < 16);

	int i;
	char tab[16];
	for (i = 0; i < depth; i++) {
		tab[i] = '\t';
	}
	tab[i] = '\0';

	FS_Printf(file, "%s%s %s {\n", tab, node->behaviour->name, node->name);
	uiNode_t* child = node->firstChild;

	/* properties */
	if (child) {
		FS_Printf(file, "%s\t{\n", tab);
		FS_Printf(file, "%s\t\tpos\t\"%d %d\"\n", tab, (int)node->box.pos[0], (int)node->box.pos[1]);
		FS_Printf(file, "%s\t\tsize\t\"%d %d\"\n", tab, (int)node->box.size[0], (int)node->box.size[1]);
		FS_Printf(file, "%s\t}\n", tab);
	} else {
		FS_Printf(file, "%s\tpos\t\"%d %d\"\n", tab, (int)node->box.pos[0], (int)node->box.pos[1]);
		FS_Printf(file, "%s\tsize\t\"%d %d\"\n", tab, (int)node->box.size[0], (int)node->box.size[1]);
	}

	/* child */
	while (child) {
		UI_EditorNodeExtractNode(file, child, depth + 1);
		child = child->next;
	}

	FS_Printf(file, "%s}\n", tab);
}
Esempio n. 8
0
void R_CreateDetailTexturesList( const char *filename )
{
	file_t		*detail_txt = NULL;
	const char	*detail_name, *texname;
	int		i;

	for( i = 0; i < cl.worldmodel->numtextures; i++ )
	{
		texname = cl.worldmodel->textures[i]->name;
		detail_name = R_DetailTextureForName( texname );
		if( !detail_name ) continue;

		// detailtexture detected
		if( detail_name )
		{
			if( !detail_txt ) detail_txt = FS_Open( filename, "w", false ); 
			if( !detail_txt )
			{
				MsgDev( D_ERROR, "Can't write %s\n", filename );
				break;
			}

			// store detailtexture description
			FS_Printf( detail_txt, "%s detail/%s 10.0 10.0\n", texname, detail_name );
		}
	}

	if( detail_txt ) FS_Close( detail_txt );
}
Esempio n. 9
0
void SV_StartDemoRecording(client_t *client, const char *filename, int forcetrack)
{
	prvm_prog_t *prog = SVVM_prog;
	char name[MAX_QPATH];

	if(client->sv_demo_file != NULL)
		return; // we already have a demo

	strlcpy(name, filename, sizeof(name));
	FS_DefaultExtension(name, ".dem", sizeof(name));

	Con_Printf("Recording demo for # %d (%s) to %s\n", PRVM_NUM_FOR_EDICT(client->edict), client->netaddress, name);

	// Reset discardable flag for every new demo.
	PRVM_serveredictfloat(client->edict, discardabledemo) = 0;

	client->sv_demo_file = FS_OpenRealFile(name, "wb", false);
	if(!client->sv_demo_file)
	{
		Con_Print("ERROR: couldn't open.\n");
		return;
	}

	FS_Printf(client->sv_demo_file, "%i\n", forcetrack);
}
Esempio n. 10
0
qboolean Sys_WritePIDFile(void)
{
	fileHandle_t f;

	// First, check if the pid file is already there
	if (FS_FileInPathExists(com_pidfile->string))
	{
		// TODO: check if we are hijacking live pid file
		/*
		FS_FOpenFileRead(com_pidfile->string, &f, qtrue);

		if(Sys_PIDIsRunning(pid))
		{
		    Com_Printf("WARNING: another instance of ET:L is using this path!\n");
		    return qfalse;
		}
		*/
		FS_Delete(com_pidfile->string); // stale pid from previous run
	}

	f = FS_FOpenFileWrite(com_pidfile->string);
	if (f < 0)
	{
		return qfalse;
	}

	FS_Printf(f, "%d", com_pid->integer);

	FS_FCloseFile(f);

	// track profile changes
	Com_TrackProfile(com_pidfile->string);

	return qtrue;
}
Esempio n. 11
0
static void Cmd_WriteHelp(const char *name, const char *unused, const char *desc, void *f )
{
	if( !desc ) return;				// ignore fantom cmds
	if( !Q_strcmp( desc, "" )) return;		// blank description
	if( name[0] == '+' || name[0] == '-' ) return;	// key bindings	
	FS_Printf( f, "%s\t\t\t\"%s\"\n", name, desc );
}
Esempio n. 12
0
/**
 * @brief appends lines containing "set variable value" for all variables
 * with the archive flag set to true.
 * @note Stores the archive cvars
 */
void Cvar_WriteVariables (qFILE* f)
{
	for (const cvar_t* var = cvarVars; var; var = var->next) {
		if (var->flags & CVAR_ARCHIVE)
			FS_Printf(f, "set %s \"%s\" a\n", var->name, var->string);
	}
}
Esempio n. 13
0
/*
* Cvar_WriteVariables
* 
* Appends lines containing "set variable value" for all variables
* with the archive flag set to true.
*/
void Cvar_WriteVariables( int file )
{
	char buffer[MAX_PRINTMSG];
	struct trie_dump_s *dump;
	unsigned int i;
	cvar_flag_t cvar_archive = CVAR_ARCHIVE;

	assert( cvar_trie );
	Trie_DumpIf( cvar_trie, "", TRIE_DUMP_VALUES, Cvar_HasFlags, &cvar_archive, &dump );
	for( i = 0; i < dump->size; ++i )
	{
		cvar_t *const var = dump->key_value_vector[i].value;
		const char *cmd;

		if( Cvar_FlagIsSet( var->flags, CVAR_USERINFO ) )
			cmd = "setau";
		else if( Cvar_FlagIsSet( var->flags, CVAR_SERVERINFO ) )
			cmd = "setas";
		else
			cmd = "seta";

		if( Cvar_FlagIsSet( var->flags, CVAR_LATCH ) || Cvar_FlagIsSet( var->flags, CVAR_LATCH_VIDEO ) ||
			Cvar_FlagIsSet( var->flags, CVAR_LATCH_SOUND ) )
		{
			if( var->latched_string )
				Q_snprintfz( buffer, sizeof( buffer ), "%s %s \"%s\"\r\n", cmd, var->name, var->latched_string );
			else
				Q_snprintfz( buffer, sizeof( buffer ), "%s %s \"%s\"\r\n", cmd, var->name, var->string );
		}
		else
			Q_snprintfz( buffer, sizeof( buffer ), "%s %s \"%s\"\r\n", cmd, var->name, var->string );
		FS_Printf( file, "%s", buffer );
	}
	Trie_FreeDump( dump );
}
Esempio n. 14
0
/**
 * @sa Key_WriteBindings
 */
void Com_WriteConfigToFile (const char* filename)
{
	ScopedFile f;

	FS_OpenFile(filename, &f, FILE_WRITE);
	if (!f.file()) {
		Com_Printf("Couldn't write %s.\n", filename);
		return;
	}

	FS_Printf(&f, "// generated by ufo, do not modify\n");
	FS_Printf(&f, "// variables\n");
	Cvar_WriteVariables(&f);
	FS_Printf(&f, "// aliases\n");
	Cmd_WriteAliases(&f);
	Com_Printf("Wrote %s.\n", filename);
}
Esempio n. 15
0
/*
===============
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" );
}
Esempio n. 16
0
/*
===============
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" );
}
Esempio n. 17
0
/**
 * @brief Write lines containing "aliasa alias value" for all aliases
 * with the archive flag set to true
 * @param f Filehandle to write the aliases to
 */
void Cmd_WriteAliases (qFILE *f)
{
	cmd_alias_t *a;

	for (a = cmd_alias; a; a = a->next)
		if (a->archive) {
			int i;
			FS_Printf(f, "aliasa %s \"", a->name);
			for (i = 0; i < strlen(a->value); i++) {
				if (a->value[i] == '"')
					FS_Printf(f, "\\\"");
				else
					FS_Printf(f, "%c", a->value[i]);
			}
			FS_Printf(f, "\"\n");
		}
}
Esempio n. 18
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" );
}
Esempio n. 19
0
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 );
}
Esempio n. 20
0
File: cvar.cpp Progetto: DaTa-/cnq3x
void Cvar_WriteVariables( fileHandle_t f )
{
	for (const cvar_t* var = cvar_vars; var; var = var->next) {
		if ((Q_stricmp( var->name, "cl_cdkey" ) == 0) || !(var->flags & CVAR_ARCHIVE))
			continue;
		// write the latched value, even if it hasn't taken effect yet
		FS_Printf( f, "seta %s \"%s\"\n", var->name, var->latchedString ? var->latchedString : var->string );
	}
}
Esempio n. 21
0
/**
 * @brief Recurse down the epair list
 * @note First writes the last element
 */
static inline void WriteMapEntities (qFILE* f, const epair_t* e)
{
	if (!e)
		return;

	if (e->next)
		WriteMapEntities(f, e->next);

	FS_Printf(f, "\"%s\" \"%s\"\n", e->key, e->value);
}
Esempio n. 22
0
static void QGL_Log( const char* Fmt, ... ) {
	va_list ArgPtr;
	char string[ 1024 ];

	va_start( ArgPtr, Fmt );
	Q_vsnprintf( string, 1024, Fmt, ArgPtr );
	va_end( ArgPtr );

	FS_Printf( log_fp, "%s", string );
}
Esempio n. 23
0
/*
===============
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
}
Esempio n. 24
0
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);
}
Esempio n. 25
0
/*
=================
CL_CloseJoystickRemap

Write out "<event> <key>" lines
=================
*/
void CL_CloseJoystickRemap( int localPlayerNum ) {
	fileHandle_t	f;
	char			filename[MAX_QPATH];
	int				i;
	joyDevice_t *device;

	if ( playerJoyRemapIndex[ localPlayerNum ] == -1 ) {
		return;
	}

	device = &joyDevice[ playerJoyRemapIndex[ localPlayerNum ] ];
	device->references--;

	playerJoyRemapIndex[ localPlayerNum ] = -1;

	if ( !device->modified ) {
		return;
	}
	device->modified = qfalse;

	Com_sprintf( filename, sizeof ( filename ), "joy-%s-%s.txt", JOY_PLATFORM, device->ident );

	f = FS_SV_FOpenFileWrite( filename );
	if ( !f ) {
		Com_Printf ("Couldn't write %s.\n", filename );
		return;
	}

	FS_Printf (f, "// Joystick remap created using " PRODUCT_NAME " on " JOY_PLATFORM " for %s\n", device->name);

	for ( i = 0 ; i < MAX_JOY_REMAPS ; i++ ) {
		if ( device->remap[i].event.type == JOYEVENT_NONE ) {
			continue;
		}

		FS_Printf (f, "%s %s\n", CL_JoyEventToString( &device->remap[i].event ),
								Key_KeynumToString( device->remap[i].keynum ) );
	}

	FS_FCloseFile( f );
}
Esempio n. 26
0
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 );
}
Esempio n. 27
0
/*
====================
CL_CutDemo

Dumps the current demo to a buffer, and resets the demo to its starting point.
Used to insert csprogs.dat files as a download to the beginning of a demo file.
====================
*/
void CL_CutDemo (unsigned char **buf, fs_offset_t *filesize)
{
	*buf = NULL;
	*filesize = 0;

	FS_Close(cls.demofile);
	*buf = FS_LoadFile(cls.demoname, tempmempool, false, filesize);

	// restart the demo recording
	cls.demofile = FS_OpenRealFile(cls.demoname, "wb", false);
	if(!cls.demofile)
		Sys_Error("failed to reopen the demo file");
	FS_Printf(cls.demofile, "%i\n", cls.forcetrack);
}
Esempio n. 28
0
static void Key_History_Shutdown(void)
{
	// TODO write history to a file

	qfile_t *historyfile = FS_OpenRealFile("darkplaces_history.txt", "w", false);
	if(historyfile)
	{
		int i;
		for(i = 0; i < CONBUFFER_LINES_COUNT(&history); ++i)
			FS_Printf(historyfile, "%s\n", ConBuffer_GetLine(&history, i));
		FS_Close(historyfile);
	}

	ConBuffer_Shutdown(&history);
}
Esempio n. 29
0
/*
============
Cvar_WriteVariables

Appends lines containing "set variable value" for all variables
with the archive flag set to qtrue.
============
*/
void Cvar_WriteVariables( fileHandle_t f ) {
	cvar_t	*var;
	char	buffer[1024];

	for (var = cvar_vars ; var ; var = var->next) {
		if (var->flags & CVAR_ARCHIVE ) {
			// write the latched value, even if it hasn't taken effect yet
			if ( var->latchedString ) {
				Com_sprintf (buffer, sizeof(buffer), "seta %s \"%s\"\n", var->name, var->latchedString);
			} else {
				Com_sprintf (buffer, sizeof(buffer), "seta %s \"%s\"\n", var->name, var->string);
			}
			FS_Printf (f, "%s", buffer);
		}
	}
}
Esempio n. 30
0
void WriteVariables(fileHandle_t f) {
    CvarMap& cvars = GetCvarMap();

    for (auto& entry : cvars) {
        cvarRecord_t* cvar = entry.second;

        if (cvar->IsArchived()) {
            const char* value;
            if (cvar->ccvar.latchedString) {
                value = cvar->ccvar.latchedString;
            } else {
                value = cvar->value.c_str();
            }
            FS_Printf(f, "seta %s %s\n", entry.first.c_str(), Cmd::Escape(value).c_str());
        }
    }
}