Example #1
0
        private static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                foreach (var arg in args)
                {
                    if (arg.ToLower() == "-tc")
                    {
                        Settings.UseTestConfig = true;
                    }
                }
            }

            #if DEBUG
            Settings.UseTestConfig = true;
            #endif

            try
            {
                if (UpdatePatcher())
                {
                    return;
                }

                if (RuntimePolicyHelper.LegacyV2RuntimeEnabledSuccessfully == true)
                {
                }

                Packet.IsServer = false;
                Settings.Load();

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                if (Settings.P_Patcher)
                {
                    Application.Run(PForm = new Launcher.AMain());
                }
                else
                {
                    Application.Run(Form = new CMain());
                }

                Settings.Save();
                CMain.InputKeys.Save();

                if (Restart)
                {
                    Application.Restart();
                }
            }
            catch (Exception ex)
            {
                CMain.SaveError(ex.ToString());
            }
        }
Example #2
0
        private static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                foreach (var arg in args)
                {
                    if (arg.ToLower() == "-tc") Settings.UseTestConfig = true;
                }
            }

            #if DEBUG
                Settings.UseTestConfig = true;
            #endif

            if (UpdatePatcher()) return;

            if (RuntimePolicyHelper.LegacyV2RuntimeEnabledSuccessfully == true) { }

            try
            {
                Packet.IsServer = false;
                Settings.Load();

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                if (Settings.P_Patcher) Application.Run(PForm = new Launcher.AMain());
                else Application.Run(Form = new CMain());

                Settings.Save();
                CMain.InputKeys.Save();

                if (Restart)
                {
                    Application.Restart();
                }
            }
            catch (Exception ex)
            {
                CMain.SaveError(ex.ToString());
            }
        }
Example #3
0
        private static void Main()
        {
            if (UpdatePatcher()) return;

            try
            {
                Packet.IsServer = false;
                Settings.Load();

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                Application.Run(Form = new CMain());

                Settings.Save();
            }
            catch (Exception ex)
            {
                CMain.SaveError(ex.ToString());
            }
        }
Example #4
0
        private static void Main()
        {
            if (UpdatePatcher())
            {
                return;
            }

            if (RuntimePolicyHelper.LegacyV2RuntimeEnabledSuccessfully == true)
            {
            }

            try
            {
                Packet.IsServer = false;
                Settings.Load();

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                if (Settings.P_Patcher)
                {
                    Application.Run(PForm = new Launcher.AMain());
                }
                else
                {
                    Application.Run(Form = new CMain());
                }

                Settings.Save();

                if (Restart)
                {
                    Application.Restart();
                }
            }
            catch (Exception ex)
            {
                CMain.SaveError(ex.ToString());
            }
        }
Example #5
0
        private static void Main()
        {
            if (UpdatePatcher())
            {
                return;
            }

            try
            {
                Packet.IsServer = false;
                Settings.Load();

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                Application.Run(Form = new CMain());

                Settings.Save();
            }
            catch (Exception ex)
            {
                CMain.SaveError(ex.ToString());
            }
        }
Example #6
0
        private static bool UpdatePatcher()
        {
            try
            {
                const string fromName = @".\AutoPatcher.gz", toName = @".\AutoPatcher.exe";
                if (!File.Exists(fromName))
                {
                    return(false);
                }

                Process[] processes = Process.GetProcessesByName("AutoPatcher");

                if (processes.Length > 0)
                {
                    string patcherPath = Application.StartupPath + @"\AutoPatcher.exe";

                    for (int i = 0; i < processes.Length; i++)
                    {
                        if (processes[i].MainModule.FileName == patcherPath)
                        {
                            processes[i].Kill();
                        }
                    }

                    Stopwatch stopwatch = Stopwatch.StartNew();
                    bool      wait      = true;
                    processes = Process.GetProcessesByName("AutoPatcher");

                    while (wait)
                    {
                        wait = false;
                        for (int i = 0; i < processes.Length; i++)
                        {
                            if (processes[i].MainModule.FileName == patcherPath)
                            {
                                wait = true;
                            }
                        }

                        if (stopwatch.ElapsedMilliseconds <= 3000)
                        {
                            continue;
                        }
                        MessageBox.Show("Failed to close AutoPatcher during update.");
                        return(true);
                    }
                }

                if (File.Exists(toName))
                {
                    File.Delete(toName);
                }
                File.Move(fromName, toName);
                Process.Start(toName, "Auto");

                return(true);
            }
            catch (Exception ex)
            {
                CMain.SaveError(ex.ToString());

                throw;
            }
        }
