コード例 #1
0
        public static ArgsOptions Parse(string[] args)
        {
            ArgsOptions options = null;

            Parser.Default.ParseArguments <ArgsOptions>(args).WithParsed(argOptions => options = argOptions);
            return(options);
        }
コード例 #2
0
        private static void Main(string[] args)
        {
            var parsedArgs = ArgsOptions.Parse(args);

            parsedArgs.GameInfoJson = LoadConfig(
                parsedArgs.GameInfoJsonPath,
                parsedArgs.GameInfoJson,
                Encoding.UTF8.GetString(Resources.GameInfo));

            var gameServerBlowFish = "17BLOhi6KZsTtldTsizvHg==";
            var gameServerLauncher = new GameServerLauncher(
                parsedArgs.ServerPort,
                parsedArgs.GameInfoJson,
                gameServerBlowFish);

#if DEBUG
            var configGameServerSettings = GameServerConfig.LoadFromJson(LoadConfig(
                                                                             parsedArgs.GameServerSettingsJsonPath,
                                                                             parsedArgs.GameServerSettingsJson,
                                                                             Encoding.UTF8.GetString(Resources.GameServerSettings)));
            if (configGameServerSettings.AutoStartClient)
            {
                var leaguePath = configGameServerSettings.ClientLocation;
                if (Directory.Exists(leaguePath))
                {
                    leaguePath = Path.Combine(leaguePath, "League of Legends.exe");
                }
                if (File.Exists(leaguePath))
                {
                    var startInfo = new ProcessStartInfo(leaguePath)
                    {
                        Arguments = String.Format("\"8394\" \"LoLLauncher.exe\" \"\" \"127.0.0.1 {0} {1} 1\"",
                                                  parsedArgs.ServerPort, gameServerBlowFish),
                        WorkingDirectory = Path.GetDirectoryName(leaguePath)
                    };

                    var leagueProcess = Process.Start(startInfo);

                    _logger.Info("Launching League of Legends. You can disable this in GameServerSettings.json.");

                    if (Environment.OSVersion.Platform == PlatformID.Win32NT ||
                        Environment.OSVersion.Platform == PlatformID.Win32S ||
                        Environment.OSVersion.Platform == PlatformID.Win32Windows ||
                        Environment.OSVersion.Platform == PlatformID.WinCE)
                    {
                        WindowsConsoleCloseDetection.SetCloseHandler((_) =>
                        {
                            if (!leagueProcess.HasExited)
                            {
                                leagueProcess.Kill();
                            }
                            return(true);
                        });
                    }
                }
                else
                {
                    _logger.Warn("Unable to find League of Legends.exe. Check the GameServerSettings.json settings and your League location.");
                }
            }
            else
            {
                _logger.Info("Server is ready, clients can now connect.");
            }
#endif
            gameServerLauncher.StartNetworkLoop();
            Console.ReadLine();
        }