refactor workshop installation: make LuaCsInstaller a little less cursed
This commit is contained in:
@@ -1268,69 +1268,7 @@ namespace Barotrauma
|
||||
#if WINDOWS
|
||||
commands.Add(new Command("install_cl_lua", "Installs Client-Side Lua into your client.", (string[] args) =>
|
||||
{
|
||||
ContentPackage luaPackage = LuaCsSetup.GetPackage("Lua For Barotrauma");
|
||||
|
||||
if (luaPackage == null)
|
||||
{
|
||||
GameMain.Server.SendChatMessage("Couldn't find the Lua For Barotrauma package.", ChatMessageType.ServerMessageBox);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
string path = Path.GetDirectoryName(luaPackage.Path);
|
||||
|
||||
string[] filesToCopy = new string[]
|
||||
{
|
||||
"Barotrauma.dll", "Barotrauma.deps.json",
|
||||
"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",
|
||||
|
||||
"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)
|
||||
.Where(s => s.Contains("mscordaccore_amd64_amd64_4.")).Select(s => Path.GetFileName(s))).ToArray();
|
||||
|
||||
File.Move("Barotrauma.dll", "Barotrauma.dll.old", true);
|
||||
File.Move("Barotrauma.deps.json", "Barotrauma.deps.json.old", true);
|
||||
|
||||
File.Move("System.Reflection.Metadata.dll", "System.Reflection.Metadata.dll.old", true);
|
||||
File.Move("System.Collections.Immutable.dll", "System.Collections.Immutable.dll.old", true);
|
||||
File.Move("System.Runtime.CompilerServices.Unsafe.dll", "System.Runtime.CompilerServices.Unsafe.dll.old", true);
|
||||
|
||||
foreach (string file in filesToCopy)
|
||||
{
|
||||
if (File.Exists(file))
|
||||
{
|
||||
File.Move(file, file + ".todelete", true);
|
||||
}
|
||||
File.Copy(Path.Combine(path, "Binary", file), file, true);
|
||||
}
|
||||
|
||||
File.WriteAllText(LuaCsSetup.VersionFile, luaPackage.ModVersion);
|
||||
File.WriteAllText("LuaDedicatedServer.bat", "\"%LocalAppData%/Daedalic Entertainment GmbH/Barotrauma/WorkshopMods/Installed/2559634234/Binary/DedicatedServer.exe\"");
|
||||
}
|
||||
catch (UnauthorizedAccessException e)
|
||||
{
|
||||
GameMain.LuaCs.PrintError("You seem to already have Client Side Lua installed, if you are trying to reinstall, make sure uninstall it first (mainmenu button located top left).", LuaCsMessageOrigin.LuaCs);
|
||||
|
||||
return;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
GameMain.LuaCs.HandleException(e, LuaCsMessageOrigin.LuaCs);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
GameMain.Server.SendChatMessage("Client-Side Lua installed, restart your game to apply changes.", ChatMessageType.ServerMessageBox);
|
||||
LuaCsInstaller.Install();
|
||||
}));
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user