Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Athlon007 committed Apr 30, 2021
1 parent 3d939c0 commit 55f47be
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
35 changes: 35 additions & 0 deletions MSCLoader/CoolUpdater/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Windows.Forms;
using System.Diagnostics;
using System.Reflection;
using System.Security.Principal;

namespace CoolUpdater
{
Expand Down Expand Up @@ -84,6 +85,18 @@ static void Main(string[] args)
DownloadFile(args[1], args[2], token2);
break;
case "update-all":
if (!IsUserAdministrator())
{
// Restart as an admin, if no admin right has been given
Process p = new Process();
p.StartInfo.FileName = Assembly.GetEntryAssembly().Location;
p.StartInfo.Arguments = string.Join(" ", args);
p.StartInfo.Verb = "runas";
p.Start();
Environment.Exit(0);
return;
}

string pathToMods = args.Length < 2 ? "" : args[1].Replace("%20", " ");
UpdateView view = new UpdateView(pathToMods);
Application.Run(view);
Expand Down Expand Up @@ -193,5 +206,27 @@ private static void Client_DownloadProgressChanged(object sender, DownloadProgre
{
Console.WriteLine(e.ProgressPercentage + "%");
}

public static bool IsUserAdministrator()
{
//bool value to hold our return value
bool isAdmin;
try
{
//get the currently logged in user
WindowsIdentity user = WindowsIdentity.GetCurrent();
WindowsPrincipal principal = new WindowsPrincipal(user);
isAdmin = principal.IsInRole(WindowsBuiltInRole.Administrator);
}
catch (UnauthorizedAccessException ex)
{
isAdmin = false;
}
catch (Exception ex)
{
isAdmin = false;
}
return isAdmin;
}
}
}
2 changes: 1 addition & 1 deletion MSCLoader/CoolUpdater/UpdateView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public UpdateView(string modsPath)
title.MouseMove += DragWindowByThis;

Version version = Assembly.GetExecutingAssembly().GetName().Version;
labVer.Text = "GM-" + version.Major + "." + version.Minor;
labVer.Text = version.Major + "." + version.Minor;
if (version.Build != 0)
{
labVer.Text += "." + version.Build;
Expand Down
7 changes: 7 additions & 0 deletions MSCLoader/MSCLoader/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 1.0.4 (tba)

### Bug Fixes

- Mod Auto Updater should now prioritze archives with .pro.zip extension as intended
- CoolUpdater: Fixed "Start Game" button not starting the game with Mod Loader Pro

## 1.0.3 (30.04.2021)

### Added
Expand Down
2 changes: 1 addition & 1 deletion MSCLoader/MSCLoader/ModUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ IEnumerator CheckForModUpdates(IEnumerable<Mod> mods)
}

// Breaking out of the loop, if we found all that we've been looking for.
if (!string.IsNullOrEmpty(mod.ModUpdateData.ZipUrl) && !string.IsNullOrEmpty(mod.ModUpdateData.LatestVersion) && foundProBuild)
if (!string.IsNullOrEmpty(mod.ModUpdateData.ZipUrl) && !string.IsNullOrEmpty(mod.ModUpdateData.LatestVersion) || foundProBuild)
{
break;
}
Expand Down

0 comments on commit 55f47be

Please sign in to comment.