From 0d28d1149fb5bd122e6085390fb2722d03521e47 Mon Sep 17 00:00:00 2001 From: Miepee <38186597+Miepee@users.noreply.github.com> Date: Sun, 1 Aug 2021 10:15:48 +0200 Subject: [PATCH] Throw more useful error if game is in a subdirectory --- AM2RLauncher/AM2RLauncher/MainForm/MainForm.Methods.cs | 8 ++++++++ AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Methods.cs b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Methods.cs index ad6aadd..6fb7e8e 100644 --- a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Methods.cs +++ b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Methods.cs @@ -1118,9 +1118,17 @@ namespace AM2RLauncher string tmpPath = Path.GetTempPath() + Path.GetFileNameWithoutExtension(zipPath); + // clean up in case folder exists already + if (Directory.Exists(tmpPath)) + Directory.Delete(tmpPath, true); + //extract zip to tmp path first ZipFile.ExtractToDirectory(zipPath, tmpPath); + // If the game is packed into a subfolder, throw error for that + if (Directory.GetDirectories(tmpPath).Length == 1 && new DirectoryInfo(Directory.GetDirectories(tmpPath).First()).Name != "lang") + return IsZipAM2R11ReturnCodes.GameIsInASubfolder; + // check if exe exists if (!File.Exists(tmpPath + "/AM2R.exe")) return IsZipAM2R11ReturnCodes.MissingAM2RExe; diff --git a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs index 3d0563f..9798d99 100644 --- a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs +++ b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs @@ -56,7 +56,8 @@ namespace AM2RLauncher Successful, MissingAM2RExe, MissingOrInvalidD3DX9_43Dll, - MissingOrInvalidDataWin + MissingOrInvalidDataWin, + GameIsInASubfolder } // Splashes