Skip to content

Commit

Permalink
Merge pull request #362 from Micdu70/patch-1
Browse files Browse the repository at this point in the history
Bug fix
  • Loading branch information
qutrits authored Jul 25, 2024
2 parents 7d81073 + 0186849 commit ad22e83
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 100 deletions.
89 changes: 44 additions & 45 deletions Entities/LevelStats.cs

Large diffs are not rendered by default.

74 changes: 52 additions & 22 deletions Entities/LogFileWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,12 @@ public override string ToString() {
public class LogRound {
public bool CurrentlyInParty;
public bool PrivateLobby;
public bool InLoadingGameScreen;
public bool IsRoundPreloaded;
public bool CountingPlayers;
public bool GetCurrentPlayerID;
public bool FindingPosition;
public bool IsFinal;
public bool HasIsFinal;
public string CurrentPlayerID;
public int Duration;

public RoundInfo Info;
}
Expand All @@ -49,6 +48,7 @@ public class ThreadLocalData {
public string selectedShowId;
public bool useShareCode;
public string currentSessionId;
public string sceneName;

public bool toggleCountryInfoApi;
public bool toggleFgdbCreativeApi;
Expand Down Expand Up @@ -85,7 +85,7 @@ public class LogFileWatcher {

public Stats StatsForm { get; set; }

private ThreadLocal<ThreadLocalData> threadLocalVariable = new ThreadLocal<ThreadLocalData>(() => new ThreadLocalData());
private readonly ThreadLocal<ThreadLocalData> threadLocalVariable = new ThreadLocal<ThreadLocalData>(() => new ThreadLocalData());
public event Action<List<RoundInfo>> OnParsedLogLines;
public event Action<List<RoundInfo>> OnParsedLogLinesCurrent;
public event Action<DateTime> OnNewLogFileDate;
Expand Down Expand Up @@ -716,6 +716,7 @@ private bool ParseLine(LogLine line, List<RoundInfo> round, LogRound logRound) {

logRound.PrivateLobby = line.Line.IndexOf("StatePrivateLobby", StringComparison.OrdinalIgnoreCase) != -1;
logRound.CurrentlyInParty = !logRound.PrivateLobby && (line.Line.IndexOf("solo", StringComparison.OrdinalIgnoreCase) == -1);
logRound.InLoadingGameScreen = false;
logRound.CountingPlayers = false;
logRound.GetCurrentPlayerID = false;
logRound.FindingPosition = false;
Expand Down Expand Up @@ -765,25 +766,52 @@ private bool ParseLine(LogLine line, List<RoundInfo> round, LogRound logRound) {
}
}

logRound.Info = new RoundInfo {
ShowNameId = this.threadLocalVariable.Value.selectedShowId, SessionId = this.threadLocalVariable.Value.currentSessionId,
UseShareCode = this.threadLocalVariable.Value.useShareCode, IsCasualShow = this.IsShowIsCasualShow(this.threadLocalVariable.Value.selectedShowId),
OnlineServiceType = (int)Stats.OnlineServiceType, OnlineServiceId = Stats.OnlineServiceId, OnlineServiceNickname = Stats.OnlineServiceNickname
};
int index2 = line.Line.IndexOf(" on frame ");
this.threadLocalVariable.Value.sceneName = line.Line.Substring(index + 57, index2 - (index + 57));

if (logRound.Info.UseShareCode) {
this.SetCreativeLevelVariable(logRound.Info.IsCasualShow ? this.threadLocalVariable.Value.creativeShareCode : logRound.Info.ShowNameId);
logRound.Info.SceneName = this.threadLocalVariable.Value.creativeGameModeId;
} else {
int index2 = line.Line.IndexOf(" on frame ");
logRound.Info.SceneName = line.Line.Substring(index + 57, index2 - (index + 57));
if (this._sceneNameReplacer.TryGetValue(logRound.Info.SceneName, out string newName)) {
logRound.Info.SceneName = newName;
if (logRound.InLoadingGameScreen) {
logRound.Info = new RoundInfo {
ShowNameId = this.threadLocalVariable.Value.selectedShowId, SessionId = this.threadLocalVariable.Value.currentSessionId,
UseShareCode = this.threadLocalVariable.Value.useShareCode, IsCasualShow = this.IsShowIsCasualShow(this.threadLocalVariable.Value.selectedShowId),
OnlineServiceType = (int)Stats.OnlineServiceType, OnlineServiceId = Stats.OnlineServiceId, OnlineServiceNickname = Stats.OnlineServiceNickname
};

if (logRound.Info.UseShareCode) {
this.SetCreativeLevelVariable(logRound.Info.IsCasualShow ? this.threadLocalVariable.Value.creativeShareCode : logRound.Info.ShowNameId);
logRound.Info.SceneName = this.threadLocalVariable.Value.creativeGameModeId;
} else {
logRound.Info.SceneName = this._sceneNameReplacer.TryGetValue(this.threadLocalVariable.Value.sceneName, out string sceneName)
? sceneName
: this.threadLocalVariable.Value.sceneName;
}
logRound.FindingPosition = false;

round.Add(logRound.Info);
} else {
logRound.IsRoundPreloaded = true;
}
logRound.FindingPosition = false;
} else if (line.Line.IndexOf("[StateGameLoading] ShowLoadingGameScreenAndLoadLevel", StringComparison.OrdinalIgnoreCase) != -1) {
logRound.InLoadingGameScreen = true;
if (logRound.IsRoundPreloaded) {
logRound.IsRoundPreloaded = false;
logRound.Info = new RoundInfo {
ShowNameId = this.threadLocalVariable.Value.selectedShowId, SessionId = this.threadLocalVariable.Value.currentSessionId,
UseShareCode = this.threadLocalVariable.Value.useShareCode, IsCasualShow = this.IsShowIsCasualShow(this.threadLocalVariable.Value.selectedShowId),
OnlineServiceType = (int)Stats.OnlineServiceType, OnlineServiceId = Stats.OnlineServiceId, OnlineServiceNickname = Stats.OnlineServiceNickname
};

if (logRound.Info.UseShareCode) {
this.SetCreativeLevelVariable(logRound.Info.IsCasualShow ? this.threadLocalVariable.Value.creativeShareCode : logRound.Info.ShowNameId);
logRound.Info.SceneName = this.threadLocalVariable.Value.creativeGameModeId;
} else {
logRound.Info.SceneName = this._sceneNameReplacer.TryGetValue(this.threadLocalVariable.Value.sceneName, out string sceneName)
? sceneName
: this.threadLocalVariable.Value.sceneName;
}
logRound.FindingPosition = false;

round.Add(logRound.Info);
round.Add(logRound.Info);
}
} else if (logRound.Info != null && (index = line.Line.IndexOf("[StateGameLoading] Finished loading game level", StringComparison.OrdinalIgnoreCase)) != -1) {
int index2 = line.Line.IndexOf(". ", index + 62);
if (index2 < 0) { index2 = line.Line.Length; }
Expand All @@ -803,9 +831,9 @@ private bool ParseLine(LogLine line, List<RoundInfo> round, LogRound logRound) {
} else if (this.IsModeException(logRound.Info.Name, logRound.Info.ShowNameId)) {
logRound.Info.IsFinal = this.IsModeFinalException(logRound.Info.Name);
} else if (logRound.Info.Name.StartsWith("wle_s10_") || logRound.Info.Name.StartsWith("wle_mrs_")) {
logRound.Info.IsFinal = logRound.IsFinal || (!logRound.HasIsFinal && this.StatsForm.StatLookup.TryGetValue(logRound.Info.Name, out LevelStats levelStats) && levelStats.IsFinal);
logRound.Info.IsFinal = this.StatsForm.StatLookup.TryGetValue(logRound.Info.Name, out LevelStats levelStats) && levelStats.IsFinal;
} else {
logRound.Info.IsFinal = logRound.IsFinal || (!logRound.HasIsFinal && LevelStats.SceneToRound.TryGetValue(logRound.Info.SceneName, out string levelId) && this.StatsForm.StatLookup.TryGetValue(levelId, out LevelStats levelStats) && levelStats.IsFinal);
logRound.Info.IsFinal = LevelStats.SceneToRound.TryGetValue(logRound.Info.SceneName, out string levelId) && this.StatsForm.StatLookup.TryGetValue(levelId, out LevelStats levelStats) && levelStats.IsFinal;
}
logRound.Info.IsTeam = this.IsTeamException(logRound.Info.Name);

Expand All @@ -821,7 +849,6 @@ private bool ParseLine(LogLine line, List<RoundInfo> round, LogRound logRound) {
logRound.Info.Start = line.Date;
logRound.Info.InParty = logRound.CurrentlyInParty;
logRound.Info.PrivateLobby = logRound.PrivateLobby;
logRound.Info.GameDuration = logRound.Duration;

logRound.CountingPlayers = true;
logRound.GetCurrentPlayerID = true;
Expand Down Expand Up @@ -852,6 +879,7 @@ private bool ParseLine(LogLine line, List<RoundInfo> round, LogRound logRound) {
} else if (logRound.Info != null && line.Line.IndexOf("[GameSession] Changing state from Countdown to Playing", StringComparison.OrdinalIgnoreCase) != -1) {
logRound.Info.Start = line.Date;
logRound.Info.Playing = true;
logRound.InLoadingGameScreen = false;
logRound.CountingPlayers = false;
logRound.GetCurrentPlayerID = false;
} else if (logRound.Info != null && line.Line.IndexOf($"HandleServerPlayerProgress PlayerId={logRound.CurrentPlayerID} is succeeded=", StringComparison.OrdinalIgnoreCase) != -1) {
Expand Down Expand Up @@ -912,6 +940,7 @@ private bool ParseLine(LogLine line, List<RoundInfo> round, LogRound logRound) {
Stats.IsLastRoundRunning = false;
Stats.IsLastPlayedRoundStillPlaying = false;

logRound.InLoadingGameScreen = false;
logRound.CountingPlayers = false;
logRound.GetCurrentPlayerID = false;
logRound.FindingPosition = false;
Expand Down Expand Up @@ -1111,6 +1140,7 @@ private bool ParseLine(LogLine line, List<RoundInfo> round, LogRound logRound) {

if (logRound.Info.Qualified) {
logRound.Info.Crown = true;
logRound.InLoadingGameScreen = false;
logRound.CountingPlayers = false;
logRound.GetCurrentPlayerID = false;
logRound.FindingPosition = false;
Expand Down
34 changes: 18 additions & 16 deletions Views/LeaderboardDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,25 +158,27 @@ private void LeaderboardDisplay_Load(object sender, EventArgs e) {
.ThenByDescending(s => s.players)
.ThenBy(s => s.country).ToList();
int weight = 0;
for (int i = 0; i < this.overallSummary.Count; i++) {
OverallSummary current = this.overallSummary[i];
if (current.gold == 0 && current.silver == 0 &&current.bronze == 0) {
break;
}
if (i > 0) {
OverallSummary previous = this.overallSummary[i - 1];
if (previous.gold == current.gold && previous.silver == current.silver && previous.bronze == current.bronze) {
current.rank = previous.rank;
weight++;
if (this.overallSummary.Any()) {
for (int i = 0; i < this.overallSummary.Count; i++) {
OverallSummary current = this.overallSummary[i];
if (current.gold == 0 && current.silver == 0 && current.bronze == 0) {
break;
}
if (i > 0) {
OverallSummary previous = this.overallSummary[i - 1];
if (previous.gold == current.gold && previous.silver == current.silver && previous.bronze == current.bronze) {
current.rank = previous.rank;
weight++;
} else {
current.rank = previous.rank + 1 + weight;
weight = 0;
}
} else {
current.rank = previous.rank + 1 + weight;
weight = 0;
current.rank = 1;
}
} else {
current.rank = 1;
this.overallSummary[i] = current;
}
this.overallSummary[i] = current;
}
this.gridOverallSummary.DataSource = prevTask.Result ? this.overallSummary : this.overallSummaryNodata;
Expand Down
4 changes: 2 additions & 2 deletions Views/LevelDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ public partial class LevelDetails : MetroFramework.Forms.MetroForm {
readonly DataGridViewCellStyle dataGridViewCellStyle1 = new DataGridViewCellStyle();
readonly DataGridViewCellStyle dataGridViewCellStyle2 = new DataGridViewCellStyle();

private Timer spinnerTransition = new Timer { Interval = 1 };
private readonly Timer spinnerTransition = new Timer { Interval = 1 };
private bool isIncreasing;
private bool preventPaging;

private Timer scrollTimer = new Timer { Interval = 100 };
private readonly Timer scrollTimer = new Timer { Interval = 100 };
private bool isScrollingStopped = true;
private bool isHeaderClicked;

Expand Down
16 changes: 10 additions & 6 deletions Views/Overlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ private void UpdateTimer() {
}

private void SetRoundLabel(Image roundIcon, LevelType type, string roundName, int setting) {
if (Stats.IsQueued && (setting == 1 || setting == 5)) {
if (!Stats.InShow && Stats.IsQueued && (setting == 1 || setting == 5)) {
this.lblRound.LevelColor = Color.Empty;
this.lblRound.LevelTrueColor = Color.Empty;
this.lblRound.RoundIcon = null;
Expand Down Expand Up @@ -620,7 +620,7 @@ private void SetRoundLabel(Image roundIcon, LevelType type, string roundName, in
}

private void SetWinsLabel(StatSummary summary, int setting) {
if (Stats.IsQueued && setting == 3) {
if (!Stats.InShow && Stats.IsQueued && setting == 3) {
this.lblWins.Text = $@"{Multilingual.GetWord("overlay_queued_players")} :";
this.lblWins.TextRight = $"{Stats.QueuedPlayers:N0}";
this.lblWins.ForeColor = this.ForeColor;
Expand Down Expand Up @@ -714,7 +714,7 @@ private void SetFastestLabel(StatSummary summary, BestRecordType bestRecordType,
this.lblFastest.Text = $@"{Multilingual.GetWord("overlay_current_time")} :";
this.lblFastest.TextRight = $"{DateTime.Now:HH\\:mm\\:ss}";
} else {
if (Stats.IsQueued && setting == 6) {
if (!Stats.InShow && Stats.IsQueued && setting == 6) {
this.lblFastest.Text = $@"{Multilingual.GetWord("overlay_queued_players")} :";
this.lblFastest.TextRight = Stats.QueuedPlayers.ToString();
this.lblFastest.ForeColor = this.ForeColor;
Expand Down Expand Up @@ -867,11 +867,15 @@ private void SetDurationLabel(LevelStats level, LevelType type, DateTime current
this.lblDuration.TickProgress = 0;
string showId = this.StatsForm.GetAlternateShowId(this.lastRound.ShowNameId);
int showType = (level == null) ? 0
: (string.Equals(this.lastRound.ShowNameId, "no_elimination_explore") && level.TimeLimitSecondsForExploreClassic > 0) ? 3
// : (string.Equals(this.lastRound.ShowNameId, "no_elimination_explore") && level.TimeLimitSecondsForLTM > 0) ? 3
: (showId.StartsWith("event_xtreme_fall_guys_") && level.TimeLimitSecondsForLTM > 0) ? 3
: ((string.Equals(showId, "squads_2player_template") || string.Equals(showId, "squads_4player")) && level.TimeLimitSecondsForSquad > 0) ? 2
: ((string.Equals(showId, "main_show") || string.Equals(showId, "invisibeans_mode") || level.IsCreative) && level.TimeLimitSeconds > 0) ? 1 : 0;
int timeLimit = this.lastRound.IsCasualShow ? ((showType == 3) ? level.TimeLimitSecondsForExploreClassic : (type == LevelType.CreativeSurvival ? 180 : 0))
int timeLimit = // this.lastRound.IsCasualShow ? ((showType == 3) ? level.TimeLimitSecondsForLTM
// : ((type == LevelType.CreativeSurvival) ? this.lastRound.CreativeTimeLimitSeconds : 0))
this.lastRound.IsCasualShow ? ((type == LevelType.CreativeSurvival) ? this.lastRound.CreativeTimeLimitSeconds : 0)
: this.lastRound.UseShareCode ? this.lastRound.CreativeTimeLimitSeconds
: (showType == 3) ? level.TimeLimitSecondsForLTM
: (showType == 2) ? level.TimeLimitSecondsForSquad
: (showType == 1) ? level.TimeLimitSeconds : 0;

Expand Down Expand Up @@ -912,7 +916,7 @@ private void SetFinishLabel(StatSummary summary, LevelType type, string roundId,
this.lblFinish.TextRight = $@"{DateTime.Now.ToString(Multilingual.GetWord("level_date_format"), Utils.GetCultureInfo())}";
this.lblFinish.ForeColor = this.ForeColor;
} else {
if (Stats.IsQueued && (setting == 0 || setting == 2 || setting == 4)) {
if (!Stats.InShow && Stats.IsQueued && (setting == 0 || setting == 2 || setting == 4)) {
this.lblFinish.Text = $@"{Multilingual.GetWord("overlay_queued_players")} :";
this.lblFinish.TextRight = Stats.QueuedPlayers.ToString();
this.lblFinish.ForeColor = this.ForeColor;
Expand Down
Loading

0 comments on commit ad22e83

Please sign in to comment.