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