Example #7
0
        private static void Main(string[] args)
        {
#if DEBUG
            //Settings.UseTestConfig = true;
#endif

            //MirLog.info("DEBUG:" + Settings.UseTestConfig);
            try
            {
                //加大连接并发数
                System.Net.ServicePointManager.DefaultConnectionLimit = 256;

                if (UpdatePatcher())
                {
                    return;
                }

                if (RuntimePolicyHelper.LegacyV2RuntimeEnabledSuccessfully == true)
                {
                }

                long currExeLen = new FileInfo(Process.GetCurrentProcess().MainModule.FileName).Length;
                //客户端多开限制,只运行开3个客户端
                int       currClient = 0;
                string[]  dsmach     = { "Config", "Data", "DirectX", "Map", "Sound" };
                Process[] ps         = Process.GetProcesses();
                foreach (Process p in ps)
                {
                    try
                    {
                        if (p.MainModule.FileName == null)
                        {
                            continue;
                        }
                        MirLog.info(p.MainModule.FileName);
                        if (new FileInfo(p.MainModule.FileName).Length == currExeLen)
                        {
                            currClient++;
                        }

                        FileInfo        f           = new FileInfo(p.MainModule.FileName);
                        DirectoryInfo[] ds          = f.Directory.GetDirectories();
                        int             dsmachcount = 0;
                        foreach (DirectoryInfo di in ds)
                        {
                            foreach (string dm in dsmach)
                            {
                                if (di.Name.ToLower().Equals(dm.ToLower()))
                                {
                                    dsmachcount++;
                                }
                            }
                        }
                        if (dsmachcount >= 5)
                        {
                            //currClient++;
                        }
                    }
                    catch (Exception e)
                    {
                        MirLog.error(e.Message);
                    }
                }
                if (currClient >= 4)
                {
                    MirLog.info("最多只运行同时打开3个客户端");
                    MessageBox.Show("最多只运行同时打开3个客户端", "提示", MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
                    Application.Exit();
                    return;
                }


                Packet.IsServer = false;
                Settings.Load();

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                Application.Run(PForm = new Launcher.AMain());

                //if (Settings.P_Patcher) Application.Run(PForm = new Launcher.AMain());
                //else Application.Run(Form = new CMain());
                //Application.Run(Form = new CMain());
                //Application.Run( new Test());
                Settings.Save();
                CMain.InputKeys.Save();

                if (Restart)
                {
                    Application.Restart();
                }
            }
            catch (Exception ex)
            {
                CMain.SaveError(ex.ToString());
            }
        }
Example #8
0
        private static void Main(string[] args)
        {
            //var discord = DiscordsApp.GetApp();
            discord.ClientId      = 863371338324508682;
            discord.StartFailure += DiscordOnStartFailure;
            discord.Started      += DiscordOnStarted;
            discord.HasException += DiscordOnHasException;
            discord.Stopped      += DiscordOnStopped;
            discord.StartApp();
            //discord.UpdateActivity();
            discord.StartLoop();

            if (args.Length > 0)
            {
                foreach (var arg in args)
                {
                    if (arg.ToLower() == "-tc")
                    {
                        Settings.UseTestConfig = true;
                    }
                }
            }

            #if DEBUG
            Settings.UseTestConfig = true;
            #endif

            try
            {
                if (UpdatePatcher())
                {
                    return;
                }

                if (RuntimePolicyHelper.LegacyV2RuntimeEnabledSuccessfully == true)
                {
                }

                Packet.IsServer = false;
                Settings.Load();

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                if (Settings.P_Patcher)
                {
                    discord.UpdateStage(StatusType.GameState, GameState.Patching);
                    discord.UpdateActivity();
                    Application.Run(PForm = new Launcher.AMain());
                }
                else
                {
                    discord.UpdateStage(StatusType.GameState, GameState.Launching);
                    discord.UpdateActivity();
                    Application.Run(Form = new CMain());
                }

                Settings.Save();
                CMain.InputKeys.Save();

                if (Restart)
                {
                    Application.Restart();
                }
            }
            catch (Exception ex)
            {
                CMain.SaveError(ex.ToString());
            }
        }