Exemplo n.º 1
0
 public bool Apply(string arg, string next, PatchData data)
 {
     if (arg.EqualsIgnoreCase("/InitialPatch"))
     {
         data.RunSection = RunSection.InitialPatch;
         return(true);
     }
     if (arg.EqualsIgnoreCase("/LinkedPatch"))
     {
         data.RunSection = RunSection.LinkedPatch;
         return(true);
     }
     if (arg.EqualsIgnoreCase("/FinalPatch"))
     {
         data.RunSection = RunSection.FinalPatch;
         return(true);
     }
     return(false);
 }
Exemplo n.º 2
0
        internal void RemoteBuild(frmMain frm, PatchData data = null)
        {
            Start = DateTime.Now;
            Form  = frm;
            Form?.DisableButtons();

            data = data ?? PatchData.Create(BuildSettings.Instance);

            foreach (var location in BuildSettings.Instance.GameFolders)
            {
                data.GameFolder = location;

                if (BuildSettings.Instance.AutoClose)
                {
                    var isDedicatedServer = data.IsDedicatedServer;
                    var exe = isDedicatedServer ? "7DaysToDieServer" : "7DaysToDie";
                    Helper.KillProcessByName(exe);
                }

                var extraArgs = "";
                if (BuildSettings.AutoBuild)
                {
                    extraArgs += " /ScriptOnly";
                }
                if (BuildSettings.EnableAllMods)
                {
                    extraArgs += " /EnableAllMods";
                }

                BuildArguments.Add($@"/InitialPatch /GameFolder ""{data.GameFolder}"" /ModFolder ""{data.ModFolder}""" + extraArgs);
                BuildArguments.Add($@"/LinkedPatch /GameFolder ""{data.GameFolder}"" /ModFolder ""{data.ModFolder}""" + extraArgs);
                BuildArguments.Add($@"/FinalPatch /GameFolder ""{data.GameFolder}"" /ModFolder ""{data.ModFolder}""" + extraArgs);

                if (BuildSettings.Instance.AutoPlay)
                {
                    BuildArguments.Add($@"startprocess {data.StartPath}");
                }
            }
            Next();
        }
Exemplo n.º 3
0
        internal void InternalBuild(frmMain frm)
        {
            Logging.LogAction = ParseLog;
            Start             = DateTime.Now;
            Form = frm;

            Form.DisableButtons();

            var data = PatchData.Create(BuildSettings.Instance);

            data.GameFolder = BuildSettings.Instance.GameFolders[0];
            data.Init();
            data.RunSection = RunSection.InitialPatch;
            var ret = data.Patch();

            data.RunSection = RunSection.LinkedPatch;
            BuildSettings.Instance.Init();
            ret = data.Patch();

            data.RunSection = RunSection.FinalPatch;
            BuildSettings.Instance.Init();
            ret = data.Patch();
        }
Exemplo n.º 4
0
        public static string StartDebugging()
        {
            try
            {
                Logging.Log("Starting debugging...");
                var data = PatchData.Create(BuildSettings.Instance);

                var isDedicatedServer = data.IsDedicatedServer;
                var exe = isDedicatedServer ? "7DaysToDieServer" : "7DaysToDie";
                Helper.KillProcessByName(exe);

                var settings = BuildSettings.Instance;

                if (settings.GameFolders.Count == 0)
                {
                    return("No game folder has been set up");
                }

                var folder = settings.GameFolders[0];

                data.GameFolder = BuildSettings.Instance.GameFolders.FirstOrDefault();

                if (!File.Exists(data.ExePath))
                {
                    return("No exe file found to run");
                }

                var info           = FileVersionInfo.GetVersionInfo(data.ExePath);
                var productVersion = info.ProductVersion.Substring(0, info.ProductVersion.LastIndexOf("."));

                var unityResourceLocation = UnityResourcesLocation + "Unity." + productVersion;

                if (!Directory.Exists(unityResourceLocation))
                {
                    return("Can't find mono version to patch for Unity " + productVersion + "\nYou can try manually adding the files found at https://github.com/0xd4d/dnSpy/releases under 'Unity-debugging-XXX'");
                }

                var monoLocationPatched = unityResourceLocation + "/mono.dll";
                var monoLocation        = data.GameFolder + "/Mono/EmbedRuntime/mono.dll";
                if (File.Exists(monoLocation))
                {
                    File.Copy(monoLocationPatched, monoLocation, true);
                }
                var monov4LocationPatched = unityResourceLocation + "/mono-2.0-bdwgc.dll";
                var monov4Location        = data.GameFolder + "/MonoBleedingEdge/EmbedRuntime/mono-2.0-bdwgc.dll";
                if (File.Exists(monov4Location))
                {
                    File.Copy(monov4LocationPatched, monov4Location, true);
                }


                var dnspyExe = DnSpyLocation + "dnSpy.exe";
                var args     = $@"""{data.GameFolder + data.GameDllLocation}"" --start-debugger ""{data.ExePath}""";

                ProcessStartInfo pInfo = new ProcessStartInfo(Path.GetFileName(dnspyExe), args);
                pInfo.WorkingDirectory = Path.GetDirectoryName(dnspyExe);
                Process.Start(pInfo);

                return(string.Empty);
            }
            catch (Exception ex)
            {
                return("I'm sorry Dave, I'm afraid I can't do that: " + ex.Message);
            }
        }