diff --git a/Assets/Script/Gameplay/GameManager.cs b/Assets/Script/Gameplay/GameManager.cs index d6523f805..cf63228b7 100644 --- a/Assets/Script/Gameplay/GameManager.cs +++ b/Assets/Script/Gameplay/GameManager.cs @@ -69,7 +69,14 @@ public partial class GameManager : MonoBehaviour public bool IsSongStarted { get; private set; } = false; - private bool _loadFailure; + private enum LoadFailureState + { + None, + Rescan, + Error + } + + private LoadFailureState _loadState; private string _loadFailureMessage; // All access to chart data must be done through this event, @@ -201,7 +208,14 @@ private async UniTaskVoid Start() LoadingManager.Instance.Queue(LoadAudio, "Loading audio..."); await LoadingManager.Instance.StartLoad(); - if (_loadFailure) + if (_loadState == LoadFailureState.Rescan) + { + ToastManager.ToastWarning("Chart requires a rescan!"); + GlobalVariables.Instance.LoadScene(SceneIndex.Menu); + return; + } + + if (_loadState == LoadFailureState.Error) { Debug.LogError(_loadFailureMessage); ToastManager.ToastError(_loadFailureMessage); @@ -370,7 +384,7 @@ private async UniTask LoadReplay() } catch (Exception ex) { - _loadFailure = true; + _loadState = LoadFailureState.Error; _loadFailureMessage = "Failed to load replay!"; Debug.LogException(ex, this); return; @@ -378,9 +392,10 @@ private async UniTask LoadReplay() Song = GlobalVariables.Instance.SongContainer.SongsByHash[ GlobalVariables.Instance.CurrentReplay.SongChecksum][0]; + if (Song is null || result != ReplayReadResult.Valid) { - _loadFailure = true; + _loadState = LoadFailureState.Error; _loadFailureMessage = "Failed to load replay!"; return; } @@ -411,12 +426,18 @@ await UniTask.RunOnThreadPool(() => } catch (Exception ex) { - _loadFailure = true; + _loadState = LoadFailureState.Error; _loadFailureMessage = "Failed to load chart!"; Debug.LogException(ex, this); return; } + if (Chart is null) + { + _loadState = LoadFailureState.Rescan; + return; + } + // Ensure sync track is present var syncTrack = Chart.SyncTrack; if (syncTrack.Beatlines is null or { Count: < 1 }) @@ -433,7 +454,8 @@ await UniTask.RunOnThreadPool(() => } }); - if (_loadFailure) return; + if (_loadState != LoadFailureState.None) + return; _chartLoaded?.Invoke(Chart); } @@ -453,13 +475,14 @@ await UniTask.RunOnThreadPool(() => } catch (Exception ex) { - _loadFailure = true; + _loadState = LoadFailureState.Error; _loadFailureMessage = "Failed to load audio!"; Debug.LogException(ex, this); } }); - if (_loadFailure) return; + if (_loadState != LoadFailureState.None) + return; _songLoaded?.Invoke(); } diff --git a/YARG.Core b/YARG.Core index ae4a4e1ec..84b90b047 160000 --- a/YARG.Core +++ b/YARG.Core @@ -1 +1 @@ -Subproject commit ae4a4e1ecc2828dc902f7df7d5574d231373cbb3 +Subproject commit 84b90b0470507773e07687863af94dece1b772a2