private static void Main(string[] args)
 {
     //Process currentProcess = Process.GetCurrentProcess();
     //currentProcess.PriorityClass = ProcessPriorityClass.High;
     game = new Main();
     for (int i = 0; i < args.Length; i++)
     {
         if (args[i].ToLower() == "-config")
         {
             i++;
             game.LoadDedConfig(args[i]);
         }
         if (args[i].ToLower() == "-port")
         {
             i++;
             try
             {
                 int serverPort = Convert.ToInt32(args[i]);
                 Netplay.ListenPort = serverPort;
             }
             catch
             {
             }
         }
         if (args[i].ToLower() == "-players" || args[i].ToLower() == "-maxplayers")
         {
             i++;
             try
             {
                 int netPlayers = Convert.ToInt32(args[i]);
                 game.SetNetPlayers(netPlayers);
             }
             catch
             {
             }
         }
         if (args[i].ToLower() == "-pass" || args[i].ToLower() == "-password")
         {
             i++;
             Netplay.ServerPassword = args[i];
         }
         if (args[i].ToLower() == "-lang")
         {
             i++;
             Lang.lang = Convert.ToInt32(args[i]);
         }
         if (args[i].ToLower() == "-world")
         {
             i++;
             game.SetWorld(args[i], false);
         }
         if (args[i].ToLower() == "-worldname")
         {
             i++;
             game.SetWorldName(args[i]);
         }
         if (args[i].ToLower() == "-motd")
         {
             i++;
             game.NewMOTD(args[i]);
         }
         if (args[i].ToLower() == "-banlist")
         {
             i++;
             Netplay.BanFilePath = args[i];
         }
         if (args[i].ToLower() == "-autoshutdown")
         {
             game.autoShut();
         }
         if (args[i].ToLower() == "-secure")
         {
             Netplay.spamCheck = true;
         }
         if (args[i].ToLower() == "-autocreate")
         {
             i++;
             string newOpt = args[i];
             game.autoCreate(newOpt);
         }
         if (args[i].ToLower() == "-loadlib")
         {
             i++;
             string path = args[i];
             game.loadLib(path);
         }
         if (args[i].ToLower() == "-noupnp")
         {
             Netplay.UseUPNP = false;
         }
     }
     game.DedServ();
 }
Ejemplo n.º 2
0
 private static void Main(string[] args)
 {
     try
     {
         Game = new Main();
         for (int i = 0; i < args.Length; i++)
         {
             switch (args[i].ToLower())
             {
                 case "-config":
                     i++;
                     Game.LoadDedConfig(args[i]);
                     break;
                 case "-port":
                     i++;
                     try
                     {
                         int serverPort = Convert.ToInt32(args[i]);
                         Netplay.serverPort = serverPort;
                     }
                     catch
                     {
                     }
                     break;
                 case "-world":
                     i++;
                     Game.SetWorld(args[i]);
                     break;
                 case "-worldname":
                     i++;
                     Game.SetWorldName(args[i]);
                     break;
                 case "-autoshutdown":
                     Game.autoShut();
                     break;
                 case "-autocreate":
                     i++;
                     string newOpt = args[i];
                     Game.autoCreate(newOpt);
                     break;
                 case "-ip":
                     IPAddress ip;
                     if (IPAddress.TryParse(args[++i], out ip))
                     {
                         Netplay.serverListenIP = ip;
                         Console.Write("Using IP: {0}", ip);
                     }
                     else
                         Console.WriteLine("Bad IP: {0}", args[i]);
                     break;
                 case "-connperip":
                     int limit;
                     if (int.TryParse(args[++i], out limit))
                     {
                         Netplay.connectionLimit = limit;
                         Console.WriteLine("Each IP is now limited to {0} connections", limit);
                     }
                     else
                     Console.WriteLine("Bad int for -connperip");
                     break;
                 case "-killinactivesocket":
                     Netplay.killInactive = true;
                     break;
                 case "-lang":
                     Lang.lang = Convert.ToInt32(args[++i]);
                     break;
                 case "-ignoreversion":
                     IgnoreVersion = true;
                     Console.WriteLine("WARNING: Versions are no longer being regarded!");
                     Console.WriteLine("You are on your own! If problems arise, TShock developers will not help you with issues regarding this.");
                     break;
             }
         }
         if (Environment.OSVersion.Platform == PlatformID.Unix)
             Terraria.Main.SavePath = "Terraria";
         else
             Terraria.Main.SavePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "My Games", "Terraria");
         Terraria.Main.WorldPath = Path.Combine(Terraria.Main.SavePath, "Worlds");
         Terraria.Main.PlayerPath = Path.Combine(Terraria.Main.SavePath, "Players");
         Initialize(Game);
         Game.DedServ();
         DeInitialize();
     }
     catch (Exception value)
     {
         try
         {
             using (var streamWriter = new StreamWriter("crashlog.txt", true))
             {
                 streamWriter.WriteLine(DateTime.Now);
                 streamWriter.WriteLine(value);
                 streamWriter.WriteLine("");
             }
             Console.WriteLine("Server crash: " + DateTime.Now);
             Console.WriteLine(value);
             Console.WriteLine("");
             Console.WriteLine("Please send crashlog.txt to [email protected]");
         }
         catch
         {
         }
     }
 }
