mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-13 08:50:43 -05:00
If SPT is started by directly running EscapeFromTarkov.exe, exit (!116)
Inform user via messagebox that they need to run Aki.Launcher.exe Refactored a bit of the validation code in Aki.Prepatch Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com> Reviewed-on: SPT-AKI/Modules#116 Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com> Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com> (cherry picked from commit d6845c4337d616cd17d6d2e1eed746c25779b35b)
This commit is contained in:
parent
296d4fa391
commit
b529261845
@ -18,17 +18,7 @@ namespace Aki.PrePatch
|
|||||||
|
|
||||||
public static void Patch(ref AssemblyDefinition assembly)
|
public static void Patch(ref AssemblyDefinition assembly)
|
||||||
{
|
{
|
||||||
// Make sure the user hasn't deleted the SPT plugins folder
|
PerformPreValidation();
|
||||||
string assemblyFolder = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
|
|
||||||
string sptPluginPath = Path.GetFullPath(Path.Combine(assemblyFolder, "..", _sptPluginFolder));
|
|
||||||
if (!ValidateSpt(sptPluginPath))
|
|
||||||
{
|
|
||||||
string message = $"'{sptPluginPath}' or required plugin files not found.\n\n" +
|
|
||||||
"Please re-install SPT. Exiting.";
|
|
||||||
MessageBoxHelper.Show(message, "[SPT-AKI] Missing Core Files", MessageBoxHelper.MessageBoxType.OK);
|
|
||||||
Environment.Exit(0);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var botEnums = assembly.MainModule.GetType("EFT.WildSpawnType");
|
var botEnums = assembly.MainModule.GetType("EFT.WildSpawnType");
|
||||||
|
|
||||||
@ -46,14 +36,52 @@ namespace Aki.PrePatch
|
|||||||
botEnums.Fields.Add(sptBear);
|
botEnums.Fields.Add(sptBear);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool ValidateSpt(string sptPluginPath)
|
private static void PerformPreValidation()
|
||||||
{
|
{
|
||||||
|
// Check if the launcher was used
|
||||||
|
bool launcherUsed = ValidateLauncherUse(out string launcherError);
|
||||||
|
|
||||||
|
// Check that all the expected plugins are in the BepInEx/Plugins/spt/ folder
|
||||||
|
string assemblyFolder = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
|
||||||
|
string sptPluginPath = Path.GetFullPath(Path.Combine(assemblyFolder, "..", _sptPluginFolder));
|
||||||
|
bool pluginsValidated = ValidateSptPlugins(sptPluginPath, out string pluginErrorMessage);
|
||||||
|
|
||||||
|
// If either the launcher wasn't used, or the plugins weren't found, exit
|
||||||
|
if (!launcherUsed || !pluginsValidated)
|
||||||
|
{
|
||||||
|
string errorTitle = (!launcherUsed) ? "Startup Error" : "Missing Core Files";
|
||||||
|
string errorMessage = (!launcherUsed) ? launcherError : pluginErrorMessage;
|
||||||
|
MessageBoxHelper.Show(errorMessage, $"[SPT-AKI] {errorTitle}", MessageBoxHelper.MessageBoxType.OK);
|
||||||
|
Environment.Exit(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool ValidateLauncherUse(out string message)
|
||||||
|
{
|
||||||
|
// Validate that parameters were passed to EscapeFromTarkov.exe, to verify the
|
||||||
|
// player used the SPT Launcher to start the process
|
||||||
|
string[] args = Environment.GetCommandLineArgs();
|
||||||
|
if (args.Length > 1)
|
||||||
|
{
|
||||||
|
message = "";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
message = "Please start SPT-AKI using Aki.Launcher.exe. Exiting.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool ValidateSptPlugins(string sptPluginPath, out string message)
|
||||||
|
{
|
||||||
|
string exitMessage = "\n\nPlease re-install SPT. Exiting.";
|
||||||
ManualLogSource logger = Logger.CreateLogSource(nameof(AkiBotsPrePatcher));
|
ManualLogSource logger = Logger.CreateLogSource(nameof(AkiBotsPrePatcher));
|
||||||
|
|
||||||
// Validate that the SPT plugin path exists
|
// Validate that the SPT plugin path exists
|
||||||
if (!Directory.Exists(sptPluginPath))
|
if (!Directory.Exists(sptPluginPath))
|
||||||
{
|
{
|
||||||
logger.LogError($"'{sptPluginPath}' directory not found");
|
message = $"'{sptPluginPath}' directory not found{exitMessage}";
|
||||||
|
logger.LogError(message);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,10 +93,13 @@ namespace Aki.PrePatch
|
|||||||
{
|
{
|
||||||
if (!foundPlugins.Contains(plugin))
|
if (!foundPlugins.Contains(plugin))
|
||||||
{
|
{
|
||||||
|
message = $"Required SPT plugins missing from '{sptPluginPath}'{exitMessage}";
|
||||||
|
logger.LogError(message);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message = "";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user