Browse Source

Drunk programming isn't necessarily a good idea

tags/v1.4.0
NorbiPeti 4 years ago
parent
commit
4eec201547
2 changed files with 7 additions and 15 deletions
  1. +1
    -1
      GCMM/MainForm.cs
  2. +6
    -14
      GCMM/MainUtils.cs

+ 1
- 1
GCMM/MainForm.cs View File

@@ -240,7 +240,7 @@ You may also want to verify the game's files by right clicking the game in Steam
private async void refreshbtn_Click(object sender, EventArgs e)
{
CheckIfPatched(); //Set from placeholder
lastGameUpdateTime = GetLastGameUpdateTime();
lastGameUpdateTime = await GetLastGameUpdateTime();
var mods = GetInstalledMods();
await GetAvailableMods();
CheckUninstalledMods(mods);


+ 6
- 14
GCMM/MainUtils.cs View File

@@ -161,25 +161,17 @@ namespace GCMM
return false;
}

public DateTime GetLastGameUpdateTime()
public async Task<DateTime> GetLastGameUpdateTime()
{
if (GetExe() == null)
return default;
foreach (var line in File.ReadAllLines(GamePath(@"\..\..\appmanifest_1078000.acf")))
using (var client = GetClient())
{
var regex = new Regex("\\t\"LastUpdated\"\\t\\t\"(\\d+)\"");
var match = regex.Match(line);
string html = await client.DownloadStringTaskAsync("https://steamdb.info/app/1078000/depots/?branch=public");
var regex = new Regex("<i>timeupdated:</i>[^<]*<b>([^<]*)</b>");
var match = regex.Match(html);
if (!match.Success)
continue;
string updated = match.Groups[1].Value;
if (string.IsNullOrWhiteSpace(updated))
return default;
var updatedTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
updatedTime = updatedTime.AddSeconds(double.Parse(updated)).ToLocalTime();
return updatedTime;

return new DateTime(1970, 1, 1).AddSeconds(long.Parse(match.Groups[1].Value));
}
return default;
}
}
}

Loading…
Cancel
Save