Ejemplo n.º 3
0
        private static void Main(string[] args)
        {
            try
            {
                Game = new Main();
                for (int i = 0; i < args.Length; i++)
                {
                    switch (args[i].ToLower())
                    {
                    case "-config":
                        i++;
                        Game.LoadDedConfig(args[i]);
                        break;

                    case "-port":
                        i++;
                        try
                        {
                            int serverPort = Convert.ToInt32(args[i]);
                            Netplay.serverPort = serverPort;
                        }
                        catch
                        {
                        }
                        break;

                    case "-world":
                        i++;
                        Game.SetWorld(args[i]);
                        break;

                    case "-worldname":
                        i++;
                        Game.SetWorldName(args[i]);
                        break;

                    case "-autoshutdown":
                        Game.autoShut();
                        break;

                    case "-autocreate":
                        i++;
                        string newOpt = args[i];
                        Game.autoCreate(newOpt);
                        break;

                    case "-ip":
                        IPAddress ip;
                        if (IPAddress.TryParse(args[++i], out ip))
                        {
                            Netplay.serverListenIP = ip;
                            Console.Write("Using IP: {0}", ip);
                        }
                        else
                        {
                            Console.WriteLine("Bad IP: {0}", args[i]);
                        }
                        break;

                    case "-connperip":
                        int limit;
                        if (int.TryParse(args[++i], out limit))
                        {
                            Netplay.connectionLimit = limit;
                            Console.WriteLine("Each IP is now limited to {0} connections", limit);
                        }
                        else
                        {
                            Console.WriteLine("Bad int for -connperip");
                        }
                        break;

                    case "-killinactivesocket":
                        Netplay.killInactive = true;
                        break;

                    case "-lang":
                        Lang.lang = Convert.ToInt32(args[++i]);
                        break;

                    case "-ignoreversion":
                        IgnoreVersion = true;
                        Console.WriteLine("Ignoring API version checks on plguins.");
                        break;
                    }
                }
                if (Environment.OSVersion.Platform == PlatformID.Unix)
                {
                    Terraria.Main.SavePath = "Terraria";
                }
                else
                {
                    Terraria.Main.SavePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "My Games", "Terraria");
                }
                Terraria.Main.WorldPath  = Path.Combine(Terraria.Main.SavePath, "Worlds");
                Terraria.Main.PlayerPath = Path.Combine(Terraria.Main.SavePath, "Players");
                Initialize(Game);
                Game.DedServ();
                DeInitialize();
            }
            catch (Exception value)
            {
                try
                {
                    using (var streamWriter = new StreamWriter("crashlog.txt", true))
                    {
                        streamWriter.WriteLine(DateTime.Now);
                        streamWriter.WriteLine(value);
                        streamWriter.WriteLine("");
                    }
                    Console.WriteLine("Server crash: " + DateTime.Now);
                    Console.WriteLine(value);
                    Console.WriteLine("");
                    Console.WriteLine("Please send crashlog.txt to [email protected]");
                }
                catch
                {
                }
            }
        }