Skip to content

Commit

Permalink
Fix playhash on LBP2 (#499)
Browse files Browse the repository at this point in the history
god this game is a disaster

See this thread for why we need to revert this on LBP2 

https://canary.discord.com/channels/1049223665243389953/1240476031786156162/1240477912516399237
  • Loading branch information
jvyden authored May 16, 2024
2 parents 960c1c6 + 16bfc05 commit ff6e0ce
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ public static int LevelIdFromHash(string hash)
return rangeStart + Math.Abs(hash.GetHashCode()) % range;
}

public static GameLevelResponse FromHash(string hash)
public static GameLevelResponse FromHash(string hash, DataContext dataContext)
{
return new GameLevelResponse
{
LevelId = LevelIdFromHash(hash),
LevelId = dataContext.Game == TokenGame.LittleBigPlanet3 ? LevelIdFromHash(hash) : int.MaxValue,
Title = $"Hashed Level - {hash}",
IconHash = "0",
GameVersion = 0,
Expand Down
2 changes: 1 addition & 1 deletion Refresh.GameServer/Endpoints/Game/Levels/LevelEndpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public class LevelEndpoints : EndpointGroup
// If the user has had a hash override in the past, and the level id they requested matches the level ID associated with that hash
if (overrideService.GetLastHashOverrideForUser(token, out string hash) && GameLevelResponse.LevelIdFromHash(hash) == id)
// Return the hashed level info
return GameLevelResponse.FromHash(hash);
return GameLevelResponse.FromHash(hash, dataContext);

return GameLevelResponse.FromOld(database.GetLevelByIdAndType(slotType, id), dataContext);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private GameMinimalLevelResponse() {}
/// <returns></returns>
public static GameMinimalLevelResponse FromHash(string hash, DataContext dataContext)
{
return FromOld(GameLevelResponse.FromHash(hash), dataContext)!;
return FromOld(GameLevelResponse.FromHash(hash, dataContext), dataContext)!;
}

public static GameMinimalLevelResponse? FromOld(GameLevel? level, DataContext dataContext)
Expand Down

0 comments on commit ff6e0ce

Please sign in to comment.