Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
qubqub committed Sep 13, 2023
1 parent 9e0a1c8 commit fdf3943
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 16 deletions.
44 changes: 28 additions & 16 deletions Entities/LogFileWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -503,30 +503,42 @@ private bool ParseLine(LogLine line, List<RoundInfo> round, LogRound logRound) {
int timeout = 1000;
try {
Task.Run(() => {
this.pingReply = pingSender.Send(ip, timeout, bufferArray);
if (this.pingReply.Status == IPStatus.Success) {
Stats.LastServerPing = this.pingReply.RoundtripTime;
Stats.IsBadPing = false;
if (Stats.IsClientRunning()) {
this.pingReply = pingSender.Send(ip, timeout, bufferArray);
if (this.pingReply.Status == IPStatus.Success) {
Stats.LastServerPing = this.pingReply.RoundtripTime;
Stats.IsBadPing = false;
} else {
Stats.LastServerPing = this.pingReply.RoundtripTime;
Stats.IsBadPing = true;
}
} else {
Stats.LastServerPing = this.pingReply.RoundtripTime;
Stats.IsBadPing = true;
Stats.LastServerPing = 0;
Stats.IsBadPing = false;
}
});

if (!this.toggleRequestIp2cApi) {
this.toggleRequestIp2cApi = true;
Task.Run(() => {
try {
string[] countryArr = this.StatsForm.GetCountryCode(ip);
Stats.LastCountryAlpha2Code = countryArr[0].ToLower();
Stats.LastCountryAlpha3Code = countryArr[1];
Stats.LastCountryDefaultName = countryArr[2];
if (this.StatsForm.CurrentSettings.NotifyServerConnected && (!string.IsNullOrEmpty(Stats.LastCountryAlpha3Code) || !string.IsNullOrEmpty(Stats.LastCountryDefaultName))) {
this.StatsForm.ShowNotification(Multilingual.GetWord("message_connected_to_server_caption"),
$"{Multilingual.GetWord("message_connected_to_server_prefix")}{Multilingual.GetCountryName(Stats.LastCountryAlpha3Code) ?? Stats.LastCountryDefaultName}{Multilingual.GetWord("message_connected_to_server_suffix")}",
System.Windows.Forms.ToolTipIcon.Info, 2000);
if (Stats.IsClientRunning()) {
try {
string[] countryArr = this.StatsForm.GetCountryCode(ip);
Stats.LastCountryAlpha2Code = countryArr[0].ToLower();
Stats.LastCountryAlpha3Code = countryArr[1];
Stats.LastCountryDefaultName = countryArr[2];
if (this.StatsForm.CurrentSettings.NotifyServerConnected && (!string.IsNullOrEmpty(Stats.LastCountryAlpha3Code) || !string.IsNullOrEmpty(Stats.LastCountryDefaultName))) {
this.StatsForm.ShowNotification(Multilingual.GetWord("message_connected_to_server_caption"),
$"{Multilingual.GetWord("message_connected_to_server_prefix")}{Multilingual.GetCountryName(Stats.LastCountryAlpha3Code) ?? Stats.LastCountryDefaultName}{Multilingual.GetWord("message_connected_to_server_suffix")}",
System.Windows.Forms.ToolTipIcon.Info, 2000);
}
} catch {
this.toggleRequestIp2cApi = false;
Stats.LastCountryAlpha2Code = string.Empty;
Stats.LastCountryAlpha3Code = string.Empty;
Stats.LastCountryDefaultName = string.Empty;
}
} catch {
} else {
this.toggleRequestIp2cApi = false;
Stats.LastCountryAlpha2Code = string.Empty;
Stats.LastCountryAlpha3Code = string.Empty;
Expand Down
11 changes: 11 additions & 0 deletions Views/Stats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,17 @@ private static bool IsAlreadyRunning() {
return true;
}
}
public static bool IsClientRunning() {
try {
Process[] processes = Process.GetProcessesByName("FallGuys_client_game");
if (processes.Length > 0) {
return true;
}
return false;
} catch {
return false;
}
}
private static string LOGNAME = "Player.log";
public static List<DateTime> Seasons = new List<DateTime> {
new DateTime(2020, 8, 4, 0, 0, 0, DateTimeKind.Utc),
Expand Down

0 comments on commit fdf3943

Please sign in to comment.