- Fixed int parsing-related exceptions
This commit is contained in:
pointfeev 2022-01-25 17:57:01 -05:00
parent 947809b4ad
commit 18eb4e3ce0
3 changed files with 7 additions and 7 deletions

View file

@ -112,7 +112,7 @@ internal static class SteamCMD
{
string buildid = appInfo.Value?.GetChild("depots")?.GetChild("branches")?.GetChild(branch)?.GetChild("buildid")?.ToString();
if (buildid is null && type is not null) return appInfo;
if (type is null || int.Parse(buildid) < buildId)
if (type is null || int.TryParse(buildid, out int gamebuildId) && gamebuildId < buildId)
{
List<int> dlcAppIds = await ParseDlcAppIds(appInfo);
foreach (int id in dlcAppIds)
@ -136,7 +136,7 @@ internal static class SteamCMD
foreach (VProperty property in 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 (int.TryParse(id, out int appId) && !dlcIds.Contains(appId)) dlcIds.Add(appId);
VToken depots = appInfo.Value.GetChild("depots");
if (depots is not null) foreach (VProperty property in depots)
if (int.TryParse(property.Key.ToString(), out int _)

View file

@ -5,7 +5,7 @@
<UseWindowsForms>true</UseWindowsForms>
<ApplicationIcon>Resources\ini.ico</ApplicationIcon>
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
<Version>2.2.4.2</Version>
<Version>2.2.4.3</Version>
<PackageIcon>Resources\ini.ico</PackageIcon>
<PackageIconUrl />
<Description>Automatically generates and installs CreamAPI files for Steam games on the user's computer. It can also generate and install CreamAPI for the Paradox Launcher should the user select a Paradox Interactive game.</Description>

View file

@ -334,15 +334,15 @@ internal partial class SelectForm : CustomForm
{
if (e.Action == TreeViewAction.Unknown) return;
TreeNode node = e.Node;
if (node is not null)
if (node is not null && int.TryParse(node.Name, out int appId))
{
ProgramSelection selection = ProgramSelection.FromAppId(int.Parse(node.Name));
ProgramSelection selection = ProgramSelection.FromAppId(appId);
if (selection is null)
{
TreeNode parent = node.Parent;
if (parent is not null)
if (parent is not null && int.TryParse(parent.Name, out int gameAppId))
{
ProgramSelection.FromAppId(int.Parse(parent.Name)).ToggleDlc(int.Parse(node.Name), node.Checked);
ProgramSelection.FromAppId(gameAppId).ToggleDlc(appId, node.Checked);
parent.Checked = parent.Nodes.Cast<TreeNode>().ToList().Any(treeNode => treeNode.Checked);
}
}