PageRenderTime 317ms CodeModel.GetById 111ms app.highlight 6ms RepoModel.GetById 104ms app.codeStats 0ms

/tdsm-core/ServerEntry.cs

http://github.com/DeathCradle/Terraria-s-Dedicated-Server-Mod
C# | 103 lines | 100 code | 1 blank | 2 comment | 33 complexity | 26d155a6a447989670612ffccf70a3d3 MD5 | raw file
  1using System;
  2using Terraria;
  3
  4namespace tdsm.core
  5{
  6    class ServerEntry
  7    {
  8        private static Main game;
  9        private static void Main(string[] args)
 10        {
 11            //Process currentProcess = Process.GetCurrentProcess();
 12            //currentProcess.PriorityClass = ProcessPriorityClass.High;
 13            game = new Main();
 14            for (int i = 0; i < args.Length; i++)
 15            {
 16                if (args[i].ToLower() == "-config")
 17                {
 18                    i++;
 19                    game.LoadDedConfig(args[i]);
 20                }
 21                if (args[i].ToLower() == "-port")
 22                {
 23                    i++;
 24                    try
 25                    {
 26                        int serverPort = Convert.ToInt32(args[i]);
 27                        Netplay.serverPort = serverPort;
 28                    }
 29                    catch
 30                    {
 31                    }
 32                }
 33                if (args[i].ToLower() == "-players" || args[i].ToLower() == "-maxplayers")
 34                {
 35                    i++;
 36                    try
 37                    {
 38                        int netPlayers = Convert.ToInt32(args[i]);
 39                        game.SetNetPlayers(netPlayers);
 40                    }
 41                    catch
 42                    {
 43                    }
 44                }
 45                if (args[i].ToLower() == "-pass" || args[i].ToLower() == "-password")
 46                {
 47                    i++;
 48                    Netplay.password = args[i];
 49                }
 50                if (args[i].ToLower() == "-lang")
 51                {
 52                    i++;
 53                    Lang.lang = Convert.ToInt32(args[i]);
 54                }
 55                if (args[i].ToLower() == "-world")
 56                {
 57                    i++;
 58                    game.SetWorld(args[i]);
 59                }
 60                if (args[i].ToLower() == "-worldname")
 61                {
 62                    i++;
 63                    game.SetWorldName(args[i]);
 64                }
 65                if (args[i].ToLower() == "-motd")
 66                {
 67                    i++;
 68                    game.NewMOTD(args[i]);
 69                }
 70                if (args[i].ToLower() == "-banlist")
 71                {
 72                    i++;
 73                    Netplay.banFile = args[i];
 74                }
 75                if (args[i].ToLower() == "-autoshutdown")
 76                {
 77                    game.autoShut();
 78                }
 79                if (args[i].ToLower() == "-secure")
 80                {
 81                    Netplay.spamCheck = true;
 82                }
 83                if (args[i].ToLower() == "-autocreate")
 84                {
 85                    i++;
 86                    string newOpt = args[i];
 87                    game.autoCreate(newOpt);
 88                }
 89                if (args[i].ToLower() == "-loadlib")
 90                {
 91                    i++;
 92                    string path = args[i];
 93                    game.loadLib(path);
 94                }
 95                if (args[i].ToLower() == "-noupnp")
 96                {
 97                    Netplay.uPNP = false;
 98                }
 99            }
100            game.DedServ();
101        }
102    }
103}