Skip to content

Commit

Permalink
Merge pull request #69 from rynan4818/songHash_fix2
Browse files Browse the repository at this point in the history
Fixed an exception when SongCore is not installed.
  • Loading branch information
opl- authored Sep 7, 2021
2 parents 4d02bb5 + 4925352 commit ed48310
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion BeatSaberHTTPStatus/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Threading;
using UnityEngine;
using UnityEngine.SceneManagement;
Expand Down Expand Up @@ -343,7 +344,7 @@ public async void HandleSongStart() {
gameStatus.songBPM = level.beatsPerMinute;
gameStatus.noteJumpSpeed = diff.noteJumpMovementSpeed;
// 13 is "custom_level_" and 40 is the magic number for the length of the SHA-1 hash
gameStatus.songHash = level.levelID.StartsWith("custom_level_") && !level.levelID.EndsWith(" WIP") ? level.levelID.Substring(13, 40) : null;
gameStatus.songHash = Regex.IsMatch(level.levelID, "^custom_level_[0-9A-F]{40}", RegexOptions.IgnoreCase) && !level.levelID.EndsWith(" WIP") ? level.levelID.Substring(13, 40) : null;
gameStatus.levelId = level.levelID;
gameStatus.songTimeOffset = (long) (level.songTimeOffset * 1000f / songSpeedMul);
gameStatus.length = (long) (level.beatmapLevelData.audioClip.length * 1000f / songSpeedMul);
Expand Down

0 comments on commit ed48310

Please sign in to comment.