Skip to content

Commit

Permalink
Treat beta builds way better
Browse files Browse the repository at this point in the history
  • Loading branch information
jvyden committed Feb 28, 2024
1 parent 37c4a43 commit 5ec11fe
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Refresh.GameServer/Database/GameDatabaseContext.Users.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
};

Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions Refresh.GameServer/Extensions/LevelEnumerableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public static IQueryable<GameLevel> 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 {
Expand Down Expand Up @@ -73,6 +75,8 @@ public static IEnumerable<GameLevel> 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 {
Expand Down
5 changes: 5 additions & 0 deletions Refresh.GameServer/Types/UserData/GameUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
/// </remarks>
public string VitaIconHash { get; set; } = "0";
/// <summary>
/// The <see cref="IconHash"/>, except only for clients in beta mode.
/// </summary>
public string BetaIconHash { get; set; } = "0";

public string Description { get; set; } = "";
public GameLocation Location { get; set; } = GameLocation.Zero;
Expand Down Expand Up @@ -77,6 +81,7 @@ public partial class GameUser : IRealmObject, IRateLimitUser
public IList<GameIpVerificationRequest> 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";
Expand Down

0 comments on commit 5ec11fe

Please sign in to comment.