本文整理汇总了C++中FBaseCVar类的典型用法代码示例。如果您正苦于以下问题:C++ FBaseCVar类的具体用法?C++ FBaseCVar怎么用?C++ FBaseCVar使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FBaseCVar类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FindCVar
FBaseCVar *GetCVar(AActor *activator, const char *cvarname)
{
FBaseCVar *cvar = FindCVar(cvarname, nullptr);
// Either the cvar doesn't exist, or it's for a mod that isn't loaded, so return nullptr.
if (cvar == nullptr || (cvar->GetFlags() & CVAR_IGNORE))
{
return nullptr;
}
else
{
// For userinfo cvars, redirect to GetUserCVar
if (cvar->GetFlags() & CVAR_USERINFO)
{
if (activator == nullptr || activator->player == nullptr)
{
return nullptr;
}
return GetUserCVar(int(activator->player - players), cvarname);
}
return cvar;
}
}
示例2:
FBaseCVar *FindCVar (const char *var_name, FBaseCVar **prev)
{
FBaseCVar *var;
FBaseCVar *dummy;
if (var_name == NULL)
return NULL;
if (prev == NULL)
prev = &dummy;
var = CVars;
*prev = NULL;
while (var)
{
if (stricmp (var->GetName (), var_name) == 0)
break;
*prev = var;
var = var->m_Next;
}
return var;
}
示例3: void
FBaseCVar::FBaseCVar (const char *var_name, DWORD flags, void (*callback)(FBaseCVar &))
{
FBaseCVar *var;
var = FindCVar (var_name, NULL);
m_Callback = callback;
Flags = 0;
Name = NULL;
if (var_name)
{
C_AddTabCommand (var_name);
Name = copystring (var_name);
m_Next = CVars;
CVars = this;
}
if (var)
{
ECVarType type;
UCVarValue value;
value = var->GetFavoriteRep (&type);
ForceSet (value, type);
if (var->Flags & CVAR_AUTO)
delete var;
else
var->~FBaseCVar();
Flags = flags;
}
else
{
Flags = flags | CVAR_ISDEFAULT;
}
}
示例4: it
void userinfo_t::Reset()
{
// Clear this player's userinfo.
TMapIterator<FName, FBaseCVar *> it(*this);
TMap<FName, FBaseCVar *>::Pair *pair;
while (it.NextPair(pair))
{
delete pair->Value;
}
Clear();
// Create userinfo vars for this player, initialized to their defaults.
for (FBaseCVar *cvar = CVars; cvar != NULL; cvar = cvar->GetNext())
{
if ((cvar->GetFlags() & (CVAR_USERINFO|CVAR_IGNORE)) == CVAR_USERINFO)
{
ECVarType type;
FName cvarname(cvar->GetName());
FBaseCVar *newcvar;
// Some cvars have different types for their shadow copies.
switch (cvarname.GetIndex())
{
case NAME_Skin:
type = CVAR_Int;
break;
case NAME_Gender:
type = CVAR_Int;
break;
case NAME_PlayerClass:
type = CVAR_Int;
break;
default:
type = cvar->GetRealType();
break;
}
newcvar = C_CreateCVar(NULL, type, cvar->GetFlags() & CVAR_MOD);
newcvar->SetGenericRepDefault(cvar->GetGenericRepDefault(CVAR_String), CVAR_String);
Insert(cvarname, newcvar);
}
}
}
示例5: D_SetupUserInfo
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); 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);
}
示例6: ListVars
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);
}
示例7: ReadCVars
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 ArtiEgg");
SetValueForKey ("5", "use ArtiInvulnerability");
}
}
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 ();
}
}
}
}
}
示例8: C_ReadCVars
void C_ReadCVars (BYTE **demo_p)
{
char *ptr = *((char **)demo_p);
char *breakpt;
if (*ptr++ != '\\')
return;
if (*ptr == '\\')
{ // compact mode
TArray<FBaseCVar *> cvars;
FBaseCVar *cvar;
DWORD filter;
ptr++;
breakpt = strchr (ptr, '\\');
*breakpt = 0;
filter = strtoul (ptr, NULL, 16);
*breakpt = '\\';
ptr = breakpt + 1;
FilterCompactCVars (cvars, filter);
while (cvars.Pop (cvar))
{
UCVarValue val;
breakpt = strchr (ptr, '\\');
if (breakpt)
*breakpt = 0;
val.String = ptr;
cvar->ForceSet (val, CVAR_String);
if (breakpt)
{
*breakpt = '\\';
ptr = breakpt + 1;
}
else
break;
}
}
else
{
char *value;
while ( (breakpt = strchr (ptr, '\\')) )
{
*breakpt = 0;
value = breakpt + 1;
if ( (breakpt = strchr (value, '\\')) )
*breakpt = 0;
cvar_set (ptr, value);
*(value - 1) = '\\';
if (breakpt)
{
*breakpt = '\\';
ptr = breakpt + 1;
}
else
{
break;
}
}
}
*demo_p += strlen (*((char **)demo_p)) + 1;
}
示例9: FindCVar
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;
}
示例10: ReadCVars
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");
//.........这里部分代码省略.........