Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions Refresh.Interfaces.Workers/Repeating/CoolLevelsJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,15 @@ private static float CalculatePositiveScore(GameLevel level, WorkContext context

// Reward for a good ratio between plays and yays.
// Doesn't apply to LBP1 levels.
float ratingRatio = (positiveRatings - negativeRatings) / (float)uniquePlays;
if (ratingRatio > 0.5f && level.GameVersion != TokenGame.LittleBigPlanet1)
// Skip this reward entirely if the level has no unique plays, as division by 0.0 floats
// results in infinity values, which should never happen and will also screw with API clients.
if (uniquePlays > 0)
{
score += positiveRatings * (positiveRatingPoints * ratingRatio);
float ratingRatio = (positiveRatings - negativeRatings) / (float)uniquePlays;
if (ratingRatio > 0.5f && level.GameVersion != TokenGame.LittleBigPlanet1)
{
score += positiveRatings * (positiveRatingPoints * ratingRatio);
}
}

if (level.Publisher?.Role == GameUserRole.Trusted)
Expand Down