babelshift / SteamWebAPI2

🎮 C# / .NET library that makes it easy to use the Steam Web API. It conveniently wraps around all of the JSON data and ugly API details with clean methods, structures and classes.
MIT License
263 stars 43 forks source link

PlayerSummaryModel.ProfileVisibility is 2 but has no enum value. #47

Closed Tvde1 closed 7 years ago

Tvde1 commented 7 years ago

So I'm checking if a player has a public profile, and I made this method:

  private async Task<PlayerProfileState> IsProfilePrivate(ulong steamId)
  {
      var profile = new PlayerSummaryModel();
      try
      {
          profile = (await _steamUser.GetPlayerSummaryAsync(steamId)).Data;
      }
      catch
      {
          return await IsProfilePrivate(steamId); 
          //Haven't found any issues in looping if there was an error. Might be bad when API is down but whatever.
      }
      if (profile.ProfileState != 1) return PlayerProfileState.NotSetup;

      var visi = profile.ProfileVisibility;

      switch (visi)
      {
          case ProfileVisibility.Unknown:
              return PlayerProfileState.NotSetup;
          case ProfileVisibility.Private:
              return PlayerProfileState.Private;
          case ProfileVisibility.Public:
              return PlayerProfileState.Normal;
          case ProfileVisibility.FriendsOnly:
              return PlayerProfileState.FriendsOnly;
          default:
              throw new ArgumentOutOfRangeException();
      }
  }

It returns my enum which is this:

public enum PlayerProfileState
{
    Normal,
    Private,
    FriendsOnly,
    NotSetup,
    Bot
}

And the enum returned by PlayerSummaryModel.ProfileVisibility is:

public enum ProfileVisibility
{
    Unknown = 0,
    Private = 1,
    Public = 3,
    FriendsOnly = 8
}

Only PlayerSummaryModel.ProfileVisibility is returning 2 for me. And thus generating an ArgumentOutOfRangeException. I've tried with the steam id "76561198014386060" (private profile).

babelshift commented 7 years ago

Thanks for the report. I'll check this out today/tomorrow.

babelshift commented 7 years ago

I wrote this particular enum many years ago and now I can't remember why I made the FriendsOnly option as 8. I assume that I had a good reason, but now that I'm testing, I don't even see that as a valid value.

I'm also having trouble testing my own profile by changing the privacy settings to see what option maps to what number. I think it's like this:

Private = 1
FriendsOnly = 2
Public = 3

But when I change the option in my profile, the API returns the same number as before. I'm confused!

Tvde1 commented 7 years ago

I had never gotten such a result. Maybe my previous methods had something else in the default case. But I only seem to get it with this guy.

Secret Valve employee confirmed?

babelshift commented 7 years ago

I've updated the enum to have "FriendsOnly" as "2".

I'm still not sure why changing my profile privacy settings doesn't affect the output I receive from GetPlayerSummary.