Skip to content

Commit

Permalink
Merge pull request #849 from xPaw/fix-571
Browse files Browse the repository at this point in the history
Remove Max value from enums and update some
  • Loading branch information
yaakov-h authored May 16, 2020
2 parents 66eab3b + 59843b4 commit 9d42533
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 41 deletions.
27 changes: 1 addition & 26 deletions Resources/SteamLanguage/enums.steamd
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ enum EUniverse
Beta = 2;
Internal = 3;
Dev = 4;

Max = 5;
};

enum EChatEntryType
Expand Down Expand Up @@ -42,8 +40,6 @@ enum EPersonaState
LookingToTrade = 5;
LookingToPlay = 6;
Invisible = 7;

Max = 8;
};

enum EAccountType
Expand All @@ -60,8 +56,6 @@ enum EAccountType
Chat = 8;
ConsoleUser = 9;
AnonUser = 10;

Max = 11;
};

enum EFriendRelationship
Expand All @@ -75,8 +69,6 @@ enum EFriendRelationship
Ignored = 5;
IgnoredFriend = 6;
SuggestedFriend = 7; removed "was used by the original implementation of the facebook linking feature; but now unused."

Max = 8;
};

enum EAccountFlags flags
Expand Down Expand Up @@ -352,6 +344,7 @@ enum EPaymentMethod
MasterComp = 130;
StorePromotion = 131; removed "renamed to Promotional"
Promotional = 131;
MasterSubscription = 134;
OEMTicket = 256;
Split = 512;
Complimentary = 1024;
Expand Down Expand Up @@ -613,8 +606,6 @@ enum EAppInfoSection
Broadcastgamedata = 18;
Computed = 19;
Albummetadata = 20;

Max = 21;
};

enum EContentDownloadSourceType
Expand All @@ -630,8 +621,6 @@ enum EContentDownloadSourceType
SteamCache = 7;
OpenCache = 8;
LANCache = 9;

Max = 10;
};

enum EPlatformType
Expand All @@ -645,8 +634,6 @@ enum EPlatformType
OSX = 4;
PS3 = 5;
Linux32 = 6;

Max = 7;
};

enum EOSType
Expand Down Expand Up @@ -760,8 +747,6 @@ enum EOSType
Win2016 = 17;

WinMAX = 18;

Max = 26;
};

enum EServerType
Expand Down Expand Up @@ -908,8 +893,6 @@ enum EServerType
SteamAR = 124;
China = 125;
CrashDump = 126;

Max = 127;
};

enum EBillingType
Expand Down Expand Up @@ -1016,8 +999,6 @@ enum ECurrencyCode
QAR = 39;
CRC = 40;
UYU = 41;

Max = 42;
};

enum EDepotFileFlag flags
Expand Down Expand Up @@ -1072,8 +1053,6 @@ enum EWorkshopFileType
SteamworksAccessInvite = 13;
SteamVideo = 14;
GameManagedItem = 15;

Max = 16;
};

enum EWorkshopFileAction
Expand Down Expand Up @@ -1152,8 +1131,6 @@ enum ESystemIMType
GiftRevoked = 7;
SupportMessage = 8;
SupportMessageClearAlert = 9;

Max = 10;
};

enum EChatFlags flags
Expand Down Expand Up @@ -1230,8 +1207,6 @@ enum EClientStat
P2PGameConnections = 2;
P2PVoiceConnections = 3;
BytesDownloaded = 4;

Max = 5;
};

