-MD5 should no longer self-relocate or self-update

Changing install directory SHOULD now also move the patcher to the new directory.
This commit is contained in:
Starsman
2015-05-23 20:20:32 -04:00
committed by Leandro Pardini
parent 2bd4b74c44
commit 0edba9fdde
2 changed files with 42 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace Tequila
{
@@ -106,6 +107,8 @@ namespace Tequila
} while (!PathValid);
SelfRelocate();
Settings.GamePath = myPath;
}
@@ -159,5 +162,42 @@ namespace Tequila
}
}
private void SelfRelocate()
{
try {
if (Application.StartupPath == Settings.GamePath) return;
if (!File.Exists(Application.ExecutablePath)) return;
string ShortcutPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
string ShortcutTarget = Path.Combine(Settings.GamePath, "Tequila.exe");
if (!Directory.Exists(Settings.GamePath))
Directory.CreateDirectory(Settings.GamePath);
try {
if (File.Exists(ShortcutTarget)) File.Delete(ShortcutTarget);
File.Move(Application.ExecutablePath, ShortcutTarget);
} catch (Exception ex) {
File.Copy(Application.ExecutablePath, ShortcutTarget);
try { File.Move(Application.ExecutablePath, Path.Combine(Application.StartupPath, "deleteme.txt")); }
catch (Exception ex2) { }
}
try {
using (ShellLink shortcut = new ShellLink()) {
shortcut.Target = ShortcutTarget;
//shortcut.WorkingDirectory = Path.GetDirectoryName(ShortcutTarget);
shortcut.Description = "Drink up!";
shortcut.DisplayMode = ShellLink.LinkDisplayMode.edmNormal;
shortcut.Save(Path.Combine(ShortcutPath, "Tequila.lnk"));
}
} catch (Exception ex) {
MessageBox.Show(ex.Message);
}
} catch (Exception ex) {
MyToolkit.ErrorReporter(ex, this.Name + ".SelfRelocate");
}
}
}
}

View File

@@ -165,6 +165,8 @@ namespace Tequila
// Check for parameters overriding self patching
else if (MyToolkit.args[i].Trim() == "-md5")
{
NoMove = true;
WorkThread.DontSelfUpdate = true;
WorkThread.GenerageChecksumToClipboard = true;
}
// Check for parameters disabling self relocate (this option also makes it not self patch)