error fixes

This commit is contained in:
pointfeev 2021-11-06 05:25:25 -04:00
parent 351847727b
commit 51d3a1c9cb
No known key found for this signature in database
GPG key ID: AA14DC36C4D7D13C
2 changed files with 31 additions and 39 deletions

View file

@ -140,25 +140,17 @@ namespace CreamInstaller
List<int> dlcIds = new();
if (!(appInfo is null))
{
try
{
if (!(appInfo.Value["extended"] is null))
foreach (VProperty property in appInfo.Value["extended"])
if (property.Key.ToString() == "listofdlc")
foreach (string id in property.Value.ToString().Split(","))
if (!dlcIds.Contains(int.Parse(id)))
dlcIds.Add(int.Parse(id));
}
catch { }
try
{
if (!(appInfo.Value["depots"] is null))
foreach (VProperty _property in appInfo.Value["depots"])
if (int.TryParse(_property.Key.ToString(), out int _))
if (int.TryParse(_property.Value?["dlcappid"]?.ToString(), out int appid) && !dlcIds.Contains(appid))
dlcIds.Add(appid);
}
catch { }
if (!(appInfo.Value["extended"] is null))
foreach (VProperty property in appInfo.Value["extended"])
if (property.Key.ToString() == "listofdlc")
foreach (string id in property.Value.ToString().Split(","))
if (!dlcIds.Contains(int.Parse(id)))
dlcIds.Add(int.Parse(id));
if (!(appInfo.Value["depots"] is null))
foreach (VProperty _property in appInfo.Value["depots"])
if (int.TryParse(_property.Key.ToString(), out int _) && !(_property.Value is VValue))
if (int.TryParse(_property.Value?["dlcappid"]?.ToString(), out int appid) && !dlcIds.Contains(appid))
dlcIds.Add(appid);
}
if (!(dlcIds is null) && dlcIds.Count > 0)
{
@ -170,7 +162,7 @@ namespace CreamInstaller
if (Program.Canceled) return;
string dlcName = null;
VProperty dlcAppInfo = null;
if (SteamCMD.GetAppInfo(id, 0, out dlcAppInfo)) try { dlcName = dlcAppInfo?.Value?["common"]?["name"]?.ToString(); } catch { }
if (SteamCMD.GetAppInfo(id, 0, out dlcAppInfo)) dlcName = dlcAppInfo?.Value?["common"]?["name"]?.ToString();
if (Program.Canceled) return;
if (string.IsNullOrWhiteSpace(dlcName)) dlcName = $"Unnamed DLC ({id})";
dlc.Add(new Tuple<int, string>(id, dlcName));

View file

@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
namespace CreamInstaller
@ -70,32 +71,31 @@ namespace CreamInstaller
Run($@"+@ShutdownOnFailedCommand 0 +login anonymous +app_info_print {appId} +quit", out output);
int openBracket = output.IndexOf("{");
int closeBracket = output.LastIndexOf("}");
output = $"\"{appId}\"\n" + output.Substring(openBracket, 1 + closeBracket - openBracket);
File.WriteAllText(appUpdateFile, output);
if (openBracket != -1 && closeBracket != -1)
{
output = $"\"{appId}\"\n" + output.Substring(openBracket, 1 + closeBracket - openBracket);
File.WriteAllText(appUpdateFile, output);
}
}
if (Program.Canceled || output is null) return false;
appInfo = VdfConvert.Deserialize(output);
try
VToken type = appInfo?.Value?["common"]?["type"];
if (type is null || type.ToString() == "Game")
{
VToken type = appInfo?.Value?["common"]?["type"];
if (type is null || type.ToString() == "Game")
string buildid = appInfo?.Value?["depots"]?["public"]?["buildid"]?.ToString();
if (appInfo?.Value?.Children()?.ToList()?.Count > 0 && !(buildid is null)
&& (type is null || int.Parse(buildid?.ToString()) < buildId
|| appInfo.Value["extended"] is null
|| appInfo.Value["depots"] is null))
{
string buildid = appInfo.Value["depots"]?["public"]?["buildid"]?.ToString();
buildid = buildid ?? appInfo.Value["depots"]?["branches"]?["public"]?["buildid"]?.ToString();
if (type is null || int.Parse(buildid) < buildId
|| appInfo.Value["extended"] is null
|| appInfo.Value["depots"] is null)
{
if (retries.TryGetValue(appId, out int count)) retries[appId] = ++count;
else retries.Add(appId, 1);
if (count > 3) return false;
File.Delete(appUpdateFile);
bool success = GetAppInfo(appId, buildId, out appInfo);
return success;
}
//if (retries.TryGetValue(appId, out int count)) retries[appId] = ++count;
//else retries.Add(appId, 1);
//if (count > 10) return false;
File.Delete(appUpdateFile);
bool success = GetAppInfo(appId, buildId, out appInfo);
return success;
}
}
catch { }
return true;
}