Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
qutrits committed May 9, 2024
1 parent c728859 commit c7b84ba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions Entities/LogFileWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -586,15 +586,15 @@ private void SetCountryCodeByIp(string ip) {
}

private void UpdateServerConnectionLog(string session, string show) {
if (!this.StatsForm.ExistsServerConnectionLog(session, show)) {
if (!this.StatsForm.ExistsServerConnectionLog(session)) {
this.StatsForm.InsertServerConnectionLog(session, show, Stats.LastServerIp, Stats.ConnectedToServerDate, true, true);
this.serverPingWatcher.Start();
this.SetCountryCodeByIp(Stats.LastServerIp);
if (!Stats.IsClientHasBeenClosed && this.StatsForm.CurrentSettings.NotifyServerConnected && !string.IsNullOrEmpty(Stats.LastCountryAlpha2Code)) {
this.OnServerConnectionNotification?.Invoke();
}
} else {
ServerConnectionLog serverConnectionLog = this.StatsForm.SelectServerConnectionLog(session, show);
ServerConnectionLog serverConnectionLog = this.StatsForm.SelectServerConnectionLog(session);
if (!serverConnectionLog.IsNotify) {
if (!Stats.IsClientHasBeenClosed && this.StatsForm.CurrentSettings.NotifyServerConnected && !string.IsNullOrEmpty(Stats.LastCountryAlpha2Code)) {
this.OnServerConnectionNotification?.Invoke();
Expand Down Expand Up @@ -638,7 +638,7 @@ private bool ParseLine(LogLine line, List<RoundInfo> round, LogRound logRound) {
int index;
if ((!string.Equals(this.threadLocalVariable.Value.selectedShowId, "casual_show") && line.Line.IndexOf("[StateDisconnectingFromServer] Shutting down game and resetting scene to reconnect", StringComparison.OrdinalIgnoreCase) != -1)
|| line.Line.IndexOf("[GameStateMachine] Replacing FGClient.StateDisconnectingFromServer with FGClient.StateMainMenu", StringComparison.OrdinalIgnoreCase) != -1) {
this.StatsForm.UpdateServerConnectionLog(this.threadLocalVariable.Value.currentSessionId, this.threadLocalVariable.Value.selectedShowId, false);
this.StatsForm.UpdateServerConnectionLog(this.threadLocalVariable.Value.currentSessionId, false);
Stats.InShow = false;
Stats.QueuedPlayers = 0;
Stats.IsQueued = false;
Expand Down Expand Up @@ -921,7 +921,7 @@ private bool ParseLine(LogLine line, List<RoundInfo> round, LogRound logRound) {
round[i].IsFinal = false;
}
}
this.StatsForm.UpdateServerConnectionLog(logRound.Info.SessionId, logRound.Info.ShowNameId, false);
this.StatsForm.UpdateServerConnectionLog(logRound.Info.SessionId, false);
logRound.Info = null;
Stats.InShow = false;
Stats.EndedShow = true;
Expand Down Expand Up @@ -1040,7 +1040,7 @@ private bool ParseLine(LogLine line, List<RoundInfo> round, LogRound logRound) {
logRound.GetCurrentPlayerID = false;
logRound.FindingPosition = false;
}
this.StatsForm.UpdateServerConnectionLog(logRound.Info.SessionId, logRound.Info.ShowNameId, false);
this.StatsForm.UpdateServerConnectionLog(logRound.Info.SessionId, false);
logRound.Info = null;
return true;
}
Expand Down
14 changes: 7 additions & 7 deletions Views/Stats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4274,23 +4274,23 @@ private void ClearWeeklyCrownLog(int days) {
}
}

public bool ExistsServerConnectionLog(string sessionId, string showId) {
if (string.IsNullOrEmpty(sessionId) || string.IsNullOrEmpty(showId)) return false;
public bool ExistsServerConnectionLog(string sessionId) {
if (string.IsNullOrEmpty(sessionId)) return false;
// BsonExpression condition = Query.And(
// Query.EQ("_id", sessionId),
// Query.EQ("ShowId", showId)
// );
// return this.ServerConnectionLog.Exists(condition);
return this.ServerConnectionLogCache.Exists(l => string.Equals(l.SessionId, sessionId) && string.Equals(l.ShowId, showId));
return this.ServerConnectionLogCache.Exists(l => string.Equals(l.SessionId, sessionId));
}

public ServerConnectionLog SelectServerConnectionLog(string sessionId, string showId) {
public ServerConnectionLog SelectServerConnectionLog(string sessionId) {
// BsonExpression condition = Query.And(
// Query.EQ("_id", sessionId),
// Query.EQ("ShowId", showId)
// );
// return this.ServerConnectionLog.FindOne(condition);
return this.ServerConnectionLogCache.Find(l => string.Equals(l.SessionId, sessionId) && string.Equals(l.ShowId, showId));
return this.ServerConnectionLogCache.Find(l => string.Equals(l.SessionId, sessionId));
}

public void InsertServerConnectionLog(string sessionId, string showId, string serverIp, DateTime connectionDate, bool isNotify, bool isPlaying) {
Expand All @@ -4306,9 +4306,9 @@ public void InsertServerConnectionLog(string sessionId, string showId, string se
}
}

public void UpdateServerConnectionLog(string sessionId, string showId, bool isPlaying) {
public void UpdateServerConnectionLog(string sessionId, bool isPlaying) {
lock (this.StatsDB) {
ServerConnectionLog log = this.SelectServerConnectionLog(sessionId, showId);
ServerConnectionLog log = this.SelectServerConnectionLog(sessionId);
if (log != null) {
log.IsPlaying = isPlaying;
this.StatsDB.BeginTrans();
Expand Down

0 comments on commit c7b84ba

Please sign in to comment.