enum EClientStatAggregateMethod
Expand Down
1 change: 1 addition & 0 deletions Resources/SteamLanguage/eresult.steamd
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,5 @@ enum EResult
CantRemoveItem = 113;
AccountHasBeenDeleted = 114;
AccountHasAnExistingUserCancelledLicense = 115;
DeniedDueToCommunityCooldown = 116;
};
15 changes: 2 additions & 13 deletions SteamKit2/SteamKit2/Base/Generated/SteamLanguage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1864,6 +1864,7 @@ public enum EResult
CantRemoveItem = 113,
AccountHasBeenDeleted = 114,
AccountHasAnExistingUserCancelledLicense = 115,
DeniedDueToCommunityCooldown = 116,
}
public enum EUniverse
{
Expand All @@ -1872,7 +1873,6 @@ public enum EUniverse
Beta = 2,
Internal = 3,
Dev = 4,
Max = 5,
}
public enum EChatEntryType
{
Expand Down Expand Up @@ -1900,7 +1900,6 @@ public enum EPersonaState
LookingToTrade = 5,
LookingToPlay = 6,
Invisible = 7,
Max = 8,
}
public enum EAccountType
{
Expand All @@ -1915,7 +1914,6 @@ public enum EAccountType
Chat = 8,
ConsoleUser = 9,
AnonUser = 10,
Max = 11,
}
public enum EFriendRelationship
{
Expand All @@ -1926,7 +1924,6 @@ public enum EFriendRelationship
RequestInitiator = 4,
Ignored = 5,
IgnoredFriend = 6,
Max = 8,
}
[Flags]
public enum EAccountFlags
Expand Down Expand Up @@ -2179,6 +2176,7 @@ public enum EPaymentMethod
Valve = 129,
MasterComp = 130,
Promotional = 131,
MasterSubscription = 134,
OEMTicket = 256,
Split = 512,
Complimentary = 1024,
Expand Down Expand Up @@ -2415,7 +2413,6 @@ public enum EAppInfoSection
Broadcastgamedata = 18,
Computed = 19,
Albummetadata = 20,
Max = 21,
}
public enum EContentDownloadSourceType
{
Expand All @@ -2429,7 +2426,6 @@ public enum EContentDownloadSourceType
SteamCache = 7,
OpenCache = 8,
LANCache = 9,
Max = 10,
}
public enum EPlatformType
{
Expand All @@ -2440,7 +2436,6 @@ public enum EPlatformType
OSX = 4,
PS3 = 5,
Linux32 = 6,
Max = 7,
}
public enum EOSType
{
Expand Down Expand Up @@ -2539,7 +2534,6 @@ public enum EOSType
Windows10 = 16,
Win2016 = 17,
WinMAX = 18,
Max = 26,
}
public enum EServerType
{
Expand Down Expand Up @@ -2670,7 +2664,6 @@ public enum EServerType
SteamAR = 124,
China = 125,
CrashDump = 126,
Max = 127,
}
public enum EBillingType
{
Expand Down Expand Up @@ -2769,7 +2762,6 @@ public enum ECurrencyCode
QAR = 39,
CRC = 40,
UYU = 41,
Max = 42,
}
[Flags]
public enum EDepotFileFlag
Expand Down Expand Up @@ -2820,7 +2812,6 @@ public enum EWorkshopFileType
SteamworksAccessInvite = 13,
SteamVideo = 14,
GameManagedItem = 15,
Max = 16,
}
public enum EWorkshopFileAction
{
Expand Down Expand Up @@ -2894,7 +2885,6 @@ public enum ESystemIMType
GiftRevoked = 7,
SupportMessage = 8,
SupportMessageClearAlert = 9,
Max = 10,
}
[Flags]
public enum EChatFlags
Expand Down Expand Up @@ -2963,7 +2953,6 @@ public enum EClientStat
P2PGameConnections = 2,
P2PVoiceConnections = 3,
BytesDownloaded = 4,
Max = 5,
}
public enum EClientStatAggregateMethod
{
Expand Down
4 changes: 2 additions & 2 deletions SteamKit2/SteamKit2/Types/SteamID.cs
Original file line number Diff line number Diff line change
Expand Up @@ -459,10 +459,10 @@ public bool IsValid
{
get
{
if ( this.AccountType <= EAccountType.Invalid || this.AccountType >= EAccountType.Max )
if ( this.AccountType <= EAccountType.Invalid || this.AccountType > EAccountType.AnonUser )
return false;

if ( this.AccountUniverse <= EUniverse.Invalid || this.AccountUniverse >= EUniverse.Max )
if ( this.AccountUniverse <= EUniverse.Invalid || this.AccountUniverse > EUniverse.Dev )
return false;

if ( this.AccountType == EAccountType.Individual )
Expand Down
69 changes: 69 additions & 0 deletions SteamKit2/Tests/SteamIDFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -396,5 +396,74 @@ public void TryGetClanIDOnlySupportsClanChatRooms( EAccountType type )
Assert.False( id.TryGetClanID( out var groupID ), groupID?.Render() );
Assert.Null( groupID );
}

[Theory]
[InlineData(EAccountType.Individual)]
[InlineData(EAccountType.Multiseat)]
[InlineData(EAccountType.GameServer)]
[InlineData(EAccountType.AnonGameServer)]
[InlineData(EAccountType.Pending)]
[InlineData(EAccountType.ContentServer)]
[InlineData(EAccountType.Clan)]
[InlineData(EAccountType.Chat)]
[InlineData(EAccountType.ConsoleUser)]
[InlineData(EAccountType.AnonUser)]
public void KnownAccountTypesAreValid( EAccountType type )
{
SteamID sid = 76561198074261126;
sid.AccountInstance = 0; // for Clan to pass
sid.AccountType = type;
Assert.True( sid.IsValid );
}

[Theory]
[InlineData(EAccountType.Invalid)]
[InlineData((EAccountType)11)]
[InlineData((EAccountType)12)]
[InlineData((EAccountType)13)]
public void UnknownAccountTypesAreInvalid( EAccountType type )
{
SteamID sid = 76561198074261126;
sid.AccountType = type;
Assert.False( sid.IsValid );
}

[Theory]
[InlineData(EUniverse.Public)]
[InlineData(EUniverse.Beta)]
[InlineData(EUniverse.Internal)]
[InlineData(EUniverse.Dev)]
public void KnownAccountUniversesAreValid( EUniverse universe )
{
SteamID sid = 76561198074261126;
sid.AccountUniverse = universe;
Assert.True( sid.IsValid );
}

[Theory]
[InlineData(EUniverse.Invalid)]
[InlineData((EUniverse)5)]
[InlineData((EUniverse)6)]
[InlineData((EUniverse)7)]
public void UnknownAccountUniversesAreInvalid( EUniverse universe )
{
SteamID sid = 76561198074261126;
sid.AccountUniverse = universe;
Assert.False( sid.IsValid );
}

[Fact]
public void EUniverseEnumHasNotChanged()
{
// If this enum has changed, update SteamID.IsValid
Assert.Equal( 5, Enum.GetValues( typeof( EUniverse ) ).Length );
}

[Fact]
public void EAccountTypeEnumHasNotChanged()
{
// If this enum has changed, update SteamID.IsValid
Assert.Equal( 11, Enum.GetValues( typeof( EAccountType ) ).Length );
}
}
}

0 comments on commit 9d42533

Please sign in to comment.