Example #1
0
void ReadUserInfo(FArchive &arc, userinfo_t &info)
{
	FName name;
	FBaseCVar **cvar;
	char *str = NULL;
	UCVarValue val;

	info.Reset();
	for (arc << name; name != NAME_None; arc << name)
	{
		cvar = info.CheckKey(name);
		arc << str;
		if (cvar != NULL && *cvar != NULL)
		{
			switch (name)
			{
			case NAME_Team:			info.TeamChanged(atoi(str)); break;
			case NAME_Skin:			info.SkinChanged(str); break;
			case NAME_PlayerClass:	info.PlayerClassChanged(str); break;
			default:
				val.String = str;
				(*cvar)->SetGenericRep(val, CVAR_String);
				break;
			}
		}
	}
	if (str != NULL)
	{
		delete[] str;
	}
}
void ReadUserInfo(FArchive &arc, userinfo_t &info, FString &skin)
{
    FName name;
    FBaseCVar **cvar;
    char *str = NULL;
    UCVarValue val;

    if (SaveVersion < 4253)
    {
        ReadCompatibleUserInfo(arc, info);
        return;
    }

    info.Reset();
    skin = NULL;
    for (arc << name; name != NAME_None; arc << name)
    {
        cvar = info.CheckKey(name);
        arc << str;
        if (cvar != NULL && *cvar != NULL)
        {
            switch (name)
            {
            case NAME_Team:
                info.TeamChanged(atoi(str));
                break;
            case NAME_Skin:
                skin = str;
                break;	// Caller must call SkinChanged() once current calss is known
            case NAME_PlayerClass:
                info.PlayerClassChanged(str);
                break;
            default:
                val.String = str;
                (*cvar)->SetGenericRep(val, CVAR_String);
                break;
            }
        }
    }
    if (str != NULL)
    {
        delete[] str;
    }
}