From 0edba9fddecb6f258a8a38b6447dd45be6c299bc Mon Sep 17 00:00:00 2001 From: Starsman Date: Sat, 23 May 2015 20:20:32 -0400 Subject: [PATCH] -MD5 should no longer self-relocate or self-update Changing install directory SHOULD now also move the patcher to the new directory. --- TequilaPC/Preferences.cs | 40 ++++++++++++++++++++++++++++++++++++++++ TequilaPC/Tequila.cs | 2 ++ 2 files changed, 42 insertions(+) diff --git a/TequilaPC/Preferences.cs b/TequilaPC/Preferences.cs index c6091bc..363c58c 100644 --- a/TequilaPC/Preferences.cs +++ b/TequilaPC/Preferences.cs @@ -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"); + } + } + } } diff --git a/TequilaPC/Tequila.cs b/TequilaPC/Tequila.cs index 347c0e1..9dcff78 100644 --- a/TequilaPC/Tequila.cs +++ b/TequilaPC/Tequila.cs @@ -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)