Exemplo n.º 1
0
        static void AddServer(string[] args)
        {
            GlobalConfiguration config = null;
            string hostname = null, port = "7777", queryport = "27015";

            var p = new OptionSet()
                    .Add("h|host=", delegate(string v) { hostname = v; })
                    .Add("p|port=", delegate(string v) { port = v; })
                    .Add("q|query=", delegate(string v) { queryport = v; })
            ;

            List <string> extra = p.Parse(args);

            if (hostname == null && extra.Count > 0)
            {
                hostname = extra[0];
            }

            if (hostname == null)
            {
                throw new ApplicationException("no hostname set");
            }

            /* failure to load is not fatal in this step
             */
            try {
                config = GlobalConfiguration.Load();
            } catch (Exception) {}

            if (config == null)
            {
                config = new GlobalConfiguration();
            }

            ConanServer server = new ConanServer(hostname, port, queryport);

            try {
                server.Update();
                config.Servers.Add(server);
                config.Save();
            } catch (Exception e) {
                Console.WriteLine("error: failed to add and query port, probably query port is wrong");
                Console.WriteLine("details: " + e.Message);
                Environment.Exit(3);
            }
        }
Exemplo n.º 2
0
        static void Setup(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine("error: no server provided");
                Environment.Exit(1);
            }

            GlobalConfiguration config = GlobalConfiguration.Load();
            Steam  steam = new Steam(config.SteamCMD, config.SteamEXE, config.SteamPath, config.SteamUser);
            string serv  = args[0];

            var servers = from s in config.Servers
                          where s.Hostname.Equals(serv, StringComparison.InvariantCultureIgnoreCase) ||
                          s.Name.Contains(serv, StringComparison.InvariantCultureIgnoreCase)
                          select s;

            if (servers == null || servers.Count() == 0)
            {
                Console.WriteLine("error: no such server: " + serv);
                Environment.Exit(3);
            }

            ConanServer server = servers.ToArray()[0];

            Console.WriteLine("Updating server information...");
            server.Update();
            if (server.ModList.Count() > 0)
            {
                Console.WriteLine("Updating mods...");
                steam.DownloadWorkShopItems(Steam.CONAN_EXILES_APP_ID, server.ModList.ToArray());
                Console.WriteLine("Writing updated modlist...");
                WriteModList(config, server.ModList.ToArray());
            }
            Console.WriteLine("Updating base game...");
            steam.UpdateGame(Steam.CONAN_EXILES_APP_ID);
            Console.WriteLine("Conan Exile's is now ready to be launched!");
        }