From 6b5cc9cb229e24848432364ee84391d8fe1dc5fc Mon Sep 17 00:00:00 2001 From: Micdu70 Date: Thu, 9 Oct 2025 08:40:01 +0200 Subject: [PATCH] Bug fix --- Entities/LogFileWatcher.cs | 26 ++++++++++++++++++-------- Views/Stats.cs | 4 +--- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Entities/LogFileWatcher.cs b/Entities/LogFileWatcher.cs index 7033698f..6b310f3d 100644 --- a/Entities/LogFileWatcher.cs +++ b/Entities/LogFileWatcher.cs @@ -818,21 +818,31 @@ private void UpdatePersonalBestLog(RoundInfo info) { if (!this.StatsForm.ExistsPersonalBestLog(info.Finish.Value)) { List roundInfoList = new List(); - if (!info.IsCasualShow) { + if (currentLevel.IsCreative) { roundInfoList = this.StatsForm.AllStats.FindAll(r => !r.PrivateLobby && !string.IsNullOrEmpty(r.ShowNameId) && !string.IsNullOrEmpty(r.SessionId) && string.Equals(r.ShowNameId, info.ShowNameId) && - string.Equals(r.Name, levelId) && + string.Equals(r.CreativeShareCode, currentLevel.ShareCode) && r.Finish.HasValue); } else { - roundInfoList = this.StatsForm.AllStats.FindAll(r => !r.PrivateLobby && - !string.IsNullOrEmpty(r.ShowNameId) && - !string.IsNullOrEmpty(r.SessionId) && - r.IsCasualShow && - string.Equals(r.Name, levelId) && - r.Finish.HasValue); + if (!info.IsCasualShow) { + roundInfoList = this.StatsForm.AllStats.FindAll(r => !r.PrivateLobby && + !string.IsNullOrEmpty(r.ShowNameId) && + !string.IsNullOrEmpty(r.SessionId) && + string.Equals(r.ShowNameId, info.ShowNameId) && + string.Equals(r.Name, levelId) && + r.Finish.HasValue); + } else { + roundInfoList = this.StatsForm.AllStats.FindAll(r => !r.PrivateLobby && + !string.IsNullOrEmpty(r.ShowNameId) && + !string.IsNullOrEmpty(r.SessionId) && + r.IsCasualShow && + string.Equals(r.Name, levelId) && + r.Finish.HasValue); + } } + double currentPb = roundInfoList.Count > 0 ? roundInfoList.Min(r => (r.Finish.Value - r.Start).TotalMilliseconds) : 0; double currentRecord = (info.Finish.Value - info.Start).TotalMilliseconds; bool isNewPb = currentPb == 0 || currentRecord < currentPb; diff --git a/Views/Stats.cs b/Views/Stats.cs index 2ef65260..abc8e939 100644 --- a/Views/Stats.cs +++ b/Views/Stats.cs @@ -5511,9 +5511,7 @@ public void InsertPersonalBestLog(DateTime finish, string sessionId, string show PbDate = finish, SessionId = sessionId, ShowId = showId, RoundId = roundId, Record = record, IsPb = isPb, CountryCode = HostCountryCode, OnlineServiceType = (int)OnlineServiceType, OnlineServiceId = OnlineServiceId, OnlineServiceNickname = OnlineServiceNickname }; - lock (this.PersonalBestLogCache) { - this.PersonalBestLogCache.Add(log); - } + this.PersonalBestLogCache.Add(log); Task insertPersonalBestTask = new Task(() => { this.StatsDB.BeginTrans(); this.PersonalBestLog.Insert(log);