From 5ec11fe5cb6d6d65668767f5f6ed2958fe0ea9cb Mon Sep 17 00:00:00 2001 From: jvyden Date: Wed, 28 Feb 2024 18:07:57 -0500 Subject: [PATCH] Treat beta builds way better --- .../Database/GameDatabaseContext.Users.cs | 6 ++++++ .../Game/DataTypes/Response/GameUserResponse.cs | 17 +++++++++++++++-- .../Extensions/LevelEnumerableExtensions.cs | 4 ++++ Refresh.GameServer/Types/UserData/GameUser.cs | 5 +++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/Refresh.GameServer/Database/GameDatabaseContext.Users.cs b/Refresh.GameServer/Database/GameDatabaseContext.Users.cs index b35597b6..5bcc65f3 100644 --- a/Refresh.GameServer/Database/GameDatabaseContext.Users.cs +++ b/Refresh.GameServer/Database/GameDatabaseContext.Users.cs @@ -96,6 +96,9 @@ public void UpdateUserData(GameUser user, SerializedUpdateData data, TokenGame g case TokenGame.LittleBigPlanetVita: user.VitaPlanetsHash = data.PlanetsHash; break; + case TokenGame.BetaBuild: + user.BetaPlanetsHash = data.PlanetsHash; + break; } // ReSharper disable once InvertIf @@ -131,6 +134,9 @@ public void UpdateUserData(GameUser user, SerializedUpdateData data, TokenGame g //so we separate PSP icons to another field user.PspIconHash = data.IconHash; break; + case TokenGame.BetaBuild: + user.BetaIconHash = data.IconHash; + break; } }); } diff --git a/Refresh.GameServer/Endpoints/Game/DataTypes/Response/GameUserResponse.cs b/Refresh.GameServer/Endpoints/Game/DataTypes/Response/GameUserResponse.cs index 47a04de2..34b3ac04 100644 --- a/Refresh.GameServer/Endpoints/Game/DataTypes/Response/GameUserResponse.cs +++ b/Refresh.GameServer/Endpoints/Game/DataTypes/Response/GameUserResponse.cs @@ -117,7 +117,7 @@ private void FillInExtraData(GameUser old, TokenGame gameVersion, GameDatabaseCo TokenGame.LittleBigPlanetVita => old.VitaPlanetsHash, TokenGame.LittleBigPlanetPSP => "0", TokenGame.Website => "0", - TokenGame.BetaBuild => old.Lbp2PlanetsHash, // TODO: Planet hash for beta builds + TokenGame.BetaBuild => old.BetaPlanetsHash, _ => throw new ArgumentOutOfRangeException(nameof(gameVersion), gameVersion, null), }; @@ -131,7 +131,6 @@ private void FillInExtraData(GameUser old, TokenGame gameVersion, GameDatabaseCo //Fill out LBP2/LBP1 levels goto case TokenGame.LittleBigPlanet2; } - case TokenGame.BetaBuild: case TokenGame.LittleBigPlanet2: { //Match all LBP2 levels this.UsedSlotsLBP2 = old.PublishedLevels.Count(x => x._GameVersion == (int)TokenGame.LittleBigPlanet2); @@ -174,6 +173,20 @@ private void FillInExtraData(GameUser old, TokenGame gameVersion, GameDatabaseCo this.FavouriteLevels = new SerializedMinimalFavouriteLevelList(new SerializedMinimalLevelList(favouriteLevels, favouriteLevels.Count, favouriteLevels.Count)); break; } + case TokenGame.BetaBuild: + { + // only beta levels + this.UsedSlots = old.PublishedLevels.Count(x => x._GameVersion == (int)TokenGame.BetaBuild); + this.FreeSlots = MaximumLevels - this.UsedSlotsLBP2; + + // use the same values for LBP3 and LBP2 since they're all shared under one count + this.UsedSlotsLBP3 = this.UsedSlots; + this.FreeSlotsLBP3 = this.FreeSlots; + + this.UsedSlotsLBP2 = this.UsedSlots; + this.FreeSlotsLBP2 = this.FreeSlots; + break; + } case TokenGame.Website: break; default: throw new ArgumentOutOfRangeException(nameof(gameVersion), gameVersion, null); diff --git a/Refresh.GameServer/Extensions/LevelEnumerableExtensions.cs b/Refresh.GameServer/Extensions/LevelEnumerableExtensions.cs index 49fff348..5932940d 100644 --- a/Refresh.GameServer/Extensions/LevelEnumerableExtensions.cs +++ b/Refresh.GameServer/Extensions/LevelEnumerableExtensions.cs @@ -38,6 +38,8 @@ public static IQueryable FilterByLevelFilterSettings(this IQueryable< if (levelFilterSettings.ExcludeMyLevels && user != null) levels = levels.Where(l => l.Publisher != user); + // Don't allow beta builds to use this filtering option + // If the client specifies this option then it will filter out *all* levels. if (levelFilterSettings.GameVersion != TokenGame.BetaBuild) { levels = levelFilterSettings.GameFilterType switch { @@ -73,6 +75,8 @@ public static IEnumerable FilterByLevelFilterSettings(this IEnumerabl if (levelFilterSettings.ExcludeMyLevels && user != null) levels = levels.Where(l => l.Publisher != user); + // Don't allow beta builds to use this filtering option + // If the client specifies this option then it will filter out *all* levels. if (levelFilterSettings.GameVersion != TokenGame.BetaBuild) { levels = levelFilterSettings.GameFilterType switch { diff --git a/Refresh.GameServer/Types/UserData/GameUser.cs b/Refresh.GameServer/Types/UserData/GameUser.cs index efa52791..ed21a1fe 100644 --- a/Refresh.GameServer/Types/UserData/GameUser.cs +++ b/Refresh.GameServer/Types/UserData/GameUser.cs @@ -43,6 +43,10 @@ public partial class GameUser : IRealmObject, IRateLimitUser /// Vita GUIDs do not map to mainline GUIDs, so we dont want someone to set their Vita icon, and it map to an invalid GUID on PS3. /// public string VitaIconHash { get; set; } = "0"; + /// + /// The , except only for clients in beta mode. + /// + public string BetaIconHash { get; set; } = "0"; public string Description { get; set; } = ""; public GameLocation Location { get; set; } = GameLocation.Zero; @@ -77,6 +81,7 @@ public partial class GameUser : IRealmObject, IRateLimitUser public IList IpVerificationRequests { get; } #nullable restore + public string BetaPlanetsHash { get; set; } = "0"; public string Lbp2PlanetsHash { get; set; } = "0"; public string Lbp3PlanetsHash { get; set; } = "0"; public string VitaPlanetsHash { get; set; } = "0";