Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ LoadServerParameters()

static void Terraria.Initializers.LaunchInitializer.LoadServerParameters ( Main game)
inlinestaticprivate

Definition at line 53 of file LaunchInitializer.cs.

54 {
55 try
56 {
57 string s;
58 if ((s = TryParameter("-forcepriority")) != null)
59 {
60 Process currentProcess = Process.GetCurrentProcess();
61 if (int.TryParse(s, out var result))
62 {
63 switch (result)
64 {
65 case 0:
66 currentProcess.PriorityClass = ProcessPriorityClass.RealTime;
67 break;
68 case 1:
69 currentProcess.PriorityClass = ProcessPriorityClass.High;
70 break;
71 case 2:
72 currentProcess.PriorityClass = ProcessPriorityClass.AboveNormal;
73 break;
74 case 3:
75 currentProcess.PriorityClass = ProcessPriorityClass.Normal;
76 break;
77 case 4:
78 currentProcess.PriorityClass = ProcessPriorityClass.BelowNormal;
79 break;
80 case 5:
81 currentProcess.PriorityClass = ProcessPriorityClass.Idle;
82 break;
83 default:
84 currentProcess.PriorityClass = ProcessPriorityClass.High;
85 break;
86 }
87 }
88 else
89 {
90 currentProcess.PriorityClass = ProcessPriorityClass.High;
91 }
92 }
93 else
94 {
95 Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High;
96 }
97 }
98 catch
99 {
100 }
101 string value;
102 if ((value = TryParameter("-maxplayers", "-players")) != null)
103 {
104 int num = Convert.ToInt32(value);
105 if (num <= 255 && num >= 1)
106 {
107 game.SetNetPlayers(num);
108 }
109 }
110 string arg;
111 if ((arg = TryParameter("-pass", "-password")) != null)
112 {
113 Netplay.ServerPassword = Main.ConvertFromSafeArgument(arg);
114 }
115 string s2;
116 if ((s2 = TryParameter("-lang")) != null && int.TryParse(s2, out var result2))
117 {
118 LanguageManager.Instance.SetLanguage(result2);
119 }
120 if ((s2 = TryParameter("-language")) != null)
121 {
122 LanguageManager.Instance.SetLanguage(s2);
123 }
124 string worldName;
125 if ((worldName = TryParameter("-worldname")) != null)
126 {
127 game.SetWorldName(worldName);
128 }
129 string newMOTD;
130 if ((newMOTD = TryParameter("-motd")) != null)
131 {
132 game.NewMOTD(newMOTD);
133 }
134 string banFilePath;
135 if ((banFilePath = TryParameter("-banlist")) != null)
136 {
137 Netplay.BanFilePath = banFilePath;
138 }
139 if (HasParameter("-autoshutdown"))
140 {
141 game.EnableAutoShutdown();
142 }
143 if (HasParameter("-secure"))
144 {
145 Netplay.SpamCheck = true;
146 }
147 string serverWorldRollbacks;
148 if ((serverWorldRollbacks = TryParameter("-worldrollbackstokeep")) != null)
149 {
150 game.setServerWorldRollbacks(serverWorldRollbacks);
151 }
152 string worldSize;
153 if ((worldSize = TryParameter("-autocreate")) != null)
154 {
155 game.autoCreate(worldSize);
156 }
157 if (HasParameter("-noupnp"))
158 {
159 Netplay.UseUPNP = false;
160 }
161 if (HasParameter("-experimental"))
162 {
163 Main.UseExperimentalFeatures = true;
164 }
165 string world;
166 if ((world = TryParameter("-world")) != null)
167 {
168 game.SetWorld(world, cloud: false);
169 }
170 else if (SocialAPI.Mode == SocialMode.Steam && (world = TryParameter("-cloudworld")) != null)
171 {
172 game.SetWorld(world, cloud: true);
173 }
174 string configPath;
175 if ((configPath = TryParameter("-config")) != null)
176 {
177 game.LoadDedConfig(configPath);
178 }
179 string autogenSeedName;
180 if ((autogenSeedName = TryParameter("-seed")) != null)
181 {
182 Main.AutogenSeedName = autogenSeedName;
183 }
184 }
static int ToInt32(object? value)
Definition Convert.cs:1320
static Process GetCurrentProcess()
Definition Process.cs:1107
static string TryParameter(params string[] keys)
static bool HasParameter(params string[] keys)
static SocialMode Mode
Definition SocialAPI.cs:32

References Terraria.Main.autoCreate(), Terraria.Main.ConvertFromSafeArgument(), Terraria.Main.EnableAutoShutdown(), System.Diagnostics.Process.GetCurrentProcess(), Terraria.Initializers.LaunchInitializer.HasParameter(), Terraria.Localization.LanguageManager.Instance, Terraria.Main.LoadDedConfig(), Terraria.Social.SocialAPI.Mode, Terraria.Main.NewMOTD(), System.s, Terraria.Main.SetNetPlayers(), Terraria.Main.setServerWorldRollbacks(), Terraria.Main.SetWorld(), Terraria.Main.SetWorldName(), System.Convert.ToInt32(), Terraria.Initializers.LaunchInitializer.TryParameter(), and System.value.

Referenced by Terraria.Initializers.LaunchInitializer.LoadParameters().