Beispiel #1
0
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);
		}
	}
}
Beispiel #2
0
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;
	}
}
Beispiel #3
0
FBaseCVar *GetUserCVar(int playernum, const char *cvarname)
{
	if ((unsigned)playernum >= MAXPLAYERS || !playeringame[playernum])
	{
		return nullptr;
	}
	FBaseCVar **cvar_p = players[playernum].userinfo.CheckKey(FName(cvarname, true));
	FBaseCVar *cvar;
	if (cvar_p == nullptr || (cvar = *cvar_p) == nullptr || (cvar->GetFlags() & CVAR_IGNORE))
	{
		return nullptr;
	}
	return cvar;
}
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);
}
Beispiel #5
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);
}