error fixes
This commit is contained in:
parent
351847727b
commit
51d3a1c9cb
2 changed files with 31 additions and 39 deletions
|
@ -140,25 +140,17 @@ namespace CreamInstaller
|
||||||
List<int> dlcIds = new();
|
List<int> dlcIds = new();
|
||||||
if (!(appInfo is null))
|
if (!(appInfo is null))
|
||||||
{
|
{
|
||||||
try
|
if (!(appInfo.Value["extended"] is null))
|
||||||
{
|
foreach (VProperty property in appInfo.Value["extended"])
|
||||||
if (!(appInfo.Value["extended"] is null))
|
if (property.Key.ToString() == "listofdlc")
|
||||||
foreach (VProperty property in appInfo.Value["extended"])
|
foreach (string id in property.Value.ToString().Split(","))
|
||||||
if (property.Key.ToString() == "listofdlc")
|
if (!dlcIds.Contains(int.Parse(id)))
|
||||||
foreach (string id in property.Value.ToString().Split(","))
|
dlcIds.Add(int.Parse(id));
|
||||||
if (!dlcIds.Contains(int.Parse(id)))
|
if (!(appInfo.Value["depots"] is null))
|
||||||
dlcIds.Add(int.Parse(id));
|
foreach (VProperty _property in appInfo.Value["depots"])
|
||||||
}
|
if (int.TryParse(_property.Key.ToString(), out int _) && !(_property.Value is VValue))
|
||||||
catch { }
|
if (int.TryParse(_property.Value?["dlcappid"]?.ToString(), out int appid) && !dlcIds.Contains(appid))
|
||||||
try
|
dlcIds.Add(appid);
|
||||||
{
|
|
||||||
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 (!(dlcIds is null) && dlcIds.Count > 0)
|
if (!(dlcIds is null) && dlcIds.Count > 0)
|
||||||
{
|
{
|
||||||
|
@ -170,7 +162,7 @@ namespace CreamInstaller
|
||||||
if (Program.Canceled) return;
|
if (Program.Canceled) return;
|
||||||
string dlcName = null;
|
string dlcName = null;
|
||||||
VProperty dlcAppInfo = 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 (Program.Canceled) return;
|
||||||
if (string.IsNullOrWhiteSpace(dlcName)) dlcName = $"Unnamed DLC ({id})";
|
if (string.IsNullOrWhiteSpace(dlcName)) dlcName = $"Unnamed DLC ({id})";
|
||||||
dlc.Add(new Tuple<int, string>(id, dlcName));
|
dlc.Add(new Tuple<int, string>(id, dlcName));
|
||||||
|
|
|
@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
|
||||||
namespace CreamInstaller
|
namespace CreamInstaller
|
||||||
|
@ -70,32 +71,31 @@ namespace CreamInstaller
|
||||||
Run($@"+@ShutdownOnFailedCommand 0 +login anonymous +app_info_print {appId} +quit", out output);
|
Run($@"+@ShutdownOnFailedCommand 0 +login anonymous +app_info_print {appId} +quit", out output);
|
||||||
int openBracket = output.IndexOf("{");
|
int openBracket = output.IndexOf("{");
|
||||||
int closeBracket = output.LastIndexOf("}");
|
int closeBracket = output.LastIndexOf("}");
|
||||||
output = $"\"{appId}\"\n" + output.Substring(openBracket, 1 + closeBracket - openBracket);
|
if (openBracket != -1 && closeBracket != -1)
|
||||||
File.WriteAllText(appUpdateFile, output);
|
{
|
||||||
|
output = $"\"{appId}\"\n" + output.Substring(openBracket, 1 + closeBracket - openBracket);
|
||||||
|
File.WriteAllText(appUpdateFile, output);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (Program.Canceled || output is null) return false;
|
if (Program.Canceled || output is null) return false;
|
||||||
appInfo = VdfConvert.Deserialize(output);
|
appInfo = VdfConvert.Deserialize(output);
|
||||||
try
|
VToken type = appInfo?.Value?["common"]?["type"];
|
||||||
|
if (type is null || type.ToString() == "Game")
|
||||||
{
|
{
|
||||||
VToken type = appInfo?.Value?["common"]?["type"];
|
string buildid = appInfo?.Value?["depots"]?["public"]?["buildid"]?.ToString();
|
||||||
if (type is null || type.ToString() == "Game")
|
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();
|
//if (retries.TryGetValue(appId, out int count)) retries[appId] = ++count;
|
||||||
buildid = buildid ?? appInfo.Value["depots"]?["branches"]?["public"]?["buildid"]?.ToString();
|
//else retries.Add(appId, 1);
|
||||||
if (type is null || int.Parse(buildid) < buildId
|
//if (count > 10) return false;
|
||||||
|| appInfo.Value["extended"] is null
|
File.Delete(appUpdateFile);
|
||||||
|| appInfo.Value["depots"] is null)
|
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 > 3) return false;
|
|
||||||
File.Delete(appUpdateFile);
|
|
||||||
bool success = GetAppInfo(appId, buildId, out appInfo);
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch { }
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue