예제 #1
0
FString C_GetMassCVarString (DWORD filter, bool compact)
{
	FBaseCVar *cvar;
	FString dump;

	if (compact)
	{
		TArray<FBaseCVar *> cvars;
		dump.AppendFormat("\\\\%ux", filter);
		FilterCompactCVars(cvars, filter);
		while (cvars.Pop (cvar))
		{
			UCVarValue val = cvar->GetGenericRep(CVAR_String);
			dump << '\\' << val.String;
		}
	}
	else
	{
		for (cvar = CVars; cvar != NULL; cvar = cvar->m_Next)
		{
			if ((cvar->Flags & filter) && !(cvar->Flags & (CVAR_NOSAVE|CVAR_IGNORE)))
			{
				UCVarValue val = cvar->GetGenericRep(CVAR_String);
				dump << '\\' << cvar->GetName() << '\\' << val.String;
			}
		}
	}
	return dump;
}
예제 #2
0
void C_WriteCVars (BYTE **demo_p, DWORD filter, bool compact)
{
	FBaseCVar *cvar = CVars;
	BYTE *ptr = *demo_p;

	if (compact)
	{
		TArray<FBaseCVar *> cvars;
		ptr += sprintf ((char *)ptr, "\\\\%ux", filter);
		FilterCompactCVars (cvars, filter);
		while (cvars.Pop (cvar))
		{
			UCVarValue val = cvar->GetGenericRep (CVAR_String);
			ptr += sprintf ((char *)ptr, "\\%s", val.String);
		}
	}
	else
	{
		cvar = CVars;
		while (cvar)
		{
			if ((cvar->Flags & filter) && !(cvar->Flags & (CVAR_NOSAVE|CVAR_IGNORE)))
			{
				UCVarValue val = cvar->GetGenericRep (CVAR_String);
				ptr += sprintf ((char *)ptr, "\\%s\\%s",
					cvar->GetName (), val.String);
			}
			cvar = cvar->m_Next;
		}
	}

	*demo_p = ptr + 1;
}
예제 #3
0
void C_ArchiveCVars (FConfigFile *f, uint32 filter)
{
	FBaseCVar *cvar = CVars;

	while (cvar)
	{
		if ((cvar->Flags &
			(CVAR_GLOBALCONFIG|CVAR_ARCHIVE|CVAR_MOD|CVAR_AUTO|CVAR_USERINFO|CVAR_SERVERINFO|CVAR_NOSAVE))
			== filter)
		{
			UCVarValue val;
			val = cvar->GetGenericRep (CVAR_String);
			// [BB] This is ancient code from Skulltag...
			if ( filter == (CVAR_ARCHIVE|CVAR_USERINFO) )
			{
				char	szString[64];

				strncpy( szString, val.String, 63 );
				szString[63] = 0;
				V_UnColorizeString( szString, 64 );
				f->SetValueForKey (cvar->GetName (), szString);
			}
			else
				f->SetValueForKey (cvar->GetName (), val.String);
		}
		cvar = cvar->m_Next;
	}
}
예제 #4
0
void FBaseCVar::ListVars (const char *filter, bool plain)
{
	FBaseCVar *var = CVars;
	int count = 0;

	while (var)
	{
		if (CheckWildcards (filter, var->GetName()))
		{
			DWORD flags = var->GetFlags();
			UCVarValue val;

			val = var->GetGenericRep (CVAR_String);
			if (plain)
			{ // plain formatting does not include user-defined cvars
				if (!(flags & CVAR_UNSETTABLE))
				{
					++count;
					Printf ("%s : %s\n", var->GetName(), var->GetGenericRep(CVAR_String).String);
				}
			}
			else
			{
				++count;
				Printf ("%c%c%c%c%c %s = %s\n",
					flags & CVAR_ARCHIVE ? 'A' : ' ',
					flags & CVAR_USERINFO ? 'U' :
						flags & CVAR_SERVERINFO ? 'S' :
						flags & CVAR_AUTO ? 'C' : ' ',
					flags & CVAR_NOSET ? '-' :
						flags & CVAR_LATCH ? 'L' :
						flags & CVAR_UNSETTABLE ? '*' : ' ',
					flags & CVAR_MOD ? 'M' : ' ',
					flags & CVAR_IGNORE ? 'X' : ' ',
					var->GetName(),
					var->GetGenericRep (CVAR_String).String);
			}
		}
		var = var->m_Next;
	}
	Printf ("%d cvars\n", count);
}
예제 #5
0
void FBaseCVar::ResetColors ()
{
	FBaseCVar *var = CVars;

	while (var)
	{
		if (var->GetRealType () == CVAR_Color)
		{
			var->DoSet (var->GetGenericRep (CVAR_Int), CVAR_Int);
		}
		var = var->m_Next;
	}
}
void FGameConfigFile::AddAutoexec (DArgs *list, const char *game)
{
	char section[64];
	const char *key;
	const char *value;

	mysnprintf (section, countof(section), "%s.AutoExec", game);

	if (bMigrating)
	{
		FBaseCVar *autoexec = FindCVar ("autoexec", NULL);

		if (autoexec != NULL)
		{
			UCVarValue val;
			char *path;

			val = autoexec->GetGenericRep (CVAR_String);
			path = copystring (val.String);
			delete autoexec;
			SetSection (section, true);
			SetValueForKey ("Path", path);
			list->AppendArg (path);
			delete[] path;
		}
	}
	else
	{
		// If <game>.AutoExec section does not exist, create it
		// with a default autoexec.cfg file present.
		CreateStandardAutoExec(section, false);
		// Run any files listed in the <game>.AutoExec section
		if (!SectionIsEmpty())
		{
			while (NextInSection (key, value))
			{
				if (stricmp (key, "Path") == 0 && *value != '\0')
				{
					FString expanded_path = ExpandEnvVars(value);
					if (FileExists(expanded_path))
					{
						list->AppendArg (ExpandEnvVars(value));
					}
				}
			}
		}
	}
}
예제 #7
0
void C_BackupCVars (void)
{
	assert(CVarBackups.Size() == 0);
	CVarBackups.Clear();

	FCVarBackup backup;

	for (FBaseCVar *cvar = CVars; cvar != NULL; cvar = cvar->m_Next)
	{
		if ((cvar->Flags & (CVAR_SERVERINFO|CVAR_DEMOSAVE)) && !(cvar->Flags & CVAR_LATCH))
		{
			backup.Name = cvar->GetName();
			backup.String = cvar->GetGenericRep(CVAR_String).String;
			CVarBackups.Push(backup);
		}
	}
}
예제 #8
0
파일: c_cvars.cpp 프로젝트: 1Akula1/gzdoom
void C_ArchiveCVars (FConfigFile *f, uint32 filter)
{
	FBaseCVar *cvar = CVars;

	while (cvar)
	{
		if ((cvar->Flags &
			(CVAR_GLOBALCONFIG|CVAR_ARCHIVE|CVAR_MOD|CVAR_AUTO|CVAR_USERINFO|CVAR_SERVERINFO|CVAR_NOSAVE))
			== filter)
		{
			UCVarValue val;
			val = cvar->GetGenericRep (CVAR_String);
			f->SetValueForKey (cvar->GetName (), val.String);
		}
		cvar = cvar->m_Next;
	}
}
예제 #9
0
void D_SetupUserInfo ()
{
    int i;
    userinfo_t *coninfo;

    // Reset everybody's userinfo to a default state.
    for (i = 0; i < MAXPLAYERS; i++)
    {
        players[i].userinfo.Reset();
    }
    // Initialize the console player's user info
    coninfo = &players[consoleplayer].userinfo;

    for (FBaseCVar *cvar = CVars; cvar != NULL; cvar = cvar->GetNext())
    {
        if ((cvar->GetFlags() & (CVAR_USERINFO|CVAR_IGNORE)) == CVAR_USERINFO)
        {
            FBaseCVar **newcvar;
            FName cvarname(cvar->GetName());

            switch (cvarname.GetIndex())
            {
            // Some cvars don't copy their original value directly.
            case NAME_Team:
                coninfo->TeamChanged(team);
                break;
            case NAME_Skin:
                coninfo->SkinChanged(skin, players[consoleplayer].CurrentPlayerClass);
                break;
            case NAME_Gender:
                coninfo->GenderChanged(gender);
                break;
            case NAME_PlayerClass:
                coninfo->PlayerClassChanged(playerclass);
                break;
            // The rest do.
            default:
                newcvar = coninfo->CheckKey(cvarname);
                (*newcvar)->SetGenericRep(cvar->GetGenericRep(CVAR_String), CVAR_String);
                break;
            }
        }
    }
    R_BuildPlayerTranslation(consoleplayer);
}
예제 #10
0
void C_BackupCVars (void)
{
	struct backup_s *backup = CVarBackups;
	FBaseCVar *cvar = CVars;

	while (cvar)
	{
		if ((cvar->Flags & (CVAR_SERVERINFO|CVAR_DEMOSAVE))
			&& !(cvar->Flags & CVAR_LATCH))
		{
			if (backup == &CVarBackups[MAX_DEMOCVARS])
				I_Error ("C_BackupDemoCVars: Too many cvars to save (%d)", MAX_DEMOCVARS);
			backup->name = copystring (cvar->GetName());
			backup->string = copystring (cvar->GetGenericRep (CVAR_String).String);
			backup++;
		}
		cvar = cvar->m_Next;
	}
	numbackedup = int(backup - CVarBackups);
}
예제 #11
0
파일: d_netinfo.cpp 프로젝트: Jadeon/gzdoom
static const char *SetServerVar (char *name, ECVarType type, BYTE **stream, bool singlebit)
{
	FBaseCVar *var = FindCVar (name, NULL);
	UCVarValue value;

	if (singlebit)
	{
		if (var != NULL)
		{
			int bitdata;
			int mask;

			value = var->GetFavoriteRep (&type);
			if (type != CVAR_Int)
			{
				return NULL;
			}
			bitdata = ReadByte (stream);
			mask = 1 << (bitdata & 31);
			if (bitdata & 32)
			{
				value.Int |= mask;
			}
			else
			{
				value.Int &= ~mask;
			}
		}
	}
	else
	{
		switch (type)
		{
		case CVAR_Bool:		value.Bool = ReadByte (stream) ? 1 : 0;	break;
		case CVAR_Int:		value.Int = ReadLong (stream);			break;
		case CVAR_Float:	value.Float = ReadFloat (stream);		break;
		case CVAR_String:	value.String = ReadString (stream);		break;
		default: break;	// Silence GCC
		}
	}

	if (var)
	{
		var->ForceSet (value, type);
	}

	if (type == CVAR_String)
	{
		delete[] value.String;
	}

	if (var == &teamplay)
	{
		// Put players on teams if teamplay turned on
		for (int i = 0; i < MAXPLAYERS; ++i)
		{
			if (playeringame[i])
			{
				UpdateTeam (i, players[i].userinfo.GetTeam(), true);
			}
		}
	}

	if (var)
	{
		value = var->GetGenericRep (CVAR_String);
		return value.String;
	}

	return NULL;
}
예제 #12
0
void FGameConfigFile::DoGlobalSetup ()
{
	if (SetSection ("GlobalSettings.Unknown"))
	{
		ReadCVars (CVAR_GLOBALCONFIG);
	}
	if (SetSection ("GlobalSettings"))
	{
		ReadCVars (CVAR_GLOBALCONFIG);
	}
	if (SetSection ("LastRun"))
	{
		const char *lastver = GetValueForKey ("Version");
		if (lastver != NULL)
		{
			double last = atof (lastver);
			if (last < 123.1)
			{
				FBaseCVar *noblitter = FindCVar ("vid_noblitter", NULL);
				if (noblitter != NULL)
				{
					noblitter->ResetToDefault ();
				}
			}
			if (last < 202)
			{
				// Make sure the Hexen hotkeys are accessible by default.
				if (SetSection ("Hexen.Bindings"))
				{
					SetValueForKey ("\\", "use ArtiHealth");
					SetValueForKey ("scroll", "+showscores");
					SetValueForKey ("0", "useflechette");
					SetValueForKey ("9", "use ArtiBlastRadius");
					SetValueForKey ("8", "use ArtiTeleport");
					SetValueForKey ("7", "use ArtiTeleportOther");
					SetValueForKey ("6", "use ArtiPork");
					SetValueForKey ("5", "use ArtiInvulnerability2");
				}
			}
			if (last < 204)
			{ // The old default for vsync was true, but with an unlimited framerate
			  // now, false is a better default.
				FBaseCVar *vsync = FindCVar ("vid_vsync", NULL);
				if (vsync != NULL)
				{
					vsync->ResetToDefault ();
				}
			}
			if (last < 206)
			{ // spc_amp is now a float, not an int.
				if (spc_amp > 16)
				{
					spc_amp = spc_amp / 16.f;
				}
			}
			if (last < 207)
			{ // Now that snd_midiprecache works again, you probably don't want it on.
				FBaseCVar *precache = FindCVar ("snd_midiprecache", NULL);
				if (precache != NULL)
				{
					precache->ResetToDefault();
				}
			}
			if (last < 208)
			{ // Weapon sections are no longer used, so tidy up the config by deleting them.
				const char *name;
				size_t namelen;
				bool more;

				more = SetFirstSection();
				while (more)
				{
					name = GetCurrentSection();
					if (name != NULL && 
						(namelen = strlen(name)) > 12 &&
						strcmp(name + namelen - 12, ".WeaponSlots") == 0)
					{
						more = DeleteCurrentSection();
					}
					else
					{
						more = SetNextSection();
					}
				}
			}
			if (last < 209)
			{
				// menu dimming is now a gameinfo option so switch user override off
				FBaseCVar *dim = FindCVar ("dimamount", NULL);
				if (dim != NULL)
				{
					dim->ResetToDefault ();
				}
			}
			if (last < 210)
			{
				if (SetSection ("Hexen.Bindings"))
				{
					// These 2 were misnamed in earlier versions
					SetValueForKey ("6", "use ArtiPork");
					SetValueForKey ("5", "use ArtiInvulnerability2");
				}
			}
			if (last < 213)
			{
				auto var = FindCVar("snd_channels", NULL);
				if (var != NULL)
				{
					// old settings were default 32, minimum 8, new settings are default 128, minimum 64.
					UCVarValue v = var->GetGenericRep(CVAR_Int);
					if (v.Int < 64) var->ResetToDefault();
				}
			}
			if (last < 214)
			{
				FBaseCVar *var = FindCVar("hud_scale", NULL);
				if (var != NULL) var->ResetToDefault();
				var = FindCVar("st_scale", NULL);
				if (var != NULL) var->ResetToDefault();
				var = FindCVar("hud_althudscale", NULL);
				if (var != NULL) var->ResetToDefault();
				var = FindCVar("con_scale", NULL);
				if (var != NULL) var->ResetToDefault();
				var = FindCVar("con_scaletext", NULL);
				if (var != NULL) var->ResetToDefault();
				var = FindCVar("uiscale", NULL);
				if (var != NULL) var->ResetToDefault();
			}
			if (last < 215)
			{
				// Previously a true/false boolean. Now an on/off/auto tri-state with auto as the default.
				FBaseCVar *var = FindCVar("snd_hrtf", NULL);
				if (var != NULL) var->ResetToDefault();
			}
			if (last < 216)
			{
				FBaseCVar *var = FindCVar("gl_texture_hqresize", NULL);
				if (var != NULL)
				{
					auto v = var->GetGenericRep(CVAR_Int);
					switch (v.Int)
					{
					case 1:
						gl_texture_hqresizemode = 1; gl_texture_hqresizemult = 2;
						break;
					case 2:
						gl_texture_hqresizemode = 1; gl_texture_hqresizemult = 3;
						break;
					case 3:
						gl_texture_hqresizemode = 1; gl_texture_hqresizemult = 4;
						break;
					case 4:
						gl_texture_hqresizemode = 2; gl_texture_hqresizemult = 2;
						break;
					case 5:
						gl_texture_hqresizemode = 2; gl_texture_hqresizemult = 3;
						break;
					case 6:
						gl_texture_hqresizemode = 2; gl_texture_hqresizemult = 4;
						break;
					case 7:
						gl_texture_hqresizemode = 3; gl_texture_hqresizemult = 2;
						break;
					case 8:
						gl_texture_hqresizemode = 3; gl_texture_hqresizemult = 3;
						break;
					case 9:
						gl_texture_hqresizemode = 3; gl_texture_hqresizemult = 4;
						break;
					case 10:
						gl_texture_hqresizemode = 4; gl_texture_hqresizemult = 2;
						break;
					case 11:
						gl_texture_hqresizemode = 4; gl_texture_hqresizemult = 3;
						break;
					case 12:
						gl_texture_hqresizemode = 4; gl_texture_hqresizemult = 4;
						break;
					case 18:
						gl_texture_hqresizemode = 4; gl_texture_hqresizemult = 5;
						break;
					case 19:
						gl_texture_hqresizemode = 4; gl_texture_hqresizemult = 6;
						break;
					case 13:
						gl_texture_hqresizemode = 5; gl_texture_hqresizemult = 2;
						break;
					case 14:
						gl_texture_hqresizemode = 5; gl_texture_hqresizemult = 3;
						break;
					case 15:
						gl_texture_hqresizemode = 5; gl_texture_hqresizemult = 4;
						break;
					case 16:
						gl_texture_hqresizemode = 5; gl_texture_hqresizemult = 5;
						break;
					case 17:
						gl_texture_hqresizemode = 5; gl_texture_hqresizemult = 6;
						break;
					case 20:
						gl_texture_hqresizemode = 6; gl_texture_hqresizemult = 2;
						break;
					case 21:
						gl_texture_hqresizemode = 6; gl_texture_hqresizemult = 3;
						break;
					case 22:
						gl_texture_hqresizemode = 6; gl_texture_hqresizemult = 4;
						break;
					case 23:
						gl_texture_hqresizemode = 6; gl_texture_hqresizemult = 5;
						break;
					case 24:
						gl_texture_hqresizemode = 6; gl_texture_hqresizemult = 6;
						break;
					case 0:
					default:
						gl_texture_hqresizemode = 0; gl_texture_hqresizemult = 1;
						break;
					}
				}
			}
			if (last < 217)
			{
				auto var = FindCVar("vid_scalemode", NULL);
				UCVarValue newvalue;
				newvalue.Int = 2;
				if (var != NULL)
				{
					UCVarValue v = var->GetGenericRep(CVAR_Int);
					if (v.Int == 3) var->SetGenericRep(newvalue, CVAR_Int);
				}
			}
		}
	}
}