Skip to content

Commit

Permalink
Fixed all possible nullrefs
Browse files Browse the repository at this point in the history
Thank you so much Eris 😊
  • Loading branch information
rithik-b committed Jan 13, 2022
1 parent 17c2686 commit ad080bf
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Hitbloq/Other/LeaderboardRefresher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public async Task<bool> Refresh()
}
hitbloqPanelController.PromptText = "<color=red>The action queue is very busy, your score cannot be refreshed for now.</color>";
}
else if (refreshEntry.error != null)
else if (refreshEntry != null && refreshEntry.error != null)
{
hitbloqPanelController.PromptText = $"<color=red>Error: {refreshEntry.error}</color>";
}
Expand Down
8 changes: 7 additions & 1 deletion Hitbloq/Sources/FriendLeaderboardSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public async Task<List<HitbloqLeaderboardEntry>> GetScoresTask(IDifficultyBeatma
HitbloqUserID userID = await userIDSource.GetUserIDAsync(cancellationToken);
List<int> friendIDs = await friendIDSource.GetFriendIDsAsync(cancellationToken);

if (userID.id == -1)
if (userID.id == -1 || friendIDs == null)
{
return null;
}
Expand Down Expand Up @@ -91,6 +91,12 @@ public async Task<List<HitbloqLeaderboardEntry>> GetScoresTask(IDifficultyBeatma
}
catch (TaskCanceledException) { }
}

if (cachedEntries == null)
{
return null;
}

return page < cachedEntries.Count ? cachedEntries[page] : null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,12 @@ public async void SetScores(List<HitbloqLeaderboardEntry> leaderboardEntries)
scores.Add(new LeaderboardTableView.ScoreData(leaderboardEntries[i].score, $"<size=85%>{leaderboardEntries[i].username} - <size=75%>(<color=#FFD42A>{leaderboardEntries[i].accuracy.ToString("F2")}%</color>)</size></size> - <size=75%> (<color=#aa6eff>{leaderboardEntries[i].cr[selectedPool].ToString("F2")}<size=55%>cr</size></color>)</size>",
leaderboardEntries[i].rank, false));

infoButtons[i].gameObject.SetActive(true);
HoverHint hoverHint = infoButtons[i].GetComponent<HoverHint>();
hoverHint.text = $"Score Set: {leaderboardEntries[i].dateSet}";
if (infoButtons != null)
{
infoButtons[i].gameObject.SetActive(true);
HoverHint hoverHint = infoButtons[i].GetComponent<HoverHint>();
hoverHint.text = $"Score Set: {leaderboardEntries[i].dateSet}";
}

if (leaderboardEntries[i].userID == id)
{
Expand Down
16 changes: 9 additions & 7 deletions Hitbloq/UI/ViewControllers/HitbloqPanelController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,15 @@ private void Inject(MainFlowCoordinator mainFlowCoordinator, HitbloqFlowCoordina
private async void PostParse()
{
// Backround related stuff
container.background.material = BeatSaberMarkupLanguage.Utilities.ImageResources.NoGlowMat;
ImageView background = container.background as ImageView;
background.color0 = Color.white;
background.color1 = new Color(1f, 1f, 1f, 0f);
background.color = Color.gray;
Accessors.GradientAccessor(ref background) = true;
Accessors.SkewAccessor(ref background) = 0.18f;
if (container.background is ImageView background)
{
background.material = BeatSaberMarkupLanguage.Utilities.ImageResources.NoGlowMat;
background.color0 = Color.white;
background.color1 = new Color(1f, 1f, 1f, 0f);
background.color = Color.gray;
Accessors.GradientAccessor(ref background) = true;
Accessors.SkewAccessor(ref background) = 0.18f;
}

// Loading up logos
logoSprite = logo.sprite;
Expand Down
6 changes: 4 additions & 2 deletions Hitbloq/UI/ViewControllers/HitbloqProfileModalController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,10 @@ private void PostParse()
addFriend = BeatSaberMarkupLanguage.Utilities.FindSpriteInAssembly("Hitbloq.Images.AddFriend.png");
friendAdded = BeatSaberMarkupLanguage.Utilities.FindSpriteInAssembly("Hitbloq.Images.FriendAdded.png");

ImageView verticalBackground = modalInfoVertical.background as ImageView;
verticalBackground.color = new Color(0f, 0f, 0f, 0.75f);
if (modalInfoVertical.background is ImageView verticalBackground)
{
verticalBackground.color = new Color(0f, 0f, 0f, 0.75f);
}
}

private void Parse(Transform parentTransform)
Expand Down
2 changes: 1 addition & 1 deletion Hitbloq/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"id": "Hitbloq",
"name": "Hitbloq",
"author": "PauseChampions & DaFluffyPotato",
"version": "1.2.0",
"version": "1.2.1",
"description": [
"#![Hitbloq.Description.md]",
"Hitbloq offers a unique competitive experience for Beat Saber through its use of map pools and the relative ranking algorithm."
Expand Down

0 comments on commit ad080bf

Please sign in to comment.