Skip to content
Merged
Show file tree
Hide file tree
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
26 changes: 18 additions & 8 deletions Entities/LogFileWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -818,21 +818,31 @@ private void UpdatePersonalBestLog(RoundInfo info) {

if (!this.StatsForm.ExistsPersonalBestLog(info.Finish.Value)) {
List<RoundInfo> roundInfoList = new List<RoundInfo>();
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;
Expand Down
4 changes: 1 addition & 3 deletions Views/Stats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down