From 966236652a2a038f18d1ba7a72a8e2089463f9cd Mon Sep 17 00:00:00 2001 From: EvilFactory Date: Sun, 8 Oct 2023 17:49:46 -0300 Subject: [PATCH] Copy publicized folder on install script and clean up --- .../ClientSource/LuaCs/LuaCsInstaller.cs | 20 ++-------------- .../ServerSource/LuaCs/LuaCsInstaller.cs | 24 +++++-------------- .../SharedSource/LuaCs/LuaCsInstaller.cs | 21 ++++++++++++++++ 3 files changed, 29 insertions(+), 36 deletions(-) diff --git a/Barotrauma/BarotraumaClient/ClientSource/LuaCs/LuaCsInstaller.cs b/Barotrauma/BarotraumaClient/ClientSource/LuaCs/LuaCsInstaller.cs index 470e94ba20..78a22fce2b 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/LuaCs/LuaCsInstaller.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/LuaCs/LuaCsInstaller.cs @@ -67,30 +67,14 @@ public static void CheckUpdate() string clientVersion = File.ReadAllText(LuaCsSetup.VersionFile); string workshopVersion = luaPackage.ModVersion; - if (clientVersion == workshopVersion) { return; } + if (clientVersion == workshopVersion || File.Exists("debugsomething")) { return; } var msg = new GUIMessageBox($"LuaCs Update", $"Your LuaCs client version is different from the version found in the LuaCsForBarotrauma workshop files. Do you want to update?\n\n Client Version: {clientVersion}\n Workshop Version: {workshopVersion}", new LocalizedString[2] { TextManager.Get("Yes"), TextManager.Get("Cancel") }); msg.Buttons[0].OnClicked = (GUIButton button, object obj) => { - string[] filesToUpdate = new string[] - { - "Barotrauma.dll", "Barotrauma.deps.json", "Barotrauma.pdb", - "0Harmony.dll", "Mono.Cecil.dll", - "Sigil.dll", - "Mono.Cecil.Mdb.dll", "Mono.Cecil.Pdb.dll", - "Mono.Cecil.Rocks.dll", "MonoMod.Common.dll", - "MoonSharp.Interpreter.dll", "MoonSharp.VsCodeDebugger.dll", - - "Microsoft.CodeAnalysis.dll", "Microsoft.CodeAnalysis.CSharp.dll", - "Microsoft.CodeAnalysis.CSharp.Scripting.dll", "Microsoft.CodeAnalysis.Scripting.dll", - - "System.Reflection.Metadata.dll", "System.Collections.Immutable.dll", - "System.Runtime.CompilerServices.Unsafe.dll" - }; - - filesToUpdate = filesToUpdate.Concat(Directory.EnumerateFiles(luaCsPath, "*.dll", SearchOption.AllDirectories) + string[] filesToUpdate = trackingFiles.Concat(Directory.EnumerateFiles(luaCsPath, "*.dll", SearchOption.AllDirectories) .Where(s => s.Contains("mscordaccore_amd64_amd64")).Select(s => Path.GetFileName(s))).ToArray(); try diff --git a/Barotrauma/BarotraumaServer/ServerSource/LuaCs/LuaCsInstaller.cs b/Barotrauma/BarotraumaServer/ServerSource/LuaCs/LuaCsInstaller.cs index 8108aa380d..29684b30c9 100644 --- a/Barotrauma/BarotraumaServer/ServerSource/LuaCs/LuaCsInstaller.cs +++ b/Barotrauma/BarotraumaServer/ServerSource/LuaCs/LuaCsInstaller.cs @@ -21,22 +21,7 @@ public static void Install() { string path = Path.GetDirectoryName(luaPackage.Path); - string[] filesToCopy = new string[] - { - "Barotrauma.dll", "Barotrauma.deps.json", "Barotrauma.pdb", - "0Harmony.dll", "Mono.Cecil.dll", - "Sigil.dll", - "Mono.Cecil.Mdb.dll", "Mono.Cecil.Pdb.dll", - "Mono.Cecil.Rocks.dll", "MonoMod.Common.dll", - "MoonSharp.Interpreter.dll", "MoonSharp.VsCodeDebugger.dll", - - "Microsoft.CodeAnalysis.dll", "Microsoft.CodeAnalysis.CSharp.dll", - "Microsoft.CodeAnalysis.CSharp.Scripting.dll", "Microsoft.CodeAnalysis.Scripting.dll", - - "System.Reflection.Metadata.dll", "System.Collections.Immutable.dll", - "System.Runtime.CompilerServices.Unsafe.dll" - }; - filesToCopy = filesToCopy.Concat(Directory.EnumerateFiles(path, "*.dll", SearchOption.AllDirectories) + string[] filesToCopy = trackingFiles.Concat(Directory.EnumerateFiles(path, "*.dll", SearchOption.AllDirectories) .Where(s => s.Contains("mscordaccore_amd64_amd64")).Select(s => Path.GetFileName(s))).ToArray(); CreateMissingDirectory(); @@ -59,11 +44,14 @@ public static void Install() } File.WriteAllText(LuaCsSetup.VersionFile, luaPackage.ModVersion); - File.WriteAllText("LuaDedicatedServer.bat", "\"%LocalAppData%/Daedalic Entertainment GmbH/Barotrauma/WorkshopMods/Installed/2559634234/Binary/DedicatedServer.exe\""); + +#if WINDOWS + File.WriteAllText("LuaCsDedicatedServer.bat", "\"%LocalAppData%/Daedalic Entertainment GmbH/Barotrauma/WorkshopMods/Installed/2559634234/Binary/DedicatedServer.exe\""); +#endif } catch (UnauthorizedAccessException e) { - LuaCsLogger.LogError("You seem to already have Client Side LuaCs installed, if you are trying to reinstall, make sure uninstall it first (mainmenu button located top left).", LuaCsMessageOrigin.LuaCs); + LuaCsLogger.LogError($"Unauthorized file access exception. This usually means you already have LuaCs installed. ${e}", LuaCsMessageOrigin.LuaCs); return; } diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsInstaller.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsInstaller.cs index 2ac182156e..eb701716be 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsInstaller.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsInstaller.cs @@ -7,11 +7,32 @@ namespace Barotrauma { static partial class LuaCsInstaller { + private static string[] trackingFiles = new string[] + { + "Barotrauma.dll", "Barotrauma.deps.json", "Barotrauma.pdb", + "0Harmony.dll", "Mono.Cecil.dll", + "Sigil.dll", + "Mono.Cecil.Mdb.dll", "Mono.Cecil.Pdb.dll", + "Mono.Cecil.Rocks.dll", "MonoMod.Common.dll", + "MoonSharp.Interpreter.dll", "MoonSharp.VsCodeDebugger.dll", + + "Microsoft.CodeAnalysis.dll", "Microsoft.CodeAnalysis.CSharp.dll", + "Microsoft.CodeAnalysis.CSharp.Scripting.dll", "Microsoft.CodeAnalysis.Scripting.dll", + + "System.Reflection.Metadata.dll", "System.Collections.Immutable.dll", + "System.Runtime.CompilerServices.Unsafe.dll", + + "Publicized/DedicatedServer.dll", "Publicized/Barotrauma.dll" + }; + private static void CreateMissingDirectory() { Directory.CreateDirectory("Temp/Original"); Directory.CreateDirectory("Temp/ToDelete"); + Directory.CreateDirectory("Temp/ToDelete/Publicized"); Directory.CreateDirectory("Temp/Old"); + Directory.CreateDirectory("Temp/Old/Publicized"); + Directory.CreateDirectory("Publicized"); } }