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); } } }
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); }